cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r575222 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/tools/common/ tools/common/ tools/common/src/main/java/org/apache/cxf/tools/common/ tools/javato/ tools/javato/ws/ tools/javato/ws/src/main/java/org/apache/cxf/tools/java2w...
Date Thu, 13 Sep 2007 08:45:22 GMT
Author: ema
Date: Thu Sep 13 01:45:21 2007
New Revision: 575222

URL: http://svn.apache.org/viewvc?rev=575222&view=rev
Log:
[CXF-807]Applied Benson's patch. Thanks , Benson

Added:
    incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/aegis2ws/
    incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/aegis2ws/Something.aegis.xml
    incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/aegis2ws/Something.java
    incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/aegis2ws/TestAegisSEI.java
Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
    incubator/cxf/trunk/tools/common/pom.xml
    incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/AbstractCXFToolContainer.java
    incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolTestBase.java
    incubator/cxf/trunk/tools/javato/pom.xml
    incubator/cxf/trunk/tools/javato/ws/pom.xml
    incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java
    incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/Messages.properties
    incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/java2ws.xml
    incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessor.java
    incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/ServiceBuilderFactory.java
    incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
    incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/ServiceBuilderFactoryTest.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java?rev=575222&r1=575221&r2=575222&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java Thu
Sep 13 01:45:21 2007
@@ -28,6 +28,11 @@
     public static final String SCHEMA_URI = "http://www.w3.org/2001/XMLSchema";
     public static final String XML_NAMESPACE_URI = "http://www.w3.org/XML/1998/namespace";
     public static final String WSDL_NAMESPACE_URI = "http://schemas.xmlsoap.org/wsdl/";
+    
+    /**
+     * Tools permit caller to pass in additional bean definitions.
+     */
+    public static final String CFG_BEAN_CONFIG = "beans";
 
     public static final String DEFAULT_TEMP_DIR = "gen_tmp";
     public static final String CFG_OUTPUTDIR = "outputdir";
@@ -61,12 +66,13 @@
 
     public static final String CFG_VALIDATE_WSDL = "validate";
     public static final String CFG_CREATE_XSD_IMPORTS = "createxsdimports";
-
+    /**
+     * Front-end selection command-line option to java2ws.
+     */
     public static final String CFG_FRONTEND = "frontend";
 
     public static final String CFG_DATABINDING = "db";
 
-
     // WSDL2Java Constants
 
     public static final String CFG_TYPES = "types";
@@ -218,4 +224,6 @@
     public static final String IMPL_CLASS = "implClass";
     public static final String SERVICE_NAME = "serviceName";
     public static final String PORT_NAME = "portName";
+    public static final String DEFAULT_DATA_BINDING_NAME = "jaxb";
+    public static final String DATABIND_BEAN_NAME_SUFFIX = "DatabindingBean";
 }

Modified: incubator/cxf/trunk/tools/common/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/pom.xml?rev=575222&r1=575221&r2=575222&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/common/pom.xml (original)
+++ incubator/cxf/trunk/tools/common/pom.xml Thu Sep 13 01:45:21 2007
@@ -82,6 +82,12 @@
 	    <artifactId>cxf-common-utilities</artifactId>
 	    <version>${project.version}</version>
 	</dependency>
+	
+	<dependency>
+	    <groupId>org.apache.cxf</groupId>
+	    <artifactId>cxf-rt-core</artifactId>
+	    <version>${project.version}</version>
+	</dependency>	
 
     </dependencies>
 

Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/AbstractCXFToolContainer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/AbstractCXFToolContainer.java?rev=575222&r1=575221&r2=575222&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/AbstractCXFToolContainer.java
(original)
+++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/AbstractCXFToolContainer.java
Thu Sep 13 01:45:21 2007
@@ -39,6 +39,9 @@
 import org.apache.cxf.tools.common.toolspec.parser.ErrorVisitor;
 import org.apache.cxf.version.Version;
 
