[jbossws-commits] JBossWS SVN: r17012 - in container/jboss71/branches: jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/util and 7 other directories.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Fri Nov 16 09:39:04 EST 2012


Author: richard.opalka at jboss.com
Date: 2012-11-16 09:39:04 -0500 (Fri, 16 Nov 2012)
New Revision: 17012

Modified:
   container/jboss71/branches/jbossws-jboss711/pom.xml
   container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/util/VirtualFileAdaptor.java
   container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WSRefUtils.java
   container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WSRefValueSource.java
   container/jboss71/branches/jbossws-jboss712/pom.xml
   container/jboss71/branches/jbossws-jboss712/server-integration/src/main/java/org/jboss/as/webservices/util/VirtualFileAdaptor.java
   container/jboss71/branches/jbossws-jboss712/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WSRefUtils.java
   container/jboss71/branches/jbossws-jboss712/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WSRefValueSource.java
   container/jboss71/branches/jbossws-jboss713/pom.xml
   container/jboss71/branches/jbossws-jboss713/server-integration/src/main/java/org/jboss/as/webservices/util/VirtualFileAdaptor.java
   container/jboss71/branches/jbossws-jboss713/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WSRefUtils.java
   container/jboss71/branches/jbossws-jboss713/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WSRefValueSource.java
Log:
[JBWS-3565] WS ref optimization

Modified: container/jboss71/branches/jbossws-jboss711/pom.xml
===================================================================
--- container/jboss71/branches/jbossws-jboss711/pom.xml	2012-11-16 14:15:11 UTC (rev 17011)
+++ container/jboss71/branches/jbossws-jboss711/pom.xml	2012-11-16 14:39:04 UTC (rev 17012)
@@ -51,8 +51,8 @@
 
   <properties>
     <jbossws.api.version>1.0.1.Final</jbossws.api.version>
-    <jbossws.spi.version>2.1.0.Final</jbossws.spi.version>
-    <jbossws.common.version>2.1.0.Final</jbossws.common.version>
+    <jbossws.spi.version>2.1.1-SNAPSHOT</jbossws.spi.version>
+    <jbossws.common.version>2.1.1-SNAPSHOT</jbossws.common.version>
     <jboss.msc.version>1.0.2.GA</jboss.msc.version>
     <jboss.version>7.1.1.Final</jboss.version>
     <jboss.jaxws.api.version>2.0.0.Final</jboss.jaxws.api.version>

Modified: container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/util/VirtualFileAdaptor.java
===================================================================
--- container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/util/VirtualFileAdaptor.java	2012-11-16 14:15:11 UTC (rev 17011)
+++ container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/util/VirtualFileAdaptor.java	2012-11-16 14:39:04 UTC (rev 17012)
@@ -23,29 +23,13 @@
 
 import static org.jboss.as.webservices.WSMessages.MESSAGES;
 
-import java.io.File;
-import java.io.FileFilter;
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.ObjectStreamField;
-import java.io.OutputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.jar.JarEntry;
-import java.util.jar.JarInputStream;
-import java.util.jar.JarOutputStream;
 
-import org.jboss.vfs.VFS;
-import org.jboss.vfs.VFSUtils;
 import org.jboss.vfs.VirtualFile;
 import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
-import org.jboss.wsf.spi.deployment.WritableUnifiedVirtualFile;
-import org.jboss.wsf.spi.util.URLLoaderAdapter;
 
 /**
  * A VirtualFile adaptor.
@@ -54,68 +38,20 @@
  * @author Ales.Justin at jboss.org
  * @author alessio.soldano at jboss.com
  */
