Package org.apache.cxf.dosgi.dsw.service

Examples of org.apache.cxf.dosgi.dsw.service.DistributionProviderImpl


        context.addServiceListener(this);                
        checkExistingServices();       
    }

    private CxfDistributionProvider registerDistributionProviderService() {
        DistributionProviderImpl dpService = new DistributionProviderImpl(bc);
        Hashtable<String, Object> props = new Hashtable<String, Object>();
       
        props.put(DistributionProvider.PRODUCT_NAME, getHeader("Bundle-Name"));
        props.put(DistributionProvider.PRODUCT_VERSION, getHeader("Bundle-Version"));
        props.put(DistributionProvider.VENDOR_NAME, getHeader("Bundle-Vendor"));
View Full Code Here


        EasyMock.replay(sr);
        EasyMock.replay(dswContext);
        EasyMock.replay(callingContext);
        EasyMock.replay(sd);
       
        DistributionProviderImpl dp = new DistributionProviderImpl(dswContext);
        WsdlConfigurationTypeHandler w = new WsdlConfigurationTypeHandler(dswContext, dp, handlerProps) {
            @Override
            Service createWebService(URL wsdlAddress, QName serviceQname) {
                Service svc = EasyMock.createMock(Service.class);
                EasyMock.expect(svc.getPort(CharSequence.class)).andReturn("Hi").anyTimes();
                EasyMock.replay(svc);
                return svc;
            }           
        };

        assertEquals("Precondition failed", 0, dp.getRemoteServices().size());
        w.createProxy(sr, dswContext, callingContext, CharSequence.class, sd);
        assertEquals(1, dp.getRemoteServices().size());
        assertSame(sr, dp.getRemoteServices().iterator().next());
       
    }
View Full Code Here

        EasyMock.replay(bc);
       
        ConfigTypeHandlerFactory f = ConfigTypeHandlerFactory.getInstance();
       
        ServiceEndpointDescription sd = new ServiceEndpointDescriptionImpl("MyInterface");
        CxfDistributionProvider dp = new DistributionProviderImpl(bc);
        ConfigurationTypeHandler handler = f.getHandler(bc, sd, dp, new HashMap<String, Object>());
        assertTrue(handler instanceof PojoConfigurationTypeHandler);       
        assertSame(dp, ((PojoConfigurationTypeHandler) handler).getDistributionProvider());
    }
View Full Code Here

        Map<String, Object> sdProps = new HashMap<String, Object>();
        sdProps.put("osgi.remote.configuration.type", Constants.POJO_CONFIG_TYPE);
        ServiceEndpointDescription sd = new ServiceEndpointDescriptionImpl(
                Collections.singletonList("MyInterface"), sdProps);

        CxfDistributionProvider dp = new DistributionProviderImpl(bc);
        ConfigurationTypeHandler handler = f.getHandler(bc, sd, dp, new HashMap<String, Object>());
        assertTrue(handler instanceof PojoConfigurationTypeHandler);       
        assertSame(dp, ((PojoConfigurationTypeHandler) handler).getDistributionProvider());
    }
View Full Code Here

        // use default for this: sdProps.put(Constants.CONFIG_TYPE_PROPERTY, Constants.POJO_CONFIG_TYPE);
        sdProps.put(Constants.POJO_ADDRESS_PROPERTY, "http://localhost:9876/abcd");
        ServiceEndpointDescription sd = new ServiceEndpointDescriptionImpl(
                Collections.singletonList("MyInterface"), sdProps);

        CxfDistributionProvider dp = new DistributionProviderImpl(bc);
        ConfigurationTypeHandler handler = f.getHandler(bc, sd, dp, new HashMap<String, Object>());
        assertTrue(handler instanceof PojoConfigurationTypeHandler);       
        assertSame(dp, ((PojoConfigurationTypeHandler) handler).getDistributionProvider());
    }