+/**
+ * Common processing for the CXF tools. Processes common options.
+ */
 public abstract class AbstractCXFToolContainer extends AbstractToolContainer {
     protected static final Logger LOG = LogUtils.getL7dLogger(AbstractCXFToolContainer.class);
     
@@ -47,6 +50,7 @@
     private boolean verbose;
     private String usage;
     private final ErrorVisitor errors = new ErrorVisitor();
+    private String beanConfigResource;
     
     
     public AbstractCXFToolContainer(String nm, ToolSpec toolspec) throws Exception {
@@ -70,7 +74,7 @@
         if (hasInfoOption()) {
             outputInfo();
         } else {
-            if (commandDocument.hasParameter("verbose")) {
+            if (commandDocument.hasParameter(ToolConstants.CFG_VERBOSE)) {
                 verbose = true;
                 outputFullCommandLine();
                 outputVersion();               
@@ -105,7 +109,20 @@
         }
     }
 
-    public abstract void checkParams(ErrorVisitor err) throws ToolException;
+    /**
+     * Check command-line parameters for validity. Since subclasses delegate down to here,
+     * this cannot complain about unwanted options.
+     * @param err place to report errors.
+     * @throws ToolException for impossible options.
+     */
+    public void checkParams(ErrorVisitor err) throws ToolException {
+        CommandDocument doc = getCommandDocument();
+
+        if (doc.hasParameter(ToolConstants.CFG_BEAN_CONFIG)) {
+            String beanPath = doc.getParameter(ToolConstants.CFG_BEAN_CONFIG);          

+            setBeanConfigResource(beanPath);
+        }
+    }
 
     public boolean isVerboseOn() {
         if (context != null && context.isVerbose()) {
@@ -272,5 +289,19 @@
             }
         }
         return map;
+    }
+
+    /**
+     * @return Returns the beanConfigResource.
+     */
+    public String getBeanConfigResource() {
+        return beanConfigResource;
+    }
+
+    /**
+     * @param beanConfigResource The beanConfigResource to set.
+     */
+    public void setBeanConfigResource(String beanConfigResource) {
+        this.beanConfigResource = beanConfigResource;
     }
 }

Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolTestBase.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolTestBase.java?rev=575222&r1=575221&r2=575222&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolTestBase.java
(original)
+++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolTestBase.java
Thu Sep 13 01:45:21 2007
@@ -24,11 +24,11 @@
 import java.io.PrintStream;
 
 import org.apache.cxf.helpers.FileUtils;
+import org.apache.cxf.test.AbstractCXFTest;
 import org.junit.After;
-import org.junit.Assert;
 import org.junit.Before;
 
-public abstract class ToolTestBase extends Assert {
+public abstract class ToolTestBase extends AbstractCXFTest {
 
     protected PrintStream oldStdErr; 
     protected PrintStream oldStdOut; 

Modified: incubator/cxf/trunk/tools/javato/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/pom.xml?rev=575222&r1=575221&r2=575222&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/javato/pom.xml (original)
+++ incubator/cxf/trunk/tools/javato/pom.xml Thu Sep 13 01:45:21 2007
@@ -34,6 +34,7 @@
     <modules>
         <module>core</module>
         <module>test</module>
+        <module>ws</module>
     </modules>
 
     <scm>

Modified: incubator/cxf/trunk/tools/javato/ws/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/pom.xml?rev=575222&r1=575221&r2=575222&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/pom.xml (original)
+++ incubator/cxf/trunk/tools/javato/ws/pom.xml Thu Sep 13 01:45:21 2007
@@ -123,6 +123,12 @@
             <artifactId>cxf-rt-core</artifactId>
             <version>${project.version}</version>
         </dependency>
+        
+         <dependency>
+	   <groupId>org.apache.cxf</groupId>
+           <artifactId>cxf-rt-databinding-aegis</artifactId>
+           <version>${project.version}</version>
+	</dependency>
 
         <dependency>
             <groupId>org.apache.cxf</groupId>

Modified: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java?rev=575222&r1=575221&r2=575222&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java
(original)
+++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java
Thu Sep 13 01:45:21 2007
@@ -78,7 +78,7 @@
                     processor = new SimpleFrontEndProcessor();
                     processor.setEnvironment(env);
                     processor.process();
-                }       
+                }
             }
         } catch (ToolException ex) {
             if (ex.getCause() instanceof BadUsageException) {
@@ -107,28 +107,27 @@
     }
 
     public void checkParams(ErrorVisitor errs) throws ToolException {
-
+        super.checkParams(errs);
         CommandDocument doc = super.getCommandDocument();
 
-        if (doc.hasParameter("frontend")) {
-            String ft = doc.getParameter("frontend");           
+        if (doc.hasParameter(ToolConstants.CFG_FRONTEND)) {
+            String ft = doc.getParameter(ToolConstants.CFG_FRONTEND);
             if (!"simple".equalsIgnoreCase(ft) && !"jaxws".equalsIgnoreCase(ft))
{
-                Message msg = new Message("INVALID_FORNTEND", LOG, new Object[]{ft});   
           
+                Message msg = new Message("INVALID_FRONTEND", LOG, new Object[] {ft});
                 errs.add(new ErrorVisitor.UserError(msg.toString()));
             }
         }
-        
-        
-        if (doc.hasParameter("wrapperbean")) {
-            String ft = doc.getParameter("frontend");
-            if (ft != null &&  !"jaxws".equalsIgnoreCase(ft)) {
-                Message msg = new Message("CANT_GEN_WRAPPERBEAN", LOG);               
+
+        if (doc.hasParameter(ToolConstants.CFG_WRAPPERBEAN)) {
+            String ft = doc.getParameter(ToolConstants.CFG_FRONTEND);
+            if (ft != null && !"jaxws".equalsIgnoreCase(ft)) {
+                Message msg = new Message("WRAPPERBEAN_WITHOUT_JAXWS", LOG);
                 errs.add(new ErrorVisitor.UserError(msg.toString()));
             }
         }
-  
+
         if (errs.getErrors().size() > 0) {
-            Message msg = new Message("PARAMETER_MISSING", LOG);           
+            Message msg = new Message("PARAMETER_MISSING", LOG);
             throw new ToolException(msg, new BadUsageException(getUsage(), errs));
         }
 

Modified: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/Messages.properties?rev=575222&r1=575221&r2=575222&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/Messages.properties
(original)
+++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/Messages.properties
Thu Sep 13 01:45:21 2007
@@ -23,6 +23,7 @@
 FILE_NOT_EXIST = File does not exist
 NOT_A_FILE = {0} is not a file
 PARAMETER_MISSING = Required parameter is missing or not valid
-INVALID_FORNTEND = \ "{0}" is not a valid frontend, java2ws only supports jaxws and simple
frontend.
-CANT_GEN_WRAPPERBEAN = Wrapperbean only needs to be generated for jaxws front end.
+INVALID_FRONTEND = "{0}" is not a valid frontend, java2ws only supports jaxws and the simple
frontend.
+WRAPPERBEAN_WITHOUT_JAXWS = -wrapperbean is only valid for the jaxws front end.
+INVALID_DATABINDING = Invalid value {0} for data binding type. 
 

Modified: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/java2ws.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/java2ws.xml?rev=575222&r1=575221&r2=575222&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/java2ws.xml
(original)
+++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/java2ws.xml
Thu Sep 13 01:45:21 2007
@@ -35,9 +35,19 @@
 	</annotation>
 	<usage>
 		<optionGroup id="options">
+		
+			<option id="databinding" maxOccurs="1">
+				<annotation>
+				    Specify the data binding (aegis or jaxb). Default jaxb.
+				</annotation>
+				<switch>databinding</switch>
+				<associatedArgument placement="afterSpace">
+				  <annotation>jaxb or aegis</annotation>
+				</associatedArgument>
+			</option>
 			<option id="frontend" maxOccurs="1">
 				<annotation>
-					specify which frontend should be use, support jaxws and simple frontend.
+					Specify which frontend should be use, support jaxws and simple frontend.
 				</annotation>
 				<switch>frontend</switch>
 				<associatedArgument placement="afterSpace">

Modified: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessor.java?rev=575222&r1=575221&r2=575222&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessor.java
(original)
+++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessor.java
Thu Sep 13 01:45:21 2007
@@ -24,12 +24,14 @@
 import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+
 import javax.xml.namespace.QName;
 import javax.xml.ws.BindingType;
 import javax.xml.ws.soap.SOAPBinding;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.BusApplicationContext;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.StringUtils;
@@ -47,6 +49,10 @@
 import org.apache.cxf.tools.java2wsdl.processor.internal.ServiceBuilderFactory;
 import org.apache.cxf.tools.util.AnnotationUtil;
 import org.apache.cxf.wsdl.WSDLConstants;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.core.io.ClassPathResource;
 
 public class JavaToWSDLProcessor implements Processor {
     private static final Logger LOG = LogUtils.getL7dLogger(JavaToWSDLProcessor.class);
@@ -54,7 +60,8 @@
     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)) {
             String ns = (String)context.get(ToolConstants.CFG_TNS);
@@ -73,8 +80,22 @@
             service.setName(new QName(service.getName().getNamespaceURI(), svName));
         }
     }
-
+    
+    /**
+     * This is factored out to permit use in a unit test.
+     * @param bus
+     * @return
+     */
+    public static ApplicationContext getApplicationContext(Bus bus) {
+        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"));
+        return appContext;
+    }
+    
     public void process() throws ToolException {
+        applicationContext = getApplicationContext(getBus());
         String oldClassPath = System.getProperty(JAVA_CLASS_PATH);
         LOG.log(Level.INFO, "OLD_CP", oldClassPath);
         if (context.get(ToolConstants.CFG_CLASSPATH) != null) {
@@ -83,6 +104,9 @@
             LOG.log(Level.INFO, "NEW_CP", newCp);
         }
 
+        // check for command line specification of data binding.
+       
+
         ServiceBuilder builder = getServiceBuilder();
         ServiceInfo service = builder.createService();
 
@@ -140,7 +164,7 @@
     }
 
     public ServiceBuilder getServiceBuilder() throws ToolException {
-
+        applicationContext = getApplicationContext(getBus());
         ServiceBuilderFactory builderFactory = ServiceBuilderFactory.getInstance();
         Class<?> clz = getServiceClass();
         context.put(Class.class, clz);
@@ -155,9 +179,9 @@
             context.put(ToolConstants.GEN_FROM_SEI, Boolean.FALSE); 
         }
         builderFactory.setServiceClass(clz);
-        // TODO check if user specify the style from cli arguments
-        //      builderFactory.setStyle(style/from/command/line);
-        ServiceBuilder builder = builderFactory.newBuilder();
+        builderFactory.setDatabindingName(getDataBindingName());
+        // The service class determines the frontend, so no need to pass it in twice.
+        ServiceBuilder builder = builderFactory.newBuilder(applicationContext);
 
         builder.validate();
 
@@ -284,5 +308,12 @@
     public ToolContext getEnvironment() {
         return this.context;
     }
-
+    
+    public String getDataBindingName() {
+        String databindingName = (String)context.get(ToolConstants.CFG_DATABINDING);
+        if (databindingName == null) {
+            databindingName = ToolConstants.DEFAULT_DATA_BINDING_NAME;
+        }
+        return databindingName;
+    }
 }

Modified: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/ServiceBuilderFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/ServiceBuilderFactory.java?rev=575222&r1=575221&r2=575222&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/ServiceBuilderFactory.java
(original)
+++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/ServiceBuilderFactory.java
Thu Sep 13 01:45:21 2007
@@ -19,17 +19,28 @@
 
 package org.apache.cxf.tools.java2wsdl.processor.internal;
 
+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.
+ */
 public final class ServiceBuilderFactory {
     private static ServiceBuilderFactory instance;
+    private static FrontendFactory frontend;
+    private static String databindingName;
     private Class serviceClass;
-    private FrontendFactory frontend;
     
     private ServiceBuilderFactory() {
         frontend = FrontendFactory.getInstance();
+        databindingName = ToolConstants.DEFAULT_DATA_BINDING_NAME;
     }
     
     public static ServiceBuilderFactory getInstance() {
@@ -39,17 +50,39 @@
         return instance;
     }
 
-    public ServiceBuilder newBuilder() {
-        return newBuilder(getStyle());
+    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);
+        }
 
-    public ServiceBuilder newBuilder(FrontendFactory.Style s) {
+        String beanName = getBuilderBeanName(s);
         ServiceBuilder builder = null;
+
         try {
-            String clzName = getBuilderClassName(s);
-            builder = (ServiceBuilder) Class.forName(clzName).newInstance();
-        } catch (Exception e) {
-            throw new ToolException("Can not find or initialize the ServiceBuilder for style:
" + s
+            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);
         }
@@ -57,9 +90,14 @@
         return builder;
     }
 
-    protected String getBuilderClassName(FrontendFactory.Style s) {
-        String pkgName = "org.apache.cxf";
-        return pkgName + "." + s.toString().toLowerCase() + "." + s + "ServiceBuilder";
+    /**
+     * 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 FrontendFactory.Style getStyle() {
@@ -69,5 +107,21 @@
 
     public void setServiceClass(Class c) {
         this.serviceClass = c;
+    }
+
+    /**
+     * Return the databinding name.
+     * @return
+     */
+    public String getDatabindingName() {
+        return databindingName;
+    }
+
+    /**
+     * Set the databinding name
+     * @param databindingName
+     */
+    public void setDatabindingName(String arg) {
+        databindingName = arg;
     }
 }

Added: incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/aegis2ws/Something.aegis.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/aegis2ws/Something.aegis.xml?rev=575222&view=auto
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/aegis2ws/Something.aegis.xml
(added)
+++ incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/aegis2ws/Something.aegis.xml
Thu Sep 13 01:45:21 2007
@@ -0,0 +1,5 @@
+<mappings xmlns:smt="urn:something">
+	<mapping name="smt:Something">
+    	<property name='singular' mappedName='smt:singular' minOccurs='1' nillable='true'
/>
+	</mapping>
+</mappings>

Added: incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/aegis2ws/Something.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/aegis2ws/Something.java?rev=575222&view=auto
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/aegis2ws/Something.java
(added)
+++ incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/aegis2ws/Something.java
Thu Sep 13 01:45:21 2007
@@ -0,0 +1,52 @@
+/**
+ * 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.fortest.aegis2ws;
+
+/**
+ * Test data type for Aegis in java2ws
+ */
+public class Something {
+    private String multiple;
+    private String singular;
+    
+    /**
+     *  @return Returns the multiple.
+     */
+    public String getMultiple() {
+        return multiple;
+    }
+    /**
+     * @param multiple The multiple to set.
+     */
+    public void setMultiple(String multiple) {
+        this.multiple = multiple;
+    }
+    /**
+     * @return Returns the singular.
+     */
+    public String getSingular() {
+        return singular;
+    }
+    /**
+     * @param singular The singular to set.
+     */
+    public void setSingular(String singular) {
+        this.singular = singular;
+    }
+}

Added: incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/aegis2ws/TestAegisSEI.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/aegis2ws/TestAegisSEI.java?rev=575222&view=auto
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/aegis2ws/TestAegisSEI.java
(added)
+++ incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/aegis2ws/TestAegisSEI.java
Thu Sep 13 01:45:21 2007
@@ -0,0 +1,27 @@
+/**
+ * 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.fortest.aegis2ws;
+
+import javax.jws.WebService;
+
+@WebService
+public interface TestAegisSEI {
+    void takeSomething(Something what);
+}

Modified: incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java?rev=575222&r1=575221&r2=575222&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
(original)
+++ incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
Thu Sep 13 01:45:21 2007
@@ -23,6 +23,12 @@
 import java.net.URL;
 import java.net.URLClassLoader;
 
+import javax.wsdl.Definition;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+
+import org.w3c.dom.Document;
+
 import org.apache.cxf.helpers.FileUtils;
 import org.apache.cxf.tools.common.ToolContext;
 import org.apache.cxf.tools.common.ToolTestBase;
@@ -77,8 +83,28 @@
                                       "org.apache.hello_world_doc_lit.Greeter"};
         JavaToWS.main(args);
         File wsdlFile = new File(output.getPath() + "/tmp.wsdl");
+        // TODO: validate the file.
         assertTrue("wsdl is not generated", wsdlFile.exists());
     }
+    
+    @Test
+    public void testAegis() throws Exception {
+        final String sei = "org.apache.cxf.tools.fortest.aegis2ws.TestAegisSEI";
+        String[] args = new String[] {"-wsdl", "-o", output.getPath() + "/aegis.wsdl", "-verbose",
"-d",
+                                      output.getPath(), "-frontend", "jaxws", "-databinding",
"aegis",
+                                      "-client", "-server", sei};
+        JavaToWS.main(args);
+        File wsdlFile = new File(output.getPath() + "/aegis.wsdl");
+        assertTrue("wsdl is not generated", wsdlFile.exists());
+
+        WSDLReader reader =  WSDLFactory.newInstance().newWSDLReader();
+        reader.setFeature("javax.wsdl.verbose", false);
+        Definition def = reader.readWSDL(wsdlFile.toURL().toString());
+        Document wsdl = WSDLFactory.newInstance().newWSDLWriter().getDocument(def);
+        addNamespace("ns0", "http://aegis2ws.fortest.tools.cxf.apache.org/");
+        assertValid("//xsd:element[@type='something']", wsdl);
+        assertXPathEquals("//namespace::ns0", "http://aegis2ws.fortest.tools.cxf.apache.org/",
wsdl);
+    }
 
 
     @Test
@@ -171,7 +197,7 @@
                                       "org.apache.hello_world_soap12_http.Greeter"};
         JavaToWS.main(args);
         assertTrue("wrapperbean flag error should be detected",
-                   getStdErr().indexOf("Wrapperbean only needs to be generated for jaxws
front end") > -1);
+                   getStdErr().indexOf("-wrapperbean is only valid for the jaxws front end.")
> -1);
         File wsdlFile = new File(output.getPath() + "/tmp.wsdl");
         assertTrue("wsdl is not generated", wsdlFile.exists());
     }

Modified: incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/ServiceBuilderFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/ServiceBuilderFactoryTest.java?rev=575222&r1=575221&r2=575222&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/ServiceBuilderFactoryTest.java
(original)
+++ incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/ServiceBuilderFactoryTest.java
Thu Sep 13 01:45:21 2007
@@ -19,32 +19,42 @@
 
 package org.apache.cxf.tools.java2wsdl.processor.internal;
 
+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();
-
+    private ApplicationContext applicationContext;
+    
+    @Before
+    public void setUp() {
+        applicationContext = JavaToWSDLProcessor.getApplicationContext(BusFactory.getDefaultBus());
+    }
+    
     @Test
-    public void testGetBuilderClassName() {
+    public void testGetBuilderBeanName() {
         assertNotNull(factory);
-        assertEquals(JaxwsServiceBuilder.class.getName(),
-                     factory.getBuilderClassName(FrontendFactory.Style.Jaxws));
+        assertEquals("JaxwsServiceBuilderBean",
+                     factory.getBuilderBeanName(FrontendFactory.Style.Jaxws));
 
-        assertEquals(SimpleServiceBuilder.class.getName(),
-                     factory.getBuilderClassName(FrontendFactory.Style.Simple));
+        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);
     }
@@ -52,7 +62,7 @@
     @Test
     public void testGetSimpleBuilder() {
         factory.setServiceClass(Hello.class);
-        ServiceBuilder builder = factory.newBuilder();
+        ServiceBuilder builder = factory.newBuilder(applicationContext);
         assertNotNull(builder);
         assertTrue(builder instanceof SimpleServiceBuilder);
     }



Mime
View raw message