コード例 #1
0
 @Before
 public void setUp() throws Exception {
   super.setUp();
   Server server = createService(IInterfaceService.class);
   Service service = server.getEndpoint().getService();
   service.setInvoker(new BeanInvoker(new InterfaceService()));
 }
コード例 #2
0
ファイル: ExceptionTest.java プロジェクト: CzarnyPeter/cxf
  @Before
  public void setUp() throws Exception {
    super.setUp();

    Server s = createService(ExceptionService.class, new ExceptionServiceImpl(), null);
    s.getEndpoint().getService().setInvoker(new BeanInvoker(new ExceptionServiceImpl()));
  }
コード例 #3
0
ファイル: TestPlugin.java プロジェクト: patels3/ddf
  @AfterClass
  public static void destroy() {

    if (server != null) {
      server.stop();
      server.destroy();
    }
  }
コード例 #4
0
 @AfterClass
 public static void stopService() throws Exception {
   if (s != null) {
     s.stop();
   }
   if (s2 != null) {
     s2.stop();
   }
 }
コード例 #5
0
  public void handleMessage(Message message) throws Fault {
    if (bus == null) {
      bus = message.getExchange().getBus();
      if (bus == null) {
        bus = BusFactory.getDefaultBus(false);
      }
      if (bus == null) {
        throw new Fault(new org.apache.cxf.common.i18n.Message("BUS_NOT_FOUND", BUNDLE));
      }
    }

    ServerRegistry registry = bus.getExtension(ServerRegistry.class);

    if (registry == null) {
      throw new Fault(new org.apache.cxf.common.i18n.Message("SERVER_REGISTRY_NOT_FOUND", BUNDLE));
    }

    Exchange exchange = message.getExchange();
    Endpoint senderEndpoint = exchange.getEndpoint();

    if (senderEndpoint == null) {
      throw new Fault(new org.apache.cxf.common.i18n.Message("ENDPOINT_NOT_FOUND", BUNDLE));
    }

    BindingOperationInfo boi = exchange.getBindingOperationInfo();

    if (boi == null) {
      throw new Fault(new org.apache.cxf.common.i18n.Message("OPERATIONINFO_NOT_FOUND", BUNDLE));
    }

    Server srv = isColocated(registry.getServers(), senderEndpoint, boi);

    if (srv != null) {
      if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("Operation:" + boi.getName() + " dispatched as colocated call.");
      }

      InterceptorChain outChain = message.getInterceptorChain();
      outChain.abort();
      exchange.put(Bus.class, bus);
      message.put(COLOCATED, Boolean.TRUE);
      message.put(Message.WSDL_OPERATION, boi.getName());
      message.put(Message.WSDL_INTERFACE, boi.getBinding().getInterface().getName());
      invokeColocObserver(message, srv.getEndpoint());
      if (!exchange.isOneWay()) {
        invokeInboundChain(exchange, senderEndpoint);
      }
    } else {
      if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("Operation:" + boi.getName() + " dispatched as remote call.");
      }

      message.put(COLOCATED, Boolean.FALSE);
    }
  }
コード例 #6
0
ファイル: StopEndpointCommand.java プロジェクト: Jutten/cxf
 protected Object doExecute() throws Exception {
   Bus b = cxfController.getBus(busName);
   ServerRegistry reg = b.getExtension(ServerRegistry.class);
   List<Server> servers = reg.getServers();
   for (Server serv : servers) {
     if (endpoint.equals(serv.getEndpoint().getEndpointInfo().getName().getLocalPart())) {
       serv.stop();
     }
   }
   return null;
 }
コード例 #7
0
 @Override
 public void initialize(Server server, Bus bus) {
   checkZmqConfig();
   Destination destination = server.getDestination();
   if (!(destination instanceof ZMQDestination)) {
     throw new ConfigurationException(new Message("ZMQCONFIGFEATURE_ONLY_ZMQ", LOG));
   }
   Endpoint ep = server.getEndpoint();
   changeTransportUriToZmq(ep);
   ZMQDestination zmqDestination = (ZMQDestination) destination;
   zmqDestination.setZmqConfig(zmqConfig);
   super.initialize(server, bus);
 }
