Package org.apache.tuscany.sca.runtime

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


    private void initInvocationChains() {
        chains = new ArrayList<InvocationChain>();
        InterfaceContract sourceContract = getBindingInterfaceContract();

        // It's the service wire
        RuntimeComponentService service = (RuntimeComponentService)getService();
        RuntimeComponent serviceComponent = (RuntimeComponent)getComponent();

        //InterfaceContract targetContract = getInterfaceContract();
        // TODO - EPR - why is this looking at the component types. The endpoint should have the right interface contract by this time
        InterfaceContract targetContract = getComponentTypeServiceInterfaceContract();
        // setInterfaceContract(targetContract);
        validateServiceInterfaceCompatibility();
        for (Operation operation : sourceContract.getInterface().getOperations()) {
            Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation);
            if (targetOperation == null) {
                throw new ServiceRuntimeException("No matching operation for " + operation.getName()
                    + " is found in service "
                    + serviceComponent.getURI()
                    + "#"
                    + service.getName());
            }
            InvocationChain chain = new InvocationChainImpl(operation, targetOperation, false, phaseManager, isAsyncInvocation());
            if (operation.isNonBlocking()) {
                addNonBlockingInterceptor(chain);
            }
View Full Code Here


        ImplementationProvider provider = ((RuntimeComponent)component).getImplementationProvider();

        if (provider != null) {
            Invoker invoker = null;
            RuntimeComponentService runtimeService = (RuntimeComponentService)service;
            if (runtimeService.getName().endsWith("_asyncCallback")){
                if (provider instanceof ImplementationAsyncProvider){
                    invoker = (Invoker)((ImplementationAsyncProvider)provider).createAsyncResponseInvoker(operation);
                } else {
                    // TODO - This should be an error but taking account of the
                    // existing non-native async support
View Full Code Here

    public JMSServiceListener createJMSServiceListener(JMSServiceListenerDetails jmsSLD) {
        try {

            JMSResourceFactory rf = ((JMSBindingServiceBindingProvider)jmsSLD).getResourceFactory();
           
            RuntimeComponentService service = (RuntimeComponentService) jmsSLD.getEndpoint().getService();
            MessageListener listener = new DefaultServiceInvoker(jmsSLD.getEndpoint(), jmsSLD.getTargetBinding(), jmsSLD.getMessageFactory(), rf);
          
            return new DefaultJMSServiceListener(listener, service.getName(), service.isForCallback(), jmsSLD.getJmsBinding(), workScheduler, rf);

        } catch (NamingException e) {
            throw new JMSBindingException(e);
        }
    }
View Full Code Here

     */
    private void createWires(Component component, ComponentService service, Binding binding) {
        if (!(service instanceof RuntimeComponentService)) {
            return;
        }
        RuntimeComponentService runtimeService = (RuntimeComponentService)service;

        // FIXME: [rfeng] We might need a better way to get the impl interface contract
        InterfaceContract targetContract = service.getService().getInterfaceContract();

        InterfaceContract sourceContract = getInterfaceContract(service, binding);

        EndpointReference wireSource = new EndpointReferenceImpl(null, null, binding, sourceContract);

        EndpointReference wireTarget = new EndpointReferenceImpl((RuntimeComponent)component,
                                                                 (RuntimeComponentService)service, binding,
                                                                 targetContract);

        RuntimeWire wire = new RuntimeWireImpl(wireSource, wireTarget);

        for (Operation operation : sourceContract.getInterface().getOperations()) {
            Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation);
            InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
            /* lresende */
            if (operation.isNonBlocking()) {
                chain.addInterceptor(new NonBlockingInterceptor(workScheduler));
            }

            addImplementationInterceptor(component, service, chain, targetOperation, false);
            wire.getInvocationChains().add(chain);
        }
        // if (sourceContract.getCallbackInterface() != null) {
        // for (Operation operation :
        // sourceContract.getCallbackInterface().getOperations()) {
        // Operation targetOperation =
        // interfaceContractMapper.map(targetContract.getCallbackInterface(),
        // operation);
        // InvocationChain chain = new InvocationChainImpl(operation,
        // targetOperation);
        // if (operation.isNonBlocking()) {
        // chain.addInterceptor(new NonBlockingInterceptor(workScheduler,
        // workContext));
        // }
        // addImplementationInterceptor(component, service, chain, operation,
        // true);
        // wire.getCallbackInvocationChains().add(chain);
        // }
        // }

        runtimeService.getRuntimeWires().add(wire);
        wireProcessor.process(wire);
    }
View Full Code Here

    public void start() {

        // Get the target component implementation, for now we are assuming
        // that it's an implementation.resource
        RuntimeComponentService componentService = (RuntimeComponentService) service;
        RuntimeWire wire = componentService.getRuntimeWire(binding);
        Implementation implementation = wire.getTarget().getComponent().getImplementation();
        ResourceImplementation resourceImplementation = (ResourceImplementation)implementation;
       
        // Get the resource location URL
        URL locationURL = resourceImplementation.getLocationURL();
View Full Code Here

    @SuppressWarnings("unchecked")
    public <B> CallableReference<B> getServiceReference() {
        Message msgContext = ThreadMessageContext.getMessageContext();
        // FIXME: [rfeng] Is this the service reference matching the caller side?
        EndpointReference to = msgContext.getTo();
        RuntimeComponentService service = (RuntimeComponentService) to.getContract();
        RuntimeComponent component = (RuntimeComponent) to.getComponent();
       
        CallableReference<B> callableReference = component.getComponentContext().getCallableReference(null, component, service);
        ReferenceParameters parameters = msgContext.getFrom().getReferenceParameters();
        ((CallableReferenceImpl<B>) callableReference).attachCallbackID(parameters.getCallbackID());
View Full Code Here

    @SuppressWarnings("unchecked")
    public <CB> CallableReference<CB> getCallbackReference() {
        Message msgContext = ThreadMessageContext.getMessageContext();
        EndpointReference to = msgContext.getTo();
        RuntimeComponentService service = (RuntimeComponentService) to.getContract();
        RuntimeComponentReference callbackReference = (RuntimeComponentReference)service.getCallbackReference();
        if (callbackReference == null) {
            return null;
        }
        JavaInterface javaInterface = (JavaInterface) callbackReference.getInterfaceContract().getInterface();
        Class<CB> javaClass = (Class<CB>)javaInterface.getJavaClass();
View Full Code Here

    }

    private Invoker getInvoker(RuntimeWire wire, Operation operation) {
        EndpointReference target = wire.getTarget();
        if (target != null) {
            RuntimeComponentService service = (RuntimeComponentService)target.getContract();
            if (service != null) { // not a callback wire
                SCABinding scaBinding = service.getBinding(SCABinding.class);
                InvocationChain chain =
                    service.getInvocationChain(scaBinding, wire.getSource().getInterfaceContract(), operation);
                return chain == null ? null : new SCABindingInvoker(chain);
            }
        }
        return null;
    }
View Full Code Here

        return service.getInterfaceContract();
    }

    public void start() {

        RuntimeComponentService componentService = (RuntimeComponentService) service;
        RuntimeWire wire = componentService.getRuntimeWire(binding);
        InvocationChain chain = wire.getInvocationChains().get(0);
       
        // Register with the hosting server
        String uri = component.getURI() + "/" + binding.getName();
        EchoServer.getServer().register(uri, new EchoService(chain.getHeadInvoker(), messageFactory));
View Full Code Here

    public void start() {
        if (!configuration.getDefinition().getCallbackMembers().isEmpty()) {
            Map<String, List<RuntimeWire>> callbackWires = new HashMap<String, List<RuntimeWire>>();
            for (ComponentService service : component.getServices()) {

                RuntimeComponentService componentService = (RuntimeComponentService)service;
                if (!componentService.getCallbackWires().isEmpty()) {
                    callbackWires.put(componentService.getCallbackWires().get(0).getTarget().getInterfaceContract()
                        .getCallbackInterface().toString(), componentService.getCallbackWires());
                }
            }

            for (Map.Entry<String, JavaElementImpl> entry : configuration.getDefinition().getCallbackMembers()
                .entrySet()) {
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.runtime.RuntimeComponentService

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.