Package org.switchyard

Examples of org.switchyard.ServiceReference


    }

    @Test
    public void handleMessageWithOutputType() throws HandlerException {
        final Exchange camelExchange = createCamelExchange();
        final ServiceReference serviceReference = createMockServiceRef();
        final org.switchyard.Exchange switchYardExchange = createMockExchangeWithBody(new MessageCreator() {
            @Override
            public Message create() {
                Message message = mock(Message.class);
                when(message.getContext()).thenReturn(new DefaultContext(Scope.MESSAGE));
View Full Code Here


    @Test
    public void fault() throws HandlerException {
        final String fault = "some fault";
        final Exchange camelExchange = createCamelExchange();
        final ServiceReference serviceReference = createMockServiceRef();
        final org.switchyard.Exchange switchYardExchange = createMockExchangeWithBody(new MessageCreator() {
            @Override
            public Message create() {
                Message message = mock(Message.class);
                when(message.getContext()).thenReturn(new DefaultContext(Scope.MESSAGE));
View Full Code Here

    @Test
    public void exception() throws HandlerException {
        final IllegalArgumentException exception = new IllegalArgumentException();
        final Exchange camelExchange = createCamelExchange();
        final ServiceReference serviceReference = createMockServiceRef();
        final org.switchyard.Exchange switchYardExchange = createMockExchangeWithBody(new MessageCreator() {
            @Override
            public Message create() {
                Message message = mock(Message.class);
                when(message.getContent()).thenReturn(exception);
View Full Code Here

    private Exchange createCamelExchange() {
        return new DefaultExchange((CamelContext) null);
    }

    private ServiceReference createMockServiceRef() {
        final ServiceReference serviceReference = mock(ServiceReference.class);
        when(serviceReference.getInterface()).thenReturn(JavaService.fromClass(MockService.class));
        return serviceReference;
    }
View Full Code Here

    @Override
    public void process(final org.apache.camel.Exchange camelExchange) throws Exception {
        final String namespace = camelExchange.getProperty(CamelConstants.APPLICATION_NAMESPACE, String.class);
        final String targetUri = camelExchange.getProperty(org.apache.camel.Exchange.TO_ENDPOINT, String.class);
        ServiceDomain domain = ((SwitchYardCamelContext) camelExchange.getContext()).getServiceDomain();
        final ServiceReference serviceRef = lookupServiceReference(targetUri, namespace, domain,
                camelExchange.getProperty(SwitchYardConsumer.COMPONENT_NAME, QName.class));

        // set a flag to indicate whether this producer endpoint is used within a service route
        boolean isGatewayRoute = camelExchange.getProperty(SwitchYardConsumer.IMPLEMENTATION_ROUTE) == null;
       
View Full Code Here

    }

    private ServiceReference lookupServiceReference(
            final String targetUri, final String namespace, ServiceDomain domain, QName componentName) {
        final QName serviceName = composeSwitchYardServiceName(namespace, targetUri, componentName);
        final ServiceReference serviceRef = domain.getServiceReference(serviceName);
        if (serviceRef == null) {
            throw SwitchYardCamelComponentMessages.MESSAGES.noServiceReferenceFoundForURI(targetUri);
        }
        return serviceRef;
    }
View Full Code Here

        for (ServiceDescriptor serviceDescriptor : beanDeploymentMetaData.getServiceDescriptors()) {
            String serviceName = serviceDescriptor.getServiceName();
            ServiceProxyHandler handler = serviceDescriptor.getHandler();
            ServiceInterface serviceInterface;
            ServiceReference service;

            activator.lookupBeanMetaData();
            serviceInterface = activator.buildServiceInterface(serviceName);
            QName serviceQName = XMLHelper.createQName(domain.getName().getNamespaceURI(), serviceName);
            domain.registerService(serviceQName, serviceInterface, handler);
View Full Code Here

   
    private void invokeLocal(Exchange exchange) throws HandlerException {
        // Figure out the QName for the service were invoking
        QName serviceName = getTargetServiceName(exchange);
        // Get a handle for the reference and use a copy of the exchange to invoke it
        ServiceReference ref = exchange.getProvider().getDomain().getServiceReference(serviceName);
        if (ref == null) {
            throw SCAMessages.MESSAGES.serviceReferenceNotFoundInDomain(serviceName.toString(), exchange.getProvider().getDomain().getName().toString());
        }
        SynchronousInOutHandler replyHandler = new SynchronousInOutHandler();
        Exchange ex = ref.createExchange(exchange.getContract().getProviderOperation().getName(), replyHandler);
       
        // Can't send same message twice, so make a copy
        Message invokeMsg = exchange.getMessage().copy();
        exchange.getContext().mergeInto(invokeMsg.getContext());
       
        // Since this invocation may cross application boundaries, we need to set the TCCL
        // based on the target service's application class loader
        ClassLoader origCL = null;
        try {
            ClassLoader targetCL = (ClassLoader)
                    ref.getDomain().getProperty(Deployment.CLASSLOADER_PROPERTY);
            origCL = Classes.setTCCL(targetCL);
            ex.send(invokeMsg);
        } finally {
            if (origCL != null) {
                Classes.setTCCL(origCL);
View Full Code Here

        public Service getService(QName serviceName, String portName, ServiceDomain serviceDomain) {
            Service ret = null;
            for (int index = 0, count = _services.size(); index < count; ++index) {
                if (serviceName.equals(_services.get(index))) {
                    QName refName = ComponentNames.qualify(_componentName, serviceName);
                    ServiceReference sref = serviceDomain.getServiceReference(refName);
                    if (sref != null) {
                        ret = new ServiceProxy(sref, _portTypes.get(index));
                    }
                    break;
                }
View Full Code Here

            throttling.setTimePeriod(_timePeriod);
        } else {
            throttling = null;
        }
        final BaseApplication application = (BaseApplication) _service.getApplication();
        final ServiceReference serviceReference = application.getDeployment().getDomain().getServiceReference(_service.getName());
        ServiceMetadataBuilder.update(serviceReference.getServiceMetadata()).throttling(throttling);
    }
View Full Code Here

TOP

Related Classes of org.switchyard.ServiceReference

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.