protected JavaComponentBuilder(String name, Object instance) { Class<?> clazz = instance.getClass(); String className = clazz.getName(); InjectingComponentType componentType = new InjectingComponentType(clazz); JavaImplementation implementation = new JavaImplementation(instance); implementation.setComponentType(componentType); implementation.setImplementationClass(clazz); component = new Component<>(name); component.setImplementation(implementation); }
protected JavaImplementation createImplementation(Class<?> clazz, IntrospectionContext context) { JavaImplementation implementation = new JavaImplementation(); implementation.setImplementationClass(clazz); InjectingComponentType componentType = new InjectingComponentType(clazz); implementation.setComponentType(componentType); return implementation; }
protected JavaComponentBuilder(String name, Class<?> clazz) { String className = clazz.getName(); InjectingComponentType componentType = new InjectingComponentType(clazz); JavaImplementation implementation = new JavaImplementation(); implementation.setImplementationClass(clazz); implementation.setComponentType(componentType); component = new Component<>(name); component.setImplementation(implementation); }
protected SystemComponentBuilder(String name, Class<?> clazz) { InjectingComponentType componentType = new InjectingComponentType(clazz); SystemImplementation implementation = new SystemImplementation(clazz); implementation.setComponentType(componentType); component = new Component<>(name); component.setImplementation(implementation); }
public Map<AccessibleObject, Supplier<Object>> getInjectors(Class<?> clazz) { Map<AccessibleObject, Supplier<Object>> injectors = new HashMap<>(); // introspect class InjectingComponentType componentType = new InjectingComponentType(clazz); DefaultIntrospectionContext context = new DefaultIntrospectionContext(); TypeMapping typeMapping = new TypeMapping(); context.addTypeMapping(clazz, typeMapping); introspectionHelper.resolveTypeParameters(clazz, typeMapping); classVisitor.visit(componentType, clazz, context); for (PostProcessor postProcessor : postProcessors) { postProcessor.process(componentType, clazz, context); } // process injection sites for (Map.Entry<ModelObject, InjectionSite> entry : componentType.getInjectionSiteMappings().entrySet()) { ModelObject key = entry.getKey(); InjectionSite value = entry.getValue(); if (key instanceof Reference) { Reference<?> reference = (Reference) key; handleReference(reference, value, clazz, injectors); } else if (key instanceof Producer) { Producer producer = (Producer) key; throw new UnsupportedOperationException("Not yet implemented"); } else if (key instanceof Consumer) { throw new UnsupportedOperationException("Not yet implemented"); } } return injectors; }
public Map<AccessibleObject, Supplier<Object>> getInjectors(Class<?> clazz) { Map<AccessibleObject, Supplier<Object>> injectors = new HashMap<>(); // introspect class InjectingComponentType componentType = new InjectingComponentType(clazz); DefaultIntrospectionContext context = new DefaultIntrospectionContext(); TypeMapping typeMapping = new TypeMapping(); context.addTypeMapping(clazz, typeMapping); introspectionHelper.resolveTypeParameters(clazz, typeMapping); classVisitor.visit(componentType, clazz, context); for (PostProcessor postProcessor : postProcessors) { postProcessor.process(componentType, clazz, context); } // process injection sites for (Map.Entry<ModelObject, InjectionSite> entry : componentType.getInjectionSiteMappings().entrySet()) { ModelObject key = entry.getKey(); InjectionSite value = entry.getValue(); if (key instanceof Reference) { Reference<?> reference = (Reference) key; handleReference(reference, value, clazz, injectors); } else if (key instanceof Producer) { Producer producer = (Producer) key; throw new UnsupportedOperationException("Not yet implemented"); } else if (key instanceof Consumer) { throw new UnsupportedOperationException("Not yet implemented"); } } return injectors; }
private <T> LogicalComponent<NonManagedImplementation> createComponent(Class<T> interfaze, LogicalCompositeComponent domain, String root) { URI componentUri = URI.create(root + "/F3Synthetic"); InjectingComponentType componentType = new InjectingComponentType(); NonManagedImplementation implementation = new NonManagedImplementation(); implementation.setComponentType(componentType); Component<NonManagedImplementation> component = new Component<>("F3Synthetic"); component.setContributionUri(ContributionResolver.getContribution(interfaze)); component.setImplementation(implementation); return new LogicalComponent<>(componentUri, component, domain); }
private <T> LogicalComponent<NonManagedImplementation> createComponent(Class<T> interfaze, LogicalCompositeComponent domain, String root) { URI componentUri = URI.create(root + "/F3Synthetic"); InjectingComponentType componentType = new InjectingComponentType(); NonManagedImplementation implementation = new NonManagedImplementation(); implementation.setComponentType(componentType); Component<NonManagedImplementation> component = new Component<>("F3Synthetic"); component.setContributionUri(ContributionResolver.getContribution(interfaze)); component.setImplementation(implementation); return new LogicalComponent<>(componentUri, component, domain); }
public SystemImplementation load(XMLStreamReader reader, IntrospectionContext introspectionContext) throws XMLStreamException { Location startLocation = reader.getLocation(); SystemImplementation implementation = new SystemImplementation(); validateAttributes(reader, introspectionContext, implementation); String implClass = reader.getAttributeValue(null, "class"); if (implClass == null) { MissingAttribute failure = new MissingAttribute("Implementation class must be specified using the class attribute", startLocation); introspectionContext.addError(failure); return null; } Class<?> clazz; try { clazz = introspectionContext.getClassLoader().loadClass(implClass); } catch (ClassNotFoundException e) { InvalidValue failure = new InvalidValue("Implementation class not found:" + implClass, startLocation); introspectionContext.addError(failure); return null; } LoaderUtil.skipToEndElement(reader); implementation.setImplementationClass(clazz); InjectingComponentType componentType = new InjectingComponentType(clazz); implementationIntrospector.introspect(componentType, introspectionContext); implementation.setComponentType(componentType); return implementation; }
private <T> LogicalProducer createProducer(Class<T> interfaze, URI channelUri) throws InterfaceException { JavaServiceContract contract = introspector.introspect(interfaze); LogicalCompositeComponent domainComponent = lcm.getRootComponent(); String domainRoot = domainComponent.getUri().toString(); URI componentUri = URI.create(domainRoot + "/F3Synthetic"); InjectingComponentType componentType = new InjectingComponentType(); NonManagedImplementation implementation = new NonManagedImplementation(); implementation.setComponentType(componentType); ComponentDefinition<NonManagedImplementation> componentDefinition = new ComponentDefinition<>("F3Synthetic"); componentDefinition.setContributionUri(ContributionResolver.getContribution(interfaze)); componentDefinition.setImplementation(implementation); LogicalComponent<NonManagedImplementation> logicalComponent = new LogicalComponent<>(componentUri, componentDefinition, domainComponent); ProducerDefinition producerDefinition = new ProducerDefinition("producer", contract); LogicalProducer producer = new LogicalProducer(URI.create(domainRoot + "/F3Synthetic#producer"), producerDefinition, logicalComponent); producer.addTarget(channelUri); return producer; }
public JavaImplementation load(XMLStreamReader reader, IntrospectionContext introspectionContext) throws XMLStreamException { Location startLocation = reader.getLocation(); JavaImplementation implementation = new JavaImplementation(); validateAttributes(reader, introspectionContext, implementation); String implClass = reader.getAttributeValue(null, "class"); if (implClass == null) { MissingAttribute failure = new MissingAttribute("The class attribute was not specified", startLocation); introspectionContext.addError(failure); LoaderUtil.skipToEndElement(reader); return implementation; } Class<?> clazz; try { clazz = introspectionContext.getClassLoader().loadClass(implClass); } catch (ClassNotFoundException e) { ImplementationArtifactNotFound failure = new ImplementationArtifactNotFound(implClass, e.getMessage(), implementation); introspectionContext.addError(failure); LoaderUtil.skipToEndElement(reader); return null; } LoaderUtil.skipToEndElement(reader); implementation.setImplementationClass(clazz); InjectingComponentType componentType = new InjectingComponentType(clazz); introspector.introspect(componentType, introspectionContext); implementation.setComponentType(componentType); return implementation; }
protected TimerComponentBuilder(String name, Class<?> clazz, TimerType type) { InjectingComponentType componentType = new InjectingComponentType(clazz); TimerImplementation implementation = new TimerImplementation(); implementation.setImplementationClass(clazz); TimerData data = new TimerData(); data.setType(type); implementation.setTimerData(data); implementation.setComponentType(componentType); component = new Component<>(name); component.setImplementation(implementation); }
protected TimerComponentBuilder(String name, Class<?> clazz, TimerType type) { InjectingComponentType componentType = new InjectingComponentType(clazz); TimerImplementation implementation = new TimerImplementation(); implementation.setImplementationClass(clazz); TimerData data = new TimerData(); data.setType(type); implementation.setTimerData(data); implementation.setComponentType(componentType); component = new Component<>(name); component.setImplementation(implementation); }
InjectingComponentType componentType = new InjectingComponentType(instanceClass); implementationIntrospector.introspect(componentType, context); implementation.setComponentType(componentType); Service<ComponentType> service = new Service<>(serviceName, contract); InjectingComponentType componentType = new InjectingComponentType(instanceClass); componentType.add(service);
InjectingComponentType componentType = new InjectingComponentType(instanceClass); implementationIntrospector.introspect(componentType, context); implementation.setComponentType(componentType); Service<ComponentType> service = new Service<>(serviceName, contract); InjectingComponentType componentType = new InjectingComponentType(instanceClass); componentType.add(service);
public Resource introspect(Class<?> clazz, Contribution contribution, IntrospectionContext context) { ResourceElement<WebComponentTypeSymbol, WebComponentType> element = getTypeElement(contribution); WebComponentType componentType = element.getValue(); // introspect the class and generate a component type that will be merged into the web component type WebArtifactImplementation artifactImpl = new WebArtifactImplementation(); InjectingComponentType tempType = new InjectingComponentType(clazz); artifactImpl.setComponentType(tempType); TypeMapping mapping = context.getTypeMapping(clazz); if (mapping == null) { mapping = new TypeMapping(); context.addTypeMapping(clazz, mapping); helper.resolveTypeParameters(clazz, mapping); } classVisitor.visit(tempType, clazz, context); mergeComponentTypes(componentType, tempType, context); return element.getResource(); }