コード例 #8
0
 @After
 public void done() throws Exception {
   if (mep == NO_RUN) {
     return;
   }
   if (callbackEndpoint != null) {
     callbackEndpoint.stop();
   }
   if (server != null) {
     server.stop();
     server.destroy();
   }
   checkError(true);
 }
コード例 #9
0
  private Service createService() {
    // Create the Service
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setServiceBean(new EchoImpl());
    factory.setAddress("local://Echo");
    factory.setTransportId(LocalTransportFactory.TRANSPORT_ID);
    Server server = factory.create();

    Service service = server.getEndpoint().getService();
    service.getInInterceptors().add(new LoggingInInterceptor());
    service.getOutInterceptors().add(new LoggingOutInterceptor());

    return service;
  }
コード例 #10
0
  /**
   * This determines if the service has already been published on the CXF bus.
   *
   * @return true if cxf server exists for this service.
   */
  protected boolean isServicePublished(String serviceAddress) {

    ServerRegistry serverRegistry = getCXFServerRegistry();
    List<Server> servers = serverRegistry.getServers();

    for (Server server : servers) {
      String endpointAddress = server.getEndpoint().getEndpointInfo().getAddress();
      if (endpointAddress.contains(serviceAddress)) {
        LOG.info("Service already published on CXF, not republishing: " + serviceAddress);
        return true;
      }
    }

    return false;
  }
コード例 #11
0
ファイル: EndpointImpl.java プロジェクト: Jutten/cxf
 @Override
 public void stop() {
   if (null != server) {
     server.destroy();
     server = null;
   }
 }
コード例 #12
0
ファイル: EndpointImpl.java プロジェクト: Jutten/cxf
  @Override
  public void setProperties(Map<String, Object> properties) {
    this.properties = properties;

    if (server != null) {
      server.getEndpoint().putAll(properties);
    }
  }
コード例 #13
0
  @Test
  public void testServerFactory() {
    JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();

    assert bus != null;
    sf.setServiceBean(new GreeterImpl());
    sf.setAddress("http://localhost:" + PORT + "/test");
    sf.setStart(false);

    Configurer c = getBus().getExtension(Configurer.class);
    c.configureBean("server", sf);

    Server server = sf.create();

    Endpoint endpoint = server.getEndpoint();
    checkAddressInterceptors(endpoint.getInInterceptors());
  }
コード例 #14
0
  @Override
  public void initialize(Server server, Bus bus) {
    // currently we do not filter the bus
    // remove the interceptors

    removeInterceptorWhichIsOutThePhases(
        server.getEndpoint().getService().getInInterceptors(),
        REMAINING_IN_PHASES,
        getInInterceptorNames());
    removeInterceptorWhichIsOutThePhases(
        server.getEndpoint().getInInterceptors(), REMAINING_IN_PHASES, getInInterceptorNames());

    // we need to keep the LoggingOutputInterceptor
    getOutInterceptorNames().add(LoggingOutInterceptor.class.getName());

    // Do not using the binding interceptor any more
    server.getEndpoint().getBinding().getInInterceptors().clear();

    removeInterceptorWhichIsOutThePhases(
        server.getEndpoint().getService().getOutInterceptors(),
        REMAINING_OUT_PHASES,
        getOutInterceptorNames());
    removeInterceptorWhichIsOutThePhases(
        server.getEndpoint().getOutInterceptors(), REMAINING_OUT_PHASES, getOutInterceptorNames());

    // Do not use the binding interceptor any more
    server.getEndpoint().getBinding().getOutInterceptors().clear();
    server.getEndpoint().getOutInterceptors().add(new RawMessageContentRedirectInterceptor());

    // setup the RawMessageWSDLGetInterceptor
    server.getEndpoint().getInInterceptors().add(RawMessageWSDLGetInterceptor.INSTANCE);
    // Oneway with RAW message
    if (isOneway()) {
      Interceptor<? extends Message> toRemove = null;
      for (Interceptor<? extends Message> i :
          server.getEndpoint().getService().getInInterceptors()) {
        if (i.getClass().getName().equals("org.apache.cxf.interceptor.OutgoingChainInterceptor")) {
          toRemove = i;
        }
      }
      server.getEndpoint().getService().getInInterceptors().remove(toRemove);
      server.getEndpoint().getInInterceptors().add(new OneWayOutgoingChainInterceptor());
      server.getEndpoint().getInInterceptors().add(new OneWayProcessorInterceptor());
    }
  }
