You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by mm...@apache.org on 2007/06/27 11:57:54 UTC

svn commit: r551110 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/service/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ tools/javato/core/src/main/java/org/apache/cxf/tool...

Author: mmao
Date: Wed Jun 27 02:57:53 2007
New Revision: 551110

URL: http://svn.apache.org/viewvc?view=rev&rev=551110
Log:
Java2Wsdl validate the service class before generating the artifacts
* In jaxws case, it will fail if the srevice class extends/implement from the java.rmi.Remote


Added:
    incubator/cxf/trunk/tools/javato/test/src/test/java/org/apache/cxf/tools/java2wsdl/processor/Hello.java
Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/ServiceBuilder.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxwsServiceBuilder.java
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractServiceFactory.java
    incubator/cxf/trunk/tools/javato/core/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessor.java
    incubator/cxf/trunk/tools/javato/core/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/ServiceBuilderFactory.java
    incubator/cxf/trunk/tools/javato/test/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/ServiceBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/ServiceBuilder.java?view=diff&rev=551110&r1=551109&r2=551110
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/ServiceBuilder.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/ServiceBuilder.java Wed Jun 27 02:57:53 2007
@@ -34,4 +34,6 @@
     void setServiceClass(Class clz);
 
     File getOutputFile();
+
+    void validate();
 }

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxwsServiceBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxwsServiceBuilder.java?view=diff&rev=551110&r1=551109&r2=551110
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxwsServiceBuilder.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxwsServiceBuilder.java Wed Jun 27 02:57:53 2007
@@ -41,6 +41,14 @@
         setBindingConfig(new JaxWsSoapBindingConfiguration(serviceFactory));
     }
 
+    @Override
+    public void validate() {
+        Class clz = getServiceClass();
+        if (java.rmi.Remote.class.isAssignableFrom(clz)) {
+            throw new RuntimeException("JAXWS SEI can not implement java.rmi.Remote interface.");
+        }
+    }
+    
     public File getOutputFile() {
         JaxWsImplementorInfo jaxwsImpl = serviceFactory.getJaxWsImplementorInfo();
         String wsdlLocation = jaxwsImpl.getWsdlLocation();

Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractServiceFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractServiceFactory.java?view=diff&rev=551110&r1=551109&r2=551110
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractServiceFactory.java (original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractServiceFactory.java Wed Jun 27 02:57:53 2007
@@ -40,4 +40,8 @@
         super.setServiceClass(clz);
         getServiceFactory().setServiceClass(clz);
     }
+
+    public void validate() {
+        // nothing to validate here
+    }
 }

Modified: incubator/cxf/trunk/tools/javato/core/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/core/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessor.java?view=diff&rev=551110&r1=551109&r2=551110
==============================================================================
--- incubator/cxf/trunk/tools/javato/core/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessor.java (original)
+++ incubator/cxf/trunk/tools/javato/core/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessor.java Wed Jun 27 02:57:53 2007
@@ -73,8 +73,8 @@
             service.setName(new QName(service.getName().getNamespaceURI(), svName));
         }
     }
