@SuppressWarnings("unchecked") private <C extends LogicalComponent<?>> ComponentGenerator<C> getGenerator(C component) throws GeneratorNotFoundException { Implementation<?> implementation = component.getDefinition().getImplementation(); return (ComponentGenerator<C>) generatorRegistry.getComponentGenerator(implementation.getClass()); }
@SuppressWarnings("unchecked") private <C extends LogicalComponent<?>> ComponentGenerator<C> getGenerator(C component) throws GeneratorNotFoundException { Implementation<?> implementation = component.getDefinition().getImplementation(); return (ComponentGenerator<C>) generatorRegistry.getComponentGenerator(implementation.getClass()); }
/** * Instantiates a component in the context of a parent logical composite component. * * @param definition the component definition to instantiate * @param parent the parent logical composite * @param context the instantiation context * @return the instantiated component */ @SuppressWarnings("unchecked") private LogicalComponent<?> instantiate(ComponentDefinition<?> definition, LogicalCompositeComponent parent, InstantiationContext context) { if (definition.getImplementation() instanceof CompositeImplementation) { ComponentDefinition<CompositeImplementation> componentDefinition = (ComponentDefinition<CompositeImplementation>) definition; return compositeComponentInstantiator.instantiate(componentDefinition, parent, context); } else { ComponentDefinition<Implementation<?>> componentDefinition = (ComponentDefinition<Implementation<?>>) definition; return atomicComponentInstantiator.instantiate(componentDefinition, parent, context); } }
private boolean useByReference(LogicalOperation operation, boolean remote) { if (!passByValueEnabled || remote) { // Pass-by-value is disabled or the invocation chain is remote. Pass-by-reference semantics should be used for remote invocation chains // since the binding will enforce pass-by-value implicitly through serialization return true; } LogicalAttachPoint logicalAttachPoint = operation.getParent(); LogicalComponent<?> component = logicalAttachPoint.getParent(); return operation.getIntents().contains(ALLOWS_BY_REFERENCE) || logicalAttachPoint.getIntents().contains(ALLOWS_BY_REFERENCE) || component.getIntents().contains(ALLOWS_BY_REFERENCE) || component.getDefinition().getImplementation().getIntents().contains( ALLOWS_BY_REFERENCE) || component.getDefinition().getImplementation().getComponentType().getIntents().contains(ALLOWS_BY_REFERENCE); } }
/** * Derives the context URL for the web application relative to the domain. * * @param component the component * @return the context URL */ private String calculateContextUrl(LogicalComponent<WebImplementation> component) { URI contextUri = component.getDefinition().getImplementation().getUri(); if (contextUri == null) { // the context URL for the web application is derived from the component name if a URI is not specified contextUri = component.getUri(); } return info.getDomain().relativize(contextUri).toString(); }
@SuppressWarnings({"unchecked"}) private void instantiateChildComponents(LogicalCompositeComponent component, Composite composite, InstantiationContext context) { // create the child components List<LogicalComponent<?>> children = new ArrayList<LogicalComponent<?>>(); for (ComponentDefinition<? extends Implementation<?>> child : composite.getComponents().values()) { LogicalComponent<?> childComponent; if (child.getImplementation() instanceof CompositeImplementation) { childComponent = instantiate((ComponentDefinition<CompositeImplementation>) child, component, context); } else { childComponent = atomicInstantiator.instantiate(child, component, context); } component.addComponent(childComponent); children.add(childComponent); } // resolve the reference wires after the children have been instantiated and added to the parent, otherwise targets will not resolve for (LogicalComponent<?> child : children) { wireInstantiator.instantiateReferenceWires(child, context); } }
/** * Adds the contribution URI to the system composite and its children. * * @param contributionUri the contribution URI * @param composite the composite */ private static void addContributionUri(URI contributionUri, Composite composite) { composite.setContributionUri(contributionUri); for (ComponentDefinition<?> definition : composite.getComponents().values()) { Implementation<?> implementation = definition.getImplementation(); if (CompositeImplementation.class.isInstance(implementation)) { CompositeImplementation compositeImplementation = CompositeImplementation.class.cast(implementation); Composite componentType = compositeImplementation.getComponentType(); addContributionUri(contributionUri, componentType); } else { definition.setContributionUri(contributionUri); } } }
public PhysicalComponentDefinition generate(LogicalComponent<TimerImplementation> component) throws GenerationException { TimerComponentDefinition definition = new TimerComponentDefinition(); generationHelper.generate(definition, component); TimerImplementation implementation = component.getDefinition().getImplementation(); InjectingComponentType componentType = implementation.getComponentType(); definition.setTransactional(implementation.getIntents().contains(MANAGED_TRANSACTION) || componentType.getIntents().contains(MANAGED_TRANSACTION)); TimerData data = implementation.getTimerData(); definition.setTriggerData(data); return definition; }
private void validateRequiredProperties(ComponentDefinition<? extends Implementation<?>> definition, XMLStreamReader reader, IntrospectionContext context) { AbstractComponentType<?, ?, ?, ?> type = definition.getImplementation().getComponentType(); Map<String, ? extends Property> properties = type.getProperties(); Map<String, PropertyValue> values = definition.getPropertyValues(); for (Property property : properties.values()) { if (property.isRequired() && !values.containsKey(property.getName())) { RequiredPropertyNotProvided failure = new RequiredPropertyNotProvided(property, definition.getName(), reader); context.addError(failure); } } }
private void processPropertyValues(LogicalComponent<?> component, SpringComponentDefinition physical) { for (LogicalProperty property : component.getAllProperties().values()) { Document document = property.getValue(); if (document != null) { String name = property.getName(); boolean many = property.isMany(); ComponentType componentType = component.getDefinition().getImplementation().getComponentType(); QName type = componentType.getProperties().get(property.getName()).getType(); PhysicalPropertyDefinition definition = new PhysicalPropertyDefinition(name, document, many, type); physical.setPropertyDefinition(definition); } } }
/** * Returns the key specified on the component definition, component type, or {@link Integer#MIN_VALUE} * * @param component the component * @return the key or null */ private int getOrder(LogicalComponent component) { int order = component.getDefinition().getOrder(); if (order == Integer.MIN_VALUE) { ComponentDefinition<?> definition = component.getDefinition(); Implementation<?> implementation = definition.getImplementation(); if (implementation != null && implementation.getComponentType() != null) { order = implementation.getComponentType().getOrder(); } } return order; }
/** * Returns the key specified on the component definition, component type, or null * * @param component the component * @return the key or null */ private String getKey(LogicalComponent component) { String key = component.getDefinition().getKey(); if (key == null) { // check if the key was specified in the component type Implementation implementation = component.getDefinition().getImplementation(); if (implementation != null && implementation.getComponentType() != null) { key = implementation.getComponentType().getKey(); } } return key; }
public PhysicalComponentDefinition generate(LogicalComponent<WebImplementation> component) throws GenerationException { ComponentDefinition<WebImplementation> definition = component.getDefinition(); WebComponentType componentType = definition.getImplementation().getComponentType(); String contextUrl = calculateContextUrl(component); WebComponentDefinition physical = new WebComponentDefinition(); physical.setContextUrl(contextUrl); Map<String, Map<String, InjectionSite>> sites = generateInjectionMapping(componentType); physical.setInjectionMappings(sites); processPropertyValues(component, physical); return physical; }
@SuppressWarnings("unchecked") protected PhysicalComponentDefinition generateDefinition(LogicalComponent<?> component) throws GenerationException { Implementation<?> implementation = component.getDefinition().getImplementation(); Class<? extends Implementation> type = implementation.getClass(); ComponentGenerator generator = generatorRegistry.getComponentGenerator(type); if (generator == null) { throw new GeneratorNotFoundException(type); } PhysicalComponentDefinition definition = generator.generate(component); URI uri = component.getUri(); definition.setComponentUri(uri); definition.setClassLoaderId(component.getDefinition().getContributionUri()); QName deployable = component.getDeployable(); definition.setDeployable(deployable); return definition; }
Implementation<?> impl = component.getDefinition().getImplementation(); ComponentType componentType = impl.getComponentType(); Set<Contribution> extensions = new HashSet<Contribution>();
@SuppressWarnings({"unchecked"}) public LogicalComponent instantiate(ComponentDefinition<?> definition, LogicalCompositeComponent parent, InstantiationContext context) { URI uri = URI.create(parent.getUri() + "/" + definition.getName()); LogicalComponent<?> component = new LogicalComponent(uri, definition, parent); if (parent.getComponent(uri) != null) { DuplicateComponent error = new DuplicateComponent(uri, parent); context.addError(error); } parent.addComponent(component); Implementation<?> impl = definition.getImplementation(); if (impl == null) { return component; } ComponentType componentType = impl.getComponentType(); if (componentTypeOverride) { // SCA policy conformance: override policy sets configured on the component type component.getPolicySets().removeAll(definition.getPolicySets()); } initializeProperties(component, definition, context); createServices(definition, component, componentType); createReferences(definition, component, componentType); createProducers(definition, component, componentType); createConsumers(definition, component, componentType); createResourceReferences(component, componentType); return component; }
public LogicalComponent<CompositeImplementation> instantiate(ComponentDefinition<CompositeImplementation> definition, LogicalCompositeComponent parent, InstantiationContext context) { URI uri = URI.create(parent.getUri() + "/" + definition.getName()); Composite composite = definition.getImplementation().getComponentType(); LogicalCompositeComponent component = new LogicalCompositeComponent(uri, definition, parent); if (componentTypeOverride) { // SCA policy conformance: override policy sets configured on the component type component.getPolicySets().removeAll(definition.getPolicySets()); } initializeProperties(component, definition, context); instantiateChildComponents(component, composite, context); instantiateCompositeServices(component, composite); wireInstantiator.instantiateCompositeWires(composite, component, context); instantiateCompositeReferences(component, composite); instantiateResources(component, composite); wireInstantiator.instantiateCompositeWires(composite, component, context); if (channelInstantiator != null) { channelInstantiator.instantiateChannels(composite, component, context); } if (parent.getComponent(uri) != null) { DuplicateComponent error = new DuplicateComponent(uri, parent); context.addError(error); } parent.addComponent(component); return component; }
public PhysicalComponentDefinition generate(LogicalComponent<SpringImplementation> component) throws GenerationException { URI uri = component.getUri(); ComponentDefinition<SpringImplementation> componentDefinition = component.getDefinition(); SpringImplementation implementation = componentDefinition.getImplementation(); // if the app context is in a jar, calculate the base location, otherwise it is null String baseLocation = null; List<String> contextLocations = implementation.getContextLocations(); if (SpringImplementation.LocationType.JAR == implementation.getLocationType() || SpringImplementation.LocationType.DIRECTORY == implementation.getLocationType()) { baseLocation = implementation.getLocation(); } ComponentType type = componentDefinition.getComponentType(); Map<String, String> mappings = handleDefaultReferenceMappings(componentDefinition, type); SpringComponentDefinition.LocationType locationType = SpringComponentDefinition.LocationType.valueOf(implementation.getLocationType().toString()); SpringComponentDefinition physical = new SpringComponentDefinition(uri, baseLocation, contextLocations, mappings, locationType); processPropertyValues(component, physical); return physical; }
public PhysicalComponentDefinition generate(LogicalComponent<JUnitImplementation> component) throws GenerationException { ComponentDefinition<JUnitImplementation> definition = component.getDefinition(); JUnitImplementation implementation = definition.getImplementation(); InjectingComponentType type = implementation.getComponentType(); String scope = type.getScope(); ImplementationManagerDefinition managerDefinition = new ImplementationManagerDefinition(); managerDefinition.setComponentUri(component.getUri()); managerDefinition.setReinjectable(Scope.COMPOSITE.getScope().equals(scope)); managerDefinition.setConstructor(type.getConstructor()); managerDefinition.setInitMethod(type.getInitMethod()); managerDefinition.setDestroyMethod(type.getDestroyMethod()); managerDefinition.setImplementationClass(implementation.getImplementationClass()); helper.processInjectionSites(type, managerDefinition); JavaComponentDefinition physical = new JavaComponentDefinition(); physical.setScope(scope); physical.setManagerDefinition(managerDefinition); helper.processPropertyValues(component, physical); return physical; }
return true; if (containsTransactionIntent(parent.getDefinition().getImplementation().getIntents())) { return true;