Examples of RuntimeEndpoint


Examples of org.apache.tuscany.sca.runtime.RuntimeEndpoint

        if (chain == null) {
            throw new IllegalArgumentException("No matching operation is found: " + method);
        }

        // Organize for an async service
        RuntimeEndpoint theEndpoint = getAsyncCallback(source);
        boolean isAsyncService = false;
        if (theEndpoint != null) {
            // ... the service is asynchronous ...
            attachFuture(theEndpoint, future);
            isAsyncService = true;
View Full Code Here

Examples of org.apache.tuscany.sca.runtime.RuntimeEndpoint

        if (!(source instanceof RuntimeEndpointReference))
            return null;
        RuntimeEndpointReference epr = (RuntimeEndpointReference)source;
        if (!isAsyncInvocation(epr))
            return null;
        RuntimeEndpoint endpoint;
        synchronized (epr) {
            endpoint = (RuntimeEndpoint)epr.getCallbackEndpoint();
            // If the async callback endpoint is already created, return it...
            if (endpoint != null)
                return endpoint;
            // Create the endpoint for the async callback
            endpoint = createAsyncCallbackEndpoint(epr);
            epr.setCallbackEndpoint(endpoint);
        } // end synchronized

        // Activate the new callback endpoint
        startEndpoint(epr.getCompositeContext(), endpoint);
        endpoint.getInvocationChains();

        return endpoint;
    } // end method setupAsyncCallback
View Full Code Here

Examples of org.apache.tuscany.sca.runtime.RuntimeEndpoint

     * @return - a RuntimeEndpoint representing the callback endpoint
     */
    private RuntimeEndpoint createAsyncCallbackEndpoint(RuntimeEndpointReference epr) {
        CompositeContext compositeContext = epr.getCompositeContext();
        RuntimeAssemblyFactory assemblyFactory = getAssemblyFactory(compositeContext);
        RuntimeEndpoint endpoint = (RuntimeEndpoint)assemblyFactory.createEndpoint();
        endpoint.bind(compositeContext);

        // Create a pseudo-component and pseudo-service
        // - need to end with a chain with an invoker into the AsyncCallbackHandler class
        RuntimeComponent fakeComponent = null;
        try {
            fakeComponent = (RuntimeComponent)epr.getComponent().clone();
            applyImplementation(fakeComponent);
        } catch (CloneNotSupportedException e2) {
            // will not happen
        } // end try
        endpoint.setComponent(fakeComponent);

        // Create pseudo-service
        ComponentService service = assemblyFactory.createComponentService();
        ExtensionPointRegistry registry = compositeContext.getExtensionPointRegistry();
        FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
        JavaInterfaceFactory javaInterfaceFactory =
            (JavaInterfaceFactory)modelFactories.getFactory(JavaInterfaceFactory.class);
        JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
        try {
            interfaceContract.setInterface(javaInterfaceFactory.createJavaInterface(AsyncResponseHandler.class));
        } catch (InvalidInterfaceException e1) {
            // Nothing to do here - will not happen
        } // end try
        service.setInterfaceContract(interfaceContract);
        String serviceName = epr.getReference().getName() + "_asyncCallback";
        service.setName(serviceName);
        endpoint.setService(service);
        // Set pseudo-service onto the pseudo-component
        List<ComponentService> services = fakeComponent.getServices();
        services.clear();
        services.add(service);

        // Create a binding
        Binding binding = createMatchingBinding(epr.getBinding(), fakeComponent, service, registry);
        endpoint.setBinding(binding);

        // Need to establish policies here (binding has some...)
        endpoint.getRequiredIntents().addAll(epr.getRequiredIntents());
        endpoint.getPolicySets().addAll(epr.getPolicySets());
        String epURI = epr.getComponent().getName() + "#service-binding(" + serviceName + "/" + serviceName + ")";
        endpoint.setURI(epURI);
        endpoint.setUnresolved(false);
        return endpoint;
    }
View Full Code Here

Examples of org.apache.tuscany.sca.runtime.RuntimeEndpoint

        System.out.println("Starting reg1");
        HazelcastDomainRegistry reg1 = new HazelcastDomainRegistry(extensionPoints, (Properties)null, "tuscany:foo?bind=127.0.0.1:9876&multicast=off", "bar");
        reg1.start();

        System.out.println("Adding ep1");
        RuntimeEndpoint ep1 = createEndpoint("ep1uri");
        ep1.bind(extensionPoints, reg1);
        reg1.addEndpoint(ep1);

        System.out.println("Starting reg3");
        HazelcastDomainRegistry reg2 = new HazelcastDomainRegistry(extensionPoints, (Properties)null, "tuscany:foo?bind=127.0.0.1:9877&multicast=off&wka=127.0.0.1:9876", "bar");
        reg2.start();

        System.out.println("Starting reg2");
        HazelcastDomainRegistry reg3 = new HazelcastDomainRegistry(extensionPoints, (Properties)null, "tuscany:foo?bind=127.0.0.1:9878&multicast=off&wka=127.0.0.1:9877", "bar");
        reg3.start();

        assertExists(reg1, "ep1uri");
        assertExists(reg2, "ep1uri");
        assertExists(reg3, "ep1uri");

        System.out.println("Adding ep2");
        RuntimeEndpoint ep2 = createEndpoint("ep2uri");
        ep2.bind(extensionPoints, reg2);
        reg2.addEndpoint(ep2);

        assertExists(reg2, "ep2uri");
        assertExists(reg1, "ep2uri");
        assertExists(reg3, "ep2uri");