-public final class VirtualFileAdaptor implements WritableUnifiedVirtualFile {
-    private static final long serialVersionUID = -4509594124653184348L;
+public final class VirtualFileAdaptor implements UnifiedVirtualFile {
 
-    private static final ObjectStreamField[] serialPersistentFields = { new ObjectStreamField("rootUrl", URL.class),
-            new ObjectStreamField("path", String.class), new ObjectStreamField("requiresMount", boolean.class) };
+    private static final long serialVersionUID = -4509594124653184349L;
 
-    /** Minimal info to get full vfs file structure */
-    private URL rootUrl;
-    private String path;
-    private boolean requiresMount;
-    /** The virtual file */
     private transient VirtualFile file;
 
     public VirtualFileAdaptor(VirtualFile file) {
         this.file = file;
     }
 
-    public VirtualFileAdaptor(URL rootUrl, String path) {
-        this(rootUrl, path, false);
-    }
-
-    protected VirtualFileAdaptor(URL rootUrl, String path, boolean requiresMount) {
-        if (rootUrl == null)
-            throw MESSAGES.nullRootUrl();
-        if (path == null)
-            throw MESSAGES.nullPath();
-
-        this.rootUrl = rootUrl;
-        this.path = path;
-        this.requiresMount = requiresMount;
-    }
-
-    /**
-     * Get the virtual file. Create file from root url and path if it doesn't exist yet.
-     *
-     * @return virtual file root
-     * @throws IOException for any error
-     */
-    protected VirtualFile getFile() throws IOException {
-        if (file == null) {
-            VirtualFile root;
-            try {
-                root = VFS.getChild(rootUrl.toURI());
-            } catch (URISyntaxException e) {
-                throw MESSAGES.cannotGetVirtualFile(e, rootUrl);
-            }
-            file = root.getChild(path);
-
-            if (!file.exists()) {
-                throw MESSAGES.missingVirtualFile(file);
-            } else if (requiresMount && !isMounted(root, file)) {
-                throw MESSAGES.unmountedVirtualFile(file);
-            }
-        }
+    private VirtualFile getFile() throws IOException {
         return file;
     }
 
-    private static boolean isMounted(VirtualFile root, VirtualFile child) throws IOException {
-        return !(root.getPathName().equals(root.getPhysicalFile().getAbsolutePath()) && child.getPathName().equals(
-                child.getPhysicalFile().getAbsolutePath()));
-    }
-
     public UnifiedVirtualFile findChild(String child) throws IOException {
         final VirtualFile virtualFile = getFile();
         final VirtualFile childFile = file.getChild(child);
@@ -132,84 +68,6 @@
         }
     }
 
-    public void writeContent(OutputStream bos) throws IOException {
-        writeContent(bos, null);
-    }
-
-    public void writeContent(OutputStream bos, NameFilter filter) throws IOException {
-        InputStream is = null;
-        try {
-            is = getFile().openStream();
-            if (is instanceof JarInputStream) {
-                JarInputStream jis = (JarInputStream) is;
-                JarOutputStream os = new JarOutputStream(bos);
-                JarEntry je = null;
-                while ((je = jis.getNextJarEntry()) != null) {
-                    if (filter != null && filter.accept(je.getName())) {
-                        os.putNextEntry(je);
-                        VFSUtils.copyStream(jis, os);
-                    }
-                }
-                VFSUtils.safeClose(os);
-            } else {
-                VFSUtils.copyStream(is, bos);
-            }
-        } finally {
-            VFSUtils.safeClose(is);
-        }
-    }
-
-    private void writeObject(ObjectOutputStream out) throws IOException, URISyntaxException {
-        VirtualFile file = getFile();
-        URL url = rootUrl;
-        if (url == null) {
-            VirtualFile parentFile = file.getParent();
-            url = parentFile != null ? parentFile.toURL() : null;
-        }
-        String pathName = path;
-        if (pathName == null)
-            pathName = file.getName();
-
-        ObjectOutputStream.PutField fields = out.putFields();
-        fields.put("rootUrl", url);
-        fields.put("path", pathName);
-
-        URI uri = url != null ? url.toURI() : null;
-        VirtualFile newRoot = VFS.getChild(uri);
-        VirtualFile newChild = newRoot.getChild(pathName);
-        fields.put("requiresMount", isMounted(newRoot, newChild));
-
-        out.writeFields();
-    }
-
-    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
-        ObjectInputStream.GetField fields = in.readFields();
-        rootUrl = (URL) fields.get("rootUrl", null);
-        path = (String) fields.get("path", null);
-        requiresMount = fields.get("requiresMount", false);
-    }
-
-    private Object writeReplace() {
-        // TODO: hack to enable remote tests
-        try {
-            File archive = file.getPhysicalFile();
-            if (archive.list().length == 0) {
-                final File parent = file.getPhysicalFile().getParentFile();
-                final File[] children = parent.listFiles(new FileFilter() {
-                    @Override
-                    public boolean accept(File fileOrDir) {
-                        return fileOrDir.isFile();
-                    }
-                });
-                archive = children[0];
-            }
-            // Offer different UnifiedVirtualFile implementation for deserialization process
-            return new URLLoaderAdapter(archive.toURI().toURL());
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
-    }
-
     public List<UnifiedVirtualFile> getChildren() throws IOException {
         List<VirtualFile> vfList = getFile().getChildren();
         if (vfList == null)

Modified: container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WSRefUtils.java
===================================================================
--- container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WSRefUtils.java	2012-11-16 14:15:11 UTC (rev 17011)
+++ container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WSRefUtils.java	2012-11-16 14:39:04 UTC (rev 17012)
@@ -57,7 +57,7 @@
 import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedPortComponentRefMetaData;
 import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
 import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedStubPropertyMetaData;
-import org.jboss.wsf.spi.serviceref.ServiceRefHandler.Type;
+import org.jboss.wsf.spi.serviceref.ServiceRefType;
 
 /**
  * Translates WS Refs from JBossAS MD to JBossWS UMDM format.
@@ -241,7 +241,7 @@
 
     static void processType(final UnifiedServiceRefMetaData serviceRefUMDM) {
         final boolean isJAXRPC = serviceRefUMDM.getMappingFile() != null || "javax.xml.rpc.Service".equals(serviceRefUMDM.getServiceInterface());
-        serviceRefUMDM.setType(isJAXRPC ? Type.JAXRPC : Type.JAXWS);
+        serviceRefUMDM.setType(isJAXRPC ? ServiceRefType.JAXRPC : ServiceRefType.JAXWS);
     }
 
     static void processAnnotatedElement(final AnnotatedElement anElement, final UnifiedServiceRefMetaData serviceRefUMDM) {

Modified: container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WSRefValueSource.java
===================================================================
--- container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WSRefValueSource.java	2012-11-16 14:15:11 UTC (rev 17011)
+++ container/jboss71/branches/jbossws-jboss711/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WSRefValueSource.java	2012-11-16 14:39:04 UTC (rev 17012)
@@ -25,9 +25,6 @@
 import static org.jboss.as.webservices.webserviceref.SecurityActions.getContextClassLoader;
 import static org.jboss.as.webservices.webserviceref.SecurityActions.setContextClassLoader;
 
-import javax.naming.Referenceable;
-import javax.naming.spi.ObjectFactory;
-
 import org.jboss.as.ee.component.InjectionSource;
 import org.jboss.as.naming.ManagedReferenceFactory;
 import org.jboss.as.naming.ValueManagedReferenceFactory;
@@ -41,9 +38,9 @@
 import org.jboss.wsf.spi.SPIProviderResolver;
 import org.jboss.wsf.spi.classloading.ClassLoaderProvider;
 import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-import org.jboss.wsf.spi.serviceref.ServiceRefHandler;
-import org.jboss.wsf.spi.serviceref.ServiceRefHandler.Type;
-import org.jboss.wsf.spi.serviceref.ServiceRefHandlerFactory;
+import org.jboss.wsf.spi.serviceref.ServiceRefType;
+import org.jboss.wsf.spi.serviceref.ServiceRefFactory;
+import org.jboss.wsf.spi.serviceref.ServiceRefFactoryFactory;
 
 /**
  * WebServiceRef injection source.
@@ -64,17 +61,13 @@
         serviceBuilder.addInjection(injector, factory);
     }
 
-    public Object getValue() throws IllegalStateException, IllegalArgumentException {
+    public Object getValue() {
         final ClassLoader oldCL = getContextClassLoader();
         try {
             final ClassLoader integrationCL = new DelegateClassLoader(getClassLoader(), classLoader);
             setContextClassLoader(integrationCL);
-            final Referenceable referenceable = getReferenceable(integrationCL);
-            final Class<?> clazz = Class.forName(referenceable.getReference().getFactoryClassName(), true, integrationCL);
-            final ObjectFactory factory = (ObjectFactory)clazz.newInstance();
-            return factory.getObjectInstance(referenceable.getReference(), null, null, null);
-        } catch (final Exception e) {
-            throw new RuntimeException(e);
+            final ServiceRefFactory serviceRefFactory = getServiceRefFactory();
+            return serviceRefFactory.newServiceRef(serviceRef);
         } finally {
             setContextClassLoader(oldCL);
         }
@@ -82,17 +75,16 @@
 
     private ClassLoader getClassLoader() {
         ClassLoaderProvider provider = ClassLoaderProvider.getDefaultProvider();
-        if (!Type.JAXRPC.equals(serviceRef.getType())) {
+        if (!ServiceRefType.JAXRPC.equals(serviceRef.getType())) {
             return provider.getServerIntegrationClassLoader();
         } else {
             return provider.getServerJAXRPCIntegrationClassLoader();
         }
     }
 
-    private Referenceable getReferenceable(final ClassLoader loader) {
+    private ServiceRefFactory getServiceRefFactory() {
         final SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
-        final ServiceRefHandler serviceRefHandler = spiProvider.getSPI(ServiceRefHandlerFactory.class, loader).getServiceRefHandler();
-        return serviceRefHandler.createReferenceable(serviceRef);
+        return spiProvider.getSPI(ServiceRefFactoryFactory.class).newServiceRefFactory();
     }
 
 }
\ No newline at end of file

Modified: container/jboss71/branches/jbossws-jboss712/pom.xml
===================================================================
--- container/jboss71/branches/jbossws-jboss712/pom.xml	2012-11-16 14:15:11 UTC (rev 17011)
+++ container/jboss71/branches/jbossws-jboss712/pom.xml	2012-11-16 14:39:04 UTC (rev 17012)
@@ -51,8 +51,8 @@
 
   <properties>
     <jbossws.api.version>1.0.1.Final</jbossws.api.version>
-    <jbossws.spi.version>2.1.0.Final</jbossws.spi.version>
-    <jbossws.common.version>2.1.0.Final</jbossws.common.version>
+    <jbossws.spi.version>2.1.1-SNAPSHOT</jbossws.spi.version>
+    <jbossws.common.version>2.1.1-SNAPSHOT</jbossws.common.version>
     <jboss.msc.version>1.0.2.GA</jboss.msc.version>
     <jboss.version>7.1.2.Final</jboss.version>
     <jboss.jaxws.api.version>2.0.1.Final</jboss.jaxws.api.version>

Modified: container/jboss71/branches/jbossws-jboss712/server-integration/src/main/java/org/jboss/as/webservices/util/VirtualFileAdaptor.java
===================================================================
--- container/jboss71/branches/jbossws-jboss712/server-integration/src/main/java/org/jboss/as/webservices/util/VirtualFileAdaptor.java	2012-11-16 14:15:11 UTC (rev 17011)
+++ container/jboss71/branches/jbossws-jboss712/server-integration/src/main/java/org/jboss/as/webservices/util/VirtualFileAdaptor.java	2012-11-16 14:39:04 UTC (rev 17012)
@@ -23,29 +23,13 @@
 
 import static org.jboss.as.webservices.WSMessages.MESSAGES;
 
-import java.io.File;
-import java.io.FileFilter;
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.ObjectStreamField;
-import java.io.OutputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.jar.JarEntry;
-import java.util.jar.JarInputStream;
-import java.util.jar.JarOutputStream;
 
-import org.jboss.vfs.VFS;
-import org.jboss.vfs.VFSUtils;
 import org.jboss.vfs.VirtualFile;
 import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
-import org.jboss.wsf.spi.deployment.WritableUnifiedVirtualFile;
-import org.jboss.wsf.spi.util.URLLoaderAdapter;
 
 /**
  * A VirtualFile adaptor.
@@ -54,68 +38,20 @@
  * @author Ales.Justin at jboss.org
  * @author alessio.soldano at jboss.com
  */
-public final class VirtualFileAdaptor implements WritableUnifiedVirtualFile {
-    private static final long serialVersionUID = -4509594124653184348L;
+public final class VirtualFileAdaptor implements UnifiedVirtualFile {
 
-    private static final ObjectStreamField[] serialPersistentFields = { new ObjectStreamField("rootUrl", URL.class),
-            new ObjectStreamField("path", String.class), new ObjectStreamField("requiresMount", boolean.class) };
+    private static final long serialVersionUID = -4509594124653184349L;
 
-    /** Minimal info to get full vfs file structure */
-    private URL rootUrl;
-    private String path;
-    private boolean requiresMount;
-    /** The virtual file */
     private transient VirtualFile file;
 
     public VirtualFileAdaptor(VirtualFile file) {
         this.file = file;
     }
 
-    public VirtualFileAdaptor(URL rootUrl, String path) {
-        this(rootUrl, path, false);
-    }
-
-    protected VirtualFileAdaptor(URL rootUrl, String path, boolean requiresMount) {
-        if (rootUrl == null)
-            throw MESSAGES.nullRootUrl();
-        if (path == null)
-            throw MESSAGES.nullPath();
-
-        this.rootUrl = rootUrl;
-        this.path = path;
-        this.requiresMount = requiresMount;
-    }
-
-    /**
-     * Get the virtual file. Create file from root url and path if it doesn't exist yet.
-     *
-     * @return virtual file root
-     * @throws IOException for any error
-     */
-    protected VirtualFile getFile() throws IOException {
-        if (file == null) {
-            VirtualFile root;
-            try {
-                root = VFS.getChild(rootUrl.toURI());
-            } catch (URISyntaxException e) {
-                throw MESSAGES.cannotGetVirtualFile(e, rootUrl);
-            }
-            file = root.getChild(path);
-
-            if (!file.exists()) {
-                throw MESSAGES.missingVirtualFile(file);
-            } else if (requiresMount && !isMounted(root, file)) {
-                throw MESSAGES.unmountedVirtualFile(file);
-            }
-        }
+    private VirtualFile getFile() throws IOException {
         return file;
     }
 
-    private static boolean isMounted(VirtualFile root, VirtualFile child) throws IOException {
-        return !(root.getPathName().equals(root.getPhysicalFile().getAbsolutePath()) && child.getPathName().equals(
-                child.getPhysicalFile().getAbsolutePath()));
-    }
-
     public UnifiedVirtualFile findChild(String child) throws IOException {
         final VirtualFile virtualFile = getFile();
         final VirtualFile childFile = file.getChild(child);
@@ -132,84 +68,6 @@
         }
     }
 
-    public void writeContent(OutputStream bos) throws IOException {
-        writeContent(bos, null);
-    }
-
-    public void writeContent(OutputStream bos, NameFilter filter) throws IOException {
-        InputStream is = null;
-        try {
-            is = getFile().openStream();
-            if (is instanceof JarInputStream) {
-                JarInputStream jis = (JarInputStream) is;
-                JarOutputStream os = new JarOutputStream(bos);
-                JarEntry je = null;
-                while ((je = jis.getNextJarEntry()) != null) {
-                    if (filter != null && filter.accept(je.getName())) {
-                        os.putNextEntry(je);
-                        VFSUtils.copyStream(jis, os);
-                    }
-                }
-                VFSUtils.safeClose(os);
-            } else {
-                VFSUtils.copyStream(is, bos);
-            }
-        } finally {
-            VFSUtils.safeClose(is);
-        }
-    }
-
-    private void writeObject(ObjectOutputStream out) throws IOException, URISyntaxException {
-        VirtualFile file = getFile();
-        URL url = rootUrl;
-        if (url == null) {
-            VirtualFile parentFile = file.getParent();
-            url = parentFile != null ? parentFile.toURL() : null;
-        }
-        String pathName = path;
-        if (pathName == null)
-            pathName = file.getName();
-
-        ObjectOutputStream.PutField fields = out.putFields();
-        fields.put("rootUrl", url);
-        fields.put("path", pathName);
-
-        URI uri = url != null ? url.toURI() : null;
-        VirtualFile newRoot = VFS.getChild(uri);
-        VirtualFile newChild = newRoot.getChild(pathName);
-        fields.put("requiresMount", isMounted(newRoot, newChild));
-
-        out.writeFields();
-    }
-
-    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
-        ObjectInputStream.GetField fields = in.readFields();
-        rootUrl = (URL) fields.get("rootUrl", null);
-        path = (String) fields.get("path", null);
-        requiresMount = fields.get("requiresMount", false);
-    }
-
-    private Object writeReplace() {
-        // TODO: hack to enable remote tests
-        try {
-            File archive = file.getPhysicalFile();
-            if (archive.list().length == 0) {
-                final File parent = file.getPhysicalFile().getParentFile();
-                final File[] children = parent.listFiles(new FileFilter() {
-                    @Override
-                    public boolean accept(File fileOrDir) {
-                        return fileOrDir.isFile();
-                    }
-                });
-                archive = children[0];
-            }
-            // Offer different UnifiedVirtualFile implementation for deserialization process
-            return new URLLoaderAdapter(archive.toURI().toURL());
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
-    }
-
     public List<UnifiedVirtualFile> getChildren() throws IOException {
         List<VirtualFile> vfList = getFile().getChildren();
         if (vfList == null)

Modified: container/jboss71/branches/jbossws-jboss712/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WSRefUtils.java
===================================================================
--- container/jboss71/branches/jbossws-jboss712/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WSRefUtils.java	2012-11-16 14:15:11 UTC (rev 17011)
+++ container/jboss71/branches/jbossws-jboss712/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WSRefUtils.java	2012-11-16 14:39:04 UTC (rev 17012)
@@ -57,7 +57,7 @@
 import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedPortComponentRefMetaData;
 import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
 import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedStubPropertyMetaData;
-import org.jboss.wsf.spi.serviceref.ServiceRefHandler.Type;
+import org.jboss.wsf.spi.serviceref.ServiceRefType;
 
 /**
  * Translates WS Refs from JBossAS MD to JBossWS UMDM format.
@@ -241,7 +241,7 @@
 
     static void processType(final UnifiedServiceRefMetaData serviceRefUMDM) {
         final boolean isJAXRPC = serviceRefUMDM.getMappingFile() != null || "javax.xml.rpc.Service".equals(serviceRefUMDM.getServiceInterface());
-        serviceRefUMDM.setType(isJAXRPC ? Type.JAXRPC : Type.JAXWS);
+        serviceRefUMDM.setType(isJAXRPC ? ServiceRefType.JAXRPC : ServiceRefType.JAXWS);
     }
 
     static void processAnnotatedElement(final AnnotatedElement anElement, final UnifiedServiceRefMetaData serviceRefUMDM) {

Modified: container/jboss71/branches/jbossws-jboss712/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WSRefValueSource.java
===================================================================
--- container/jboss71/branches/jbossws-jboss712/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WSRefValueSource.java	2012-11-16 14:15:11 UTC (rev 17011)
+++ container/jboss71/branches/jbossws-jboss712/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WSRefValueSource.java	2012-11-16 14:39:04 UTC (rev 17012)
@@ -25,9 +25,6 @@
 import static org.jboss.as.webservices.webserviceref.SecurityActions.getContextClassLoader;
 import static org.jboss.as.webservices.webserviceref.SecurityActions.setContextClassLoader;
 
-import javax.naming.Referenceable;
-import javax.naming.spi.ObjectFactory;
-
 import org.jboss.as.ee.component.InjectionSource;
 import org.jboss.as.naming.ManagedReferenceFactory;
 import org.jboss.as.naming.ValueManagedReferenceFactory;
@@ -41,9 +38,9 @@
 import org.jboss.wsf.spi.SPIProviderResolver;
 import org.jboss.wsf.spi.classloading.ClassLoaderProvider;
 import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-import org.jboss.wsf.spi.serviceref.ServiceRefHandler;
-import org.jboss.wsf.spi.serviceref.ServiceRefHandler.Type;
-import org.jboss.wsf.spi.serviceref.ServiceRefHandlerFactory;
+import org.jboss.wsf.spi.serviceref.ServiceRefType;
+import org.jboss.wsf.spi.serviceref.ServiceRefFactory;
+import org.jboss.wsf.spi.serviceref.ServiceRefFactoryFactory;
 
 /**
  * WebServiceRef injection source.
@@ -64,17 +61,13 @@
         serviceBuilder.addInjection(injector, factory);
     }
 
-    public Object getValue() throws IllegalStateException, IllegalArgumentException {
+    public Object getValue() {
         final ClassLoader oldCL = getContextClassLoader();
         try {
             final ClassLoader integrationCL = new DelegateClassLoader(getClassLoader(), classLoader);
             setContextClassLoader(integrationCL);
-            final Referenceable referenceable = getReferenceable(integrationCL);
-            final Class<?> clazz = Class.forName(referenceable.getReference().getFactoryClassName(), true, integrationCL);
-            final ObjectFactory factory = (ObjectFactory)clazz.newInstance();
-            return factory.getObjectInstance(referenceable.getReference(), null, null, null);
-        } catch (final Exception e) {
-            throw new RuntimeException(e);
+            final ServiceRefFactory serviceRefFactory = getServiceRefFactory();
+            return serviceRefFactory.newServiceRef(serviceRef);
         } finally {
             setContextClassLoader(oldCL);
         }
@@ -82,17 +75,16 @@
 
     private ClassLoader getClassLoader() {
         ClassLoaderProvider provider = ClassLoaderProvider.getDefaultProvider();
-        if (!Type.JAXRPC.equals(serviceRef.getType())) {
+        if (!ServiceRefType.JAXRPC.equals(serviceRef.getType())) {
             return provider.getServerIntegrationClassLoader();
         } else {
             return provider.getServerJAXRPCIntegrationClassLoader();
         }
     }
 
-    private Referenceable getReferenceable(final ClassLoader loader) {
+    private ServiceRefFactory getServiceRefFactory() {
         final SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
-        final ServiceRefHandler serviceRefHandler = spiProvider.getSPI(ServiceRefHandlerFactory.class, loader).getServiceRefHandler();
-        return serviceRefHandler.createReferenceable(serviceRef);
+        return spiProvider.getSPI(ServiceRefFactoryFactory.class).newServiceRefFactory();
     }
 
 }
\ No newline at end of file

Modified: container/jboss71/branches/jbossws-jboss713/pom.xml
===================================================================
(Binary files differ)

Modified: container/jboss71/branches/jbossws-jboss713/server-integration/src/main/java/org/jboss/as/webservices/util/VirtualFileAdaptor.java
===================================================================
--- container/jboss71/branches/jbossws-jboss713/server-integration/src/main/java/org/jboss/as/webservices/util/VirtualFileAdaptor.java	2012-11-16 14:15:11 UTC (rev 17011)
+++ container/jboss71/branches/jbossws-jboss713/server-integration/src/main/java/org/jboss/as/webservices/util/VirtualFileAdaptor.java	2012-11-16 14:39:04 UTC (rev 17012)
@@ -23,29 +23,13 @@
 
 import static org.jboss.as.webservices.WSMessages.MESSAGES;
 
-import java.io.File;
-import java.io.FileFilter;
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.ObjectStreamField;
-import java.io.OutputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.jar.JarEntry;
-import java.util.jar.JarInputStream;
-import java.util.jar.JarOutputStream;
 
-import org.jboss.vfs.VFS;
-import org.jboss.vfs.VFSUtils;
 import org.jboss.vfs.VirtualFile;
 import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
-import org.jboss.wsf.spi.deployment.WritableUnifiedVirtualFile;
-import org.jboss.wsf.spi.util.URLLoaderAdapter;
 
 /**
  * A VirtualFile adaptor.
@@ -54,68 +38,20 @@
  * @author Ales.Justin at jboss.org
  * @author alessio.soldano at jboss.com
  */
-public final class VirtualFileAdaptor implements WritableUnifiedVirtualFile {
-    private static final long serialVersionUID = -4509594124653184348L;
+public final class VirtualFileAdaptor implements UnifiedVirtualFile {
 
-    private static final ObjectStreamField[] serialPersistentFields = { new ObjectStreamField("rootUrl", URL.class),
-            new ObjectStreamField("path", String.class), new ObjectStreamField("requiresMount", boolean.class) };
+    private static final long serialVersionUID = -4509594124653184349L;
 
-    /** Minimal info to get full vfs file structure */
-    private URL rootUrl;
-    private String path;
-    private boolean requiresMount;
-    /** The virtual file */
     private transient VirtualFile file;
 
     public VirtualFileAdaptor(VirtualFile file) {
         this.file = file;
     }
 
-    public VirtualFileAdaptor(URL rootUrl, String path) {
-        this(rootUrl, path, false);
-    }
-
-    protected VirtualFileAdaptor(URL rootUrl, String path, boolean requiresMount) {
-        if (rootUrl == null)
-            throw MESSAGES.nullRootUrl();
-        if (path == null)
-            throw MESSAGES.nullPath();
-
-        this.rootUrl = rootUrl;
-        this.path = path;
-        this.requiresMount = requiresMount;
-    }
-
-    /**
-     * Get the virtual file. Create file from root url and path if it doesn't exist yet.
-     *
-     * @return virtual file root
-     * @throws IOException for any error
-     */
-    protected VirtualFile getFile() throws IOException {
-        if (file == null) {
-            VirtualFile root;
-            try {
-                root = VFS.getChild(rootUrl.toURI());
-            } catch (URISyntaxException e) {
-                throw MESSAGES.cannotGetVirtualFile(e, rootUrl);
-            }
-            file = root.getChild(path);
-
-            if (!file.exists()) {
-                throw MESSAGES.missingVirtualFile(file);
-            } else if (requiresMount && !isMounted(root, file)) {
-                throw MESSAGES.unmountedVirtualFile(file);
-            }
-        }
+    private VirtualFile getFile() throws IOException {
         return file;
     }
 
-    private static boolean isMounted(VirtualFile root, VirtualFile child) throws IOException {
-        return !(root.getPathName().equals(root.getPhysicalFile().getAbsolutePath()) && child.getPathName().equals(
-                child.getPhysicalFile().getAbsolutePath()));
-    }
-
     public UnifiedVirtualFile findChild(String child) throws IOException {
         final VirtualFile virtualFile = getFile();
         final VirtualFile childFile = file.getChild(child);
@@ -132,84 +68,6 @@
         }
     }
 
-    public void writeContent(OutputStream bos) throws IOException {
-        writeContent(bos, null);
-    }
-
-    public void writeContent(OutputStream bos, NameFilter filter) throws IOException {
-        InputStream is = null;
-        try {
-            is = getFile().openStream();
-            if (is instanceof JarInputStream) {
-                JarInputStream jis = (JarInputStream) is;
-                JarOutputStream os = new JarOutputStream(bos);
-                JarEntry je = null;
-                while ((je = jis.getNextJarEntry()) != null) {
-                    if (filter != null && filter.accept(je.getName())) {
-                        os.putNextEntry(je);
-                        VFSUtils.copyStream(jis, os);
-                    }
-                }
-                VFSUtils.safeClose(os);
-            } else {
-                VFSUtils.copyStream(is, bos);
-            }
-        } finally {
-            VFSUtils.safeClose(is);
-        }
-    }
-
-    private void writeObject(ObjectOutputStream out) throws IOException, URISyntaxException {
-        VirtualFile file = getFile();
-        URL url = rootUrl;
-        if (url == null) {
-            VirtualFile parentFile = file.getParent();
-            url = parentFile != null ? parentFile.toURL() : null;
-        }
-        String pathName = path;
-        if (pathName == null)
-            pathName = file.getName();
-
-        ObjectOutputStream.PutField fields = out.putFields();
-        fields.put("rootUrl", url);
-        fields.put("path", pathName);
-
-        URI uri = url != null ? url.toURI() : null;
-        VirtualFile newRoot = VFS.getChild(uri);
-        VirtualFile newChild = newRoot.getChild(pathName);
-        fields.put("requiresMount", isMounted(newRoot, newChild));
-
-        out.writeFields();
-    }
-
-    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
-        ObjectInputStream.GetField fields = in.readFields();
-        rootUrl = (URL) fields.get("rootUrl", null);
-        path = (String) fields.get("path", null);
-        requiresMount = fields.get("requiresMount", false);
-    }
-
-    private Object writeReplace() {
-        // TODO: hack to enable remote tests
-        try {
-            File archive = file.getPhysicalFile();
-            if (archive.list().length == 0) {
-                final File parent = file.getPhysicalFile().getParentFile();
-                final File[] children = parent.listFiles(new FileFilter() {
-                    @Override
-                    public boolean accept(File fileOrDir) {
-                        return fileOrDir.isFile();
-                    }
-                });
-                archive = children[0];
-            }
-            // Offer different UnifiedVirtualFile implementation for deserialization process
-            return new URLLoaderAdapter(archive.toURI().toURL());
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
-    }
-
     public List<UnifiedVirtualFile> getChildren() throws IOException {
         List<VirtualFile> vfList = getFile().getChildren();
         if (vfList == null)

Modified: container/jboss71/branches/jbossws-jboss713/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WSRefUtils.java
===================================================================
--- container/jboss71/branches/jbossws-jboss713/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WSRefUtils.java	2012-11-16 14:15:11 UTC (rev 17011)
+++ container/jboss71/branches/jbossws-jboss713/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WSRefUtils.java	2012-11-16 14:39:04 UTC (rev 17012)
@@ -57,7 +57,7 @@
 import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedPortComponentRefMetaData;
 import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
 import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedStubPropertyMetaData;
-import org.jboss.wsf.spi.serviceref.ServiceRefHandler.Type;
+import org.jboss.wsf.spi.serviceref.ServiceRefType;
 
 /**
  * Translates WS Refs from JBossAS MD to JBossWS UMDM format.
@@ -241,7 +241,7 @@
 
     static void processType(final UnifiedServiceRefMetaData serviceRefUMDM) {
         final boolean isJAXRPC = serviceRefUMDM.getMappingFile() != null || "javax.xml.rpc.Service".equals(serviceRefUMDM.getServiceInterface());
-        serviceRefUMDM.setType(isJAXRPC ? Type.JAXRPC : Type.JAXWS);
+        serviceRefUMDM.setType(isJAXRPC ? ServiceRefType.JAXRPC : ServiceRefType.JAXWS);
     }
 
     static void processAnnotatedElement(final AnnotatedElement anElement, final UnifiedServiceRefMetaData serviceRefUMDM) {

Modified: container/jboss71/branches/jbossws-jboss713/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WSRefValueSource.java
===================================================================
--- container/jboss71/branches/jbossws-jboss713/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WSRefValueSource.java	2012-11-16 14:15:11 UTC (rev 17011)
+++ container/jboss71/branches/jbossws-jboss713/server-integration/src/main/java/org/jboss/as/webservices/webserviceref/WSRefValueSource.java	2012-11-16 14:39:04 UTC (rev 17012)
@@ -25,9 +25,6 @@
 import static org.jboss.as.webservices.webserviceref.SecurityActions.getContextClassLoader;
 import static org.jboss.as.webservices.webserviceref.SecurityActions.setContextClassLoader;
 
-import javax.naming.Referenceable;
-import javax.naming.spi.ObjectFactory;
-
 import org.jboss.as.ee.component.InjectionSource;
 import org.jboss.as.naming.ManagedReferenceFactory;
 import org.jboss.as.naming.ValueManagedReferenceFactory;
@@ -41,9 +38,9 @@
 import org.jboss.wsf.spi.SPIProviderResolver;
 import org.jboss.wsf.spi.classloading.ClassLoaderProvider;
 import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-import org.jboss.wsf.spi.serviceref.ServiceRefHandler;
-import org.jboss.wsf.spi.serviceref.ServiceRefHandler.Type;
-import org.jboss.wsf.spi.serviceref.ServiceRefHandlerFactory;
+import org.jboss.wsf.spi.serviceref.ServiceRefType;
+import org.jboss.wsf.spi.serviceref.ServiceRefFactory;
+import org.jboss.wsf.spi.serviceref.ServiceRefFactoryFactory;
 
 /**
  * WebServiceRef injection source.
@@ -64,17 +61,13 @@
         serviceBuilder.addInjection(injector, factory);
     }
 
-    public Object getValue() throws IllegalStateException, IllegalArgumentException {
+    public Object getValue() {
         final ClassLoader oldCL = getContextClassLoader();
         try {
             final ClassLoader integrationCL = new DelegateClassLoader(getClassLoader(), classLoader);
             setContextClassLoader(integrationCL);
-            final Referenceable referenceable = getReferenceable(integrationCL);
-            final Class<?> clazz = Class.forName(referenceable.getReference().getFactoryClassName(), true, integrationCL);
-            final ObjectFactory factory = (ObjectFactory)clazz.newInstance();
-            return factory.getObjectInstance(referenceable.getReference(), null, null, null);
-        } catch (final Exception e) {
-            throw new RuntimeException(e);
+            final ServiceRefFactory serviceRefFactory = getServiceRefFactory();
+            return serviceRefFactory.newServiceRef(serviceRef);
         } finally {
             setContextClassLoader(oldCL);
         }
@@ -82,17 +75,16 @@
 
     private ClassLoader getClassLoader() {
         ClassLoaderProvider provider = ClassLoaderProvider.getDefaultProvider();
-        if (!Type.JAXRPC.equals(serviceRef.getType())) {
+        if (!ServiceRefType.JAXRPC.equals(serviceRef.getType())) {
             return provider.getServerIntegrationClassLoader();
         } else {
             return provider.getServerJAXRPCIntegrationClassLoader();
         }
     }
 
-    private Referenceable getReferenceable(final ClassLoader loader) {
+    private ServiceRefFactory getServiceRefFactory() {
         final SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
-        final ServiceRefHandler serviceRefHandler = spiProvider.getSPI(ServiceRefHandlerFactory.class, loader).getServiceRefHandler();
-        return serviceRefHandler.createReferenceable(serviceRef);
+        return spiProvider.getSPI(ServiceRefFactoryFactory.class).newServiceRefFactory();
     }
 
 }
\ No newline at end of file



More information about the jbossws-commits mailing list