/** * Determines the service transaction type. * * @param component the component * @return the transaction type */ private SessionType getSessionType(LogicalComponent<?> component) { List<String> policies = component.getDefinition().getComponentType().getPolicies(); if (policies.contains(MANAGED_TRANSACTION) || policies.contains(MANAGED_TRANSACTION_GLOBAL) || policies.contains(MANAGED_TRANSACTION_LOCAL)) { return SessionType.GLOBAL_TRANSACTED; } return SessionType.AUTO_ACKNOWLEDGE; }
/** * 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 (Component<?> definition : composite.getComponents().values()) { if (definition.getComponentType() instanceof Composite) { Composite componentType = Composite.class.cast(definition.getComponentType()); addContributionUri(contributionUri, componentType); } else { definition.setContributionUri(contributionUri); } } }
/** * 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 (Component<?> definition : composite.getComponents().values()) { if (definition.getComponentType() instanceof Composite) { Composite componentType = Composite.class.cast(definition.getComponentType()); addContributionUri(contributionUri, componentType); } else { definition.setContributionUri(contributionUri); } } }
private void setContributionUris(Composite composite) { URI uri = ContributionResolver.getContribution(); composite.setContributionUri(uri); for (Component<? extends Implementation<?>> definition : composite.getComponents().values()) { definition.setContributionUri(uri); if (definition.getComponentType() instanceof Composite) { setContributionUris((Composite) definition.getComponentType()); } } }
private void setContributionUris(Composite composite) { URI uri = ContributionResolver.getContribution(); composite.setContributionUri(uri); for (Component<? extends Implementation<?>> definition : composite.getComponents().values()) { definition.setContributionUri(uri); if (definition.getComponentType() instanceof Composite) { setContributionUris((Composite) definition.getComponentType()); } } }
/** * Returns the key specified on the component, component type, or {@link Integer#MIN_VALUE} * * @param logicalComponent the component * @return the key or null */ private int getOrder(LogicalComponent logicalComponent) { int order = logicalComponent.getDefinition().getOrder(); if (order == Integer.MIN_VALUE) { Component<?> component = logicalComponent.getDefinition(); if (component.getComponentType() != null) { order = component.getComponentType().getOrder(); } } return order; }
/** * Returns the key specified on the component, component type, or {@link Integer#MIN_VALUE} * * @param logicalComponent the component * @return the key or null */ private int getOrder(LogicalComponent logicalComponent) { int order = logicalComponent.getDefinition().getOrder(); if (order == Integer.MIN_VALUE) { Component<?> component = logicalComponent.getDefinition(); if (component.getComponentType() != null) { order = component.getComponentType().getOrder(); } } return order; }
/** * 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(Component<?> definition, LogicalCompositeComponent parent, InstantiationContext context) { if (definition.getComponentType() instanceof Composite) { Component<CompositeImplementation> component = (Component<CompositeImplementation>) definition; return compositeComponentInstantiator.instantiate(component, parent, context); } else { Component<Implementation<?>> component = (Component<Implementation<?>>) definition; return atomicComponentInstantiator.instantiate(component, parent, context); } }
/** * Returns the key specified on the component, 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 if (component.getDefinition().getComponentType() != null) { key = component.getDefinition().getComponentType().getKey(); } } return key; }
private void addService(Class<?> interfaze, Component<?> definition) throws ValidationDeploymentException { URI uri = ContributionResolver.getContribution(); DefaultIntrospectionContext context = new DefaultIntrospectionContext(uri, getClass().getClassLoader()); JavaServiceContract contract = contractProcessor.introspect(interfaze, context); Service<ComponentType> service = new Service<>(interfaze.getSimpleName(), contract); definition.getComponentType().add(service); checkErrors(context); }
/** * Returns the key specified on the component, 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 if (component.getDefinition().getComponentType() != null) { key = component.getDefinition().getComponentType().getKey(); } } return key; }
private void addService(Class<?> interfaze, Component<?> definition) throws ValidationDeploymentException { URI uri = ContributionResolver.getContribution(); DefaultIntrospectionContext context = new DefaultIntrospectionContext(uri, getClass().getClassLoader()); JavaServiceContract contract = contractProcessor.introspect(interfaze, context); Service<ComponentType> service = new Service<>(interfaze.getSimpleName(), contract); definition.getComponentType().add(service); checkErrors(context); }
private <I> ScopedComponent createPhysicalComponent(LogicalComponent<?> logicalComponent, I instance) { URI uri = logicalComponent.getUri(); InjectingComponentType type = (InjectingComponentType) logicalComponent.getDefinition().getComponentType(); type.getInjectionSites(); return new SingletonComponent(uri, instance, type.getInjectionSites(), BOOT_CONTRIBUTION); }
private <I> ScopedComponent createPhysicalComponent(LogicalComponent<?> logicalComponent, I instance) { URI uri = logicalComponent.getUri(); InjectingComponentType type = (InjectingComponentType) logicalComponent.getDefinition().getComponentType(); type.getInjectionSites(); return new SingletonComponent(uri, instance, type.getInjectionSites(), BOOT_CONTRIBUTION); }
/** * Returns true if the reference is not keyed, true if the reference is keyed and the target specifies a key, false if the reference is keyed and the target * does not specify a key. * * @param logicalReference the logical reference * @param target the target * @return true if the reference is not keyed, true if the reference is keyed and the target specifies a key, false if the reference is keyed and the target * does not specify a key */ private boolean validKey(LogicalReference logicalReference, LogicalComponent<?> target) { return !logicalReference.getDefinition().isKeyed() || target.getDefinition().getKey() != null || target.getDefinition().getComponentType().getKey() != null; } }
/** * Returns true if the reference is not keyed, true if the reference is keyed and the target specifies a key, false if the reference is keyed and the target * does not specify a key. * * @param logicalReference the logical reference * @param target the target * @return true if the reference is not keyed, true if the reference is keyed and the target specifies a key, false if the reference is keyed and the target * does not specify a key */ private boolean validKey(LogicalReference logicalReference, LogicalComponent<?> target) { return !logicalReference.getDefinition().isKeyed() || target.getDefinition().getKey() != null || target.getDefinition().getComponentType().getKey() != null; } }
/** * Validates a target key is present for keyed references. * * @param reference the reference * @param service the service * @param context the logical context */ private void validateKeyedReference(LogicalReference reference, LogicalService service, InstantiationContext context) { if (!reference.getDefinition().isKeyed()) { return; } LogicalComponent<?> parent = service.getParent(); if (parent.getDefinition().getKey() == null && parent.getDefinition().getComponentType().getKey() == null) { KeyNotFound error = new KeyNotFound(reference); context.addError(error); } }
/** * Validates a target key is present for keyed references. * * @param reference the reference * @param service the service * @param context the logical context */ private void validateKeyedReference(LogicalReference reference, LogicalService service, InstantiationContext context) { if (!reference.getDefinition().isKeyed()) { return; } LogicalComponent<?> parent = service.getParent(); if (parent.getDefinition().getKey() == null && parent.getDefinition().getComponentType().getKey() == null) { KeyNotFound error = new KeyNotFound(reference); context.addError(error); } }
@SuppressWarnings({"unchecked"}) public LogicalComponent instantiate(Component<?> component, LogicalCompositeComponent parent, InstantiationContext context) { URI uri = URI.create(parent.getUri() + "/" + component.getName()); LogicalComponent<?> logicalComponent = new LogicalComponent(uri, component, parent); if (parent.getComponent(uri) != null) { DuplicateComponent error = new DuplicateComponent(uri, parent); context.addError(error); } parent.addComponent(logicalComponent); ComponentType componentType = component.getComponentType(); if (componentType == null) { return logicalComponent; } initializeProperties(logicalComponent, component, context); createServices(component, logicalComponent, componentType); createReferences(component, logicalComponent, componentType); createProducers(component, logicalComponent, componentType); createConsumers(component, logicalComponent, componentType); createResourceReferences(logicalComponent, componentType); return logicalComponent; }
@SuppressWarnings({"unchecked"}) public LogicalComponent instantiate(Component<?> component, LogicalCompositeComponent parent, InstantiationContext context) { URI uri = URI.create(parent.getUri() + "/" + component.getName()); LogicalComponent<?> logicalComponent = new LogicalComponent(uri, component, parent); if (parent.getComponent(uri) != null) { DuplicateComponent error = new DuplicateComponent(uri, parent); context.addError(error); } parent.addComponent(logicalComponent); ComponentType componentType = component.getComponentType(); if (componentType == null) { return logicalComponent; } initializeProperties(logicalComponent, component, context); createServices(component, logicalComponent, componentType); createReferences(component, logicalComponent, componentType); createProducers(component, logicalComponent, componentType); createConsumers(component, logicalComponent, componentType); createResourceReferences(logicalComponent, componentType); return logicalComponent; }