Package org.switchyard

Examples of org.switchyard.Service


    /**
     * {@inheritDoc}
     */
    @Override
    public void handleMessage(final Exchange exchange) throws HandlerException {
        final Service service = exchange.getProvider();
        ServiceSecurity serviceSecurity = service.getServiceMetadata().getSecurity();
        if (serviceSecurity != null) {
            SecurityContext securityContext = _securityContextManager.getContext(exchange);
            PrivilegedExceptionAction<Void> action = new PrivilegedExceptionAction<Void>() {
                public Void run() throws Exception {
                    service.getProviderHandler().handleMessage(exchange);
                    return null;
                }
            };
            try {
                _securityProvider.runAs(serviceSecurity, securityContext, action);
            } catch (Exception e) {
                if (e instanceof PrivilegedActionException) {
                    e = ((PrivilegedActionException)e).getException();
                }
                if (e instanceof HandlerException) {
                    throw (HandlerException)e;
                } else {
                    throw new HandlerException(e);
                }
            }
        } else {
            service.getProviderHandler().handleMessage(exchange);
        }
    }
View Full Code Here


            throw new SwitchYardException("Failed to replace service: " + name
                    + ".  No service is registered with that name.");
        }
       
        // select the service to replace
        Service replacedService = services.get(0);
        replacedService.unregister();
       
        // add the replacement service
        getServiceDomain().registerService(name, replacedService.getInterface(), handler,
                replacedService.getServiceMetadata());
    }
View Full Code Here

        MockDomain serviceDomain = new MockDomain();
        deployment.init(serviceDomain, ActivatorLoader.createActivators(serviceDomain));
        deployment.start();
       
        // check metadata is included for services and references
        Service implService = deployment.getDomain().getServices(
                new QName("urn:test:config-mock-binding:1.0", "TestService")).get(0);
        Assert.assertNotNull(implService.getServiceMetadata().getRegistrant());
        Assert.assertTrue(implService.getServiceMetadata().getRequiredPolicies().contains(TransactionPolicy.MANAGED_TRANSACTION_GLOBAL));
        Assert.assertTrue(implService.getServiceMetadata().getRequiredPolicies().contains(TransactionPolicy.PROPAGATES_TRANSACTION));
        Assert.assertTrue(implService.getServiceMetadata().getRegistrant().getConfig() instanceof ComponentImplementationModel);
       
        Service promotedService = deployment.getDomain().getServices(
                new QName("urn:test:config-mock-binding:1.0", "PromotedTestService")).get(0);
        Assert.assertNotNull(promotedService.getServiceMetadata().getRegistrant());
        Assert.assertTrue(promotedService.getServiceMetadata().getRequiredPolicies().contains(TransactionPolicy.MANAGED_TRANSACTION_GLOBAL));
        Assert.assertTrue(promotedService.getServiceMetadata().getRequiredPolicies().contains(TransactionPolicy.PROPAGATES_TRANSACTION));
        Assert.assertTrue(promotedService.getServiceMetadata().getRegistrant().getConfig() instanceof ComponentImplementationModel);

        Service bindingService = deployment.getDomain().getServices(
                new QName("urn:test:config-mock-binding:1.0", "TestReference")).get(0);
        Assert.assertNotNull(bindingService.getServiceMetadata().getRegistrant());
        List<BindingModel> svcBindings = bindingService.getServiceMetadata().getRegistrant().getConfig();
        Assert.assertEquals(1, svcBindings.size());
       
        ServiceReference implReference = deployment.getDomain().getServiceReference(
                new QName("urn:test:config-mock-binding:1.0", "TestService/TestReference"));
        Assert.assertNotNull(implReference.getServiceMetadata().getRegistrant());
View Full Code Here

        swConfigStream.close();
        MockDomain serviceDomain = new MockDomain();
        deployment.init(serviceDomain, ActivatorLoader.createActivators(serviceDomain));
        deployment.start();

        Service service = serviceDomain.getServiceRegistry().getServices(
                new QName("urn:switchyard-interface-wsdl", "HelloService")).get(0);
        Assert.assertNotNull(service);
        ServiceInterface iface = service.getInterface();
        Assert.assertEquals(WSDLService.TYPE, iface.getType());
        ServiceOperation op = iface.getOperation("sayHello");
        Assert.assertNotNull(op);
        Assert.assertEquals(new QName("urn:switchyard-interface-wsdl", "sayHello"), op.getInputType());
        Assert.assertEquals(new QName("urn:switchyard-interface-wsdl", "sayHelloResponse"), op.getOutputType());
View Full Code Here

        MockDomain serviceDomain = new MockDomain();
        deployment.init(serviceDomain, ActivatorLoader.createActivators(serviceDomain));
        deployment.start();

        // Test the service
        Service service = serviceDomain.getServiceRegistry().getServices(
                new QName("urn:switchyard-interface-esb", "HelloService")).get(0);
        Assert.assertNotNull(service);
        ServiceInterface iface = service.getInterface();
        Assert.assertEquals(EsbInterfaceModel.ESB, iface.getType());
        ServiceOperation op = iface.getOperation(ServiceInterface.DEFAULT_OPERATION);
        Assert.assertNotNull(op);
        Assert.assertEquals(ExchangePattern.IN_ONLY, op.getExchangePattern());
       
        // Test the reference
        ServiceReference reference = serviceDomain.getServiceReference(
                new QName("urn:switchyard-interface-esb", "HelloService/SomeOtherService"));
        Assert.assertNotNull(reference);
        Assert.assertEquals(EsbInterfaceModel.ESB, service.getInterface().getType());
        ServiceOperation rop = reference.getInterface().getOperation(ServiceInterface.DEFAULT_OPERATION);
        Assert.assertNotNull(rop);
        Assert.assertEquals(ExchangePattern.IN_OUT, rop.getExchangePattern());

        deployment.stop();
View Full Code Here

       
        MockDomain serviceDomain = new MockDomain();
        deployment.init(serviceDomain, ActivatorLoader.createActivators(serviceDomain));
        deployment.start();
       
        Service implService = deployment.getDomain().getServices(
                new QName("urn:test:config-mock-binding:1.0", "TestService")).get(0);
        Assert.assertNotNull(implService.getServiceMetadata().getRegistrant());
        Assert.assertTrue(implService.getServiceMetadata().getRequiredPolicies().contains(TransactionPolicy.MANAGED_TRANSACTION_LOCAL));
        Assert.assertTrue(implService.getServiceMetadata().getRequiredPolicies().contains(TransactionPolicy.SUSPENDS_TRANSACTION));

        ServiceReference implReference = deployment.getDomain().getServiceReference(
                new QName("urn:test:config-mock-binding:1.0", "TestService/TestReference"));
        Assert.assertNotNull(implReference.getServiceMetadata().getRegistrant());
        Assert.assertTrue(implReference.getServiceMetadata().getRequiredPolicies().contains(TransactionPolicy.SUSPENDS_TRANSACTION));
View Full Code Here

    @Test
    public void testServiceEvents() {
        _domain.addEventObserver(_observer, ServiceRegistrationEvent.class)
            .addEventObserver(_observer, ServiceUnregistrationEvent.class);
       
        Service service = _domain.registerService(new QName("test"), new InOutService(), new BaseHandler());
        Assert.assertTrue(_observer.serviceRegistrationCalled);
        service.unregister();
        Assert.assertTrue(_observer.serviceUnregistrationCalled);
    }
View Full Code Here

TOP

Related Classes of org.switchyard.Service

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.