[jbossws-commits] JBossWS SVN: r14264 - in api/trunk/src/main/java/org/jboss: ws/api/tools and 1 other directories.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Fri May 6 05:43:46 EDT 2011


Author: richard.opalka at jboss.com
Date: 2011-05-06 05:43:46 -0400 (Fri, 06 May 2011)
New Revision: 14264

Added:
   api/trunk/src/main/java/org/jboss/ws/api/tools/
   api/trunk/src/main/java/org/jboss/ws/api/tools/SecurityActions.java
   api/trunk/src/main/java/org/jboss/ws/api/tools/WSContractConsumer.java
   api/trunk/src/main/java/org/jboss/ws/api/tools/WSContractConsumerFactory.java
   api/trunk/src/main/java/org/jboss/ws/api/tools/WSContractProvider.java
   api/trunk/src/main/java/org/jboss/ws/api/tools/WSContractProviderFactory.java
Removed:
   api/trunk/src/main/java/org/jboss/wsf/spi/tools/
Log:
[JBWS-3289] refactoring packages: org.jboss.wsf.spi.tools -> org.jboss.ws.api.tools

Added: api/trunk/src/main/java/org/jboss/ws/api/tools/SecurityActions.java
===================================================================
--- api/trunk/src/main/java/org/jboss/ws/api/tools/SecurityActions.java	                        (rev 0)
+++ api/trunk/src/main/java/org/jboss/ws/api/tools/SecurityActions.java	2011-05-06 09:43:46 UTC (rev 14264)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ws.api.tools;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * Security actions for this package
+ * 
+ * @author alessio.soldano at jboss.com
+ * @since 19-Jun-2009
+ *
+ */
+class SecurityActions
+{
+   /**
+    * Get context classloader.
+    * 
+    * @return the current context classloader
+    */
+   static ClassLoader getContextClassLoader()
+   {
+      SecurityManager sm = System.getSecurityManager();
+      if (sm == null)
+      {
+         return Thread.currentThread().getContextClassLoader();
+      }
+      else
+      {
+         return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+            public ClassLoader run()
+            {
+               return Thread.currentThread().getContextClassLoader();
+            }
+         });
+      }
+   }
+
+   /**
+    * Set context classloader.
+    *
+    * @param cl the classloader
+    * @return previous context classloader
+    * @throws Throwable for any error
+    */
+   static ClassLoader setContextClassLoader(final ClassLoader cl)
+   {
+      if (System.getSecurityManager() == null)
+      {
+         ClassLoader result = Thread.currentThread().getContextClassLoader();
+         if (cl != null)
+            Thread.currentThread().setContextClassLoader(cl);
+         return result;
+      }
+      else
+      {
+         try
+         {
+            return AccessController.doPrivileged(new PrivilegedExceptionAction<ClassLoader>() {
+               public ClassLoader run() throws Exception
+               {
+                  try
+                  {
+                     ClassLoader result = Thread.currentThread().getContextClassLoader();
+                     if (cl != null)
+                        Thread.currentThread().setContextClassLoader(cl);
+                     return result;
+                  }
+                  catch (Exception e)
+                  {
+                     throw e;
+                  }
+                  catch (Error e)
+                  {
+                     throw e;
+                  }
+                  catch (Throwable e)
+                  {
+                     throw new RuntimeException("Error setting context classloader", e);
+                  }
+               }
+            });
+         }
+         catch (PrivilegedActionException e)
+         {
+            throw new RuntimeException("Error running privileged action", e.getCause());
+         }
+      }
+   }
+}