コード例 #15
0
ファイル: ExceptionTest.java プロジェクト: CzarnyPeter/cxf
  @Test(expected = HelloException.class)
  public void testJaxws() throws Exception {
    JaxWsServerFactoryBean sfbean = new JaxWsServerFactoryBean();
    sfbean.setServiceClass(ExceptionService.class);
    setupAegis(sfbean);
    sfbean.setAddress("local://ExceptionService4");
    Server server = sfbean.create();
    Service service = server.getEndpoint().getService();
    service.setInvoker(new BeanInvoker(new ExceptionServiceImpl()));

    JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
    proxyFac.setAddress("local://ExceptionService4");
    proxyFac.setBus(getBus());
    setupAegis(proxyFac.getClientFactoryBean());
    ExceptionService clientInterface = proxyFac.create(ExceptionService.class);

    clientInterface.sayHiWithException();
  }
コード例 #16
0
ファイル: EndpointImpl.java プロジェクト: Jutten/cxf
 @Override
 public Map<String, Object> getProperties() {
   if (server != null) {
     return server.getEndpoint();
   }
   if (properties == null) {
     properties = new HashMap<String, Object>();
   }
   return properties;
 }
コード例 #17
0
ファイル: ExceptionTest.java プロジェクト: CzarnyPeter/cxf
  @Test(expected = HelloException.class)
  public void testJaxwsNoXfireCompat() throws Exception {
    JaxWsServerFactoryBean sfbean = new JaxWsServerFactoryBean();
    sfbean.setServiceClass(ExceptionService.class);
    sfbean.setDataBinding(new AegisDatabinding());
    sfbean.getServiceFactory().setDataBinding(sfbean.getDataBinding());
    sfbean.setAddress("local://ExceptionServiceJaxWs");
    Server server = sfbean.create();
    Service service = server.getEndpoint().getService();
    service.setInvoker(new BeanInvoker(new ExceptionServiceImpl()));

    JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
    proxyFac.setAddress("local://ExceptionServiceJaxWs");
    proxyFac.setServiceClass(ExceptionService.class);
    proxyFac.setBus(getBus());
    proxyFac.getClientFactoryBean().getServiceFactory().setDataBinding(new AegisDatabinding());
    ExceptionService clientInterface = (ExceptionService) proxyFac.create();

    clientInterface.sayHiWithException();
  }
コード例 #18
0
ファイル: ExceptionTest.java プロジェクト: CzarnyPeter/cxf
  @Test(expected = HelloException.class)
  @Ignore("Not working yet due to namespace things")
  public void testJaxwsServerSimpleClient() throws Exception {
    JaxWsServerFactoryBean sfbean = new JaxWsServerFactoryBean();
    sfbean.setServiceClass(ExceptionService.class);
    sfbean.setDataBinding(new AegisDatabinding());
    sfbean.setAddress("local://ExceptionServiceJaxWs1");
    Server server = sfbean.create();
    Service service = server.getEndpoint().getService();
    service.setInvoker(new BeanInvoker(new ExceptionServiceImpl()));

    ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean();
    proxyFac.setAddress("local://ExceptionServiceJaxWs1");
    proxyFac.setBus(getBus());
    setupAegis(proxyFac.getClientFactoryBean());

    ExceptionService clientInterface = proxyFac.create(ExceptionService.class);

    clientInterface.sayHiWithException();
  }
