Search in sources :

Example 1 with AbstractServiceFactory

use of org.apache.cxf.frontend.AbstractServiceFactory in project cxf by apache.

the class DefaultServiceBuilderFactory method newBuilder.

@Override
public ServiceBuilder newBuilder(FrontendFactory.Style s) {
    DataBinding dataBinding;
    final String dbn = getDatabindingName();
    if (ToolConstants.JAXB_DATABINDING.equals(dbn)) {
        dataBinding = new JAXBDataBinding();
    } else if (ToolConstants.AEGIS_DATABINDING.equals(dbn)) {
        dataBinding = new AegisDatabinding();
    } else {
        throw new ToolException("Unsupported databinding: " + dbn);
    }
    AbstractServiceFactory builder = null;
    if (Style.Jaxws.equals(s)) {
        builder = new JaxwsServiceBuilder();
    } else if (Style.Simple.equals(s)) {
        builder = new SimpleServiceBuilder();
    } else {
        throw new ToolException("Unsupported frontend style: " + s);
    }
    builder.setDataBinding(dataBinding);
    builder.setServiceClass(serviceClass);
    return builder;
}
Also used : AbstractServiceFactory(org.apache.cxf.frontend.AbstractServiceFactory) SimpleServiceBuilder(org.apache.cxf.simple.SimpleServiceBuilder) DataBinding(org.apache.cxf.databinding.DataBinding) JAXBDataBinding(org.apache.cxf.jaxb.JAXBDataBinding) JAXBDataBinding(org.apache.cxf.jaxb.JAXBDataBinding) AegisDatabinding(org.apache.cxf.aegis.databinding.AegisDatabinding) ToolException(org.apache.cxf.tools.common.ToolException) JaxwsServiceBuilder(org.apache.cxf.jaxws.JaxwsServiceBuilder)

Example 2 with AbstractServiceFactory

use of org.apache.cxf.frontend.AbstractServiceFactory in project cxf by apache.

the class SpringServiceBuilderFactory method newBuilder.

@Override
public ServiceBuilder newBuilder(FrontendFactory.Style s) {
    ApplicationContext applicationContext = getApplicationContext(beanDefinitions);
    DataBinding dataBinding;
    String databindingBeanName = databindingNameToBeanName(databindingName);
    try {
        dataBinding = (DataBinding) applicationContext.getBean(databindingBeanName);
    } catch (RuntimeException e) {
        throw new ToolException("Cannot get databinding bean " + databindingBeanName + " for databinding " + databindingName, e);
    }
    String beanName = getBuilderBeanName(s);
    ServiceBuilder builder = null;
    try {
        builder = applicationContext.getBean(beanName, ServiceBuilder.class);
        AbstractServiceFactory serviceFactory = (AbstractServiceFactory) builder;
        serviceFactory.setDataBinding(dataBinding);
    } catch (RuntimeException e) {
        throw new ToolException("Can not get ServiceBuilder bean " + beanName + "to initialize the ServiceBuilder for style: " + s + " Reason: \n" + e.getMessage(), e);
    }
    builder.setServiceClass(serviceClass);
    return builder;
}
Also used : BusApplicationContext(org.apache.cxf.bus.spring.BusApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) AbstractServiceFactory(org.apache.cxf.frontend.AbstractServiceFactory) DataBinding(org.apache.cxf.databinding.DataBinding) ToolException(org.apache.cxf.tools.common.ToolException) ServiceBuilder(org.apache.cxf.service.ServiceBuilder)

Aggregations

DataBinding (org.apache.cxf.databinding.DataBinding)2 AbstractServiceFactory (org.apache.cxf.frontend.AbstractServiceFactory)2 ToolException (org.apache.cxf.tools.common.ToolException)2 AegisDatabinding (org.apache.cxf.aegis.databinding.AegisDatabinding)1 BusApplicationContext (org.apache.cxf.bus.spring.BusApplicationContext)1 JAXBDataBinding (org.apache.cxf.jaxb.JAXBDataBinding)1 JaxwsServiceBuilder (org.apache.cxf.jaxws.JaxwsServiceBuilder)1 ServiceBuilder (org.apache.cxf.service.ServiceBuilder)1 SimpleServiceBuilder (org.apache.cxf.simple.SimpleServiceBuilder)1 ApplicationContext (org.springframework.context.ApplicationContext)1 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)1