Examples of AtomicComponent


Examples of org.apache.tuscany.model.assembly.AtomicComponent

    }

    private List<ContextFactory<Context>> createConfigurations() throws BuilderException, ConfigurationLoadException {
        WireFactoryService wireService = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(), new DefaultPolicyBuilderRegistry());
        JavaContextFactoryBuilder builder = new JavaContextFactoryBuilder(wireService);
        AtomicComponent component = MockFactory.createComponent("TestService1", SessionScopeComponentImpl.class, Scope.SESSION);
        ComponentTypeIntrospector introspector = MockFactory.getIntrospector();
        ComponentType type = introspector.introspect(SessionScopeComponentImpl.class);
        component.getImplementation().setComponentType(type);
        builder.build(component);
        List<ContextFactory<Context>> configs = new ArrayList<ContextFactory<Context>>();
        configs.add((ContextFactory<Context>) component.getContextFactory());
        return configs;
    }
View Full Code Here

Examples of org.apache.tuscany.model.assembly.AtomicComponent

    }

    private ContextFactory<Context> createConfiguration(String name) throws BuilderException, ConfigurationLoadException {
        WireFactoryService wireService = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(), new DefaultPolicyBuilderRegistry());
        JavaContextFactoryBuilder builder = new JavaContextFactoryBuilder(wireService);
        AtomicComponent component = MockFactory.createComponent(name, SessionScopeInitDestroyComponent.class, Scope.SESSION);
        ComponentTypeIntrospector introspector = MockFactory.getIntrospector();
        ComponentType type = introspector.introspect(SessionScopeInitDestroyComponent.class);
        component.getImplementation().setComponentType(type);
        builder.build(component);
        return (ContextFactory<Context>) component.getContextFactory();
    }
View Full Code Here

Examples of org.apache.tuscany.model.assembly.AtomicComponent

     * @param name  the component name
     * @param type  the implementation type
     * @param scope the component scope
     */
    public static AtomicComponent createComponent(String name, Class type, Scope scope) throws ConfigurationLoadException {
        AtomicComponent sc = factory.createSimpleComponent();
        JavaImplementation impl = factory.createJavaImplementation();
        impl.setComponentType(getIntrospector().introspect(type));
        impl.setImplementationClass(type);
        sc.setImplementation(impl);
        Service s = factory.createService();
        JavaServiceContract ji = factory.createJavaServiceContract();
        ji.setInterface(type);
        s.setServiceContract(ji);
        ji.setScope(scope);
        impl.getComponentType().getServices().add(s);
        sc.setName(name);
        sc.setImplementation(impl);
        return sc;
    }
View Full Code Here

Examples of org.apache.tuscany.model.assembly.AtomicComponent

        sc.setImplementation(impl);
        return sc;
    }

    public static AtomicComponent createNonIntrospectedComponent(String name, Class service, Class type, Scope scope) throws ConfigurationLoadException {
        AtomicComponent sc = factory.createSimpleComponent();
        JavaImplementation impl = factory.createJavaImplementation();
        impl.setComponentType(factory.createComponentType());
        impl.setImplementationClass(type);
        sc.setImplementation(impl);
        Service s = factory.createService();
        JavaServiceContract ji = factory.createJavaServiceContract();
        ji.setInterface(service);
        s.setServiceContract(ji);
        ji.setScope(scope);
        impl.getComponentType().getServices().add(s);
        sc.setName(name);
        sc.setImplementation(impl);
        return sc;
    }
View Full Code Here