View Full Code Here

        sdProps.put("osgi.remote.configuration.type", Constants.POJO_CONFIG_TYPE);
        sdProps.put(Constants.POJO_HTTP_SERVICE_CONTEXT, "/abc");
        ServiceEndpointDescription sd = new ServiceEndpointDescriptionImpl(
                Collections.singletonList("MyInterface"), sdProps);
       
        CxfDistributionProvider dp = new DistributionProviderImpl(bc);
        ConfigurationTypeHandler handler = f.getHandler(bc, sd, dp, new HashMap<String, Object>());
        assertTrue(handler instanceof HttpServiceConfigurationTypeHandler);
        assertSame(dp, ((HttpServiceConfigurationTypeHandler) handler).getDistributionProvider());               
    }
View Full Code Here

        Map<String, Object> sdProps = new HashMap<String, Object>();
        sdProps.put("osgi.remote.configuration.type", Constants.WSDL_CONFIG_TYPE);
        ServiceEndpointDescription sd = new ServiceEndpointDescriptionImpl(
                Collections.singletonList("MyInterface"), sdProps);
       
        CxfDistributionProvider dp = new DistributionProviderImpl(bc);
        ConfigurationTypeHandler handler = f.getHandler(bc, sd, dp, new HashMap<String, Object>());
        assertTrue(handler instanceof WsdlConfigurationTypeHandler);       
        assertSame(dp, ((WsdlConfigurationTypeHandler) handler).getDistributionProvider());
    }
View Full Code Here

        EasyMock.expect(dswContext.getService(httpSvcSR)).andReturn(httpService).anyTimes();
        EasyMock.replay(dswContext);
       
        final ServerFactoryBean sfb = createMockServerFactoryBean();
       
        DistributionProviderImpl dp = new DistributionProviderImpl(dswContext);
        Map<String, Object> handlerProps = new HashMap<String, Object>();
        HttpServiceConfigurationTypeHandler h =
            new HttpServiceConfigurationTypeHandler(dswContext, dp, handlerProps) {
                @Override
                ServerFactoryBean createServerFactoryBean() {
                    return sfb;
                }

                @Override
                String[] applyIntents(BundleContext dswContext, BundleContext callingContext,
                        List<AbstractFeature> features, AbstractEndpointFactory factory,
                        ServiceEndpointDescription sd) {
                    return new String [] {"a.b.c"};
                }           
        };
        h.httpServiceReferences.add(httpSvcSR);
       
        Runnable myService = new Runnable() {
            public void run() {
                System.out.println("blah");
            }           
        };
               
        ServiceReference sr = EasyMock.createNiceMock(ServiceReference.class);
        BundleContext callingContext = EasyMock.createNiceMock(BundleContext.class);
        EasyMock.replay(sr);
        EasyMock.replay(callingContext);

        Map<String, Object> props = new HashMap<String, Object>();
        props.put(Constants.POJO_HTTP_SERVICE_CONTEXT, "/myRunnable");
        ServiceEndpointDescription sd = new ServiceEndpointDescriptionImpl(Runnable.class.getName(), props);
       
        assertEquals("Precondition failed", 0, dp.getExposedServices().size());
        assertEquals("Precondition failed", "", sfb.getAddress());
        h.createServer(sr, dswContext, callingContext, sd, Runnable.class, myService);
        assertEquals("The address should be set to '/'. The Servlet context dictates the actual location.", "/", sfb.getAddress());
        assertEquals(1, dp.getExposedServices().size());
        assertSame(sr, dp.getExposedServices().iterator().next());
       
        String hostName = InetAddress.getLocalHost().getHostName();
        Map<String, String> expected = new HashMap<String, String>();
        expected.put("osgi.remote.configuration.type", "pojo");
        expected.put("osgi.remote.configuration.pojo.address", "http://" + hostName + ":1327/myRunnable");
        expected.put("osgi.deployment.intents", "a.b.c");
        assertEquals(expected, dp.getExposedProperties(sr));
    }
