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

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


        visitConstructor(ctor, type);
        assertNotNull(getProperty(type, "myProp"));
    }

    public void testInvalidNumberOfNames() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        Constructor<BadFoo> ctor = BadFoo.class.getConstructor(Integer.class, Integer.class);
        try {
            visitConstructor(ctor, type);
            fail();
        } catch (InvalidConstructorException e) {
View Full Code Here


            // expected
        }
    }

    public void testNoMatchingNames() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        Constructor<BadFoo> ctor = BadFoo.class.getConstructor(List.class, List.class);
        try {
            visitConstructor(ctor, type);
            fail();
        } catch (InvalidConstructorException e) {
View Full Code Here

            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 =
                            PolicyHandlerUtils.findPolicyHandler(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...
                            logger.warning("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 =
                                            PolicyHandlerUtils.findPolicyHandler(policySet, javaImpl
                                                .getPolicyHandlerClassNames());
                                        if (policyHandler != null) {
                                            policyHandler.setUp(javaImpl);
                                            applicablePolicyHandlers.add(policyHandler);
                                        } else {
View Full Code Here

        RuntimeComponent component = wire.getSource().getComponent();
        Implementation implementation = component.getImplementation();
        if (!(implementation instanceof JavaImplementation)) {
            return;
        }
        JavaImplementation javaImpl = (JavaImplementation)implementation;
        EndpointReference callbackEndpoint = wire.getSource().getCallbackEndpoint();
        if (callbackEndpoint != null) {
            Interface iface = callbackEndpoint.getContract().getInterfaceContract().getInterface();
            if (!supportsCallbackInterface(iface, javaImpl)) {
                // callback to this impl is not possible, so ensure a callback object is set
View Full Code Here

    /**
     * Verifies the property and heuristic processors don't collide
     */
    @SuppressWarnings("unchecked")
    public void testPropertyProcessorWithHeuristicProcessor() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        Constructor ctor = Foo.class.getConstructor(String.class);
        type.setConstructor(new JavaConstructorImpl(ctor));
        propertyProcessor.visitConstructorParameter(type.getConstructor().getParameters()[0], type);
        heuristicProcessor.visitEnd(Foo.class, type);
        assertEquals(1, type.getProperties().size());
        assertEquals("foo", type.getProperties().get(0).getName());
    }
View Full Code Here

    private ConstructorProcessor processor = new ConstructorProcessor(new DefaultAssemblyFactory());
   
    private JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();

    public void testDuplicateConstructor() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        try {
            processor.visitClass(BadFoo.class, type);
            fail();
        } catch (DuplicateConstructorException e) {
            // expected
View Full Code Here

            // expected
        }
    }

    public void testConstructorAnnotation() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        Constructor<Foo> ctor1 = Foo.class.getConstructor(String.class);
        processor.visitConstructor(ctor1, type);
        assertEquals("foo", type.getConstructor().getParameters()[0].getName());
    }
View Full Code Here

        processor.visitConstructor(ctor1, type);
        assertEquals("foo", type.getConstructor().getParameters()[0].getName());
    }

    public void testNoAnnotation() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        Constructor<NoAnnotation> ctor1 = NoAnnotation.class.getConstructor();
        processor.visitConstructor(ctor1, type);
        assertNull(type.getConstructor());
    }
View Full Code Here

        processor.visitConstructor(ctor1, type);
        assertNull(type.getConstructor());
    }

    public void testBadAnnotation() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        Constructor<BadAnnotation> ctor1 = BadAnnotation.class.getConstructor(String.class, Foo.class);
        try {
            processor.visitConstructor(ctor1, type);
            fail();
        } catch (InvalidConstructorException e) {
View Full Code Here

            // expected
        }
    }

    public void testMixedParameters() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        Constructor<Mixed> ctor1 = Mixed.class.getConstructor(String.class, String.class, String.class);
        processor.visitConstructor(ctor1, type);

        AssemblyFactory assemblyFactory = new DefaultAssemblyFactory();
        JavaInterfaceFactory javaFactory = new DefaultJavaInterfaceFactory();
        ReferenceProcessor referenceProcessor = new ReferenceProcessor(assemblyFactory, javaFactory);
        PropertyProcessor propertyProcessor = new PropertyProcessor(assemblyFactory);
        JavaParameterImpl[] parameters = type.getConstructor().getParameters();
        for (int i = 0; i < parameters.length; i++) {
            referenceProcessor.visitConstructorParameter(parameters[i], type);
            propertyProcessor.visitConstructorParameter(parameters[i], type);
        }
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.