Package org.apache.tuscany.core.implementation.system.model

Examples of org.apache.tuscany.core.implementation.system.model.SystemImplementation


                                     XMLStreamReader reader,
                                     DeploymentContext deploymentContext
    )
        throws XMLStreamException, LoaderException {
        assert SYSTEM_IMPLEMENTATION.equals(reader.getName());
        SystemImplementation implementation = new SystemImplementation();
        String implClass = reader.getAttributeValue(null, "class");
        Class<?> implementationClass = LoaderUtil.loadClass(implClass, deploymentContext.getClassLoader());
        implementation.setImplementationClass(implementationClass);
        registry.loadComponentType(parent, implementation, deploymentContext);
        LoaderUtil.skipToEndElement(reader);
        return implementation;
    }
View Full Code Here


    /**
     * Creates a component named "source" with a reference to target/Target
     */
    public static ComponentDefinition<SystemImplementation> createSourceWithTargetReference()
        throws NoSuchMethodException {
        SystemImplementation impl = new SystemImplementation();
        PojoComponentType componentType = new PojoComponentType();
        componentType.setImplementationScope(Scope.MODULE);
        componentType
            .setConstructorDefinition(
                new ConstructorDefinition<SourceImpl>(SourceImpl.class.getConstructor((Class[]) null)));
        JavaMappedReference reference;
        try {
            reference = new JavaMappedReference();
            reference.setName("target");
            reference.setMember(SourceImpl.class.getMethod("setTarget", Target.class));
            JavaServiceContract contract = new JavaServiceContract();
            contract.setInterfaceClass(Target.class);
            reference.setServiceContract(contract);
            componentType.add(reference);
        } catch (NoSuchMethodException e) {
            throw new AssertionError(e);
        }
        impl.setComponentType(componentType);
        impl.setImplementationClass(SourceImpl.class);
        ComponentDefinition<SystemImplementation> sourceComponentDefinition =
            new ComponentDefinition<SystemImplementation>(impl);
        sourceComponentDefinition.setName("source");

        ReferenceTarget referenceTarget = new ReferenceTarget();
View Full Code Here

    /**
     * Creates a component named "source" with an autowire reference to {@link Target}
     */
    public static ComponentDefinition<SystemImplementation> createSourceWithTargetAutowire() {
        SystemImplementation impl = new SystemImplementation();
        PojoComponentType componentType = new PojoComponentType();
        componentType.setImplementationScope(Scope.MODULE);
        JavaMappedReference reference;
        try {
            reference = new JavaMappedReference();
            reference.setName("target");
            reference.setMember(SourceImpl.class.getMethod("setTarget", Target.class));
            reference.setAutowire(true);
            ServiceContract<?> contract = new JavaServiceContract();
            contract.setInterfaceClass(Target.class);
            reference.setServiceContract(contract);
            componentType.add(reference);
        } catch (NoSuchMethodException e) {
            throw new AssertionError(e);
        }
        impl.setComponentType(componentType);
        impl.setImplementationClass(SourceImpl.class);
        ComponentDefinition<SystemImplementation> sourceComponentDefinition =
            new ComponentDefinition<SystemImplementation>(impl);
        sourceComponentDefinition.setName("source");

        ReferenceTarget referenceTarget = new ReferenceTarget();
View Full Code Here

    /**
     * Creates a component named "target" with a service named "Target"
     */
    public static ComponentDefinition<SystemImplementation> createTarget() throws NoSuchMethodException {
        SystemImplementation impl = new SystemImplementation();
        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> componentType =
            new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
        componentType.setImplementationScope(Scope.MODULE);
        componentType
            .setConstructorDefinition(
                new ConstructorDefinition<TargetImpl>(TargetImpl.class.getConstructor((Class[]) null)));
        JavaMappedService targetServiceDefinition = new JavaMappedService();
        targetServiceDefinition.setName("Target");
        ServiceContract<?> contract = new JavaServiceContract();
        contract.setInterfaceClass(Target.class);
        targetServiceDefinition.setServiceContract(contract);
        componentType.add(targetServiceDefinition);
        impl.setComponentType(componentType);
        impl.setImplementationClass(TargetImpl.class);
        ComponentDefinition<SystemImplementation> targetComponentDefinition =
            new ComponentDefinition<SystemImplementation>(impl);
        targetComponentDefinition.setName("target");
        return targetComponentDefinition;
    }
View Full Code Here

        destroyMethod.setAccessible(true);
        type.setDestroyMethod(destroyMethod);
        type.setImplementationScope(Scope.MODULE);
        ConstructorDefinition<FooImpl> ctorDef = new ConstructorDefinition<FooImpl>(FooImpl.class.getConstructor());
        type.setConstructorDefinition(ctorDef);
        SystemImplementation impl = new SystemImplementation();
        impl.setComponentType(type);
        impl.setImplementationClass(FooImpl.class);
        ComponentDefinition<SystemImplementation> definition = new ComponentDefinition<SystemImplementation>(impl);
        AtomicComponent component = builder.build(parent, definition, deploymentContext);
        component.start();
        container.onEvent(new CompositeStart(this, null));
        FooImpl foo = (FooImpl) component.getServiceInstance();
View Full Code Here

        propMethod.setAccessible(true);
        mappedProp.setMember(propMethod);
        type.add(mappedProp);
        ConstructorDefinition<FooImpl> ctorDef = new ConstructorDefinition<FooImpl>(FooImpl.class.getConstructor());
        type.setConstructorDefinition(ctorDef);
        SystemImplementation impl = new SystemImplementation();
        impl.setComponentType(type);
        impl.setImplementationClass(FooImpl.class);
        ComponentDefinition<SystemImplementation> definition = new ComponentDefinition<SystemImplementation>(impl);
        PropertyValue<String> propVal = new PropertyValue<String>();
        propVal.setName("prop");
        propVal.setValueFactory(new SingletonObjectFactory<String>("value"));
        definition.add(propVal);
View Full Code Here

        ServiceContract contract = new JavaServiceContract(Foo.class);
        mappedReference.setServiceContract(contract);
        type.add(mappedReference);
        ConstructorDefinition<FooImpl> ctorDef = new ConstructorDefinition<FooImpl>(FooImpl.class.getConstructor());
        type.setConstructorDefinition(ctorDef);
        SystemImplementation impl = new SystemImplementation();
        impl.setComponentType(type);
        impl.setImplementationClass(FooImpl.class);
        ComponentDefinition<SystemImplementation> definition = new ComponentDefinition<SystemImplementation>(impl);
        ReferenceTarget target = new ReferenceTarget();
        target.setReferenceName("ref");
        target.addTarget(new URI("foo"));
        definition.add(target);
View Full Code Here

        ServiceContract contract = new JavaServiceContract(Foo.class);
        mappedReference.setServiceContract(contract);
        type.add(mappedReference);
        ConstructorDefinition<FooImpl> ctorDef = new ConstructorDefinition<FooImpl>(FooImpl.class.getConstructor());
        type.setConstructorDefinition(ctorDef);
        SystemImplementation impl = new SystemImplementation();
        impl.setComponentType(type);
        impl.setImplementationClass(FooImpl.class);
        ComponentDefinition<SystemImplementation> definition = new ComponentDefinition<SystemImplementation>(impl);
        CompositeComponent parent = EasyMock.createNiceMock(CompositeComponent.class);
        FooImpl targetFoo = new FooImpl();
        EasyMock.expect(parent.resolveSystemInstance(EasyMock.eq(Foo.class))).andReturn(targetFoo);
        EasyMock.replay(parent);
View Full Code Here

        type.setImplementationScope(Scope.MODULE);
        ConstructorDefinition<FooImpl2> ctorDef =
            new ConstructorDefinition<FooImpl2>(FooImpl2.class.getConstructor(Foo.class));
        ctorDef.getInjectionNames().add("ref");
        type.setConstructorDefinition(ctorDef);
        SystemImplementation impl = new SystemImplementation();
        impl.setComponentType(type);
        impl.setImplementationClass(FooImpl2.class);
        JavaMappedReference mappedReference = new JavaMappedReference();
        mappedReference.setName("ref");
        mappedReference.setAutowire(true);
        ServiceContract contract = new JavaServiceContract(Foo.class);
        mappedReference.setServiceContract(contract);
View Full Code Here

public class SystemComponentTypeLoaderTestCase extends TestCase {
    private SystemComponentTypeLoader loader;

    public void testIntrospectUnannotatedClass() throws ProcessingException {
        CompositeComponent parent = EasyMock.createNiceMock(CompositeComponent.class);
        SystemImplementation impl = new SystemImplementation(BasicInterfaceImpl.class);
        PojoComponentType<?, ?, ?> componentType = loader.loadByIntrospection(parent, impl, null);
        ServiceDefinition service = componentType.getServices().get("BasicInterface");
        assertEquals(BasicInterface.class, service.getServiceContract().getInterfaceClass());
        Property<?> property = componentType.getProperties().get("publicProperty");
        assertEquals(String.class, property.getJavaType());
View Full Code Here

TOP

Related Classes of org.apache.tuscany.core.implementation.system.model.SystemImplementation

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.