Added: api/trunk/src/main/java/org/jboss/ws/api/tools/WSContractConsumer.java
===================================================================
--- api/trunk/src/main/java/org/jboss/ws/api/tools/WSContractConsumer.java	                        (rev 0)
+++ api/trunk/src/main/java/org/jboss/ws/api/tools/WSContractConsumer.java	2011-05-06 09:43:46 UTC (rev 14264)
@@ -0,0 +1,212 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ws.api.tools;
+
+import java.io.File;
+import java.io.PrintStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+
+import org.jboss.wsf.spi.util.ServiceLoader;
+
+/**
+ * WSContractConsumer is responsible for generating JAX-WS client and server
+ * artifacts from the specified WSDL file. To implement a client, one would use
+ * the generated ___Service.java file. For a server, one only needs to provide
+ * an implementation class that implements the generated service endpoint
+ * interface.
+ * 
+ * @author <a href="mailto:jason.greene at jboss.com">Jason T. Greene</a>
+ */
+public abstract class WSContractConsumer
+{
+   private static String DEFAULT_PROVIDER = "org.jboss.ws.tools.jaxws.impl.SunRIConsumerFactoryImpl";
+   public static final String PROVIDER_PROPERTY = "org.jboss.ws.api.tools.ConsumerFactory";
+
+   /**
+    * Obtain a new instance of a WSContractConsumer. This will use the current
+    * thread's context class loader to locate the WSContractConsumerFactory
+    * implementation.
+    *
+    * @return a new WSContractConsumer
+    */
+   public static WSContractConsumer newInstance()
+   {
+      return newInstance(SecurityActions.getContextClassLoader());
+   }
+
+   /**
+    * Obtain a new instance of a WSContractConsumer. The specified ClassLoader will be used to
+    * locate the WebServiceImporterProvide implementation
+    *
+    * @param loader the ClassLoader to use
+    * @return a new WSContractConsumer
+    */
+   public static WSContractConsumer newInstance(ClassLoader loader)
+   {
+      ClassLoader oldLoader = SecurityActions.getContextClassLoader();
+      try
+      {
+         SecurityActions.setContextClassLoader(loader);
+         WSContractConsumerFactory factory = (WSContractConsumerFactory) ServiceLoader.loadService(PROVIDER_PROPERTY, DEFAULT_PROVIDER);
+         return factory.createConsumer();
+      }
+      finally
+      {
+         SecurityActions.setContextClassLoader(oldLoader);
+      }
+   }
+
+   /**
+    * Specifies the JAX-WS and JAXB binding files to use on import operations.
+    *
+    * @param bindingFiles list of JAX-WS or JAXB binding files
+    */
+   public abstract void setBindingFiles(List<File> bindingFiles);
+
+   /**
+    * Sets the OASIS XML Catalog file to use for entity resolution.
+    *
+    * @param catalog the OASIS XML Catalog file
+    */
+   public abstract void setCatalog(File catalog);
+
+   /**
+    * Sets the main output directory. If the directory does not exist, it will be created.
+    *
+    * @param directory the root directory for generated files
+    */
+   public abstract void setOutputDirectory(File directory);
+
+   /**
+    * Sets the source directory. This directory will contain any generated Java source.
+    * If the directory does not exist, it will be created. If not specified,
+    * the output directory will be used instead.
+    *
+    * @param directory the root directory for generated source code
+    */
+   public abstract void setSourceDirectory(File directory);
+
+   /**
+    * Enables/Disables SOAP 1.2 binding extension
+    * 
+    * @param extension whether or not to enable SOAP 1.2 binding extension
+    */
+   public abstract void setExtension(boolean extension);
+
+   /**
+    * Enables/Disables Java source generation.
+    *
+    * @param generateSource whether or not to generate Java source.
+    */
+   public abstract void setGenerateSource(boolean generateSource);
+
+   /**
+    * Enables/Disables Java source compilation.
+    *
+    * @param nocompile whether or not to compile Java source.
+    */
+   public abstract void setNoCompile(boolean nocompile);
+   
+   /**
+    * Sets the target package for generated source. If not specified the default
+    * is based off of the XML namespace.
+    *
+    * @param targetPackage the target package for generated source
+    */
+   public abstract void setTargetPackage(String targetPackage);
+
+   /**
+    * Sets the @@WebService.wsdlLocation and @@WebServiceClient.wsdlLocation attributes to a custom value.
+    *
+    * @param wsdlLocation the custom WSDL location to use in generated source
+    */
+   public abstract void setWsdlLocation(String wsdlLocation);
+
+   /**
+    * Sets the PrintStream to use for status feedback. The simplest example
+    * would be to use System.out.
+    *
+    * @param messageStream  the stream to use for status messages:
+    */
+   public abstract void setMessageStream(PrintStream messageStream);
+
+   /**
+    * Sets the additional classpath to use if/when invoking the Java compiler.
+    * Typically an implementation will use the system <code>java.class.path</code>
+    * property. So for most normal applications this method is not needed. However,
+    * if this API is being used from an isolated classloader, then it needs to
+    * be called in order to reference all jars that are required by the
+    * implementation.
+    *
+    * @param classPath a list of strings where each entry references a
+    *                  single jar or directory
+    */
+   public abstract void setAdditionalCompilerClassPath(List<String> classPath);
+
+   /**
+    * Enables or disables processing of implicit SOAP headers (i.e. SOAP headers
+    * defined in the wsdl:binding but not wsdl:portType section.) Default is false. 
+    * 
+    * @param additionalHeaders a boolean enabling processing of implicit SOAP headers
+    */
+   public abstract void setAdditionalHeaders(boolean additionalHeaders);
+   
+   /**
+    * Set the target JAX-WS specification target. Allowed values are 2.0, 2.1 and 2.2
+    * @param target  the JAX-WS specification version.
+    */
+   public abstract void setTarget(String target);
+
+   /**
+    * Generate the required artifacts using the specified WSDL URL. This method
+    * may be called more than once, although this is probably not desireable
+    * 
+    * @param wsdl the URL of the WSDL
+    */
+   public abstract void consume(URL wsdl);
+
+   /**
+    * Generate the required artifacts using the specified WSDL. This method
+    * may be called more than once, although this is probably not desireable.
+    * The passed string is expect to either be a valid URL, or a local file path.
+    *
+    * @param wsdl a URL or local file path
+    * @throws MalformedURLException if wsdl is not a legal URL or local file
+    */
+   public void consume(String wsdl) throws MalformedURLException
+   {
+      URL url = null;
+      try
+      {
+         url = new URL(wsdl);
+      }
+      catch (MalformedURLException e)
+      {
+         File file = new File(wsdl);
+         url = file.toURI().toURL();
+      }
+
+      consume(url);
+   }
+}

