Package org.apache.tuscany.container.java.assembly

Examples of org.apache.tuscany.container.java.assembly.JavaImplementation


    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);
View Full Code Here


    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);
View Full Code Here

    public void stop() {
        registry.unregisterLoader(IMPLEMENTATION_JAVA, this);
    }

    public JavaImplementation load(XMLStreamReader reader, LoaderContext loaderContext) throws XMLStreamException, ConfigurationLoadException {
        JavaImplementation javaImpl = factory.createJavaImplementation();
        String typeName = reader.getAttributeValue(null, "class");
        Class<?> implementationClass = getImplementationClass(loaderContext.getResourceLoader(), typeName);
        javaImpl.setImplementationClass(implementationClass);
        javaImpl.setComponentType(loadComponentType(loaderContext, implementationClass));
        return javaImpl;
    }
View Full Code Here

     * @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

        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

TOP

Related Classes of org.apache.tuscany.container.java.assembly.JavaImplementation

Copyright © 2018 www.massapicom. 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.