/** * 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); } }
/** * 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); } }
/** * Attaches a future to the callback endpoint - so that the Future is triggered when a response is * received from the asynchronous service invocation associated with the Future * @param endpoint - the async callback endpoint * @param future - the async invocation future to attach */ private void attachFuture(RuntimeEndpoint endpoint, AsyncInvocationFutureImpl<?> future) { Implementation impl = endpoint.getComponent().getImplementation(); AsyncResponseHandlerImpl<?> asyncHandler = (AsyncResponseHandlerImpl<?>)impl; asyncHandler.addFuture(future); } // end method attachFuture
private String writeComposite(Composite composite, ExtensionPointRegistry registry, StAXArtifactProcessor<Composite> compositeProcessor){ ByteArrayOutputStream bos = new ByteArrayOutputStream(); XMLOutputFactory outputFactory = registry.getExtensionPoint(FactoryExtensionPoint.class) .getFactory(XMLOutputFactory.class); try { compositeProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), new ProcessorContext(registry)); } catch(Exception ex) { return ex.toString(); } String result = bos.toString(); // write out and nested composites for (Component component : composite.getComponents()) { if (component.getImplementation() instanceof Composite) { result += "\n<!-- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -->\n" + writeComposite((Composite)component.getImplementation(), registry, compositeProcessor); } } return result; } }
private String writeComposite(Composite composite, StAXArtifactProcessor<Composite> compositeProcessor){ ByteArrayOutputStream bos = new ByteArrayOutputStream(); XMLOutputFactory outputFactory = nodeFactory.getExtensionPointRegistry().getExtensionPoint(FactoryExtensionPoint.class) .getFactory(XMLOutputFactory.class); try { XMLStreamWriter xmlStreamWriter = outputFactory.createXMLStreamWriter(bos); compositeProcessor.write(composite, xmlStreamWriter, new ProcessorContext(nodeFactory.registry)); xmlStreamWriter.flush(); } catch(Exception ex) { return ex.toString(); } String result = bos.toString(); // write out and nested composites for (Component component : composite.getComponents()) { if (component.getImplementation() instanceof Composite) { result += "\n<!-- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -->\n" + writeComposite((Composite)component.getImplementation(), compositeProcessor); } } return result; }
protected boolean compositeUses(Composite c, String contributionURI, String compositeURI) { if (contributionURI.equals(c.getContributionURI()) && compositeURI.equals(c.getURI())) { return true; } for (Composite include : ((CompositeImpl)c).getFusedIncludes()) { if (compositeUses(include, contributionURI, compositeURI)) { return true; } } for (Component comp : c.getComponents()) { if (comp.getImplementation() instanceof Composite) { if (compositeUses((Composite)comp.getImplementation(), contributionURI, compositeURI)) { return true; } } } return false; } }
protected boolean compositeUses(Composite c, String contributionURI, String compositeURI) { if (contributionURI.equals(c.getContributionURI()) && compositeURI.equals(c.getURI())) { return true; } for (Composite include : ((CompositeImpl)c).getFusedIncludes()) { if (compositeUses(include, contributionURI, compositeURI)) { return true; } } for (Component comp : c.getComponents()) { if (comp.getImplementation() instanceof Composite) { if (compositeUses((Composite)comp.getImplementation(), contributionURI, compositeURI)) { return true; } } } return false; } }
private void processComposite(Composite composite, BuilderContext context){ // Index components, services and references Map<String, Component> components = new HashMap<String, Component>(); Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>(); Map<String, ComponentReference> componentReferences = new HashMap<String, ComponentReference>(); indexComponentsServicesAndReferences(composite, components, componentServices, componentReferences); // Connect component references as described in wires connectWires(composite, componentServices, componentReferences, context.getMonitor()); for (Component component : composite.getComponents()) { // recurse for composite implementations Implementation implementation = component.getImplementation(); if (implementation instanceof Composite) { processComposite((Composite)implementation, context); } } }
private String writeComposite(Composite composite, StAXArtifactProcessor<Composite> compositeProcessor){ ByteArrayOutputStream bos = new ByteArrayOutputStream(); XMLOutputFactory outputFactory = registry.getExtensionPoint(FactoryExtensionPoint.class) .getFactory(XMLOutputFactory.class); try { compositeProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), new ProcessorContext(registry)); } catch(Exception ex) { return ex.toString(); } String result = bos.toString(); // write out and nested composites for (Component component : composite.getComponents()) { if (component.getImplementation() instanceof Composite) { result += "\n<!-- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -->\n" + writeComposite((Composite)component.getImplementation(), compositeProcessor); } } return result; } }
private String writeComposite(Composite composite, StAXArtifactProcessor<Composite> compositeProcessor){ ByteArrayOutputStream bos = new ByteArrayOutputStream(); XMLOutputFactory outputFactory = registry.getExtensionPoint(FactoryExtensionPoint.class) .getFactory(XMLOutputFactory.class); try { compositeProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), new ProcessorContext(registry)); } catch(Exception ex) { return ex.toString(); } String result = bos.toString(); // write out and nested composites for (Component component : composite.getComponents()) { if (component.getImplementation() instanceof Composite) { result += "\n<!-- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -->\n" + writeComposite((Composite)component.getImplementation(), compositeProcessor); } } return result; } }
private void processComposite(Composite composite, BuilderContext context){ // Index components, services and references Map<String, Component> components = new HashMap<String, Component>(); Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>(); Map<String, ComponentReference> componentReferences = new HashMap<String, ComponentReference>(); indexComponentsServicesAndReferences(composite, components, componentServices, componentReferences); // Connect component references as described in wires connectWires(composite, componentServices, componentReferences, context.getMonitor()); for (Component component : composite.getComponents()) { // recurse for composite implementations Implementation implementation = component.getImplementation(); if (implementation instanceof Composite) { processComposite((Composite)implementation, context); } } }
/** * 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); } } } }
/** * 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); } } } }
protected List<T> findPolicies(Operation operation) { // collect together all the candidate policy sets List<PolicySet> policySets = new ArrayList<PolicySet>(); // add endpoint or endpoint reference policy sets policySets.addAll(subject.getPolicySets()); // add interface operation policy sets policySets.addAll(operation.getPolicySets()); // add implementation operation policy sets if (subject instanceof Endpoint){ for(Operation op :((Endpoint)subject).getComponent().getImplementation().getOperations()){ if (op.getName().equals(operation.getName())){ policySets.addAll(op.getPolicySets()); break; } } } return findPolicies(policySets); }
protected List<T> findPolicies(Operation operation) { // collect together all the candidate policy sets List<PolicySet> policySets = new ArrayList<PolicySet>(); // add endpoint or endpoint reference policy sets policySets.addAll(subject.getPolicySets()); // add interface operation policy sets policySets.addAll(operation.getPolicySets()); // add implementation operation policy sets if (subject instanceof Endpoint){ for(Operation op :((Endpoint)subject).getComponent().getImplementation().getOperations()){ if (op.getName().equals(operation.getName())){ policySets.addAll(op.getPolicySets()); break; } } } return findPolicies(policySets); }
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); } } } }
private void buildServiceBindings(Composite composite, BuilderContext context) { // build bindings recursively for (Component component : composite.getComponents()) { Implementation implementation = component.getImplementation(); if (implementation instanceof Composite) { buildServiceBindings((Composite)implementation, context); } } // find all the component service bindings for (Component component : composite.getComponents()) { for (ComponentService componentService : component.getServices()) { for (Binding binding : componentService.getBindings()) { BindingBuilder builder = builders.getBindingBuilder(binding.getType()); if (builder != null) { builder.build(component, componentService, binding, context, false); } } } } }
private void buildReferenceBindings(Composite composite, BuilderContext context) { // find all the component reference bindings (starting at top level) for (Component component : composite.getComponents()) { for (ComponentReference componentReference : component.getReferences()) { for (Binding binding : componentReference.getBindings()) { BindingBuilder builder = builders.getBindingBuilder(binding.getType()); if (builder != null) { builder.build(component, componentReference, binding, context, false); } } } } // build bindings recursively for (Component component : composite.getComponents()) { Implementation implementation = component.getImplementation(); if (implementation instanceof Composite) { buildReferenceBindings((Composite)implementation, context); } } }
private void buildReferenceBindings(Composite composite, BuilderContext context) { // find all the component reference bindings (starting at top level) for (Component component : composite.getComponents()) { for (ComponentReference componentReference : component.getReferences()) { for (Binding binding : componentReference.getBindings()) { BindingBuilder builder = builders.getBindingBuilder(binding.getType()); if (builder != null) { builder.build(component, componentReference, binding, context, false); } } } } // build bindings recursively for (Component component : composite.getComponents()) { Implementation implementation = component.getImplementation(); if (implementation instanceof Composite) { buildReferenceBindings((Composite)implementation, context); } } }
private void buildServiceBindings(Composite composite, BuilderContext context) { // build bindings recursively for (Component component : composite.getComponents()) { Implementation implementation = component.getImplementation(); if (implementation instanceof Composite) { buildServiceBindings((Composite)implementation, context); } } // find all the component service bindings for (Component component : composite.getComponents()) { for (ComponentService componentService : component.getServices()) { for (Binding binding : componentService.getBindings()) { BindingBuilder builder = builders.getBindingBuilder(binding.getType()); if (builder != null) { builder.build(component, componentService, binding, context, false); } } } } }