-    
-    public void process() throws ToolException {
+
+    public void process() throws ToolException {        
         String oldClassPath = System.getProperty(JAVA_CLASS_PATH);
         LOG.log(Level.INFO, "OLD_CP", oldClassPath);
         if (context.get(ToolConstants.CFG_CLASSPATH) != null) {
@@ -141,6 +141,9 @@
         // TODO check if user specify the style from cli arguments
         //      builderFactory.setStyle(style/from/command/line);
         ServiceBuilder builder = builderFactory.newBuilder();
+
+        builder.validate();
+        
         if (context.get(ToolConstants.CFG_ADDRESS) != null) {
             String address = (String)context.get(ToolConstants.CFG_ADDRESS);
             builder.setAddress(address);

Modified: incubator/cxf/trunk/tools/javato/core/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/ServiceBuilderFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/core/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/ServiceBuilderFactory.java?view=diff&rev=551110&r1=551109&r2=551110
==============================================================================
--- incubator/cxf/trunk/tools/javato/core/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/ServiceBuilderFactory.java (original)
+++ incubator/cxf/trunk/tools/javato/core/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/ServiceBuilderFactory.java Wed Jun 27 02:57:53 2007
@@ -49,7 +49,9 @@
             String clzName = getBuilderClassName(s);
             builder = (ServiceBuilder) Class.forName(clzName).newInstance();
         } catch (Exception e) {
-            throw new ToolException("Can not find the ServiceBulider for style: " + s, e);
+            throw new ToolException("Can not find or initialize the ServiceBulider for style: " + s
+                                    + " Reason: \n" + e.getMessage(),
+                                    e);
         }
         builder.setServiceClass(serviceClass);
         return builder;

Added: incubator/cxf/trunk/tools/javato/test/src/test/java/org/apache/cxf/tools/java2wsdl/processor/Hello.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/test/src/test/java/org/apache/cxf/tools/java2wsdl/processor/Hello.java?view=auto&rev=551110
==============================================================================
--- incubator/cxf/trunk/tools/javato/test/src/test/java/org/apache/cxf/tools/java2wsdl/processor/Hello.java (added)
+++ incubator/cxf/trunk/tools/javato/test/src/test/java/org/apache/cxf/tools/java2wsdl/processor/Hello.java Wed Jun 27 02:57:53 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.java2wsdl.processor;
+
+import javax.jws.WebService; 
+
+@WebService
+public interface Hello extends java.rmi.Remote {
+    String hello();
+}
\ No newline at end of file

Modified: incubator/cxf/trunk/tools/javato/test/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/test/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java?view=diff&rev=551110&r1=551109&r2=551110
==============================================================================
--- incubator/cxf/trunk/tools/javato/test/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java (original)
+++ incubator/cxf/trunk/tools/javato/test/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java Wed Jun 27 02:57:53 2007
@@ -351,8 +351,14 @@
         assertEquals(oldCP, newCP);
     }
     
-    
-    
-    
-    
+    @Test
+    public void testWrongInterface() throws Exception {
+        env.put(ToolConstants.CFG_CLASSNAME, "org.apache.cxf.tools.java2wsdl.processor.Hello");
+        processor.setEnvironment(env);
+        try {
+            processor.process();
+        } catch (RuntimeException e) {
+            assertEquals("JAXWS SEI can not implement java.rmi.Remote interface.", e.getMessage());
+        }
+    }
 }



Re: svn commit: r551110 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/service/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ tools/javato/core/src/main/java/org/apache/cxf/tool...

Posted by Glen Mazza <gl...@verizon.net>.
Am Donnerstag, den 28.06.2007, 10:45 +0800 schrieb James Mao:
> Hi Glen,
> 
> Excellent catch!
> 
> The reason tools ignore the service class implement the java.rmi.Remote 
> is that we don't support it in the runtime.

Of course, which makes sense.

> And the reason that we throw exceptions, is that in other project 
> (especially the Eclipse STP)  would like to catch such exception.

Oh, I see.

> I know in tools we should have a concept of warnings and errors, but 
> that will be another story.

OK.  As I learn more about the project, perhaps this is an area where I
can help.

Glen




Re: svn commit: r551110 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/service/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ tools/javato/core/src/main/java/org/apache/cxf/tool...

Posted by James Mao <ja...@iona.com>.
Hi Glen,

Excellent catch!

The reason tools ignore the service class implement the java.rmi.Remote 
is that we don't support it in the runtime.
And the reason that we throw exceptions, is that in other project 
(especially the Eclipse STP)  would like to catch such exception.
I know in tools we should have a concept of warnings and errors, but 
that will be another story.

James

> Am Mittwoch, den 27.06.2007, 09:57 +0000 schrieb mmao@apache.org:
>   
>> Author: mmao
>> Date: Wed Jun 27 02:57:53 2007
>> New Revision: 551110
>>
>> URL: http://svn.apache.org/viewvc?view=rev&rev=551110
>> Log:
>> Java2Wsdl validate the service class before generating the artifacts
>> * In jaxws case, it will fail if the srevice class extends/implement from the java.rmi.Remote
>>
>>
>>     
>
> I wonder if a warning "this interface is ignored by JAXWS" instead of an
> exception would be preferable.  While I understand the java.rmi.Remote
> interface is not used by JAXWS, I'm unsure why forbidding it is
> necessary (or even encouraged by the spec), it's just a marker interface
> that is ignored in JAXWS.  That service class might also be implementing
> 15 other things that CXF will ignore--why worry about java.rmi.Remote in
> particular?
>
>
>   
>> -            throw new ToolException("Can not find the ServiceBulider
>> for style: " + s, e);
>> +            throw new ToolException("Can not find or initialize the ServiceBulider for style: " + s
>> +                                    + " Reason: \n" + e.getMessage(),
>> +                                    e);
>>     
>
> "ServiceBuilder"
>
> Glen
>
>
>   

Re: svn commit: r551110 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/service/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ tools/javato/core/src/main/java/org/apache/cxf/tool...

Posted by Glen Mazza <gl...@verizon.net>.
Am Mittwoch, den 27.06.2007, 09:57 +0000 schrieb mmao@apache.org:
> Author: mmao
> Date: Wed Jun 27 02:57:53 2007
> New Revision: 551110
> 
> URL: http://svn.apache.org/viewvc?view=rev&rev=551110
> Log:
> Java2Wsdl validate the service class before generating the artifacts
> * In jaxws case, it will fail if the srevice class extends/implement from the java.rmi.Remote
> 
> 

I wonder if a warning "this interface is ignored by JAXWS" instead of an
exception would be preferable.  While I understand the java.rmi.Remote
interface is not used by JAXWS, I'm unsure why forbidding it is
necessary (or even encouraged by the spec), it's just a marker interface
that is ignored in JAXWS.  That service class might also be implementing
15 other things that CXF will ignore--why worry about java.rmi.Remote in
particular?


> -            throw new ToolException("Can not find the ServiceBulider
> for style: " + s, e);
> +            throw new ToolException("Can not find or initialize the ServiceBulider for style: " + s
> +                                    + " Reason: \n" + e.getMessage(),
> +                                    e);

"ServiceBuilder"

Glen