Examples of org.apache.tuscany.model.assembly.AtomicComponent

     */

    public static Module createModuleWithWiredComponents(Scope sourceScope, Scope targetScope) {

        // create the target component
        AtomicComponent target = factory.createSimpleComponent();
        target.setName("target");
        JavaImplementation targetImpl = factory.createJavaImplementation();
        targetImpl.setComponentType(factory.createComponentType());
        targetImpl.setImplementationClass(TargetImpl.class);
        target.setImplementation(targetImpl);
        Service targetService = factory.createService();
        JavaServiceContract targetContract = factory.createJavaServiceContract();
        targetContract.setInterface(Target.class);
        targetService.setServiceContract(targetContract);
        targetService.setName("Target");
        targetImpl.getComponentType().getServices().add(targetService);
        targetContract.setScope(targetScope);
        ConfiguredService cTargetService = factory.createConfiguredService();
        cTargetService.setPort(targetService);
        cTargetService.initialize(assemblyContext);
        target.getConfiguredServices().add(cTargetService);
        target.initialize(assemblyContext);

        // create the source component
        AtomicComponent source = factory.createSimpleComponent();
        ComponentType componentType = factory.createComponentType();
        source.setName("source");
        JavaImplementation impl = factory.createJavaImplementation();
        impl.setComponentType(componentType);
        impl.setImplementationClass(SourceImpl.class);
        source.setImplementation(impl);
        Service s = systemFactory.createService();
        JavaServiceContract contract = systemFactory.createJavaServiceContract();
        contract.setInterface(Source.class);
        s.setServiceContract(contract);
        contract.setScope(sourceScope);
        impl.getComponentType().getServices().add(s);
        source.setImplementation(impl);

        // wire source to target
        JavaServiceContract refContract = systemFactory.createJavaServiceContract();
        refContract.setInterface(Target.class);
        Reference reference = systemFactory.createReference();
        reference.setName("setTarget");
        reference.setServiceContract(refContract);
        componentType.getReferences().add(reference);
        ConfiguredReference cReference = systemFactory.createConfiguredReference(reference.getName(), "target");
        cReference.initialize(assemblyContext);
        source.getConfiguredReferences().add(cReference);

        // wire multiplicity using a setter
        JavaServiceContract refContract2 = systemFactory.createJavaServiceContract();
        refContract2.setInterface(Target.class);
        Reference reference2 = systemFactory.createReference();
        reference2.setName("setTargets");
        reference2.setServiceContract(refContract2);
        reference2.setMultiplicity(Multiplicity.ONE_N);
        componentType.getReferences().add(reference2);
        ConfiguredReference cReference2 = systemFactory.createConfiguredReference(reference2.getName(), "target");
        cReference2.initialize(assemblyContext);
        source.getConfiguredReferences().add(cReference2);

        // wire multiplicity using a field
        JavaServiceContract refContract3 = systemFactory.createJavaServiceContract();
        refContract3.setInterface(Target.class);
        Reference reference3 = systemFactory.createReference();
        reference3.setName("targetsThroughField");
        reference3.setServiceContract(refContract3);
        reference3.setMultiplicity(Multiplicity.ONE_N);
        componentType.getReferences().add(reference3);
        ConfiguredReference cReference3 = systemFactory.createConfiguredReference(reference3.getName(), "target");
        cReference3.initialize(assemblyContext);
        source.getConfiguredReferences().add(cReference3);

        // wire multiplicity using a array
        JavaServiceContract refContract4 = systemFactory.createJavaServiceContract();
        refContract4.setInterface(Target.class);
        Reference reference4 = systemFactory.createReference();
        reference4.setName("setArrayOfTargets");
        reference4.setServiceContract(refContract4);
        reference4.setMultiplicity(Multiplicity.ONE_N);
        componentType.getReferences().add(reference4);
        ConfiguredReference cReference4 = systemFactory.createConfiguredReference(reference4.getName(), "target");
        cReference4.initialize(assemblyContext);
        source.getConfiguredReferences().add(cReference4);

        source.initialize(assemblyContext);

        Module module = systemFactory.createModule();
        module.setName("system.module");

        module.getComponents().add(source);
View Full Code Here

Examples of org.apache.tuscany.model.assembly.AtomicComponent

     */

    public static Module createModuleWithWiredComponentsOfDifferentInterface(Scope sourceScope, Scope targetScope) {

        // create the target component
        AtomicComponent target = factory.createSimpleComponent();
        target.setName("target");
        JavaImplementation targetImpl = factory.createJavaImplementation();
        targetImpl.setComponentType(factory.createComponentType());
        targetImpl.setImplementationClass(OtherTargetImpl.class);
        target.setImplementation(targetImpl);
        Service targetService = factory.createService();
        JavaServiceContract targetContract = factory.createJavaServiceContract();
        targetContract.setInterface(OtherTarget.class);
        targetService.setServiceContract(targetContract);
        targetService.setName("Target");
        targetImpl.getComponentType().getServices().add(targetService);
        targetContract.setScope(targetScope);
        ConfiguredService cTargetService = factory.createConfiguredService();
        cTargetService.setPort(targetService);
        cTargetService.initialize(assemblyContext);
        target.getConfiguredServices().add(cTargetService);
        target.initialize(assemblyContext);

        // create the source component
        AtomicComponent source = factory.createSimpleComponent();
        ComponentType componentType = factory.createComponentType();
        source.setName("source");
        JavaImplementation impl = factory.createJavaImplementation();
        impl.setComponentType(componentType);
        impl.setImplementationClass(SourceImpl.class);
        source.setImplementation(impl);
        Service s = systemFactory.createService();
        JavaServiceContract contract = systemFactory.createJavaServiceContract();
        contract.setInterface(Source.class);
        s.setServiceContract(contract);
        contract.setScope(sourceScope);
        impl.getComponentType().getServices().add(s);
        source.setImplementation(impl);

        // wire source to target
        JavaServiceContract refContract = systemFactory.createJavaServiceContract();
        refContract.setInterface(Target.class);
        Reference reference = systemFactory.createReference();
        reference.setName("setTarget");
        reference.setServiceContract(refContract);
        componentType.getReferences().add(reference);
        ConfiguredReference cReference = systemFactory.createConfiguredReference(reference.getName(), "target");
        cReference.initialize(assemblyContext);
        source.getConfiguredReferences().add(cReference);

        // wire multiplicity using a setter
        JavaServiceContract refContract2 = systemFactory.createJavaServiceContract();
        refContract2.setInterface(Target.class);
        Reference reference2 = systemFactory.createReference();
        reference2.setName("setTargets");
        reference2.setServiceContract(refContract2);
        reference2.setMultiplicity(Multiplicity.ONE_N);
        componentType.getReferences().add(reference2);
        ConfiguredReference cReference2 = systemFactory.createConfiguredReference(reference2.getName(), "target");
        cReference2.initialize(assemblyContext);
        source.getConfiguredReferences().add(cReference2);

        // wire multiplicity using a field
        JavaServiceContract refContract3 = systemFactory.createJavaServiceContract();
        refContract3.setInterface(Target.class);
        Reference reference3 = systemFactory.createReference();
        reference3.setName("targetsThroughField");
        reference3.setServiceContract(refContract3);
        reference3.setMultiplicity(Multiplicity.ONE_N);
        componentType.getReferences().add(reference3);
        ConfiguredReference cReference3 = systemFactory.createConfiguredReference(reference3.getName(), "target");
        cReference3.initialize(assemblyContext);
        source.getConfiguredReferences().add(cReference3);

        // wire multiplicity using a array
        JavaServiceContract refContract4 = systemFactory.createJavaServiceContract();
        refContract4.setInterface(Target.class);
        Reference reference4 = systemFactory.createReference();
        reference4.setName("setArrayOfTargets");
        reference4.setServiceContract(refContract4);
        reference4.setMultiplicity(Multiplicity.ONE_N);
        componentType.getReferences().add(reference4);
        ConfiguredReference cReference4 = systemFactory.createConfiguredReference(reference4.getName(), "target");
        cReference4.initialize(assemblyContext);
        source.getConfiguredReferences().add(cReference4);

        source.initialize(assemblyContext);

        Module module = systemFactory.createModule();
        module.setName("system.module");

        module.getComponents().add(source);
View Full Code Here

Examples of org.apache.tuscany.model.assembly.AtomicComponent

     * @param moduleComponentContext the containing composite context
     * @throws NoSuchMethodException if the POJO does not have a default noi-args constructor
     */
    public static JavaAtomicContext createPojoContext(String name, Class implType, Scope scope,
                                                      CompositeContext moduleComponentContext) throws NoSuchMethodException, ConfigurationLoadException {
        AtomicComponent component = createComponent(name, implType, scope);

        Set<Field> fields = JavaIntrospectionHelper.getAllFields(implType);
        Set<Method> methods = JavaIntrospectionHelper.getAllUniqueMethods(implType);
        List<Injector> injectors = new ArrayList<Injector>();

View Full Code Here

Examples of org.apache.tuscany.model.assembly.AtomicComponent

     *
     */
    private List<Extensible> createAssembly() throws BuilderException, ConfigurationLoadException {
        WireFactoryService wireService = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(), new DefaultPolicyBuilderRegistry());
        JavaContextFactoryBuilder builder = new JavaContextFactoryBuilder(wireService);
        AtomicComponent component = MockFactory.createComponent("TestService1", ModuleScopeComponentImpl.class, Scope.MODULE);
        AtomicComponent sessionComponent = MockFactory.createComponent("TestService2", SessionScopeComponentImpl.class,
                Scope.SESSION);
        AtomicComponent requestComponent = MockFactory.createComponent("TestService3", SessionScopeComponentImpl.class,
                Scope.REQUEST);
        builder.build(component);
        builder.build(sessionComponent);
        builder.build(requestComponent);
        List<Extensible> configs = new ArrayList<Extensible>();
View Full Code Here

Examples of org.apache.tuscany.model.assembly.AtomicComponent

        scope.stop();
    }

    private List<ContextFactory<Context>> createConfigurations()
            throws NoSuchMethodException, BuilderException, ConfigurationLoadException {
        AtomicComponent component = MockFactory.createComponent("TestService1", StatelessComponentImpl.class,
                Scope.INSTANCE);
        WireFactoryService wireService = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(), new DefaultPolicyBuilderRegistry());
        JavaContextFactoryBuilder builder = new JavaContextFactoryBuilder(wireService);
        builder.build(component);
        List<ContextFactory<Context>> configs = new ArrayList();
        configs.add((ContextFactory<Context>) component.getContextFactory());
        return configs;
    }
View Full Code Here

Examples of org.apache.tuscany.model.assembly.AtomicComponent

        return configs;
    }

    private ContextFactory<Context> createConfiguration(String name)
            throws NoSuchMethodException, BuilderException, ConfigurationLoadException {
        AtomicComponent component = MockFactory.createComponent(name, StatelessComponentImpl.class,
                Scope.INSTANCE);
        WireFactoryService wireService = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(),new DefaultPolicyBuilderRegistry());
        JavaContextFactoryBuilder builder = new JavaContextFactoryBuilder(wireService);
        builder.build(component);
        return (ContextFactory<Context>) component.getContextFactory();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.