コード例 #19
0
  @Before
  public void setup() throws Exception {
    jmsBroker = createJmsBroker();
    server = createServer();

    assertThat(server, notNullValue()); // it's important that we can obtain the server bean
    assertThat(
        server.isStarted(),
        is(
            true)); // for all we care, we could also start the server, but we need to know if we
                    // have to or not
  }
コード例 #20
0
  protected Server isColocated(List<Server> servers, Endpoint endpoint, BindingOperationInfo boi) {
    if (servers != null) {
      Service senderService = endpoint.getService();
      EndpointInfo senderEI = endpoint.getEndpointInfo();
      for (Server s : servers) {
        Endpoint receiverEndpoint = s.getEndpoint();
        Service receiverService = receiverEndpoint.getService();
        EndpointInfo receiverEI = receiverEndpoint.getEndpointInfo();
        if (receiverService.getName().equals(senderService.getName())
            && receiverEI.getName().equals(senderEI.getName())) {
          // Check For Operation Match.
          BindingOperationInfo receiverOI = receiverEI.getBinding().getOperation(boi.getName());
          if (receiverOI != null && isCompatibleOperationInfo(boi, receiverOI)) {
            return s;
          }
        }
      }
    }

    return null;
  }
コード例 #21
0
 @Override
 public void initialize(Server server, Bus bus) {
   setupEndpoint(server.getEndpoint());
 }
コード例 #22
0
 @AfterClass
 public static void cleanup() throws Exception {
   for (Server server : serverList) {
     server.stop();
   }
 }
