Search in sources :

Example 41 with Server

use of org.apache.cxf.endpoint.Server in project cxf by apache.

the class MDBActivationWork method createServer.

private Server createServer(Bus bus, Class<?> serviceClass, MDBInvoker invoker) {
    // create server bean factory
    final ServerFactoryBean factory;
    if (serviceClass != null && EndpointUtils.hasWebServiceAnnotation(serviceClass)) {
        factory = new JaxWsServerFactoryBean();
    } else {
        factory = new ServerFactoryBean();
    }
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("Creating a server using " + factory.getClass().getName());
    }
    if (serviceClass != null) {
        factory.setServiceClass(serviceClass);
    }
    if (spec.getWsdlLocation() != null) {
        factory.setWsdlLocation(spec.getWsdlLocation());
    }
    if (spec.getAddress() != null) {
        factory.setAddress(spec.getAddress());
    }
    factory.setBus(bus);
    if (spec.getEndpointName() != null) {
        factory.setEndpointName(QName.valueOf(spec.getEndpointName()));
    }
    if (spec.getSchemaLocations() != null) {
        factory.setSchemaLocations(getListOfString(spec.getSchemaLocations()));
    }
    if (spec.getServiceName() != null) {
        factory.setServiceName(QName.valueOf(spec.getServiceName()));
    }
    factory.setInvoker(invoker);
    // Don't start the server yet
    factory.setStart(false);
    final Server retval;
    if (factory instanceof JaxWsServerFactoryBean) {
        retval = createServerFromJaxwsEndpoint((JaxWsServerFactoryBean) factory);
    } else {
        retval = factory.create();
    }
    return retval;
}
Also used : Server(org.apache.cxf.endpoint.Server) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean)

Example 42 with Server

use of org.apache.cxf.endpoint.Server in project cxf by apache.

the class JCABusFactory method deregisterServants.

private void deregisterServants(Bus aBus) {
    synchronized (servantsCache) {
        for (Server servant : servantsCache) {
            // REVISIT: seems using server.stop() doesn't release resource properly.
            servant.destroy();
            LOG.info("Shutdown the EJB Endpoint: " + servant.getEndpoint().getEndpointInfo().getName());
        }
        servantsCache.clear();
    }
}
Also used : Server(org.apache.cxf.endpoint.Server)

Example 43 with Server

use of org.apache.cxf.endpoint.Server in project cxf by apache.

the class JCABusFactory method initializeServantsFromProperties.

private void initializeServantsFromProperties(Properties ejbServants) throws ResourceException {
    deregisterServants(bus);
    LOG.info("Initializing EJB endpoints from properties file...");
    try {
        Enumeration<?> keys = ejbServants.keys();
        while (keys.hasMoreElements()) {
            String theJNDIName = (String) keys.nextElement();
            String value = (String) ejbServants.get(theJNDIName);
            EJBServantConfig config = new EJBServantConfig(theJNDIName, value);
            EJBEndpoint ejbEndpoint = new EJBEndpoint(config);
            ejbEndpoint.setEjbServantBaseURL(mcf.getEJBServantBaseURL());
            ejbEndpoint.setWorkManager(getWorkManager());
            Server servant = ejbEndpoint.publish();
            synchronized (servantsCache) {
                if (servant != null) {
                    servantsCache.add(servant);
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        throw new ResourceException(new Message("FAIL_TO_START_EJB_SERVANTS", BUNDLE).toString(), e);
    }
}
Also used : EJBServantConfig(org.apache.cxf.jca.servant.EJBServantConfig) Server(org.apache.cxf.endpoint.Server) Message(org.apache.cxf.common.i18n.Message) EJBEndpoint(org.apache.cxf.jca.servant.EJBEndpoint) ResourceException(javax.resource.ResourceException) ResourceException(javax.resource.ResourceException) ResourceAdapterInternalException(org.apache.cxf.jca.core.resourceadapter.ResourceAdapterInternalException) IOException(java.io.IOException)

Example 44 with Server

use of org.apache.cxf.endpoint.Server in project cxf by apache.

the class ExceptionTest method testJaxws.

@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();
}
Also used : Server(org.apache.cxf.endpoint.Server) BeanInvoker(org.apache.cxf.service.invoker.BeanInvoker) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) Service(org.apache.cxf.service.Service) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 45 with Server

use of org.apache.cxf.endpoint.Server in project cxf by apache.

the class ExceptionTest method testJaxwsServerSimpleClient.

@Test(expected = HelloException.class)
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();
}
Also used : Server(org.apache.cxf.endpoint.Server) BeanInvoker(org.apache.cxf.service.invoker.BeanInvoker) ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean) Service(org.apache.cxf.service.Service) AegisDatabinding(org.apache.cxf.aegis.databinding.AegisDatabinding) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Aggregations

Server (org.apache.cxf.endpoint.Server)199 Test (org.junit.Test)119 ReferenceParametersType (org.apache.cxf.ws.addressing.ReferenceParametersType)54 ResourceManager (org.apache.cxf.ws.transfer.manager.ResourceManager)52 MemoryResourceManager (org.apache.cxf.ws.transfer.manager.MemoryResourceManager)50 Resource (org.apache.cxf.ws.transfer.resource.Resource)50 ExpressionType (org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType)47 ValueType (org.apache.cxf.ws.transfer.dialect.fragment.ValueType)44 Element (org.w3c.dom.Element)44 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)33 Put (org.apache.cxf.ws.transfer.Put)33 Fragment (org.apache.cxf.ws.transfer.dialect.fragment.Fragment)32 Service (org.apache.cxf.service.Service)27 Bus (org.apache.cxf.Bus)25 PutResponse (org.apache.cxf.ws.transfer.PutResponse)25 Endpoint (org.apache.cxf.endpoint.Endpoint)21 ArrayList (java.util.ArrayList)18 QName (javax.xml.namespace.QName)18 ServerRegistry (org.apache.cxf.endpoint.ServerRegistry)18 Document (org.w3c.dom.Document)18