View Full Code Here

        EasyMock.expect(dswContext.getService(httpSvcSR)).andReturn(httpService).anyTimes();
        EasyMock.replay(dswContext);
       
        final ServerFactoryBean sfb = createMockServerFactoryBean();
       
        DistributionProviderImpl dp = new DistributionProviderImpl(dswContext);
        Map<String, Object> handlerProps = new HashMap<String, Object>();
        HttpServiceConfigurationTypeHandler h =
            new HttpServiceConfigurationTypeHandler(dswContext, dp, handlerProps) {
                @Override
                ServerFactoryBean createServerFactoryBean() {
                    return sfb;
                }

                @Override
                String[] applyIntents(BundleContext dswContext, BundleContext callingContext,
                        List<AbstractFeature> features, AbstractEndpointFactory factory,
                        ServiceEndpointDescription sd) {
                    return new String [] {};
                }           
        };
        h.httpServiceReferences.add(httpSvcSR);
       
        Runnable myService = new Runnable() {
            public void run() {
                System.out.println("blah");
            }           
        };
               
        ServiceReference sr = EasyMock.createNiceMock(ServiceReference.class);
        BundleContext callingContext = EasyMock.createNiceMock(BundleContext.class);
        EasyMock.replay(sr);
        EasyMock.replay(callingContext);

        Map<String, Object> props = new HashMap<String, Object>();
        ServiceEndpointDescription sd = new ServiceEndpointDescriptionImpl(Runnable.class.getName(), props);
       
        assertEquals("Precondition failed", 0, dp.getExposedServices().size());
        h.createServer(sr, dswContext, callingContext, sd, Runnable.class, myService);
        assertEquals(1, dp.getExposedServices().size());
        assertSame(sr, dp.getExposedServices().iterator().next());
       
        String hostname = InetAddress.getLocalHost().getHostName();
        Map<String, String> expected = new HashMap<String, String>();
        expected.put("osgi.remote.configuration.type", "pojo");
        expected.put("osgi.remote.configuration.pojo.address", "http://" + hostname + ":8080/java/lang/Runnable");
        assertEquals(expected, dp.getExposedProperties(sr));
    }
View Full Code Here

        EasyMock.expect(dswContext.getService(httpSvcSR)).andReturn(httpService).anyTimes();
        EasyMock.replay(dswContext);
       
        final ServerFactoryBean sfb = createMockServerFactoryBean();
       
        DistributionProviderImpl dp = new DistributionProviderImpl(dswContext);
        Map<String, Object> handlerProps = new HashMap<String, Object>();
        HttpServiceConfigurationTypeHandler h =
            new HttpServiceConfigurationTypeHandler(dswContext, dp, handlerProps) {
                @Override
                ServerFactoryBean createServerFactoryBean() {
                    return sfb;
                }

                @Override
                String[] applyIntents(BundleContext dswContext, BundleContext callingContext,
                        List<AbstractFeature> features, AbstractEndpointFactory factory,
                        ServiceEndpointDescription sd) {
                    return new String [] {};
                }           
        };
        h.httpServiceReferences.add(httpSvcSR);
       
        Runnable myService = new Runnable() {
            public void run() {
                System.out.println("blah");
            }           
        };
               
        ServiceReference sr = EasyMock.createNiceMock(ServiceReference.class);
        BundleContext callingContext = EasyMock.createNiceMock(BundleContext.class);
        EasyMock.replay(sr);
        EasyMock.replay(callingContext);

        Map<String, Object> props = new HashMap<String, Object>();
        props.put("osgi.remote.configuration.type", Constants.POJO_CONFIG_TYPE);
        props.put(Constants.POJO_HTTP_SERVICE_CONTEXT, "/myRunnable");
        ServiceEndpointDescription sd = new ServiceEndpointDescriptionImpl(Runnable.class.getName(), props);
       
        assertEquals("Precondition failed", 0, dp.getExposedServices().size());
        h.createServer(sr, dswContext, callingContext, sd, Runnable.class, myService);
        assertEquals(1, dp.getExposedServices().size());
        assertSame(sr, dp.getExposedServices().iterator().next());
       
        String hostName = InetAddress.getLocalHost().getHostName();
        Map<String, String> expected = new HashMap<String, String>();
        expected.put("osgi.remote.configuration.type", "pojo");
        expected.put("osgi.remote.configuration.pojo.address", "https://" + hostName + ":8432/myRunnable");
        assertEquals(expected, dp.getExposedProperties(sr));
    }
View Full Code Here

TOP

Related Classes of org.apache.cxf.dosgi.dsw.service.DistributionProviderImpl

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.