コード例 #23
0
  @SuppressWarnings("unchecked")
  protected void registerReceiverWithMuleService(MessageReceiver receiver, EndpointURI ep)
      throws MuleException {
    CxfMessageReceiver cxfReceiver = (CxfMessageReceiver) receiver;
    Server server = cxfReceiver.getServer();

    uriToServer.put(server.getEndpoint().getEndpointInfo().getAddress(), server);

    // TODO MULE-2228 Simplify this API
    SedaService c = new SedaService();

    String uniqueServiceName = createServiceName(server.getEndpoint());
    c.setName(uniqueServiceName);

    c.setModel(muleContext.getRegistry().lookupSystemModel());

    CxfServiceComponent svcComponent = new CxfServiceComponent(this, (CxfMessageReceiver) receiver);
    svcComponent.setBus(bus);

    c.setComponent(new DefaultJavaComponent(new SingletonObjectFactory(svcComponent)));

    // No determine if the endpointUri requires a new connector to be
    // registed in the case of http we only need to register the new
    // endpointUri if the port is different
    String endpoint = receiver.getEndpointURI().getAddress();
    String scheme = ep.getScheme().toLowerCase();

    InboundEndpoint originalEndpoint = receiver.getEndpoint();
    boolean sync = originalEndpoint.isSynchronous();

    // If we are using sockets then we need to set the endpoint name appropiately
    // and if using http/https
    // we need to default to POST and set the Content-Type
    if (scheme.equals("http")
        || scheme.equals("https")
        || scheme.equals("ssl")
        || scheme.equals("tcp")
        || scheme.equals("servlet")) {
      originalEndpoint.getProperties().put(HttpConnector.HTTP_METHOD_PROPERTY, "POST");
      originalEndpoint.getProperties().put(HttpConstants.HEADER_CONTENT_TYPE, "text/xml");
    }

    QName serviceName = server.getEndpoint().getEndpointInfo().getName();

    EndpointBuilder protocolEndpointBuilder = new EndpointURIEndpointBuilder(endpoint, muleContext);
    protocolEndpointBuilder.setSynchronous(sync);
    protocolEndpointBuilder.setName(ep.getScheme() + ":" + serviceName.getLocalPart());
    protocolEndpointBuilder.setTransactionConfig(originalEndpoint.getTransactionConfig());

    EndpointBuilder receiverEndpointBuilder =
        new EndpointURIEndpointBuilder(originalEndpoint, muleContext);

    // Apply the transformers to the correct endpoint
    EndpointBuilder transformerEndpoint;
    if (cxfReceiver.isApplyTransformersToProtocol()) {
      transformerEndpoint = protocolEndpointBuilder;
      receiverEndpointBuilder.setTransformers(Collections.emptyList());
      receiverEndpointBuilder.setResponseTransformers(Collections.emptyList());
    } else {
      transformerEndpoint = receiverEndpointBuilder;
    }

    // Ensure that the transformers aren't empty before setting them. Otherwise Mule will get
    // confused
    // and won't add the default transformers.
    if (originalEndpoint.getTransformers() != null
        && !originalEndpoint.getTransformers().isEmpty()) {
      transformerEndpoint.setTransformers(originalEndpoint.getTransformers());
    }

    if (originalEndpoint.getResponseTransformers() != null
        && !originalEndpoint.getResponseTransformers().isEmpty()) {
      transformerEndpoint.setResponseTransformers(originalEndpoint.getResponseTransformers());
    }

    // apply the filters to the correct endpoint
    EndpointBuilder filterEndpoint;
    if (cxfReceiver.isApplyFiltersToProtocol()) {
      filterEndpoint = protocolEndpointBuilder;
      receiverEndpointBuilder.setFilter(null);
    } else {
      filterEndpoint = receiverEndpointBuilder;
    }
    filterEndpoint.setFilter(originalEndpoint.getFilter());

    // apply the security filter to the correct endpoint
    EndpointBuilder secFilterEndpoint;
    if (cxfReceiver.isApplySecurityToProtocol()) {
      secFilterEndpoint = protocolEndpointBuilder;
      receiverEndpointBuilder.setSecurityFilter(null);
    } else {
      secFilterEndpoint = receiverEndpointBuilder;
    }
    secFilterEndpoint.setSecurityFilter(originalEndpoint.getSecurityFilter());

    String connectorName = (String) originalEndpoint.getProperty(CxfConstants.PROTOCOL_CONNECTOR);
    if (connectorName != null) {
      protocolEndpointBuilder.setConnector(
          muleContext.getRegistry().lookupConnector(connectorName));
    }

    InboundEndpoint protocolEndpoint =
        muleContext
            .getRegistry()
            .lookupEndpointFactory()
            .getInboundEndpoint(protocolEndpointBuilder);

    InboundEndpoint receiverEndpoint =
        muleContext
            .getRegistry()
            .lookupEndpointFactory()
            .getInboundEndpoint(receiverEndpointBuilder);

    receiver.setEndpoint(receiverEndpoint);

    c.setInboundRouter(new DefaultInboundRouterCollection());
    c.getInboundRouter().addEndpoint(protocolEndpoint);
    services.add(c);
  }
コード例 #24
0
 public void initialize(Server server, Bus bus) {
   initializeProvider(server.getEndpoint(), bus);
 }
コード例 #25
0
 @After
 public void tearDown() throws Exception {
   server.destroy();
   assertThat(server.isStarted(), is(false));
   jmsBroker.stop();
 }
コード例 #26
0
ファイル: EndpointImpl.java プロジェクト: Jutten/cxf
 public List<Interceptor<? extends Message>> getOutInterceptors() {
   if (server == null) {
     return out;
   }
   return new DoubleAddInterceptorList(out, server.getEndpoint().getOutInterceptors());
 }
コード例 #27
0
 public void tearDown() throws Exception {
   server.stop();
   server.destroy();
   server = null;
 }
