Author: fnasser(a)redhat.com
Date: 2010-08-05 13:29:16 -0400 (Thu, 05 Aug 2010)
New Revision: 12746
Modified:
thirdparty/cxf/branches/cxf-2.2.6/tools/javato/ws/pom.xml
thirdparty/cxf/branches/cxf-2.2.6/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/processor/JavaToJSProcessor.java
thirdparty/cxf/branches/cxf-2.2.6/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessor.java
thirdparty/cxf/branches/cxf-2.2.6/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/DefaultServiceBuilderFactory.java
thirdparty/cxf/branches/cxf-2.2.6/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/ServiceBuilderFactory.java
thirdparty/cxf/branches/cxf-2.2.6/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/SpringServiceBuilderFactory.java
thirdparty/cxf/branches/cxf-2.2.6/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/ServiceBuilderFactoryTest.java
Log:
REVERT (not needed for EAP 5.1): Make use of Spring optional in CXF's JAXWS tooling
Modified: thirdparty/cxf/branches/cxf-2.2.6/tools/javato/ws/pom.xml
===================================================================
--- thirdparty/cxf/branches/cxf-2.2.6/tools/javato/ws/pom.xml 2010-08-05 15:23:53 UTC (rev
12745)
+++ thirdparty/cxf/branches/cxf-2.2.6/tools/javato/ws/pom.xml 2010-08-05 17:29:16 UTC (rev
12746)
@@ -140,6 +140,7 @@
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${project.version}</version>
+ <scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.apache.cxf</groupId>
Modified:
thirdparty/cxf/branches/cxf-2.2.6/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/processor/JavaToJSProcessor.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.6/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/processor/JavaToJSProcessor.java 2010-08-05
15:23:53 UTC (rev 12745)
+++
thirdparty/cxf/branches/cxf-2.2.6/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/processor/JavaToJSProcessor.java 2010-08-05
17:29:16 UTC (rev 12746)
@@ -37,6 +37,7 @@
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.BusApplicationContext;
import org.apache.cxf.common.WSDLConstants;
import org.apache.cxf.common.i18n.Message;
import org.apache.cxf.common.logging.LogUtils;
@@ -55,13 +56,42 @@
import org.apache.cxf.tools.common.ToolException;
import org.apache.cxf.tools.java2wsdl.processor.internal.ServiceBuilderFactory;
import org.apache.cxf.tools.util.AnnotationUtil;
+import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.FileSystemResource;
public class JavaToJSProcessor implements Processor {
private static final Logger LOG = LogUtils.getL7dLogger(JavaToJSProcessor.class);
private static final String JAVA_CLASS_PATH = "java.class.path";
private static final Charset UTF8 = Charset.forName("utf-8");
private ToolContext context;
+ private ApplicationContext applicationContext;
+ /**
+ * This is factored out to permit use in a unit test.
+ *
+ * @param bus
+ * @return
+ */
+ public static ApplicationContext getApplicationContext(Bus bus, List<String>
additionalFilePathnames) {
+ BusApplicationContext busApplicationContext =
bus.getExtension(BusApplicationContext.class);
+ GenericApplicationContext appContext = new
GenericApplicationContext(busApplicationContext);
+ XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(appContext);
+ reader.loadBeanDefinitions(new
ClassPathResource("META-INF/cxf/java2wsbeans.xml"));
+ for (String pathname : additionalFilePathnames) {
+ try {
+ reader.loadBeanDefinitions(new FileSystemResource(pathname));
+ } catch (BeanDefinitionStoreException bdse) {
+ throw new ToolException("Unable to open bean definition file "
+ pathname, bdse.getCause());
+ }
+ }
+
+ return appContext;
+ }
+
public void process() throws ToolException {
String oldClassPath = System.getProperty(JAVA_CLASS_PATH);
LOG.log(Level.INFO, "OLD_CP", oldClassPath);
@@ -87,10 +117,10 @@
if (null != context.get(ToolConstants.CFG_JAVASCRIPT_UTILS)) {
JavascriptQueryHandler.writeUtilsToResponseStream(JavaToJSProcessor.class,
fileOutputStream);
}
-
+
OutputStreamWriter outputStreamWriter = new
OutputStreamWriter(fileOutputStream, UTF8);
BufferedWriter writer = new BufferedWriter(outputStreamWriter);
-
+
for (SchemaInfo schema : schemata) {
SchemaJavascriptBuilder jsBuilder = new
SchemaJavascriptBuilder(serviceInfo
.getXmlSchemaCollection(), prefixManager, nameManager);
@@ -98,8 +128,10 @@
writer.append(allThatJavascript);
}
- ServiceJavascriptBuilder serviceBuilder = new
ServiceJavascriptBuilder(serviceInfo, null,
-
prefixManager, nameManager);
+ ServiceJavascriptBuilder serviceBuilder = new
ServiceJavascriptBuilder(serviceInfo,
+ null,
+
prefixManager,
+
nameManager);
serviceBuilder.walk();
String serviceJavascript = serviceBuilder.getCode();
writer.append(serviceJavascript);
@@ -125,13 +157,14 @@
// is there a better way to avoid the warning?
beanDefinitions.addAll((List<String>)beanFilesParameter);
} else {
- String list[] = (String[])beanFilesParameter;
+ String list[] = (String[]) beanFilesParameter;
for (String b : list) {
beanDefinitions.add(b);
}
}
}
- ServiceBuilderFactory builderFactory =
ServiceBuilderFactory.getInstance(beanDefinitions);
+ applicationContext = getApplicationContext(getBus(), beanDefinitions);
+ ServiceBuilderFactory builderFactory = ServiceBuilderFactory.getInstance();
Class<?> clz = getServiceClass();
context.put(Class.class, clz);
if (clz.isInterface()) {
@@ -150,7 +183,7 @@
builderFactory.setDatabindingName(getDataBindingName());
// The service class determines the frontend, so no need to pass it in
// twice.
- ServiceBuilder builder = builderFactory.newBuilder();
+ ServiceBuilder builder = builderFactory.newBuilder(applicationContext);
builder.validate();
@@ -190,12 +223,13 @@
protected File getOutputDir(File wsdlLocation) {
String dir = (String)context.get(ToolConstants.CFG_OUTPUTDIR);
if (dir == null) {
- if (wsdlLocation == null || wsdlLocation.getParentFile() == null
+ if (wsdlLocation == null
+ || wsdlLocation.getParentFile() == null
|| !wsdlLocation.getParentFile().exists()) {
dir = "./";
} else {
dir = wsdlLocation.getParent();
- }
+ }
}
return new File(dir);
}
Modified:
thirdparty/cxf/branches/cxf-2.2.6/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessor.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.6/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessor.java 2010-08-05
15:23:53 UTC (rev 12745)
+++
thirdparty/cxf/branches/cxf-2.2.6/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessor.java 2010-08-05
17:29:16 UTC (rev 12746)
@@ -31,6 +31,7 @@
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.BusApplicationContext;
import org.apache.cxf.common.WSDLConstants;
import org.apache.cxf.common.i18n.Message;
import org.apache.cxf.common.logging.LogUtils;
@@ -48,14 +49,20 @@
import org.apache.cxf.tools.java2wsdl.generator.wsdl11.WrapperBeanGenerator;
import org.apache.cxf.tools.java2wsdl.processor.internal.ServiceBuilderFactory;
import org.apache.cxf.tools.util.AnnotationUtil;
+import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.FileSystemResource;
-
public class JavaToWSDLProcessor implements Processor {
private static final Logger LOG = LogUtils.getL7dLogger(JavaToWSDLProcessor.class);
private static final String DEFAULT_ADDRESS =
"http://localhost:9090/hello";
private static final String JAVA_CLASS_PATH = "java.class.path";
private ToolContext context;
private final List<AbstractGenerator> generators = new
ArrayList<AbstractGenerator>();
+ private ApplicationContext applicationContext;
private void customize(ServiceInfo service) {
if (context.containsKey(ToolConstants.CFG_TNS)) {
@@ -84,6 +91,26 @@
}
+ /**
+ * This is factored out to permit use in a unit test.
+ * @param bus
+ * @return
+ */
+ public static ApplicationContext getApplicationContext(Bus bus, List<String>
additionalFilePathnames) {
+ BusApplicationContext busApplicationContext =
bus.getExtension(BusApplicationContext.class);
+ GenericApplicationContext appContext = new
GenericApplicationContext(busApplicationContext);
+ XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(appContext);
+ reader.loadBeanDefinitions(new
ClassPathResource("META-INF/cxf/java2wsbeans.xml"));
+ for (String pathname : additionalFilePathnames) {
+ try {
+ reader.loadBeanDefinitions(new FileSystemResource(pathname));
+ } catch (BeanDefinitionStoreException bdse) {
+ throw new ToolException("Unable to open bean definition file "
+ pathname, bdse.getCause());
+ }
+ }
+
+ return appContext;
+ }
public void process() throws ToolException {
String oldClassPath = System.getProperty(JAVA_CLASS_PATH);
@@ -172,8 +199,8 @@
}
}
}
-
- ServiceBuilderFactory builderFactory =
ServiceBuilderFactory.getInstance(beanDefinitions);
+ applicationContext = getApplicationContext(getBus(), beanDefinitions);
+ ServiceBuilderFactory builderFactory = ServiceBuilderFactory.getInstance();
Class<?> clz = getServiceClass();
context.put(Class.class, clz);
if (clz.isInterface()) {
@@ -191,7 +218,7 @@
builderFactory.setServiceClass(clz);
builderFactory.setDatabindingName(getDataBindingName());
// The service class determines the frontend, so no need to pass it in twice.
- ServiceBuilder builder = builderFactory.newBuilder();
+ ServiceBuilder builder = builderFactory.newBuilder(applicationContext);
builder.validate();
Modified:
thirdparty/cxf/branches/cxf-2.2.6/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/DefaultServiceBuilderFactory.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.6/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/DefaultServiceBuilderFactory.java 2010-08-05
15:23:53 UTC (rev 12745)
+++
thirdparty/cxf/branches/cxf-2.2.6/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/DefaultServiceBuilderFactory.java 2010-08-05
17:29:16 UTC (rev 12746)
@@ -1,63 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.cxf.tools.java2wsdl.processor.internal;
-
-import org.apache.cxf.aegis.databinding.AegisDatabinding;
-import org.apache.cxf.databinding.DataBinding;
-import org.apache.cxf.frontend.AbstractServiceFactory;
-import org.apache.cxf.jaxb.JAXBDataBinding;
-import org.apache.cxf.jaxws.JaxwsServiceBuilder;
-import org.apache.cxf.service.ServiceBuilder;
-import org.apache.cxf.simple.SimpleServiceBuilder;
-import org.apache.cxf.tools.common.ToolConstants;
-import org.apache.cxf.tools.common.ToolException;
-import org.apache.cxf.tools.java2wsdl.processor.FrontendFactory;
-import org.apache.cxf.tools.java2wsdl.processor.FrontendFactory.Style;
-
-/**
- * This class constructs ServiceBuilder objects. These objects are used to access the
services and the data
- * bindings to generate the wsdl.
- */
-public final class DefaultServiceBuilderFactory extends ServiceBuilderFactory {
-
- @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: " + s);
- }
- 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;
- }
-}
Modified:
thirdparty/cxf/branches/cxf-2.2.6/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/ServiceBuilderFactory.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.6/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/ServiceBuilderFactory.java 2010-08-05
15:23:53 UTC (rev 12745)
+++
thirdparty/cxf/branches/cxf-2.2.6/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/ServiceBuilderFactory.java 2010-08-05
17:29:16 UTC (rev 12746)
@@ -19,54 +19,98 @@
package org.apache.cxf.tools.java2wsdl.processor.internal;
-import java.util.List;
-
+import org.apache.cxf.databinding.DataBinding;
+import org.apache.cxf.frontend.AbstractServiceFactory;
import org.apache.cxf.service.ServiceBuilder;
import org.apache.cxf.tools.common.ToolConstants;
+import org.apache.cxf.tools.common.ToolException;
import org.apache.cxf.tools.java2wsdl.processor.FrontendFactory;
+import org.apache.cxf.tools.util.NameUtil;
+import org.springframework.context.ApplicationContext;
/**
- * This class constructs ServiceBuilder objects. These objects are used to access the
services and the data
- * bindings to generate the wsdl.
+ * This class constructs ServiceBuilder objects. These objects are used to access the
services
+ * and the data bindings to generate the wsdl.
*/
-public abstract class ServiceBuilderFactory {
- protected FrontendFactory frontend;
- protected String databindingName;
- protected Class<?> serviceClass;
-
- protected ServiceBuilderFactory() {
+public final class ServiceBuilderFactory {
+ private static ServiceBuilderFactory instance;
+ private static FrontendFactory frontend;
+ private static String databindingName;
+ private Class serviceClass;
+
+ private ServiceBuilderFactory() {
frontend = FrontendFactory.getInstance();
databindingName = ToolConstants.DEFAULT_DATA_BINDING_NAME;
}
+
+ public static ServiceBuilderFactory getInstance() {
+ if (instance == null) {
+ instance = new ServiceBuilderFactory();
+ }
+ return instance;
+ }
- public static ServiceBuilderFactory getInstance(List<String> beanDefinitions)
{
- ServiceBuilderFactory factory;
- if (beanDefinitions == null || beanDefinitions.isEmpty()) {
- factory = new DefaultServiceBuilderFactory();
- } else {
- factory = new SpringServiceBuilderFactory(beanDefinitions);
+ public ServiceBuilder newBuilder(ApplicationContext applicationContext) {
+ return newBuilder(applicationContext, getStyle());
+ }
+
+ /**
+ * Convert a parameter value to the name of a bean we'd use for a data binding.
+ * @param databindingName
+ * @return
+ */
+ public static String databindingNameToBeanName(String dbName) {
+ return NameUtil.capitalize(dbName.toLowerCase()) +
ToolConstants.DATABIND_BEAN_NAME_SUFFIX;
+ }
+
+ public ServiceBuilder newBuilder(ApplicationContext applicationContext,
FrontendFactory.Style s) {
+ 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);
}
- return factory;
+
+ String beanName = getBuilderBeanName(s);
+ ServiceBuilder builder = null;
+
+ try {
+ builder = (ServiceBuilder) 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;
}
- public ServiceBuilder newBuilder() {
- return newBuilder(getStyle());
+ /**
+ * Return the name of a prototype bean from Spring that can provide the service. The
use of a bean
+ * allows for the possibility of an override.
+ * @param s Style of service
+ * @return name of bean.
+ */
+ protected String getBuilderBeanName(FrontendFactory.Style s) {
+ return s + "ServiceBuilderBean";
}
- public abstract ServiceBuilder newBuilder(FrontendFactory.Style s);
-
public FrontendFactory.Style getStyle() {
frontend.setServiceClass(this.serviceClass);
return frontend.discoverStyle();
}
- public void setServiceClass(Class<?> c) {
+ public void setServiceClass(Class c) {
this.serviceClass = c;
}
/**
* Return the databinding name.
- *
* @return
*/
public String getDatabindingName() {
@@ -75,7 +119,6 @@
/**
* Set the databinding name
- *
* @param databindingName
*/
public void setDatabindingName(String arg) {
Modified:
thirdparty/cxf/branches/cxf-2.2.6/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/SpringServiceBuilderFactory.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.6/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/SpringServiceBuilderFactory.java 2010-08-05
15:23:53 UTC (rev 12745)
+++
thirdparty/cxf/branches/cxf-2.2.6/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/SpringServiceBuilderFactory.java 2010-08-05
17:29:16 UTC (rev 12746)
@@ -1,136 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.cxf.tools.java2wsdl.processor.internal;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.cxf.BusFactory;
-import org.apache.cxf.bus.spring.BusApplicationContext;
-import org.apache.cxf.databinding.DataBinding;
-import org.apache.cxf.frontend.AbstractServiceFactory;
-import org.apache.cxf.service.ServiceBuilder;
-import org.apache.cxf.tools.common.ToolConstants;
-import org.apache.cxf.tools.common.ToolException;
-import org.apache.cxf.tools.java2wsdl.processor.FrontendFactory;
-import org.apache.cxf.tools.util.NameUtil;
-
-import org.springframework.beans.factory.BeanDefinitionStoreException;
-import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.GenericApplicationContext;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.core.io.FileSystemResource;
-
-/**
- * This class constructs ServiceBuilder objects using Spring. These objects are used to
access the services
- * and the data bindings to generate the wsdl.
- */
-public final class SpringServiceBuilderFactory extends ServiceBuilderFactory {
-
- private List<String> beanDefinitions;
-
- public SpringServiceBuilderFactory(List<String> beanDefinitions) {
- super();
- this.beanDefinitions = beanDefinitions;
- }
-
- public SpringServiceBuilderFactory() {
- super();
- this.beanDefinitions = new ArrayList<String>(0);
- }
-
- /**
- * Convert a parameter value to the name of a bean we'd use for a data binding.
- *
- * @param databindingName
- * @return
- */
- public static String databindingNameToBeanName(String dbName) {
- return NameUtil.capitalize(dbName.toLowerCase()) +
ToolConstants.DATABIND_BEAN_NAME_SUFFIX;
- }
-
- @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);
- }
-
- String beanName = getBuilderBeanName(s);
- ServiceBuilder builder = null;
-
- try {
- builder = (ServiceBuilder)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;
- }
-
- /**
- * Return the name of a prototype bean from Spring that can provide the service. The
use of a bean allows
- * for the possibility of an override.
- *
- * @param s Style of service
- * @return name of bean.
- */
- protected String getBuilderBeanName(FrontendFactory.Style s) {
- return s + "ServiceBuilderBean";
- }
-
- /**
- * This is factored out to permit use in a unit test.
- *
- * @param bus
- * @return
- */
- public static ApplicationContext getApplicationContext(List<String>
additionalFilePathnames) {
- BusApplicationContext busApplicationContext = BusFactory.getDefaultBus()
- .getExtension(BusApplicationContext.class);
- GenericApplicationContext appContext = new
GenericApplicationContext(busApplicationContext);
- XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(appContext);
- reader.loadBeanDefinitions(new
ClassPathResource("META-INF/cxf/java2wsbeans.xml"));
- for (String pathname : additionalFilePathnames) {
- try {
- reader.loadBeanDefinitions(new FileSystemResource(pathname));
- } catch (BeanDefinitionStoreException bdse) {
- throw new ToolException("Unable to open bean definition file "
+ pathname, bdse.getCause());
- }
- }
-
- return appContext;
- }
-
- public void setBeanDefinitions(List<String> beanDefinitions) {
- this.beanDefinitions = beanDefinitions;
- }
-
-}
Modified:
thirdparty/cxf/branches/cxf-2.2.6/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/ServiceBuilderFactoryTest.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.6/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/ServiceBuilderFactoryTest.java 2010-08-05
15:23:53 UTC (rev 12745)
+++
thirdparty/cxf/branches/cxf-2.2.6/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/ServiceBuilderFactoryTest.java 2010-08-05
17:29:16 UTC (rev 12746)
@@ -21,21 +21,43 @@
import java.util.ArrayList;
+import org.apache.cxf.BusFactory;
import org.apache.cxf.jaxws.JaxwsServiceBuilder;
import org.apache.cxf.service.ServiceBuilder;
import org.apache.cxf.simple.SimpleServiceBuilder;
import org.apache.cxf.tools.fortest.classnoanno.docbare.Stock;
import org.apache.cxf.tools.fortest.simple.Hello;
+import org.apache.cxf.tools.java2wsdl.processor.FrontendFactory;
+import org.apache.cxf.tools.java2wsdl.processor.JavaToWSDLProcessor;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
+import org.springframework.context.ApplicationContext;
public class ServiceBuilderFactoryTest extends Assert {
- ServiceBuilderFactory factory = ServiceBuilderFactory.getInstance(new
ArrayList<String>());
+ ServiceBuilderFactory factory = ServiceBuilderFactory.getInstance();
+ private ApplicationContext applicationContext;
+
+ @Before
+ public void setUp() {
+ applicationContext =
JavaToWSDLProcessor.getApplicationContext(BusFactory.getDefaultBus(),
+ new
ArrayList<String>());
+ }
+
+ @Test
+ public void testGetBuilderBeanName() {
+ assertNotNull(factory);
+ assertEquals("JaxwsServiceBuilderBean",
+ factory.getBuilderBeanName(FrontendFactory.Style.Jaxws));
+ assertEquals("SimpleServiceBuilderBean",
+ factory.getBuilderBeanName(FrontendFactory.Style.Simple));
+ }
+
@Test
public void testGetJaxwsBuilder() {
factory.setServiceClass(Stock.class);
- ServiceBuilder builder = factory.newBuilder();
+ ServiceBuilder builder = factory.newBuilder(applicationContext);
assertNotNull(builder);
assertTrue(builder instanceof JaxwsServiceBuilder);
}
@@ -43,7 +65,7 @@
@Test
public void testGetSimpleBuilder() {
factory.setServiceClass(Hello.class);
- ServiceBuilder builder = factory.newBuilder();
+ ServiceBuilder builder = factory.newBuilder(applicationContext);
assertNotNull(builder);
assertTrue(builder instanceof SimpleServiceBuilder);
}