Added: api/trunk/src/main/java/org/jboss/ws/api/tools/WSContractConsumerFactory.java
===================================================================
--- api/trunk/src/main/java/org/jboss/ws/api/tools/WSContractConsumerFactory.java	                        (rev 0)
+++ api/trunk/src/main/java/org/jboss/ws/api/tools/WSContractConsumerFactory.java	2011-05-06 09:43:46 UTC (rev 14264)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ws.api.tools;
+
+import org.jboss.ws.api.tools.WSContractConsumer;
+
+/**
+ * Creates WSContractConsumer implementations.
+ * 
+ * @author <a href="mailto:jason.greene at jboss.com">Jason T. Greene</a>
+ */
+public interface WSContractConsumerFactory
+{
+   /**
+    * Create a new WSContractConsumer. There are no restrictions on how this
+    * should be performed. 
+    * 
+    * @return a new WSContractConsumer
+    */
+   public WSContractConsumer createConsumer();
+}

Added: api/trunk/src/main/java/org/jboss/ws/api/tools/WSContractProvider.java
===================================================================
--- api/trunk/src/main/java/org/jboss/ws/api/tools/WSContractProvider.java	                        (rev 0)
+++ api/trunk/src/main/java/org/jboss/ws/api/tools/WSContractProvider.java	2011-05-06 09:43:46 UTC (rev 14264)
@@ -0,0 +1,185 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ws.api.tools;
+
+import java.io.File;
+import java.io.PrintStream;
+
+import org.jboss.wsf.spi.util.ServiceLoader;
+
+/**
+ * WSContractProvider is responsible for generating the required portable
+ * JAX-WS artifacts for a service endpoint implementation. This includes class
+ * files for wrapper types and fault beans. WSDL may be optionally generated as
+ * well using this API.
+ *
+ * <p>The following example generates class files, source files and WSDL for an
+ * endpoint:</p> 
+ * <pre>
+ * WSContractProvider provider = WSContractProvider.newInstance();
+ * provider.setGenerateSource(true);
+ * provider.setGenerateWsdl(true);
+ * provider.setOutputDirectory(new File("output"));
+ * provider.setMessageStream(System.out);
+ * provider.provide(TestMe.class);
+ * </pre>
+ * 
+ * <p>Thread-Safety:</p>
+ * This class expects to be thread-confined, so it can not be shared between threads.
+ *
+ * @author <a href="mailto:jason.greene at jboss.com">Jason T. Greene</a>
+ */
+public abstract class WSContractProvider
+{
+   private static String DEFAULT_PROVIDER = "org.jboss.ws.tools.jaxws.impl.JBossWSProviderFactoryImpl";
+   public static final String PROVIDER_PROPERTY = "org.jboss.ws.api.tools.ProviderFactory";
+
+   protected WSContractProvider()
+   {
+
+   }
+
+   /**
+    * Obtain a new instance of a WSContractProvider. This will use the current
+    * thread's context class loader to locate the WSContractProviderFactory
+    * implementation.
+    * 
+    * @return a new WSContractProvider
+    */
+   public static WSContractProvider newInstance()
+   {
+      return newInstance(SecurityActions.getContextClassLoader());
+   }
+
+   /**
+    * Obtain a new instance of a WSContractProvider. The specified ClassLoader will be used to
+    * locate the WSContractProviderFactory implementation
+    * 
+    * @param loader the ClassLoader to use
+    * @return a new WSContractProvider
+    */
+   public static WSContractProvider newInstance(ClassLoader loader)
+   {
+      ClassLoader oldLoader = SecurityActions.getContextClassLoader();
+      try
+      {
+         SecurityActions.setContextClassLoader(loader);
+         WSContractProviderFactory factory = (WSContractProviderFactory) ServiceLoader.loadService(PROVIDER_PROPERTY, DEFAULT_PROVIDER);
+         return factory.createProvider(loader);
+      }
+      finally
+      {
+         SecurityActions.setContextClassLoader(oldLoader);
+      }
+   }
+
+   /**
+    * Enables/Disables WSDL generation.
+    * 
+    * @param generateWsdl whether or not to generate WSDL
+    */
+   public abstract void setGenerateWsdl(boolean generateWsdl);
+   
+   /**
+    * Enables/Disables SOAP 1.2 binding extension
+    * 
+    * @param extension whether or not to enable SOAP 1.2 binding extension
+    */
+   public abstract void setExtension(boolean extension);
+
+   /**
+    * Enables/Disables Java source generation.
+    * 
+    * @param generateSource whether or not to generate Java source.
+    */
+   public abstract void setGenerateSource(boolean generateSource);
+
+   /**
+    * Sets the main output directory. If the directory does not exist, it will be created.
+    * 
+    * @param directory the root directory for generated files
+    */
+   public abstract void setOutputDirectory(File directory);
+
+   /**
+    * Sets the resource directory. This directory will contain any generated
+    * WSDL and XSD files. If the directory does not exist, it will be created.
+    * If not specified, the output directory will be used instead.
+    * 
+    * @param directory the root directory for generated resource files
+    */
+   public abstract void setResourceDirectory(File directory);
+
+   /**
+    * Sets the source directory. This directory will contain any generated Java source.
+    * If the directory does not exist, it will be created. If not specified, 
+    * the output directory will be used instead.
+    * 
+    * @param directory the root directory for generated source code
+    */
+   public abstract void setSourceDirectory(File directory);
+
+   /**
+    * Sets the ClassLoader used to discover types. This defaults to the one used
+    * in instantiation.
+    * 
+    * @param loader the ClassLoader to use
+    */
+   public abstract void setClassLoader(ClassLoader loader);
+
+   /**
+    * Generates artifacts using the current settings. This method may be invoked
+    * more than once (e.g. multiple endpoints).
+    * 
+    * @param endpointClass the name of the endpoint implementation bean
+    * @throws RuntimeException if any error occurs during processing, or the class is not found
+    */
+   public abstract void provide(String endpointClass);
+
+   /**
+    * Generates artifacts using the current settings. This method may be invoked
+    * more than once (e.g. multiple endpoints).
+    * 
+    * @param endpointClass the endpoint implementation bean
+    * @throws RuntimeException if any error occurs during processing
+    */
+   public abstract void provide(Class<?> endpointClass);
+
+   /**
+    * Sets the PrintStream to use for status feedback. The simplest example
+    * would be to use System.out.
+    * 
+    * <p>Example output:</p> 
+    * <pre>
+    * Generating WSDL: 
+    * TestMeService.wsdl 
+    * Writing Source:
+    * org/jboss/ws/tools/jaxws/TestMe.java
+    * org/jboss/ws/tools/jaxws/TestMeResponse.java 
+    * Writing Classes:
+    * org/jboss/ws/tools/jaxws/TestMe.class
+    * org/jboss/ws/tools/jaxws/TestMeResponse.class
+    * </pre>
+    * @param messageStream  the stream to use for status messages:
+    */
+   public abstract void setMessageStream(PrintStream messageStream);
+}

Added: api/trunk/src/main/java/org/jboss/ws/api/tools/WSContractProviderFactory.java
===================================================================
--- api/trunk/src/main/java/org/jboss/ws/api/tools/WSContractProviderFactory.java	                        (rev 0)
+++ api/trunk/src/main/java/org/jboss/ws/api/tools/WSContractProviderFactory.java	2011-05-06 09:43:46 UTC (rev 14264)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ws.api.tools;
+
+import org.jboss.ws.api.tools.WSContractProvider;
+
+/**
+ * Creates WSContractProvider implementations.
+ * 
+ * @author <a href="mailto:jason.greene at jboss.com">Jason T. Greene</a>
+ */
+public interface WSContractProviderFactory
+{
+   /**
+    * Create a new WSContractProvider. There are no restrictions on how this
+    * should be performed. The passed ClassLoader is the one used in
+    * {@link WSContractProvider#newInstance(ClassLoader)}. This loader
+    * should be made available to the generated WSContractProvider.
+    * 
+    * @param loader the ClassLoader for type discovery
+    * @return a new WSContractProvider
+    */
+   public WSContractProvider createProvider(ClassLoader loader);
+}



More information about the jbossws-commits mailing list