コード例 #28
0
  @org.junit.Test
  public void testAnnotations() throws Exception {
    Bus bus = BusFactory.getDefaultBus();
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setBus(bus);
    factory.setServiceBean(new TestImpl());
    factory.setStart(false);
    List<String> tp =
        Arrays.asList(
            "http://schemas.xmlsoap.org/soap/http",
            "http://schemas.xmlsoap.org/wsdl/http/",
            "http://schemas.xmlsoap.org/wsdl/soap/http",
            "http://www.w3.org/2003/05/soap/bindings/HTTP/",
            "http://cxf.apache.org/transports/http/configuration",
            "http://cxf.apache.org/bindings/xformat");

    LocalTransportFactory f = new LocalTransportFactory(bus);
    f.getUriPrefixes().add("http");
    f.setTransportIds(tp);
    f.setBus(bus);
    f.register();

    Server s = factory.create();

    try {
      ServiceWSDLBuilder builder =
          new ServiceWSDLBuilder(bus, s.getEndpoint().getService().getServiceInfos());
      Definition def = builder.build();
      WSDLWriter wsdlWriter = bus.getExtension(WSDLManager.class).getWSDLFactory().newWSDLWriter();
      def.setExtensionRegistry(bus.getExtension(WSDLManager.class).getExtensionRegistry());
      Element wsdl = wsdlWriter.getDocument(def).getDocumentElement();

      Map<String, String> ns = new HashMap<String, String>();
      ns.put("wsdl", WSDLConstants.NS_WSDL11);
      ns.put(
          "wsu",
          "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
      ns.put("wsp", Constants.URI_POLICY_13_NS);
      XPathUtils xpu = new XPathUtils(ns);
      // org.apache.cxf.helpers.XMLUtils.printDOM(wsdl);
      check(xpu, wsdl, "/wsdl:definitions/wsdl:service/wsdl:port", "TestImplPortPortPolicy");
      check(xpu, wsdl, "/wsdl:definitions/wsdl:portType/", "TestInterfacePortTypePolicy");
      check(
          xpu, wsdl, "/wsdl:definitions/wsdl:portType/wsdl:operation/", "echoIntPortTypeOpPolicy");
      check(
          xpu,
          wsdl,
          "/wsdl:definitions/wsdl:portType/wsdl:operation/wsdl:input",
          "echoIntPortTypeOpInputPolicy");
      check(
          xpu,
          wsdl,
          "/wsdl:definitions/wsdl:portType/wsdl:operation/wsdl:output",
          "echoIntPortTypeOpOutputPolicy");
      check(
          xpu, wsdl, "/wsdl:definitions/wsdl:binding/", "TestImplServiceSoapBindingBindingPolicy");
      check(xpu, wsdl, "/wsdl:definitions/wsdl:binding/wsdl:operation/", "echoIntBindingOpPolicy");
      check(
          xpu,
          wsdl,
          "/wsdl:definitions/wsdl:binding/wsdl:operation/wsdl:input",
          "echoIntBindingOpInputPolicy");
      check(
          xpu,
          wsdl,
          "/wsdl:definitions/wsdl:binding/wsdl:operation/wsdl:output",
          "echoIntBindingOpOutputPolicy");
      check(xpu, wsdl, "/wsdl:definitions/wsdl:service/", "TestImplServiceServicePolicy");

      EndpointPolicy policy =
          bus.getExtension(PolicyEngine.class)
              .getServerEndpointPolicy(s.getEndpoint().getEndpointInfo(), null);
      assertNotNull(policy);
      assertEquals(1, policy.getChosenAlternative().size());
    } finally {
      bus.shutdown(true);
    }
  }
コード例 #29
0
 @After
 public void unpublish() {
   server.stop();
   server = null;
   client = null;
 }
コード例 #30
0
ファイル: RMManager.java プロジェクト: eonezhang/cxf
 public void startServer(Server server) {
   recoverReliableEndpoint(server.getEndpoint(), (Conduit) null);
 }