@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());
  }
  public void start() {

    // define a JSON provider and a mapping between REST and JSON namespace's
    JSONProvider<IngredientRESTService> jsonProvider = new JSONProvider<IngredientRESTService>();
    Map<String, String> map = new HashMap<String, String>();
    map.put("http://rest.ws.wfm", "{}");
    jsonProvider.setNamespaceMap(map);

    JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
    sf.setResourceClasses(IngredientRESTService.class);
    sf.setResourceProvider(
        IngredientRESTService.class,
        new SingletonResourceProvider(new IngredientRESTServiceImpl()));
    sf.setAddress("http://localhost:63083");

    sf.getInFaultInterceptors().add(new LoggingInInterceptor());
    sf.getOutFaultInterceptors().add(new LoggingOutInterceptor());
    sf.getInInterceptors().add(new LoggingInInterceptor());
    sf.getOutInterceptors().add(new LoggingOutInterceptor());
    sf.setProvider(jsonProvider);

    BindingFactoryManager manager = sf.getBus().getExtension(BindingFactoryManager.class);
    JAXRSBindingFactory factory = new JAXRSBindingFactory();
    factory.setBus(sf.getBus());
    manager.registerBindingFactory(JAXRSBindingFactory.JAXRS_BINDING_ID, factory);

    // REST-Service
    this.restserver = sf.create();
    this.restserver.start();
  }
示例#3
0
  private NutchServer() {
    configManager = new ConfManagerImpl();
    BlockingQueue<Runnable> runnables = Queues.newArrayBlockingQueue(JOB_CAPACITY);
    NutchServerPoolExecutor executor =
        new NutchServerPoolExecutor(10, JOB_CAPACITY, 1, TimeUnit.HOURS, runnables);
    jobManager = new JobManagerImpl(new JobFactory(), configManager, executor);

    sf = new JAXRSServerFactoryBean();
    BindingFactoryManager manager = sf.getBus().getExtension(BindingFactoryManager.class);
    JAXRSBindingFactory factory = new JAXRSBindingFactory();
    factory.setBus(sf.getBus());
    manager.registerBindingFactory(JAXRSBindingFactory.JAXRS_BINDING_ID, factory);
    sf.setResourceClasses(getClasses());
    sf.setResourceProviders(getResourceProviders());
    sf.setProvider(new JacksonJaxbJsonProvider());
  }
  @Before
  public void publish() {
    JAXRSServerFactoryBean serverFactoryBean = new JAXRSServerFactoryBean();
    serverFactoryBean.setProvider(new JacksonJsonProvider());
    serverFactoryBean.setResourceClasses(HelloService.class);
    ResourceProvider resourceProvider = new SingletonResourceProvider(helloServiceImplementation);
    serverFactoryBean.setResourceProvider(HelloService.class, resourceProvider);
    serverFactoryBean.setAddress("http://localhost:9000/");
    BindingFactoryManager manager =
        serverFactoryBean.getBus().getExtension(BindingFactoryManager.class);
    JAXRSBindingFactory bindingFactory = new JAXRSBindingFactory();
    bindingFactory.setBus(serverFactoryBean.getBus());
    manager.registerBindingFactory(JAXRSBindingFactory.JAXRS_BINDING_ID, bindingFactory);
    server = serverFactoryBean.create();

    JAXRSClientFactoryBean clientFactoryBean = new JAXRSClientFactoryBean();
    clientFactoryBean.setResourceClass(HelloService.class);
    clientFactoryBean.setAddress("http://localhost:9000/");
    clientFactoryBean.setProvider(new JacksonJsonProvider());
    client = clientFactoryBean.create(HelloService.class);
  }