Examples of RuntimeEndpoint


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

        for (ComponentService service : component.getServices()) {
            if (logger.isLoggable(Level.FINE)) {
                logger.fine("Stopping component service: " + component.getURI() + "#" + service.getName());
            }
            for (Endpoint endpoint : service.getEndpoints()) {
                RuntimeEndpoint ep = (RuntimeEndpoint) endpoint;
                stop(ep);
            }
        }
        for (ComponentReference reference : component.getReferences()) {
            if (logger.isLoggable(Level.FINE)) {
View Full Code Here

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

    @Path("/{service}/{method}")
    public void handleRequest(@PathParam("service") String service, @PathParam("method") String method,
            @FormParam("sessionId") String sessionId, @FormParam("callbackMethod") String callbackMethod,
            @FormParam("params") String jsonData) throws InvocationTargetException {
        String url = "/" + service + "/" + method;
        RuntimeEndpoint wire = CometEndpointManager.get(url);
        Operation operation = CometOperationManager.get(url);

        final Object[] args = JSONUtil.decodeJsonParamsForOperation(jsonData, operation);
        Message msg = createMessageWithMockedCometReference(args, sessionId, callbackMethod);
        boolean isVoidReturnType = operation.getOutputType().getLogical().isEmpty();
        if (!isVoidReturnType) {
            Object response = wire.invoke(operation, args);
            Broadcaster broadcaster = CometSessionManager.get(sessionId);
            if (broadcaster != null) {
                broadcaster.broadcast(callbackMethod + "($.secureEvalJSON('" + JSONUtil.encodeResponse(response)
                        + "'))");
            }
        } else {
            wire.invoke(operation, msg);
        }
    }
View Full Code Here

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

            // message in thread context could be null if the user has
            // spun up a new thread inside their component implementation
            return null;
        }
        // FIXME: [rfeng] Is this the service reference matching the caller side?
        RuntimeEndpoint to = (RuntimeEndpoint) msgContext.getTo();
        RuntimeComponent component = (RuntimeComponent) to.getComponent();
       
        ServiceReference<B> callableReference = component.getComponentContext().getServiceReference(null, to);
       
        return callableReference;
    }
View Full Code Here

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 but binding does not support async natively ...
            attachFuture(theEndpoint, future);
        } // end if
View Full Code Here

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

        ReferenceBindingProvider eprProvider = epr.getBindingProvider();
        if( eprProvider instanceof EndpointReferenceAsyncProvider) {
          if( ((EndpointReferenceAsyncProvider)eprProvider).supportsNativeAsync() ) return null;
        } // end if
       
        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(AsyncResponseService.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);
        // MJE 06/12/2010 - fixup for JMS binding code which looks at the implementation service
        // as well as the component service...
        // Create a pseudo implementation service...
        Service implService = assemblyFactory.createService();
        implService.setName(serviceName);
        implService.setInterfaceContract(interfaceContract);
        service.setService(implService);
        //
        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

    public Broadcastable callAndRespond(@PathParam("service") final String service,
                                        @PathParam("method") final String method,
                                        @FormParam("callback") final String callbackMethod,
                                        @FormParam("params") final String jsonData) throws InvocationTargetException {
        final String url = "/" + service + "/" + method;
        final RuntimeEndpoint wire = this.endpoints.get(url);
        final Operation operation = this.operations.get(url);
        final Object[] args = new Object[operation.getInputType().getLogical().size()];
        final String[] json = this.parseArray(jsonData);
        int index = 0;
        // convert each argument to the corresponding class
        for (final DataType<?> dataType : operation.getInputType().getLogical()) {
            args[index] = this.gson.fromJson(json[index], dataType.getPhysical());
            index++;
        }
        // invoke the service operation
        final Object response = wire.invoke(operation, args);
        return new Broadcastable(callbackMethod + "($.secureEvalJSON('" + this.gson.toJson(response) + "'))", "",
                                 this.broadcaster);
    }
View Full Code Here

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

    }
    }
   
    protected String getCallbackDestinationName(RuntimeEndpointReference reference) {
        RuntimeEndpoint endpoint = (RuntimeEndpoint) reference.getCallbackEndpoint();
        if (endpoint != null) {
            JMSBindingServiceBindingProvider bp = (JMSBindingServiceBindingProvider)endpoint.getBindingProvider();
            return bp.getDestinationName();
        }
        return null;
   
View Full Code Here

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

     */
    private void selectCallbackEndpoint(EndpointReference endpointReference, ComponentService callbackService, Audit matchAudit) {
     
        // find the first callback endpoint that matches a callback endpoint reference
        // at the service
        RuntimeEndpoint callbackEndpoint = null;
        match:
        for ( EndpointReference callbackEndpointReference : endpointReference.getTargetEndpoint().getCallbackEndpointReferences()){
            for (Endpoint endpoint : callbackService.getEndpoints()){
                if (haveMatchingPolicy(callbackEndpointReference, endpoint, matchAudit) &&
                    haveMatchingInterfaceContracts(callbackEndpointReference, endpoint, matchAudit)){
                    callbackEndpoint = (RuntimeEndpoint)endpoint;
                    break match;
                }
            }
        }
       
        // if no callback endpoint was found or if the binding is the SCA binding and it doesn't match
        // the forward binding then create a new callback endpoint
        // TODO - there is a hole here in that the user may explicitly specify an SCA binding for the
        //        callback that is different from the forward binding. Waiting for feedback form OASIS
        //        before doing more drastic surgery to fix this corner case as there are other things
        //        wrong with the default case, such as what to do about policy
        if (callbackEndpoint == null ||
            (callbackEndpoint.getBinding().getType().equals(SCABinding.TYPE) &&
             !endpointReference.getBinding().getType().equals(SCABinding.TYPE))){
            // no endpoint in place so we need to create one
            callbackEndpoint = (RuntimeEndpoint)assemblyFactory.createEndpoint();
            callbackEndpoint.setComponent(endpointReference.getComponent());
            callbackEndpoint.setService(callbackService);
           
            Binding forwardBinding = endpointReference.getBinding();
            Binding callbackBinding = null;
            for (EndpointReference callbackEPR : endpointReference.getTargetEndpoint().getCallbackEndpointReferences()){
                if (callbackEPR.getBinding().getType().equals(forwardBinding.getType())){
                    try {
                        callbackBinding = (Binding)callbackEPR.getBinding().clone();
                    } catch (CloneNotSupportedException ex){
                       
                    } 
                    break;
                }
            }
           
            // get the callback binding URI by looking at the SCA binding
            // that will have been added at build time
            callbackBinding.setURI(null);
            for (Endpoint endpoint : callbackService.getEndpoints()){
                if (endpoint.getBinding().getType().equals(SCABinding.TYPE)){
                    callbackBinding.setURI(endpoint.getBinding().getURI());
                }
            }
           
            callbackEndpoint.setBinding(callbackBinding);
            callbackService.getBindings().add(callbackBinding);
           
            callbackEndpoint.setUnresolved(false);
            callbackService.getEndpoints().add(callbackEndpoint);
           
            // build it
            build(callbackEndpoint);
           
View Full Code Here

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

        System.out.println("Starting reg1");
        HazelcastEndpointRegistry reg1 = new HazelcastEndpointRegistry(extensionPoints, null, null, "bar");
        reg1.start();

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

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

        System.out.println("Starting reg2");
        HazelcastEndpointRegistry reg3 = new HazelcastEndpointRegistry(extensionPoints, null, "tuscany:foo?listen=127.0.0.1:9878&multicast=off&remotes=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
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.