Author: richard.opalka(a)jboss.com
Date: 2008-02-15 08:23:05 -0500 (Fri, 15 Feb 2008)
New Revision: 5703
Added:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/client/MetroServiceObjectFactory.java
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/client/MetroServiceReferenceable.java
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/MetroConsumerFactoryImpl.java
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/MetroConsumerImpl.java
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/MetroProviderFactoryImpl.java
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/MetroProviderImpl.java
Removed:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/client/SunRIServiceObjectFactory.java
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/client/SunRIServiceReferenceable.java
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/SunRIConsumerFactoryImpl.java
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/SunRIConsumerImpl.java
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/SunRIProviderFactoryImpl.java
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/SunRIProviderImpl.java
Modified:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/client/MetroServiceRefBinderJAXWS.java
stack/metro/trunk/src/main/resources/jbossws-metro-client.jar/META-INF/services/org.jboss.wsf.spi.tools.ConsumerFactoryImpl
stack/metro/trunk/src/main/resources/jbossws-metro-client.jar/META-INF/services/org.jboss.wsf.spi.tools.ProviderFactoryImpl
Log:
[JBWS-1994] finalized refactoring
Added:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/client/MetroServiceObjectFactory.java
===================================================================
---
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/client/MetroServiceObjectFactory.java
(rev 0)
+++
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/client/MetroServiceObjectFactory.java 2008-02-15
13:23:05 UTC (rev 5703)
@@ -0,0 +1,213 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.metro.client;
+
+import org.jboss.wsf.spi.WSFException;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
+
+import javax.naming.*;
+import javax.naming.spi.ObjectFactory;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.Hashtable;
+import org.jboss.logging.Logger;
+
+/**
+ * This ServiceObjectFactory reconstructs a javax.xml.ws.Service
+ * for a given WSDL when the webservice client does a JNDI lookup
+ *
+ * @see MetroServiceReferenceable
+ *
+ * @author Heiko.Braun(a)jboss.com
+ * Created: Jul 12, 2007
+ * */
+public class MetroServiceObjectFactory implements ObjectFactory
+{
+ protected final Logger log = Logger.getLogger(MetroServiceObjectFactory.class);
+
+ /**
+ * Creates an object using the location or reference information specified.
+ * <p/>
+ *
+ * @param obj The possibly null object containing location or reference
+ * information that can be used in creating an object.
+ * @param name The name of this object relative to
<code>nameCtx</code>,
+ * or null if no name is specified.
+ * @param nameCtx The context relative to which the <code>name</code>
+ * parameter is specified, or null if <code>name</code>
is
+ * relative to the default initial context.
+ * @param environment The possibly null environment that is used in
+ * creating the object.
+ * @return The object created; null if an object cannot be created.
+ * @throws Exception if this object factory encountered an exception
+ * while attempting to create an object, and no other object
factories are
+ * to be tried.
+ * @see javax.naming.spi.NamingManager#getObjectInstance
+ * @see javax.naming.spi.NamingManager#getURLContext
+ */
+ public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable
environment) throws Exception
+ {
+ try
+ {
+ Reference ref = (Reference)obj;
+
+ // Get the target class name
+ String targetClassName =
(String)ref.get(MetroServiceReferenceable.TARGET_CLASS_NAME).getContent();
+
+ // Unmarshall the UnifiedServiceRef
+ UnifiedServiceRefMetaData serviceRef = unmarshallServiceRef(ref);
+ String serviceRefName = serviceRef.getServiceRefName();
+ QName serviceQName = serviceRef.getServiceQName();
+
+ String serviceImplClass = serviceRef.getServiceImplClass();
+ if (serviceImplClass == null)
+ serviceImplClass =
(String)ref.get(MetroServiceReferenceable.SERVICE_IMPL_CLASS).getContent();
+
+ // If the target defaults to javax.xml.ws.Service, use the service as the
target
+ if (Service.class.getName().equals(targetClassName))
+ targetClassName = serviceImplClass;
+
+ log.debug("getObjectInstance [name=" + serviceRefName +
",service=" + serviceImplClass + ",target=" + targetClassName +
"]");
+
+ // Load the service class
+ ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+ Class serviceClass = ctxLoader.loadClass(serviceImplClass);
+ Class targetClass = (targetClassName != null ?
ctxLoader.loadClass(targetClassName) : null);
+
+ if (Service.class.isAssignableFrom(serviceClass) == false)
+ throw new IllegalArgumentException("WebServiceRef type '" +
serviceClass + "' is not assignable to javax.xml.ws.Service");
+
+ // Receives either a javax.xml.ws.Service or a dynamic proxy
+ Object target;
+
+ // Get the URL to the wsdl
+ URL wsdlURL = serviceRef.getWsdlLocation();
+
+ // Generic javax.xml.ws.Service
+ if (serviceClass == Service.class)
+ {
+ if (wsdlURL != null)
+ {
+ target = Service.create(wsdlURL, serviceQName);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Cannot create generic
javax.xml.ws.Service without wsdlLocation: " + serviceRefName);
+ }
+ }
+ // Generated javax.xml.ws.Service subclass
+ else
+ {
+ if (wsdlURL != null)
+ {
+ Constructor ctor = serviceClass.getConstructor(new Class[] { URL.class,
QName.class });
+ target = ctor.newInstance(new Object[] { wsdlURL, serviceQName });
+ }
+ else
+ {
+ target = (Service)serviceClass.newInstance();
+ }
+ }
+
+ // Configure the service
+ configureService((Service)target, serviceRef);
+
+ if (targetClassName != null && targetClassName.equals(serviceImplClass)
== false)
+ {
+ try
+ {
+ Object port = null;
+ if (serviceClass != Service.class)
+ {
+ for (Method method : serviceClass.getDeclaredMethods())
+ {
+ String methodName = method.getName();
+ Class retType = method.getReturnType();
+ if (methodName.startsWith("get") &&
targetClass.isAssignableFrom(retType))
+ {
+ port = method.invoke(target, new Object[0]);
+ target = port;
+ break;
+ }
+ }
+ }
+
+ if (port == null)
+ {
+ Method method = serviceClass.getMethod("getPort", new Class[]
{ Class.class });
+ port = method.invoke(target, new Object[] { targetClass });
+ target = port;
+ }
+ }
+ catch (InvocationTargetException ex)
+ {
+ throw ex.getTargetException();
+ }
+ }
+
+ return target;
+ }
+ catch (Throwable ex)
+ {
+ WSFException.rethrow("Cannot create service", ex);
+ return null;
+ }
+ }
+
+
+ private void configureService(Service service, UnifiedServiceRefMetaData serviceRef)
+ {
+ log.warn("Service configuration not available in Sun-RI");
+ }
+
+ private UnifiedServiceRefMetaData unmarshallServiceRef(Reference ref) throws
ClassNotFoundException, NamingException
+ {
+ UnifiedServiceRefMetaData sref;
+ RefAddr refAddr = ref.get(MetroServiceReferenceable.SERVICE_REF_META_DATA);
+ ByteArrayInputStream bais = new
ByteArrayInputStream((byte[])refAddr.getContent());
+ try
+ {
+ ObjectInputStream ois = new ObjectInputStream(bais);
+ sref = (UnifiedServiceRefMetaData)ois.readObject();
+ ois.close();
+ }
+ catch (IOException e)
+ {
+ throw new NamingException("Cannot unmarshall service ref meta data, cause:
" + e.toString());
+ }
+
+ // Verify it. There is some know coinstraints
+ if(null == sref.getServiceQName())
+ throw new IllegalArgumentException("ServiceQName may not be null. " +
+ "Specify a service QName in the <service-ref> declaration, or
thorugh the @WebServiceClient annotation.");
+
+ return sref;
+ }
+}
+
Property changes on:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/client/MetroServiceObjectFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/client/MetroServiceRefBinderJAXWS.java
===================================================================
---
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/client/MetroServiceRefBinderJAXWS.java 2008-02-15
12:50:14 UTC (rev 5702)
+++
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/client/MetroServiceRefBinderJAXWS.java 2008-02-15
13:23:05 UTC (rev 5703)
@@ -216,6 +216,6 @@
*/
protected Referenceable buildServiceReferenceable(String serviceImplClass, String
targetClassName, UnifiedServiceRefMetaData serviceRef)
{
- return new SunRIServiceReferenceable(serviceImplClass, targetClassName,
serviceRef);
+ return new MetroServiceReferenceable(serviceImplClass, targetClassName,
serviceRef);
}
}
Added:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/client/MetroServiceReferenceable.java
===================================================================
---
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/client/MetroServiceReferenceable.java
(rev 0)
+++
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/client/MetroServiceReferenceable.java 2008-02-15
13:23:05 UTC (rev 5703)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.metro.client;
+
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
+
+import javax.naming.*;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.io.IOException;
+
+/**
+ * A JNDI reference to a javax.xml.ws.Service
+ *
+ * It holds the information to reconstrut the javax.xml.ws.Service
+ * when the client does a JNDI lookup.
+ *
+ * @author Heiko.Braun(a)jboss.com
+ */
+public class MetroServiceReferenceable implements Referenceable
+{
+ public static final String SERVICE_REF_META_DATA = "SERVICE_REF_META_DATA";
+ public static final String SERVICE_IMPL_CLASS = "SERVICE_CLASS_NAME";
+ public static final String TARGET_CLASS_NAME = "TARGET_CLASS_NAME";
+
+ private String serviceImplClass;
+ private String targetClassName;
+ private UnifiedServiceRefMetaData serviceRef;
+
+ public MetroServiceReferenceable(String serviceImplClass, String targetClassName,
UnifiedServiceRefMetaData serviceRef)
+ {
+ this.serviceImplClass = serviceImplClass;
+ this.targetClassName = targetClassName;
+ this.serviceRef = serviceRef;
+ }
+
+ /**
+ * Retrieves the Reference of this object.
+ *
+ * @return The non-null Reference of this object.
+ * @throws javax.naming.NamingException If a naming exception was encountered while
retrieving the reference.
+ */
+ public Reference getReference() throws NamingException
+ {
+ Reference myRef = new Reference(MetroServiceReferenceable.class.getName(),
MetroServiceObjectFactory.class.getName(), null);
+
+ myRef.add(new StringRefAddr(SERVICE_IMPL_CLASS, serviceImplClass));
+ myRef.add(new StringRefAddr(TARGET_CLASS_NAME, targetClassName));
+ myRef.add(new BinaryRefAddr(SERVICE_REF_META_DATA, marshall(serviceRef)));
+
+ return myRef;
+ }
+
+ private byte[] marshall(Object obj) throws NamingException
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
+ try
+ {
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(obj);
+ oos.close();
+ }
+ catch (IOException e)
+ {
+ throw new NamingException("Cannot marshall object, cause: " +
e.toString());
+ }
+ return baos.toByteArray();
+ }
+}
Property changes on:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/client/MetroServiceReferenceable.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/client/SunRIServiceObjectFactory.java
===================================================================
---
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/client/SunRIServiceObjectFactory.java 2008-02-15
12:50:14 UTC (rev 5702)
+++
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/client/SunRIServiceObjectFactory.java 2008-02-15
13:23:05 UTC (rev 5703)
@@ -1,213 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.wsf.stack.metro.client;
-
-import org.jboss.wsf.spi.WSFException;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-
-import javax.naming.*;
-import javax.naming.spi.ObjectFactory;
-import javax.xml.namespace.QName;
-import javax.xml.ws.Service;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.util.Hashtable;
-import org.jboss.logging.Logger;
-
-/**
- * This ServiceObjectFactory reconstructs a javax.xml.ws.Service
- * for a given WSDL when the webservice client does a JNDI lookup
- *
- * @see SunRIServiceReferenceable
- *
- * @author Heiko.Braun(a)jboss.com
- * Created: Jul 12, 2007
- * */
-public class SunRIServiceObjectFactory implements ObjectFactory
-{
- protected final Logger log = Logger.getLogger(SunRIServiceObjectFactory.class);
-
- /**
- * Creates an object using the location or reference information specified.
- * <p/>
- *
- * @param obj The possibly null object containing location or reference
- * information that can be used in creating an object.
- * @param name The name of this object relative to
<code>nameCtx</code>,
- * or null if no name is specified.
- * @param nameCtx The context relative to which the <code>name</code>
- * parameter is specified, or null if <code>name</code>
is
- * relative to the default initial context.
- * @param environment The possibly null environment that is used in
- * creating the object.
- * @return The object created; null if an object cannot be created.
- * @throws Exception if this object factory encountered an exception
- * while attempting to create an object, and no other object
factories are
- * to be tried.
- * @see javax.naming.spi.NamingManager#getObjectInstance
- * @see javax.naming.spi.NamingManager#getURLContext
- */
- public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable
environment) throws Exception
- {
- try
- {
- Reference ref = (Reference)obj;
-
- // Get the target class name
- String targetClassName =
(String)ref.get(SunRIServiceReferenceable.TARGET_CLASS_NAME).getContent();
-
- // Unmarshall the UnifiedServiceRef
- UnifiedServiceRefMetaData serviceRef = unmarshallServiceRef(ref);
- String serviceRefName = serviceRef.getServiceRefName();
- QName serviceQName = serviceRef.getServiceQName();
-
- String serviceImplClass = serviceRef.getServiceImplClass();
- if (serviceImplClass == null)
- serviceImplClass =
(String)ref.get(SunRIServiceReferenceable.SERVICE_IMPL_CLASS).getContent();
-
- // If the target defaults to javax.xml.ws.Service, use the service as the
target
- if (Service.class.getName().equals(targetClassName))
- targetClassName = serviceImplClass;
-
- log.debug("getObjectInstance [name=" + serviceRefName +
",service=" + serviceImplClass + ",target=" + targetClassName +
"]");
-
- // Load the service class
- ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
- Class serviceClass = ctxLoader.loadClass(serviceImplClass);
- Class targetClass = (targetClassName != null ?
ctxLoader.loadClass(targetClassName) : null);
-
- if (Service.class.isAssignableFrom(serviceClass) == false)
- throw new IllegalArgumentException("WebServiceRef type '" +
serviceClass + "' is not assignable to javax.xml.ws.Service");
-
- // Receives either a javax.xml.ws.Service or a dynamic proxy
- Object target;
-
- // Get the URL to the wsdl
- URL wsdlURL = serviceRef.getWsdlLocation();
-
- // Generic javax.xml.ws.Service
- if (serviceClass == Service.class)
- {
- if (wsdlURL != null)
- {
- target = Service.create(wsdlURL, serviceQName);
- }
- else
- {
- throw new IllegalArgumentException("Cannot create generic
javax.xml.ws.Service without wsdlLocation: " + serviceRefName);
- }
- }
- // Generated javax.xml.ws.Service subclass
- else
- {
- if (wsdlURL != null)
- {
- Constructor ctor = serviceClass.getConstructor(new Class[] { URL.class,
QName.class });
- target = ctor.newInstance(new Object[] { wsdlURL, serviceQName });
- }
- else
- {
- target = (Service)serviceClass.newInstance();
- }
- }
-
- // Configure the service
- configureService((Service)target, serviceRef);
-
- if (targetClassName != null && targetClassName.equals(serviceImplClass)
== false)
- {
- try
- {
- Object port = null;
- if (serviceClass != Service.class)
- {
- for (Method method : serviceClass.getDeclaredMethods())
- {
- String methodName = method.getName();
- Class retType = method.getReturnType();
- if (methodName.startsWith("get") &&
targetClass.isAssignableFrom(retType))
- {
- port = method.invoke(target, new Object[0]);
- target = port;
- break;
- }
- }
- }
-
- if (port == null)
- {
- Method method = serviceClass.getMethod("getPort", new Class[]
{ Class.class });
- port = method.invoke(target, new Object[] { targetClass });
- target = port;
- }
- }
- catch (InvocationTargetException ex)
- {
- throw ex.getTargetException();
- }
- }
-
- return target;
- }
- catch (Throwable ex)
- {
- WSFException.rethrow("Cannot create service", ex);
- return null;
- }
- }
-
-
- private void configureService(Service service, UnifiedServiceRefMetaData serviceRef)
- {
- log.warn("Service configuration not available in Sun-RI");
- }
-
- private UnifiedServiceRefMetaData unmarshallServiceRef(Reference ref) throws
ClassNotFoundException, NamingException
- {
- UnifiedServiceRefMetaData sref;
- RefAddr refAddr = ref.get(SunRIServiceReferenceable.SERVICE_REF_META_DATA);
- ByteArrayInputStream bais = new
ByteArrayInputStream((byte[])refAddr.getContent());
- try
- {
- ObjectInputStream ois = new ObjectInputStream(bais);
- sref = (UnifiedServiceRefMetaData)ois.readObject();
- ois.close();
- }
- catch (IOException e)
- {
- throw new NamingException("Cannot unmarshall service ref meta data, cause:
" + e.toString());
- }
-
- // Verify it. There is some know coinstraints
- if(null == sref.getServiceQName())
- throw new IllegalArgumentException("ServiceQName may not be null. " +
- "Specify a service QName in the <service-ref> declaration, or
thorugh the @WebServiceClient annotation.");
-
- return sref;
- }
-}
-
Deleted:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/client/SunRIServiceReferenceable.java
===================================================================
---
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/client/SunRIServiceReferenceable.java 2008-02-15
12:50:14 UTC (rev 5702)
+++
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/client/SunRIServiceReferenceable.java 2008-02-15
13:23:05 UTC (rev 5703)
@@ -1,88 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.wsf.stack.metro.client;
-
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-
-import javax.naming.*;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectOutputStream;
-import java.io.IOException;
-
-/**
- * A JNDI reference to a javax.xml.ws.Service
- *
- * It holds the information to reconstrut the javax.xml.ws.Service
- * when the client does a JNDI lookup.
- *
- * @author Heiko.Braun(a)jboss.com
- */
-public class SunRIServiceReferenceable implements Referenceable
-{
- public static final String SERVICE_REF_META_DATA = "SERVICE_REF_META_DATA";
- public static final String SERVICE_IMPL_CLASS = "SERVICE_CLASS_NAME";
- public static final String TARGET_CLASS_NAME = "TARGET_CLASS_NAME";
-
- private String serviceImplClass;
- private String targetClassName;
- private UnifiedServiceRefMetaData serviceRef;
-
- public SunRIServiceReferenceable(String serviceImplClass, String targetClassName,
UnifiedServiceRefMetaData serviceRef)
- {
- this.serviceImplClass = serviceImplClass;
- this.targetClassName = targetClassName;
- this.serviceRef = serviceRef;
- }
-
- /**
- * Retrieves the Reference of this object.
- *
- * @return The non-null Reference of this object.
- * @throws javax.naming.NamingException If a naming exception was encountered while
retrieving the reference.
- */
- public Reference getReference() throws NamingException
- {
- Reference myRef = new Reference(SunRIServiceReferenceable.class.getName(),
SunRIServiceObjectFactory.class.getName(), null);
-
- myRef.add(new StringRefAddr(SERVICE_IMPL_CLASS, serviceImplClass));
- myRef.add(new StringRefAddr(TARGET_CLASS_NAME, targetClassName));
- myRef.add(new BinaryRefAddr(SERVICE_REF_META_DATA, marshall(serviceRef)));
-
- return myRef;
- }
-
- private byte[] marshall(Object obj) throws NamingException
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
- try
- {
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(obj);
- oos.close();
- }
- catch (IOException e)
- {
- throw new NamingException("Cannot marshall object, cause: " +
e.toString());
- }
- return baos.toByteArray();
- }
-}
Added:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/MetroConsumerFactoryImpl.java
===================================================================
---
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/MetroConsumerFactoryImpl.java
(rev 0)
+++
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/MetroConsumerFactoryImpl.java 2008-02-15
13:23:05 UTC (rev 5703)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.metro.tools;
+
+import org.jboss.wsf.spi.tools.WSContractConsumerFactory;
+import org.jboss.wsf.spi.tools.WSContractConsumer;
+
+/**
+ * Creates a WSContractConsumer that delegates to the Metro.
+ *
+ * @author <a href="jason.greene(a)jboss.com">Jason T. Greene</a>
+ * @version $Revision:2311 $
+ */
+public class MetroConsumerFactoryImpl implements WSContractConsumerFactory
+{
+ public WSContractConsumer createConsumer() {
+ return new MetroConsumerImpl();
+ }
+}
Property changes on:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/MetroConsumerFactoryImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/MetroConsumerImpl.java
===================================================================
---
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/MetroConsumerImpl.java
(rev 0)
+++
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/MetroConsumerImpl.java 2008-02-15
13:23:05 UTC (rev 5703)
@@ -0,0 +1,203 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.metro.tools;
+
+import org.jboss.wsf.spi.tools.WSContractConsumer;
+
+import java.io.File;
+import java.io.PrintStream;
+import java.util.List;
+import java.util.ArrayList;
+import java.net.URL;
+
+import com.sun.tools.ws.wscompile.WsimportTool;
+
+/**
+ * WSContractConsumer that delegates to the Sun CompileTool.
+ *
+ * @author <a href="jason.greene(a)jboss.com">Jason T. Greene</a>
+ * @author <a href="heiko.braun(a)jboss.com">Heiko Braun</a>
+ * @version $Revision$
+ */
+public class MetroConsumerImpl extends WSContractConsumer
+{
+ private List<File> bindingFiles = null;
+ private File catalog = null;
+ private boolean generateSource = false;
+ private File outputDir = new File("output");
+ private File sourceDir = null;
+ private String targetPackage = null;
+ private PrintStream messageStream = null;
+ private String wsdlLocation = null;
+ private List<String> additionalCompilerClassPath = new ArrayList<String>();
+ private String target = "2.0";
+
+ @Override
+ public void setBindingFiles(List<File> bindingFiles) {
+ this.bindingFiles = bindingFiles;
+ }
+
+ @Override
+ public void setCatalog(File catalog) {
+ this.catalog = catalog;
+ }
+
+ @Override
+ public void setGenerateSource(boolean generateSource) {
+ this.generateSource = generateSource;
+ }
+
+ @Override
+ public void setMessageStream(PrintStream messageStream) {
+ // TODO Auto-generated method stub
+ this.messageStream = messageStream;
+ }
+
+ @Override
+ public void setOutputDirectory(File directory) {
+ // TODO Auto-generated method stub
+ outputDir = directory;
+ }
+
+ @Override
+ public void setSourceDirectory(File directory) {
+ sourceDir = directory;
+ }
+
+ @Override
+ public void setTargetPackage(String targetPackage) {
+ this.targetPackage = targetPackage;
+ }
+
+ @Override
+ public void setWsdlLocation(String wsdlLocation) {
+ this.wsdlLocation = wsdlLocation;
+ }
+
+ public void setAdditionalCompilerClassPath(List<String>
additionalCompilerClassPath) {
+ this.additionalCompilerClassPath = additionalCompilerClassPath;
+ }
+
+ @Override
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ @Override
+ public void consume(URL wsdl) {
+ List<String> args = new ArrayList<String>();
+ if (bindingFiles != null) {
+ for (File file : bindingFiles) {
+ args.add("-b");
+ args.add(file.getAbsolutePath());
+
+ }
+ }
+
+ if (catalog != null) {
+ args.add("-catalog");
+ args.add(catalog.getAbsolutePath());
+ }
+
+ if (generateSource) {
+ args.add("-keep");
+ if (sourceDir != null) {
+ if (!sourceDir.exists() && !sourceDir.mkdirs())
+ throw new IllegalStateException("Could not make directory: " +
sourceDir.getName());
+
+ args.add("-s");
+ args.add(sourceDir.getAbsolutePath());
+ }
+ }
+
+ if (targetPackage != null) {
+ args.add("-p");
+ args.add(targetPackage);
+ }
+
+ if (wsdlLocation != null) {
+ args.add("-wsdllocation");
+ args.add(wsdlLocation);
+ }
+
+ PrintStream stream = messageStream;
+ if (stream != null) {
+ args.add("-verbose");
+ } else {
+ stream = new NullPrintStream();
+ }
+
+ if (!outputDir.exists() && !outputDir.mkdirs())
+ throw new IllegalStateException("Could not make directory: " +
outputDir.getName());
+
+ // Always add the output directory and the wsdl location
+ args.add("-d");
+ args.add(outputDir.getAbsolutePath());
+
+ // Always set the target
+ if(!target.equals("2.0"))
+ throw new IllegalArgumentException("WSConsume (metro) only supports JAX-WS
2.0");
+
+ args.add("-target");
+ args.add(target);
+
+ // finally the WSDL file
+ args.add(wsdl.toString());
+
+ // See WsimportTool#compileGeneratedClasses()
+ if(!additionalCompilerClassPath.isEmpty())
+ {
+ StringBuffer javaCP = new StringBuffer();
+ for(String s : additionalCompilerClassPath)
+ {
+ javaCP.append(s).append(File.pathSeparator);
+ }
+ System.setProperty("java.class.path", javaCP.toString());
+ }
+
+ try
+ {
+ // enforce woodstox
+ if(null == System.getProperty("javax.xml.stream.XMLInputFactory"))
+ System.setProperty("javax.xml.stream.XMLInputFactory",
"com.ctc.wstx.stax.WstxInputFactory");
+
+ WsimportTool compileTool = new WsimportTool(stream);
+ boolean success = compileTool.run(args.toArray(new String[0]));
+
+ if(!success) throw new IllegalStateException("WsImport invocation failed");
+ }
+ catch (Throwable t)
+ {
+ if (messageStream != null)
+ {
+ messageStream.println("Failed to invoke WsImport");
+ t.printStackTrace(messageStream);
+ }
+ else
+ {
+ t.printStackTrace();
+ }
+ }
+
+ }
+
+}
Property changes on:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/MetroConsumerImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/MetroProviderFactoryImpl.java
===================================================================
---
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/MetroProviderFactoryImpl.java
(rev 0)
+++
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/MetroProviderFactoryImpl.java 2008-02-15
13:23:05 UTC (rev 5703)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.metro.tools;
+
+import org.jboss.wsf.spi.tools.WSContractProviderFactory;
+import org.jboss.wsf.spi.tools.WSContractProvider;
+
+/**
+ * @author Heiko.Braun(a)jboss.com
+ * @version $Revision$
+ */
+public class MetroProviderFactoryImpl implements WSContractProviderFactory
+{
+ public WSContractProvider createProvider(ClassLoader loader)
+ {
+ WSContractProvider metroProvider = new MetroProviderImpl();
+ metroProvider.setClassLoader(loader);
+ return metroProvider;
+ }
+}
Property changes on:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/MetroProviderFactoryImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/MetroProviderImpl.java
===================================================================
---
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/MetroProviderImpl.java
(rev 0)
+++
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/MetroProviderImpl.java 2008-02-15
13:23:05 UTC (rev 5703)
@@ -0,0 +1,193 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.metro.tools;
+
+import org.jboss.wsf.spi.tools.WSContractProvider;
+
+import java.io.File;
+import java.io.PrintStream;
+import java.util.List;
+import java.util.ArrayList;
+import java.net.URLClassLoader;
+import java.net.URL;
+
+import com.sun.tools.ws.wscompile.WsgenTool;
+
+/**
+ * @author Heiko.Braun(a)jboss.com
+ * @version $Revision$
+ */
+public class MetroProviderImpl extends WSContractProvider
+{
+
+ private ClassLoader loader;
+ private boolean generateWsdl = false;
+ private boolean generateSource = false;
+ private File outputDir = new File("output");
+ private File resourceDir = null;
+ private File sourceDir = null;
+ private PrintStream messageStream = new NullPrintStream();
+
+ public MetroProviderImpl()
+ {
+ }
+
+ public void setGenerateWsdl(boolean generateWsdl)
+ {
+ this.generateWsdl = generateWsdl;
+ }
+
+ public void setGenerateSource(boolean generateSource)
+ {
+ this.generateSource = generateSource;
+ }
+
+ public void setOutputDirectory(File directory)
+ {
+ this.outputDir = directory;
+ }
+
+ public void setResourceDirectory(File directory)
+ {
+ this.resourceDir = directory;
+ }
+
+ public void setSourceDirectory(File directory)
+ {
+ this.sourceDir = directory;
+ }
+
+ public void setClassLoader(ClassLoader loader)
+ {
+ this.loader = loader;
+ }
+
+ public void setMessageStream(PrintStream messageStream)
+ {
+ this.messageStream = messageStream;
+ }
+
+ public void provide(String endpointClass)
+ {
+ try
+ {
+ provide(loader.loadClass(endpointClass));
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new IllegalArgumentException("Class not found: " +
endpointClass);
+ }
+ }
+
+ public void provide(Class<?> endpointClass)
+ {
+ // Swap the context classloader
+ // The '--classpath' switch might provide an URLClassLoader
+ ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
+
+ if(loader!=null)
+ Thread.currentThread().setContextClassLoader(loader);
+
+ try
+ {
+ List<String> args = new ArrayList<String>();
+
+ // Use the output directory as the default
+ File resourceDir = (this.resourceDir != null) ? this.resourceDir : outputDir;
+ File sourceDir = (this.sourceDir != null) ? this.sourceDir : outputDir;
+
+ if (generateSource) {
+ args.add("-keep");
+ if (sourceDir != null) {
+ if (!sourceDir.exists() && !sourceDir.mkdirs())
+ throw new IllegalStateException("Could not make directory: "
+ sourceDir.getName());
+
+ args.add("-s");
+ args.add(sourceDir.getAbsolutePath());
+ }
+ }
+
+ // -d <directory>
+ if (!outputDir.exists() && !outputDir.mkdirs())
+ throw new IllegalStateException("Could not make directory: " +
outputDir.getName());
+
+ args.add("-d");
+ args.add(outputDir.getAbsolutePath());
+
+ // -r <directory>
+ if (resourceDir != null) {
+ if (!resourceDir.exists() && !resourceDir.mkdirs())
+ throw new IllegalStateException("Could not make directory: " +
resourceDir.getName());
+ args.add("-r");
+ args.add(resourceDir.getAbsolutePath());
+ }
+
+ // -s <directory>
+ if (sourceDir != null) {
+ if (!sourceDir.exists() && !sourceDir.mkdirs())
+ throw new IllegalStateException("Could not make directory: " +
sourceDir.getName());
+ args.add("-s");
+ args.add(sourceDir.getAbsolutePath());
+ }
+
+ // -verbose
+ PrintStream stream = messageStream;
+ if (stream != null) {
+ args.add("-verbose");
+ } else {
+ stream = new NullPrintStream();
+ }
+
+ // -wsdl[:protocol]
+ if (generateWsdl) {
+ args.add("-wsdl");
+ }
+
+ // --classpath
+ if(loader instanceof URLClassLoader)
+ {
+ StringBuilder builder = new StringBuilder();
+ URLClassLoader urlLoader = (URLClassLoader)loader;
+ for(URL url : urlLoader.getURLs())
+ {
+ builder.append(url.toExternalForm());
+ builder.append(File.pathSeparator);
+ }
+
+ args.add("-classpath");
+ args.add(builder.toString());
+ }
+
+ // the SEI
+ args.add(endpointClass.getCanonicalName());
+
+ WsgenTool tool = new WsgenTool(messageStream);
+ tool.run(args.toArray(new String[0]));
+
+ }
+ finally{
+ Thread.currentThread().setContextClassLoader(oldLoader);
+ }
+ }
+
+
+}
Property changes on:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/MetroProviderImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/SunRIConsumerFactoryImpl.java
===================================================================
---
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/SunRIConsumerFactoryImpl.java 2008-02-15
12:50:14 UTC (rev 5702)
+++
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/SunRIConsumerFactoryImpl.java 2008-02-15
13:23:05 UTC (rev 5703)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.wsf.stack.metro.tools;
-
-import org.jboss.wsf.spi.tools.WSContractConsumerFactory;
-import org.jboss.wsf.spi.tools.WSContractConsumer;
-
-/**
- * Creates a WSContractConsumer that delegates to the Sun RI.
- *
- * @author <a href="jason.greene(a)jboss.com">Jason T. Greene</a>
- * @version $Revision:2311 $
- */
-public class SunRIConsumerFactoryImpl implements WSContractConsumerFactory
-{
- public WSContractConsumer createConsumer() {
- return new SunRIConsumerImpl();
- }
-}
Deleted:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/SunRIConsumerImpl.java
===================================================================
---
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/SunRIConsumerImpl.java 2008-02-15
12:50:14 UTC (rev 5702)
+++
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/SunRIConsumerImpl.java 2008-02-15
13:23:05 UTC (rev 5703)
@@ -1,203 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.wsf.stack.metro.tools;
-
-import org.jboss.wsf.spi.tools.WSContractConsumer;
-
-import java.io.File;
-import java.io.PrintStream;
-import java.util.List;
-import java.util.ArrayList;
-import java.net.URL;
-
-import com.sun.tools.ws.wscompile.WsimportTool;
-
-/**
- * WSContractConsumer that delegates to the Sun CompileTool.
- *
- * @author <a href="jason.greene(a)jboss.com">Jason T. Greene</a>
- * @author <a href="heiko.braun(a)jboss.com">Heiko Braun</a>
- * @version $Revision$
- */
-public class SunRIConsumerImpl extends WSContractConsumer
-{
- private List<File> bindingFiles = null;
- private File catalog = null;
- private boolean generateSource = false;
- private File outputDir = new File("output");
- private File sourceDir = null;
- private String targetPackage = null;
- private PrintStream messageStream = null;
- private String wsdlLocation = null;
- private List<String> additionalCompilerClassPath = new ArrayList<String>();
- private String target = "2.0";
-
- @Override
- public void setBindingFiles(List<File> bindingFiles) {
- this.bindingFiles = bindingFiles;
- }
-
- @Override
- public void setCatalog(File catalog) {
- this.catalog = catalog;
- }
-
- @Override
- public void setGenerateSource(boolean generateSource) {
- this.generateSource = generateSource;
- }
-
- @Override
- public void setMessageStream(PrintStream messageStream) {
- // TODO Auto-generated method stub
- this.messageStream = messageStream;
- }
-
- @Override
- public void setOutputDirectory(File directory) {
- // TODO Auto-generated method stub
- outputDir = directory;
- }
-
- @Override
- public void setSourceDirectory(File directory) {
- sourceDir = directory;
- }
-
- @Override
- public void setTargetPackage(String targetPackage) {
- this.targetPackage = targetPackage;
- }
-
- @Override
- public void setWsdlLocation(String wsdlLocation) {
- this.wsdlLocation = wsdlLocation;
- }
-
- public void setAdditionalCompilerClassPath(List<String>
additionalCompilerClassPath) {
- this.additionalCompilerClassPath = additionalCompilerClassPath;
- }
-
- @Override
- public void setTarget(String target) {
- this.target = target;
- }
-
- @Override
- public void consume(URL wsdl) {
- List<String> args = new ArrayList<String>();
- if (bindingFiles != null) {
- for (File file : bindingFiles) {
- args.add("-b");
- args.add(file.getAbsolutePath());
-
- }
- }
-
- if (catalog != null) {
- args.add("-catalog");
- args.add(catalog.getAbsolutePath());
- }
-
- if (generateSource) {
- args.add("-keep");
- if (sourceDir != null) {
- if (!sourceDir.exists() && !sourceDir.mkdirs())
- throw new IllegalStateException("Could not make directory: " +
sourceDir.getName());
-
- args.add("-s");
- args.add(sourceDir.getAbsolutePath());
- }
- }
-
- if (targetPackage != null) {
- args.add("-p");
- args.add(targetPackage);
- }
-
- if (wsdlLocation != null) {
- args.add("-wsdllocation");
- args.add(wsdlLocation);
- }
-
- PrintStream stream = messageStream;
- if (stream != null) {
- args.add("-verbose");
- } else {
- stream = new NullPrintStream();
- }
-
- if (!outputDir.exists() && !outputDir.mkdirs())
- throw new IllegalStateException("Could not make directory: " +
outputDir.getName());
-
- // Always add the output directory and the wsdl location
- args.add("-d");
- args.add(outputDir.getAbsolutePath());
-
- // Always set the target
- if(!target.equals("2.0"))
- throw new IllegalArgumentException("WSConsume (metro) only supports JAX-WS
2.0");
-
- args.add("-target");
- args.add(target);
-
- // finally the WSDL file
- args.add(wsdl.toString());
-
- // See WsimportTool#compileGeneratedClasses()
- if(!additionalCompilerClassPath.isEmpty())
- {
- StringBuffer javaCP = new StringBuffer();
- for(String s : additionalCompilerClassPath)
- {
- javaCP.append(s).append(File.pathSeparator);
- }
- System.setProperty("java.class.path", javaCP.toString());
- }
-
- try
- {
- // enforce woodstox
- if(null == System.getProperty("javax.xml.stream.XMLInputFactory"))
- System.setProperty("javax.xml.stream.XMLInputFactory",
"com.ctc.wstx.stax.WstxInputFactory");
-
- WsimportTool compileTool = new WsimportTool(stream);
- boolean success = compileTool.run(args.toArray(new String[0]));
-
- if(!success) throw new IllegalStateException("WsImport invocation failed");
- }
- catch (Throwable t)
- {
- if (messageStream != null)
- {
- messageStream.println("Failed to invoke WsImport");
- t.printStackTrace(messageStream);
- }
- else
- {
- t.printStackTrace();
- }
- }
-
- }
-
-}
Deleted:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/SunRIProviderFactoryImpl.java
===================================================================
---
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/SunRIProviderFactoryImpl.java 2008-02-15
12:50:14 UTC (rev 5702)
+++
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/SunRIProviderFactoryImpl.java 2008-02-15
13:23:05 UTC (rev 5703)
@@ -1,39 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.wsf.stack.metro.tools;
-
-import org.jboss.wsf.spi.tools.WSContractProviderFactory;
-import org.jboss.wsf.spi.tools.WSContractProvider;
-
-/**
- * @author Heiko.Braun(a)jboss.com
- * @version $Revision$
- */
-public class SunRIProviderFactoryImpl implements WSContractProviderFactory
-{
- public WSContractProvider createProvider(ClassLoader loader)
- {
- WSContractProvider sunRIProvider = new SunRIProviderImpl();
- sunRIProvider.setClassLoader(loader);
- return sunRIProvider;
- }
-}
Deleted:
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/SunRIProviderImpl.java
===================================================================
---
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/SunRIProviderImpl.java 2008-02-15
12:50:14 UTC (rev 5702)
+++
stack/metro/trunk/src/main/java/org/jboss/wsf/stack/metro/tools/SunRIProviderImpl.java 2008-02-15
13:23:05 UTC (rev 5703)
@@ -1,193 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.wsf.stack.metro.tools;
-
-import org.jboss.wsf.spi.tools.WSContractProvider;
-
-import java.io.File;
-import java.io.PrintStream;
-import java.util.List;
-import java.util.ArrayList;
-import java.net.URLClassLoader;
-import java.net.URL;
-
-import com.sun.tools.ws.wscompile.WsgenTool;
-
-/**
- * @author Heiko.Braun(a)jboss.com
- * @version $Revision$
- */
-public class SunRIProviderImpl extends WSContractProvider
-{
-
- private ClassLoader loader;
- private boolean generateWsdl = false;
- private boolean generateSource = false;
- private File outputDir = new File("output");
- private File resourceDir = null;
- private File sourceDir = null;
- private PrintStream messageStream = new NullPrintStream();
-
- public SunRIProviderImpl()
- {
- }
-
- public void setGenerateWsdl(boolean generateWsdl)
- {
- this.generateWsdl = generateWsdl;
- }
-
- public void setGenerateSource(boolean generateSource)
- {
- this.generateSource = generateSource;
- }
-
- public void setOutputDirectory(File directory)
- {
- this.outputDir = directory;
- }
-
- public void setResourceDirectory(File directory)
- {
- this.resourceDir = directory;
- }
-
- public void setSourceDirectory(File directory)
- {
- this.sourceDir = directory;
- }
-
- public void setClassLoader(ClassLoader loader)
- {
- this.loader = loader;
- }
-
- public void setMessageStream(PrintStream messageStream)
- {
- this.messageStream = messageStream;
- }
-
- public void provide(String endpointClass)
- {
- try
- {
- provide(loader.loadClass(endpointClass));
- }
- catch (ClassNotFoundException e)
- {
- throw new IllegalArgumentException("Class not found: " +
endpointClass);
- }
- }
-
- public void provide(Class<?> endpointClass)
- {
- // Swap the context classloader
- // The '--classpath' switch might provide an URLClassLoader
- ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
-
- if(loader!=null)
- Thread.currentThread().setContextClassLoader(loader);
-
- try
- {
- List<String> args = new ArrayList<String>();
-
- // Use the output directory as the default
- File resourceDir = (this.resourceDir != null) ? this.resourceDir : outputDir;
- File sourceDir = (this.sourceDir != null) ? this.sourceDir : outputDir;
-
- if (generateSource) {
- args.add("-keep");
- if (sourceDir != null) {
- if (!sourceDir.exists() && !sourceDir.mkdirs())
- throw new IllegalStateException("Could not make directory: "
+ sourceDir.getName());
-
- args.add("-s");
- args.add(sourceDir.getAbsolutePath());
- }
- }
-
- // -d <directory>
- if (!outputDir.exists() && !outputDir.mkdirs())
- throw new IllegalStateException("Could not make directory: " +
outputDir.getName());
-
- args.add("-d");
- args.add(outputDir.getAbsolutePath());
-
- // -r <directory>
- if (resourceDir != null) {
- if (!resourceDir.exists() && !resourceDir.mkdirs())
- throw new IllegalStateException("Could not make directory: " +
resourceDir.getName());
- args.add("-r");
- args.add(resourceDir.getAbsolutePath());
- }
-
- // -s <directory>
- if (sourceDir != null) {
- if (!sourceDir.exists() && !sourceDir.mkdirs())
- throw new IllegalStateException("Could not make directory: " +
sourceDir.getName());
- args.add("-s");
- args.add(sourceDir.getAbsolutePath());
- }
-
- // -verbose
- PrintStream stream = messageStream;
- if (stream != null) {
- args.add("-verbose");
- } else {
- stream = new NullPrintStream();
- }
-
- // -wsdl[:protocol]
- if (generateWsdl) {
- args.add("-wsdl");
- }
-
- // --classpath
- if(loader instanceof URLClassLoader)
- {
- StringBuilder builder = new StringBuilder();
- URLClassLoader urlLoader = (URLClassLoader)loader;
- for(URL url : urlLoader.getURLs())
- {
- builder.append(url.toExternalForm());
- builder.append(File.pathSeparator);
- }
-
- args.add("-classpath");
- args.add(builder.toString());
- }
-
- // the SEI
- args.add(endpointClass.getCanonicalName());
-
- WsgenTool tool = new WsgenTool(messageStream);
- tool.run(args.toArray(new String[0]));
-
- }
- finally{
- Thread.currentThread().setContextClassLoader(oldLoader);
- }
- }
-
-
-}
Modified:
stack/metro/trunk/src/main/resources/jbossws-metro-client.jar/META-INF/services/org.jboss.wsf.spi.tools.ConsumerFactoryImpl
===================================================================
---
stack/metro/trunk/src/main/resources/jbossws-metro-client.jar/META-INF/services/org.jboss.wsf.spi.tools.ConsumerFactoryImpl 2008-02-15
12:50:14 UTC (rev 5702)
+++
stack/metro/trunk/src/main/resources/jbossws-metro-client.jar/META-INF/services/org.jboss.wsf.spi.tools.ConsumerFactoryImpl 2008-02-15
13:23:05 UTC (rev 5703)
@@ -1 +1 @@
-org.jboss.wsf.stack.metro.tools.SunRIConsumerFactoryImpl
\ No newline at end of file
+org.jboss.wsf.stack.metro.tools.MetroConsumerFactoryImpl
\ No newline at end of file
Modified:
stack/metro/trunk/src/main/resources/jbossws-metro-client.jar/META-INF/services/org.jboss.wsf.spi.tools.ProviderFactoryImpl
===================================================================
---
stack/metro/trunk/src/main/resources/jbossws-metro-client.jar/META-INF/services/org.jboss.wsf.spi.tools.ProviderFactoryImpl 2008-02-15
12:50:14 UTC (rev 5702)
+++
stack/metro/trunk/src/main/resources/jbossws-metro-client.jar/META-INF/services/org.jboss.wsf.spi.tools.ProviderFactoryImpl 2008-02-15
13:23:05 UTC (rev 5703)
@@ -1 +1 @@
-org.jboss.wsf.stack.metro.tools.SunRIProviderFactoryImpl
\ No newline at end of file
+org.jboss.wsf.stack.metro.tools.MetroProviderFactoryImpl
\ No newline at end of file