Implementation implementation = component.getImplementation(); if (implementation == null) { Messages.ASSEMBLY_VALIDATION, "NoComponentImplementation", component.getName()); return false; } else if (implementation.isUnresolved()) { "UnresolvedComponentImplementation", component, component.getName(), implementation.getURI()); return false;
/** * URI construction for component bindings based on Assembly Specification section 1.7.2. This method * calculates the component URI part based on component information before calling the generic * constructBindingURI method * * @param component the component that holds the service * @param service the service that holds the binding * @param binding the binding for which the URI is being constructed * @param defaultBindings the list of default binding configurations */ private void constructBindingURI(Component component, Service service, Binding binding, Map<QName, List<String>> defaultBindings, Monitor monitor) throws CompositeBuilderException { constructBindingURI(component.getURI(), service, binding, defaultBindings, monitor); }
private void connectServicesToComponentType(Component component, Monitor monitor) { for (ComponentService componentService : component.getServices()) { if (componentService != component.getService(componentService.getName())){ Monitor.error(monitor, this, Messages.ASSEMBLY_VALIDATION, "DuplicateComponentServiceName", component.getName(), componentService.getName()); if (component.getImplementation() == null) { Service service = component.getImplementation().getService(componentService.getName()); Messages.ASSEMBLY_VALIDATION, "ServiceNotFoundForComponentService", component.getName(), componentService.getName());
/** * Clone composite component implementations * * @param composite * @param problems */ private void cloneCompositeImplementations(Composite composite) { for (Component component : composite.getComponents()) { Implementation implementation = component.getImplementation(); if (implementation instanceof Composite) { Composite compositeImplementation = (Composite)implementation; try { // Please note the clone method is recursive Composite clone = (Composite)compositeImplementation.clone(); component.setImplementation(clone); } catch (CloneNotSupportedException e) { throw new UnsupportedOperationException(e); } } } }
/** * @param component */ public static ComponentService getSingleService(Component component) { ComponentService targetService; List<ComponentService> services = component.getServices(); List<ComponentService> regularServices = new ArrayList<ComponentService>(); for (ComponentService service : services) { if (service.isForCallback()) { continue; } String name = service.getName(); if (!name.startsWith("$") || name.startsWith("$dynamic$")) { regularServices.add(service); } } if (regularServices.size() == 0) { throw new ServiceRuntimeException("No service is declared on component " + component.getURI()); } if (regularServices.size() != 1) { throw new ServiceRuntimeException("More than one service is declared on component " + component.getURI() + ". Service name is required to get the service."); } targetService = regularServices.get(0); return targetService; }
public void deactivateComponent(Component component) throws ActivationException { try { if (logger.isLoggable(Level.FINE)) { logger.fine("Deactivating component: " + component.getURI()); } for (ComponentService service : component.getServices()) { deactivate((RuntimeComponent) component, (RuntimeComponentService) service); } for (ComponentReference reference : component.getReferences()) { deactivate((RuntimeComponent) component, (RuntimeComponentReference) reference); } Implementation implementation = component.getImplementation(); if (implementation instanceof Composite) { deactivate((Composite) implementation); } else if (implementation != null) { removeImplementationProvider((RuntimeComponent) component); removeScopeContainer(component); } } catch (Exception e) { throw new ActivationException(e); } }
if (promotedService != null) { if (promotedService.getName() != null) { promote = promotedComponent.getName() + '/' + promotedService.getName(); } else { promote = promotedComponent.getName(); writeStart(writer, COMPONENT, new XAttr(NAME, component.getName()), new XAttr(URI, component.getURI()), new XAttr(AUTOWIRE, component.getAutowire()), policyProcessor.writePolicies(component)); Implementation implementation = component.getImplementation(); if (implementation instanceof Composite) { writeStart(writer, IMPLEMENTATION_COMPOSITE, new XAttr(NAME, ((Composite)implementation).getName()), policyProcessor.writePolicies(implementation)); extensionProcessor.write(component.getImplementation(), writer, context); for (Object extension : component.getExtensions()) { extensionProcessor.write(extension, writer, context); for (ComponentService service : component.getServices()) { writeStart(writer, SERVICE, new XAttr(NAME, service.getName()), policyProcessor.writePolicies(service)); for (ComponentReference reference : component.getReferences()) { writeStart(writer, REFERENCE,
resolveContracts(component, component.getServices(), resolver, context); resolveContracts(component, component.getReferences(), resolver, context); for (ComponentProperty componentProperty : component.getProperties()) { resolvePropertyType("component " + component.getName(), componentProperty, context.getContribution(), context); Implementation implementation = component.getImplementation(); if (implementation != null) { if ( !policySets.isEmpty() || !component.getPolicySets().isEmpty() ) { implementation.getPolicySets().clear(); implementation.getPolicySets().addAll(policySets); resolveContractOperationPolicy(implementation.getReferences(), resolver, context); component.setImplementation(implementation);
component.getServices().add(componentService); policyProcessor.readPolicies(contract, reader); } else { promotedComponent.setUnresolved(true); promotedComponent.setName(promotedComponentName); compositeService.setPromotedComponent(promotedComponent); component.getReferences().add(componentReference); policyProcessor.readPolicies(contract, reader); } else { promotedComponent.setName(promotedComponentName); promotedComponent.setUnresolved(true); compositeReference.getPromotedComponents().add(promotedComponent); ComponentReference promotedReference = component.getProperties().add(componentProperty); } else { component.setName(getString(reader, NAME)); if (isSet(reader, AUTOWIRE)) { component.setAutowire(getBoolean(reader, AUTOWIRE)); component.setURI(getURIString(reader, URI)); component.setImplementation(implementation); policyProcessor.readPolicies(implementation, reader); } else if (REQUIRES_QNAME.equals(name)) {
public Component getComponent(String name) { Component component = null; for (Component tmp : getComponents()){ if (tmp.getName().equals(name)){ component = tmp; break; } } return component; }
private void connectPropertiesToComponentType(Component component, Monitor monitor) { for (ComponentProperty componentProperty : component.getProperties()) { if (componentProperty != component.getProperty(componentProperty.getName())){ Monitor.error(monitor, this, Property property = component.getImplementation().getProperty(componentProperty.getName()); Messages.ASSEMBLY_VALIDATION, "PropertyNotFound", component.getName(), componentProperty.getName());
private void connectReferencesToComponentType(Component component, Monitor monitor) { for (ComponentReference componentReference : component.getReferences()) { if (componentReference != component.getReference(componentReference.getName())){ Monitor.error(monitor, this, Messages.ASSEMBLY_VALIDATION, "DuplicateComponentReferenceName", component.getName(), componentReference.getName()); if (component.getImplementation() == null) { Reference reference = component.getImplementation().getReference(componentReference.getName()); Messages.ASSEMBLY_VALIDATION, "ReferenceNotFoundForComponentReference", component.getName(), componentReference.getName());
Component component = (Component)endpoint.getComponent().clone(); component.setImplementation(null); composite.getComponents().add(component); component.getReferences().clear(); component.getServices().clear(); component.getRequiredIntents().clear(); component.getRequiredIntents().addAll(endpoint.getRequiredIntents()); component.getPolicySets().clear(); component.getPolicySets().addAll(endpoint.getPolicySets()); component.getServices().add(service); service.getBindings().clear(); service.setInterfaceContract(endpoint.getComponentServiceInterfaceContract());
Implementation implementation = component.getImplementation(); if (implementation instanceof Composite) { processIncludes((Composite)implementation, monitor); if (component.getAutowire() == null && Boolean.TRUE.equals(merged.getAutowire())) { component.setAutowire(Boolean.TRUE); component.getRequiredIntents().addAll(merged.getRequiredIntents()); component.getPolicySets().addAll(merged.getPolicySets());
/** * Use the component type builder to build the component type for * this component. * * @param component */ private void createComponentType(Component component, BuilderContext context) { Implementation implementation = component.getImplementation(); if (implementation instanceof Composite) { componentTypeBuilder.createComponentType(component, (Composite)implementation, context); } }
if (component != composite.getComponent(component.getName())) { Monitor.error(monitor, this, "DuplicateComponentName", composite.getName().toString(), component.getName()); if (component.getAutowire() == null) { component.setAutowire(composite.getAutowire());
if (!component.getName().equals(componentName)) { continue; for (Service service : component.getServices()) { if (serviceName != null && !service.getName().equals(serviceName)) { continue;
private void populateLocalRegistry(Composite composite, DomainRegistry registry, BuilderContext context){ for (Component component : composite.getComponents()) { // recurse for composite implementations Implementation implementation = component.getImplementation(); if (implementation instanceof Composite) { populateLocalRegistry((Composite)implementation, registry, context); } // add all endpoints to the local registry for (ComponentService service : component.getServices()) { for (Endpoint endpoint : service.getEndpoints()){ registry.addEndpoint(endpoint); } } // add endpoint references that we want to match to the registry for (ComponentReference reference : component.getReferences()) { for (EndpointReference epr : reference.getEndpointReferences()){ if (epr.getStatus().equals(EndpointReference.Status.WIRED_TARGET_NOT_FOUND)|| epr.getStatus().equals(EndpointReference.Status.WIRED_TARGET_IN_BINDING_URI)){ registry.addEndpointReference(epr); } } } } }
private void addServicesFromComponentType(Component component, Monitor monitor) { // Create a component service for each service if (component.getImplementation() != null) { for (Service service : component.getImplementation().getServices()) { // check for duplicate service names in implementation if (service != component.getImplementation().getService(service.getName())){ Monitor.error(monitor, this, Messages.ASSEMBLY_VALIDATION, "DuplicateImplementationServiceName", component.getName(), service.getName()); } ComponentService componentService = (ComponentService)component.getService(service.getName()); // if the component doesn't have a service with the same name as the // component type service then create one if (componentService == null) { componentService = assemblyFactory.createComponentService(); componentService.setForCallback(service.isForCallback()); String name = service.getName(); componentService.setName(name); component.getServices().add(componentService); } } } }
for (ComponentProperty componentProperty : component.getProperties()) { reconcileComponentPropertyWithComponentType(component, componentProperty, monitor); Messages.ASSEMBLY_VALIDATION, "NoTypeForComponentProperty", component.getName(), componentProperty.getName()); "PropertyMustSupplyNull", component.getName(), componentProperty.getName());