Package org.apache.tuscany.sca.implementation.java

Examples of org.apache.tuscany.sca.implementation.java.JavaImplementation


            return;
        }*/
       
        RuntimeComponent component = wire.getTarget().getComponent();
        if ( component != null && component.getImplementation() instanceof JavaImplementation ) {
            JavaImplementation javaImpl = (JavaImplementation)component.getImplementation();
            if ( javaImpl instanceof PolicySetAttachPoint ) {
                PolicyHandler policyHandler = null;
                List<PolicyHandler> implPolicyHandlers = new ArrayList<PolicyHandler>();
                PolicySetAttachPoint policiedImpl = (PolicySetAttachPoint)javaImpl;
               
                try {
                    //for ( PolicySet policySet : policiedImpl.getPolicySets() ) {
                    for ( PolicySet policySet : component.getPolicySets() ) {
                        policyHandler = getPolicyHandler(policySet, javaImpl.getPolicyHandlerClassNames());
                        if ( policyHandler != null ) {
                            policyHandler.setUp(javaImpl);
                            implPolicyHandlers.add(policyHandler);
                        } else {
                            //FIXME: to be removed after the PolicyHandler story has crystalized..
                            //maybe replace with exception then...
                            System.out.println("No PolicyHandler registered for PolicySet - " + policySet.getName());
                        }
                    }   
                   
                    List<PolicyHandler> applicablePolicyHandlers = null;
                    for (InvocationChain chain : wire.getInvocationChains() ) {
                        applicablePolicyHandlers = new ArrayList<PolicyHandler>();
                        if ( javaImpl instanceof OperationsConfigurator ) {
                            String operationName = chain.getTargetOperation().getName();
                            OperationsConfigurator opConfigurator = (OperationsConfigurator)component;
                            for ( ConfiguredOperation confOp : opConfigurator.getConfiguredOperations() ) {
                                if ( confOp.getName().equals(operationName)) {
                                    for ( PolicySet policySet : confOp.getPolicySets() ) {
                                        policyHandler = getPolicyHandler(policySet, javaImpl.getPolicyHandlerClassNames());
                                        policyHandler.setUp(javaImpl);
                                        applicablePolicyHandlers.add(policyHandler);
                                    }
                                    break;
                                }
View Full Code Here


    }

    public JavaImplementation read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {

        // Read an <implementation.java>
        JavaImplementation javaImplementation = javaFactory.createJavaImplementation();
       
        if ( javaImplementation instanceof PolicySetAttachPoint ) {
            IntentAttachPointType implType = intentAttachPointTypeFactory.createImplementationType();
            implType.setName(getArtifactType());
            implType.setUnresolved(true);
            ((PolicySetAttachPoint)javaImplementation).setType(implType);
        }
       
        javaImplementation.setUnresolved(true);
        javaImplementation.setName(reader.getAttributeValue(null, CLASS));

        // Read policies
        policyProcessor.readPolicies(javaImplementation, reader);

        // read operation elements if exists or skip unto end element
View Full Code Here

    /**
     * Verifies a single service interface is computed when only one interface
     * is implemented
     */
    public void testSingleInterface() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        Constructor<SingleInterfaceImpl> ctor = SingleInterfaceImpl.class.getConstructor();
        type.setConstructor(new JavaConstructorImpl<SingleInterfaceImpl>(ctor));
        processor.visitEnd(SingleInterfaceImpl.class, type);
        assertEquals(1, type.getServices().size());
        assertTrue(ModelHelper.matches(ModelHelper.getService(type, PropertyInterface.class.getSimpleName()),
                                       PropertyInterface.class));
        assertTrue(type.getProperties().isEmpty());
        assertTrue(type.getReferences().isEmpty());
    }
View Full Code Here

    /**
     * Verifies property and reference setters are computed
     */
    public void testPropertyReference() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        Constructor<SingleInterfaceWithPropertyReferenceImpl> ctor = SingleInterfaceWithPropertyReferenceImpl.class
            .getConstructor();
        type.setConstructor(new JavaConstructorImpl<SingleInterfaceWithPropertyReferenceImpl>(ctor));
        processor.visitEnd(SingleInterfaceWithPropertyReferenceImpl.class, type);
        assertEquals(1, type.getServices().size());
        assertTrue(ModelHelper
            .matches(ModelHelper.getService(type, Interface1.class.getSimpleName()), Interface1.class));
        assertEquals(1, type.getProperties().size());
        org.apache.tuscany.sca.assembly.Property prop = ModelHelper.getProperty(type, "property");
        assertNotNull(prop);
        assertEquals(ComplexProperty.class, type.getPropertyMembers().get("property").getType());
        assertEquals(1, type.getReferences().size());
        assertTrue(ModelHelper.matches(ModelHelper.getReference(type, "reference"), Ref.class));
    }
View Full Code Here

    /**
     * Verifies that a property setter is not introspected if an analogous
     * operation is in the service interface
     */
    public void testPropertySetterInInterface() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        Constructor<SingleInterfaceImpl> ctor = SingleInterfaceImpl.class.getConstructor();
        type.setConstructor(new JavaConstructorImpl<SingleInterfaceImpl>(ctor));
        processor.visitEnd(SingleInterfaceImpl.class, type);
        assertEquals(0, type.getProperties().size());
    }
View Full Code Here

    /**
     * Verifies that a reference setter is not introspected if an analogous
     * operation is in the service interface
     */
    public void testReferenceSetterInInterface() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        Constructor<RefInterfaceImpl> ctor = RefInterfaceImpl.class.getConstructor();
        type.setConstructor(new JavaConstructorImpl<RefInterfaceImpl>(ctor));
        processor.visitEnd(RefInterfaceImpl.class, type);
        assertEquals(0, type.getReferences().size());
    }
View Full Code Here

    /**
     * Verifies collection generic types or array types are introspected as
     * references according to specification rules
     */
    public void testReferenceCollectionType() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        Constructor<ReferenceCollectionImpl> ctor = ReferenceCollectionImpl.class.getConstructor();
        type.setConstructor(new JavaConstructorImpl<ReferenceCollectionImpl>(ctor));
        processor.visitEnd(ReferenceCollectionImpl.class, type);
        assertEquals(1, type.getProperties().size());
        assertEquals(3, type.getReferences().size());
    }
View Full Code Here

    /**
     * Verifies collection generic types or array types are introspected as
     * properties according to specification rules
     */
    public void testPropertyCollectionType() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        Constructor<PropertyCollectionImpl> ctor = PropertyCollectionImpl.class.getConstructor();
        type.setConstructor(new JavaConstructorImpl<PropertyCollectionImpl>(ctor));
        processor.visitEnd(PropertyCollectionImpl.class, type);
        assertEquals(0, type.getReferences().size());
        assertEquals(4, type.getProperties().size());
    }
View Full Code Here

     * Verifies references are calculated when the type marked with is
     *
     * @Remotable
     */
    public void testRemotableRef() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        Constructor<RemotableRefImpl> ctor = RemotableRefImpl.class.getConstructor();
        type.setConstructor(new JavaConstructorImpl<RemotableRefImpl>(ctor));
        processor.visitEnd(RemotableRefImpl.class, type);
        assertEquals(2, type.getReferences().size());
        assertEquals(0, type.getProperties().size());
    }
View Full Code Here

        assertEquals(2, type.getReferences().size());
        assertEquals(0, type.getProperties().size());
    }

    public void testParentInterface() throws IntrospectionException, NoSuchMethodException {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        Constructor<Child> ctor = Child.class.getConstructor();
        type.setConstructor(new JavaConstructorImpl<Child>(ctor));
        processor.visitEnd(Child.class, type);
        assertNotNull(ModelHelper.getService(type, Interface1.class.getSimpleName()));
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.implementation.java.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.