Search in sources :

Example 6 with ServiceBuilder

use of org.apache.cxf.service.ServiceBuilder in project cxf by apache.

the class JavaToWSDLProcessor method process.

public void process() throws ToolException {
    String oldClassPath = System.getProperty(JAVA_CLASS_PATH);
    LOG.log(Level.FINE, "OLD_CP", oldClassPath);
    if (context.get(ToolConstants.CFG_CLASSPATH) != null) {
        String newCp = (String) context.get(ToolConstants.CFG_CLASSPATH);
        System.setProperty(JAVA_CLASS_PATH, newCp + File.pathSeparator + oldClassPath);
        LOG.log(Level.FINE, "NEW_CP", newCp);
    }
    // check for command line specification of data binding.
    ServiceBuilder builder = getServiceBuilder();
    ServiceInfo service = builder.createService();
    customize(service);
    File wsdlFile = getOutputFile(builder.getOutputFile(), service.getName().getLocalPart() + ".wsdl");
    File outputDir = getOutputDir(wsdlFile);
    if (context.containsKey(ToolConstants.CFG_WSDL)) {
        generators.add(getWSDLGenerator(wsdlFile));
    }
    if (context.containsKey(ToolConstants.CFG_WRAPPERBEAN)) {
        generators.add(getWrapperBeanGenerator());
        generators.add(getFaultBeanGenerator());
    }
    generate(service, outputDir);
    List<ServiceInfo> serviceList = new ArrayList<>();
    serviceList.add(service);
    context.put(ToolConstants.SERVICE_LIST, serviceList);
    System.setProperty(JAVA_CLASS_PATH, oldClassPath);
    LOG.log(Level.FINE, "RESUME_CP", oldClassPath);
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) ArrayList(java.util.ArrayList) File(java.io.File) ServiceBuilder(org.apache.cxf.service.ServiceBuilder)

Example 7 with ServiceBuilder

use of org.apache.cxf.service.ServiceBuilder 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

ServiceBuilder (org.apache.cxf.service.ServiceBuilder)7 ArrayList (java.util.ArrayList)3 File (java.io.File)2 List (java.util.List)2 JaxwsServiceBuilder (org.apache.cxf.jaxws.JaxwsServiceBuilder)2 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)2 SimpleServiceBuilder (org.apache.cxf.simple.SimpleServiceBuilder)2 ToolException (org.apache.cxf.tools.common.ToolException)2 ServiceBuilderFactory (org.apache.cxf.tools.java2wsdl.processor.internal.ServiceBuilderFactory)2 Test (org.junit.Test)2 BufferedWriter (java.io.BufferedWriter)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 BusApplicationContext (org.apache.cxf.bus.spring.BusApplicationContext)1 DataBinding (org.apache.cxf.databinding.DataBinding)1 AbstractServiceFactory (org.apache.cxf.frontend.AbstractServiceFactory)1 BasicNameManager (org.apache.cxf.javascript.BasicNameManager)1 NamespacePrefixAccumulator (org.apache.cxf.javascript.NamespacePrefixAccumulator)1