View Full Code Here

Examples of org.apache.tuscany.sca.runtime.RuntimeEndpoint

    @Test
    public void testDuplicates() throws Exception {
        HazelcastDomainRegistry reg1 = new HazelcastDomainRegistry(extensionPoints, (Properties)null, "tuscany:foo?bind=127.0.0.1:9876&multicast=off", "bar");
        reg1.start();
        RuntimeEndpoint ep1 = createEndpoint("ep1uri");
        ep1.bind(extensionPoints, reg1);
        reg1.addEndpoint(ep1);

        HazelcastDomainRegistry reg2 = new HazelcastDomainRegistry(extensionPoints, (Properties)null, "tuscany:foo?bind=127.0.0.1:9877&multicast=off&wka=127.0.0.1:9876", "bar");
        reg2.start();
View Full Code Here

Examples of org.apache.tuscany.sca.runtime.RuntimeEndpoint

            return null;
        }

        // create a copy of the endpoint ready to set the remote binding. The original endpoint
        // retains binding.sca
        RuntimeEndpoint ep = null;
        try {
            ep = (RuntimeEndpoint)endpoint.clone();
        } catch (Exception ex) {
            // we know we can clone endpoint references
        }

        Binding binding = map(endpoint.getBinding(), bindingType);
        ep.setBinding(binding);
        BindingBuilder builder = getBindingBuilder(bindingType);
        if (builder != null) {
            builder.build(ep.getComponent(), ep.getService(), binding, new BuilderContext(registry), false);
        }
        return ep;
    }
View Full Code Here

Examples of org.apache.tuscany.sca.runtime.RuntimeEndpoint

        Assert.assertEquals(uri, ep.getURI());
        return ep;
    }

    private RuntimeEndpoint createEndpoint(String uri) {
        RuntimeEndpoint ep = (RuntimeEndpoint) assemblyFactory.createEndpoint();
        Component comp = assemblyFactory.createComponent();
        ep.setComponent(comp);
        ep.setService(assemblyFactory.createComponentService());
        ep.getService().setInterfaceContract(getIC());
        Binding b = scaBindingFactory.createSCABinding();
        ep.setBinding(b);
        ep.setURI(uri);
        return ep;
    }
View Full Code Here

Examples of org.apache.tuscany.sca.runtime.RuntimeEndpoint

        this.operationName = operationName;
        this.requestXML = msgXML;
    }

    public String call() throws Exception {
        RuntimeEndpoint endpoint = EndpointStash.getEndpoint(serviceURI);
        if (endpoint == null) {
            throw new NoSuchServiceException(serviceURI);
        }
        Operation operation = getRequestOperation(endpoint);
        DOMHelper domHelper = DOMHelper.getInstance(endpoint.getCompositeContext().getExtensionPointRegistry());
        Object[] args = getRequestArgs(domHelper);
        String responseXML;
        try {
            Object response = endpoint.invoke(operation, args);
            responseXML = getResponseXML(domHelper, response);
        } catch (Exception e) {
           if (e instanceof InvocationTargetException && ((InvocationTargetException)e).getTargetException() instanceof FaultException) {
               responseXML = "DECLAREDEXCEPTION:" + getResponseXML(domHelper, ((FaultException)((InvocationTargetException)e).getTargetException()).getFaultInfo());
           } else {
View Full Code Here

Examples of org.apache.tuscany.sca.runtime.RuntimeEndpoint

          EndpointReference from = assemblyFactory.createEndpointReference();
            Endpoint fromEndpoint = assemblyFactory.createEndpoint();
            from.setTargetEndpoint(fromEndpoint);
            from.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED);
            msg.setFrom(from);
            RuntimeEndpoint callbackEndpoint = (RuntimeEndpoint)assemblyFactory.createEndpoint();
            //
            WebServiceBinding cbBinding = webServiceBindingFactory.createWebServiceBinding();
            cbBinding.setURI(callbackAddress);
            callbackEndpoint.setBinding(cbBinding);
            //
            callbackEndpoint.setURI(callbackAddress);
            callbackEndpoint.setUnresolved(true);
            from.setCallbackEndpoint(callbackEndpoint);
        } // end if
    } // end method createCallbackEPR
View Full Code Here

Examples of org.apache.tuscany.sca.runtime.RuntimeEndpoint

    public void configureBinding(Object configuration){
    }

    protected InvocationChain getInvocationChain() {
        if (subject instanceof RuntimeEndpoint) {
            RuntimeEndpoint endpoint = (RuntimeEndpoint)subject;
            List<InvocationChain> chains = endpoint.getInvocationChains();
            for (InvocationChain chain : chains) {
                configure(chain, chain.getTargetOperation());
            }

        } else if (subject instanceof RuntimeEndpointReference) {
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.