[jbossws-commits] JBossWS SVN: r13340 - in spi/branches/jbossws-spi-1.4.1/src/main/java/org/jboss/wsf/spi/metadata: webservices and 1 other directory.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Sat Nov 27 09:25:14 EST 2010


Author: alessio.soldano at jboss.com
Date: 2010-11-27 09:25:14 -0500 (Sat, 27 Nov 2010)
New Revision: 13340

Added:
   spi/branches/jbossws-spi-1.4.1/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/UnifiedHandlerChainsMetaDataParser.java
Modified:
   spi/branches/jbossws-spi-1.4.1/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/HandlerChainsObjectFactory.java
   spi/branches/jbossws-spi-1.4.1/src/main/java/org/jboss/wsf/spi/metadata/webservices/WebservicesFactory.java
Log:
[JBWS-3169] Adding means for building UnifiedHandlersChainsMetaData and WebservicesMetaData from jbossws-spi without directly relying on JBossXB internals


Modified: spi/branches/jbossws-spi-1.4.1/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/HandlerChainsObjectFactory.java
===================================================================
--- spi/branches/jbossws-spi-1.4.1/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/HandlerChainsObjectFactory.java	2010-11-26 15:13:02 UTC (rev 13339)
+++ spi/branches/jbossws-spi-1.4.1/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/HandlerChainsObjectFactory.java	2010-11-27 14:25:14 UTC (rev 13340)
@@ -33,6 +33,7 @@
  * @author Thomas.Diesler at jboss.org
  * @since 15-Oct-2005
  */
+ at Deprecated
 public class HandlerChainsObjectFactory implements ObjectModelFactory
 {
    // provide logging

Added: spi/branches/jbossws-spi-1.4.1/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/UnifiedHandlerChainsMetaDataParser.java
===================================================================
--- spi/branches/jbossws-spi-1.4.1/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/UnifiedHandlerChainsMetaDataParser.java	                        (rev 0)
+++ spi/branches/jbossws-spi-1.4.1/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/UnifiedHandlerChainsMetaDataParser.java	2010-11-27 14:25:14 UTC (rev 13340)
@@ -0,0 +1,51 @@
+/*
+ * 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.wsf.spi.metadata.j2ee.serviceref;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+
+/** The interface of the parser for the unified metadata handler chains element
+ * 
+ * @author alessio.soldano at jboss.com
+ * @since 26-Nov-2010
+ */
+public class UnifiedHandlerChainsMetaDataParser
+{
+   @SuppressWarnings("deprecation")
+   public static UnifiedHandlerChainsMetaData parse(InputStream is) throws IOException
+   {
+      try
+      {
+         Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+         return (UnifiedHandlerChainsMetaData) unmarshaller.unmarshal(is, new HandlerChainsObjectFactory(), null);
+      }
+      catch (JBossXBException xbe)
+      {
+         throw new IOException(xbe);
+      }
+   }
+}

Modified: spi/branches/jbossws-spi-1.4.1/src/main/java/org/jboss/wsf/spi/metadata/webservices/WebservicesFactory.java
===================================================================
--- spi/branches/jbossws-spi-1.4.1/src/main/java/org/jboss/wsf/spi/metadata/webservices/WebservicesFactory.java	2010-11-26 15:13:02 UTC (rev 13339)
+++ spi/branches/jbossws-spi-1.4.1/src/main/java/org/jboss/wsf/spi/metadata/webservices/WebservicesFactory.java	2010-11-27 14:25:14 UTC (rev 13340)
@@ -45,7 +45,6 @@
  * @author Thomas.Diesler at jboss.org
  * @since 16-Apr-2004
  */
-// TODO: move to jbossws-framework or jbossws-common
 public class WebservicesFactory implements ObjectModelFactory
 {
    // provide logging
@@ -103,13 +102,9 @@
          URL wsddUrl = wsdd.toURL();
          try
          {
-            InputStream is = wsddUrl.openStream();
-            Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
-            ObjectModelFactory factory = new WebservicesFactory(wsddUrl);
-            webservices = (WebservicesMetaData)unmarshaller.unmarshal(is, factory, null);
-            is.close();
+            webservices = load(wsddUrl);
          }
-         catch (Exception e)
+         catch (IOException e)
          {
             throw new WebServiceException("Failed to unmarshall webservices.xml:" + e.getMessage());
          }
@@ -117,6 +112,34 @@
 
       return webservices;
    }
+   
+   /**
+    * Load webservices.xml from <code>META-INF/webservices.xml</code>
+    * or <code>WEB-INF/webservices.xml</code>.
+    *
+    * @param root virtual file root
+    * @return WebservicesMetaData or <code>null</code> if it cannot be found
+    */
+   public static WebservicesMetaData load(URL wsddUrl) throws IOException
+   {
+      InputStream is = null;
+      try
+      {
+         is = wsddUrl.openStream();
+         Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+         ObjectModelFactory factory = new WebservicesFactory(wsddUrl);
+         return (WebservicesMetaData)unmarshaller.unmarshal(is, factory, null);
+      }
+      catch (Exception e)
+      {
+         throw new WebServiceException("Failed to unmarshall " + wsddUrl + ":" + e.getMessage());
+      }
+      finally
+      {
+         if (is != null)
+            is.close();
+      }
+   }
 
    /**
     * This method is called on the factory by the object model builder when the parsing starts.



More information about the jbossws-commits mailing list