Package org.apache.cxf

Examples of org.apache.cxf.Bus


public class BusDefinitionParserTest extends Assert {
   
    @Test
    public void testFeatures() {
        String cfgFile = "org/apache/cxf/bus/spring/bus.xml";
        Bus bus = new SpringBusFactory().createBus(cfgFile, true);
       
        List<Interceptor<? extends Message>> in = bus.getInInterceptors();
        boolean found = false;
        for (Interceptor<? extends Message> i : in) {
            if (i instanceof LoggingInInterceptor) {
                found = true;
            }
View Full Code Here


        if (header == null) {
            return;
        }
        Element elem = DOMUtils.getFirstElement(header);
        while (elem != null) {
            Bus b = message.getExchange() == null ? null : message.getExchange().get(Bus.class);
            HeaderProcessor p =  null;
            if (b != null && b.getExtension(HeaderManager.class) != null) {
                p = b.getExtension(HeaderManager.class).getHeaderProcessor(elem.getNamespaceURI());
            }
               
            Object obj;
            DataBinding dataBinding = null;
            if (p == null || p.getDataBinding() == null) {
View Full Code Here

    @Test
    public void testBusConfigure() {
        ClassPathXmlApplicationContext context = null;
        try {
            context = new ClassPathXmlApplicationContext("org/apache/cxf/bus/spring/customerBus.xml");
            Bus cxf1 = (Bus)context.getBean("cxf1");
           
            assertTrue(cxf1.getOutInterceptors().size() == 1);
            assertTrue(cxf1.getInInterceptors().size() == 0);
           
            Bus cxf2 = (Bus)context.getBean("cxf2");
            assertTrue(cxf2.getInInterceptors().size() == 1);
            assertTrue(cxf2.getOutInterceptors().size() == 0);
        } finally {
            if (context != null) {
                context.close();
            }
        }
View Full Code Here

        mhtr.setOneWay(true);
        increaseCounter(ex, mhtr);
    }   
   
    private void increaseCounter(Exchange ex, MessageHandlingTimeRecorder mhtr) {
        Bus bus = ex.get(Bus.class);
        if (null == bus) {
            LOG.log(Level.INFO, "CAN_NOT_GET_BUS_FROM_EXCHANGE");
            bus = BusFactory.getThreadDefaultBus();
        }
       
        Message message = ex.getOutMessage();
       
        CounterRepository cr = bus.getExtension(CounterRepository.class);
       
        if (null == cr) {
            LOG.log(Level.WARNING, "NO_COUNTER_REPOSITORY");
            return;
        } else {
            Service service = ex.get(Service.class);           
            Endpoint endpoint = ex.get(Endpoint.class);
           
            String serviceName = "\"" + escapePatternChars(service.getName().toString()) + "\"";           
            String portName = "\"" + endpoint.getEndpointInfo().getName().getLocalPart() + "\"";
           
            OperationInfo opInfo = ex.get(OperationInfo.class);
            String operationName = opInfo == null ? null : "\"" + opInfo.getName().getLocalPart() + "\"";
           
            if (operationName == null) {
                Object nameProperty = ex.get("org.apache.cxf.resource.operation.name");
                if (nameProperty != null) {
                    operationName = "\"" + escapePatternChars(nameProperty.toString()) + "\"";
                }
            }
           
            StringBuilder buffer = new StringBuilder();
            buffer.append(ManagementConstants.DEFAULT_DOMAIN_NAME + ":");
            buffer.append(ManagementConstants.BUS_ID_PROP + "=" + bus.getId() + ",");
            if (isClient(message)) {
                buffer.append(ManagementConstants.TYPE_PROP + "=" + Counter.PERFORMANCE_COUNTER + ".Client,");
            } else {
                buffer.append(ManagementConstants.TYPE_PROP + "=" + Counter.PERFORMANCE_COUNTER + ".Server,");
            }
View Full Code Here

    public void testBusConfigureCreateBus() {
        ClassPathXmlApplicationContext context = null;
        final AtomicBoolean b = new AtomicBoolean();
        try {
            context = new ClassPathXmlApplicationContext("org/apache/cxf/bus/spring/customerBus2.xml");
            Bus cxf1 = (Bus)context.getBean("cxf1");
           
            assertTrue(cxf1.getOutInterceptors().size() == 1);
            assertTrue(cxf1.getInInterceptors().size() == 0);
           
            Bus cxf2 = (Bus)context.getBean("cxf2");
           
            assertTrue(cxf2.getInInterceptors().size() == 1);
            assertTrue(cxf2.getOutInterceptors().size() == 0);
           
            cxf2.getExtension(BusLifeCycleManager.class)
                .registerLifeCycleListener(new BusLifeCycleListener() {
                    public void initComplete() {
                    }

                    public void preShutdown() {
View Full Code Here

        assertTrue("postShutdown not called", b.get());
    }
    @Test
    public void testLazyInit() {
        String cfgFile = "org/apache/cxf/bus/spring/lazyInitBus.xml";
        Bus bus = new SpringBusFactory().createBus(cfgFile, true);

        List<Interceptor<? extends Message>> in = bus.getInInterceptors();
        boolean found = false;
        for (Interceptor<? extends Message> i : in) {
            if (i instanceof LoggingInInterceptor) {
                found = true;
            }
View Full Code Here

        BusFactory.setDefaultBus(null);
    }
   
    @Test
    public void testDefault() {
        Bus bus = new SpringBusFactory().createBus();
        assertNotNull(bus);
        BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class)
        assertNotNull("No binding factory manager", bfm);
        assertNotNull("No configurer", bus.getExtension(Configurer.class));
        assertNotNull("No resource manager", bus.getExtension(ResourceManager.class));
        assertNotNull("No destination factory manager", bus.getExtension(DestinationFactoryManager.class));
        assertNotNull("No conduit initiator manager", bus.getExtension(ConduitInitiatorManager.class));
        assertNotNull("No wsdl manager", bus.getExtension(WSDLManager.class));
        assertNotNull("No phase manager", bus.getExtension(PhaseManager.class));
        assertNotNull("No workqueue manager", bus.getExtension(WorkQueueManager.class));
        assertNotNull("No lifecycle manager", bus.getExtension(BusLifeCycleManager.class));
        assertNotNull("No service registry", bus.getExtension(ServerRegistry.class));
       
        try {
            bfm.getBindingFactory("http://cxf.apache.org/unknown");
        } catch (BusException ex) {
            // expected
        }
       
        assertEquals("Unexpected interceptors", 0, bus.getInInterceptors().size());
        assertEquals("Unexpected interceptors", 0, bus.getInFaultInterceptors().size());
        assertEquals("Unexpected interceptors", 0, bus.getOutInterceptors().size());
        assertEquals("Unexpected interceptors", 0, bus.getOutFaultInterceptors().size());

    }
View Full Code Here

    }
   
    @Test
    public void testCustomFileName() {
        String cfgFile = "org/apache/cxf/bus/spring/resources/bus-overwrite.xml";
        Bus bus = new SpringBusFactory().createBus(cfgFile, true);
        checkCustomerConfiguration(bus);
    }
View Full Code Here

    }

    @Test
    public void testCustomerBusShutdown() {
        String cfgFile = "org/apache/cxf/bus/spring/customerBus.xml";
        Bus bus = new SpringBusFactory().createBus(cfgFile, true);
        // We have three bus here, which should be closed rightly
        bus.shutdown(true);
    }
View Full Code Here

   
    @Test
    public void testCustomFileURLFromSystemProperty() {
        URL cfgFileURL = this.getClass().getResource("resources/bus-overwrite.xml");       
        System.setProperty(Configurer.USER_CFG_FILE_PROPERTY_URL, cfgFileURL.toString());
        Bus bus = new SpringBusFactory().createBus((String)null, true);
        checkCustomerConfiguration(bus);
        System.clearProperty(Configurer.USER_CFG_FILE_PROPERTY_URL);
    }
View Full Code Here

TOP

Related Classes of org.apache.cxf.Bus

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.