[jboss-cvs] JBossAS SVN: r91717 - in projects/embedded/trunk: core/src/main/java/org/jboss/embedded/core/incubation/deployable/api and 12 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jul 28 11:47:33 EDT 2009
Author: ALRubinger
Date: 2009-07-28 11:47:32 -0400 (Tue, 28 Jul 2009)
New Revision: 91717
Added:
projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/api/
projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/api/Deployable.java
projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/api/DeployableFactory.java
projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/api/DeploymentException.java
projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/api/SecurityActions.java
projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/api/
projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/api/SecurityActions.java
projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/api/VirtualArchive.java
projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/api/VirtualArchiveFactory.java
projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/incubation/virtual/vfs/VirtualVfsArchiveFactoryTestCase.java
Removed:
projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/spi/Deployable.java
projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/spi/DeployableFactory.java
projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/spi/DeploymentException.java
projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/spi/SecurityActions.java
projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/spi/ExtensibleVirtualArchive.java
projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/spi/vfs/ExtensibleVirtualVfsArchive.java
projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/tempdev/
Modified:
projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/spi/vdf/VdfDeployable.java
projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/impl/base/AbstractVirtualArchive.java
projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/impl/vfs/VirtualVfsArchiveImpl.java
projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/spi/vfs/VirtualVfsArchive.java
projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/server/JBossASEmbeddedServer.java
projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/server/JBossASEmbeddedServerImpl.java
projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/incubation/deployable/vfs/VfsVdfDeployableFactoryTestCase.java
projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/incubation/virtual/vfs/VirtualVfsArchiveTestCase.java
projects/embedded/trunk/testsuite-full-dep/src/test/java/org/jboss/ServerTestCase.java
Log:
[EMB-32] Remove covarient return from VirtualArchives, separate SPI/API from VirtualArchives and Deployables, create VirtualArchive factory
Copied: projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/api/Deployable.java (from rev 91698, projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/spi/Deployable.java)
===================================================================
--- projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/api/Deployable.java (rev 0)
+++ projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/api/Deployable.java 2009-07-28 15:47:32 UTC (rev 91717)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.embedded.core.incubation.deployable.api;
+
+/**
+ * Deployable
+ *
+ * Represents an entity which is eligible for deployment into an
+ * Embedded Server.
+ *
+ * In practice, this is a marker interface, where an embedded server may
+ * support a finite set of the children of this type.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface Deployable
+{
+
+}
Copied: projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/api/DeployableFactory.java (from rev 91698, projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/spi/DeployableFactory.java)
===================================================================
--- projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/api/DeployableFactory.java (rev 0)
+++ projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/api/DeployableFactory.java 2009-07-28 15:47:32 UTC (rev 91717)
@@ -0,0 +1,232 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.embedded.core.incubation.deployable.api;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+import org.jboss.embedded.core.incubation.virtual.api.VirtualArchive;
+import org.jboss.logging.Logger;
+
+/**
+ * DeployableFactory
+ *
+ * Factory to create {@link Deployable} instances from
+ * {@link VirtualArchive}s. This removes the API
+ * dependency upon internals for the client view and additionally
+ * acts as a convenience mechanism.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class DeployableFactory
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(DeployableFactory.class);
+
+ /**
+ * FQN of implementation Class used in creating new Deployables
+ */
+ private static final String CLASS_NAME_VFS_VDF_DEPLOYABLE = "org.jboss.embedded.core.incubation.deployable.impl.vdf.VfsVdfDeployable";
+
+ /**
+ * FQN of type of parameter to implementation class constructor
+ */
+ private static final String CLASS_NAME_CTOR_PARAMETER = "org.jboss.embedded.core.incubation.virtual.spi.vfs.VirtualVfsArchive";
+
+ /**
+ * FQN of the archive type actually supported by {@link DeployableFactory#createDeployable(VirtualArchive)}
+ */
+ private static final String CLASS_NAME_ARCHIVE_TYPE = "org.jboss.embedded.core.incubation.virtual.spi.vfs.VirtualVfsArchive";
+
+ /**
+ * Constructor used in creating new {@link Deployable} instances
+ */
+ private static Constructor<?> constructor;
+
+ /**
+ * The actual type expected of archives passed to
+ * {@link DeployableFactory#createDeployable(VirtualArchive)};
+ * used here to do runtime type checking so we hide the internals and don't
+ * leak out APIs to the client. Will have FQN of {@link DeployableFactory#CLASS_NAME_ARCHIVE_TYPE}.
+ */
+ private static Class<?> supportedArchiveType;
+
+ //-------------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Internal Constructor to prohibit external
+ * instantiation
+ */
+ private DeployableFactory()
+ {
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Functional Methods -----------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Creates a {@link Deployable} from the specified archive
+ *
+ * @param archive
+ * @throws IllegalArgumentException If the archive is not specified or an unsupported type
+ */
+ public static Deployable createDeployable(final VirtualArchive archive) throws IllegalArgumentException
+ {
+ // Precondition check
+ final Class<?> supportedArchiveType = getSupportedArchiveType();
+ if (!supportedArchiveType.isAssignableFrom(archive.getClass()))
+ {
+ final ClassLoader archiveCl = archive.getClass().getClassLoader();
+ final ClassLoader supportedCl = supportedArchiveType.getClassLoader();
+ log.warn("Archive CL: " + archiveCl);
+ log.warn("Expected CL: " + supportedCl);
+ throw new IllegalArgumentException("Specified archive must be of type " + supportedArchiveType.getName()
+ + "; was instead: " + archive);
+ }
+
+ // Get the implementation ctor
+ final Constructor<?> constructor = getConstructor();
+
+ // Make a new instance
+ final Object obj;
+ try
+ {
+ obj = constructor.newInstance(archive);
+ if (log.isTraceEnabled())
+ {
+ log.trace("Created: " + obj);
+ }
+ }
+ catch (final InstantiationException e)
+ {
+ throw new RuntimeException("Error in creating new " + Deployable.class.getName(), e);
+ }
+ catch (final IllegalAccessException e)
+ {
+ throw new RuntimeException("Error in creating new " + Deployable.class.getName(), e);
+ }
+ catch (final InvocationTargetException e)
+ {
+ throw new RuntimeException("Error in creating new " + Deployable.class.getName(), e);
+ }
+
+ // Cast
+ final Deployable deployable;
+ try
+ {
+ deployable = Deployable.class.cast(obj);
+ }
+ catch (final ClassCastException cce)
+ {
+ throw new RuntimeException("New instance should be of type " + Deployable.class.getName(), cce);
+ }
+
+ // Return
+ return deployable;
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Internal Helper Methods ------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Obtains the constructor used in creating new Deployable instances.
+ * Uses a cached copy unless not yet initialized.
+ */
+ private synchronized static Constructor<?> getConstructor()
+ {
+ // If we haven't yet cached the ctor
+ if (constructor == null)
+ {
+ // Load the impl class
+ final String implClassName = CLASS_NAME_VFS_VDF_DEPLOYABLE;
+ final Class<?> implClass = getClass(implClassName);
+
+ // Load the ctor param class
+ final String paramClassName = CLASS_NAME_CTOR_PARAMETER;
+ final Class<?> paramClass = getClass(paramClassName);
+
+ // Get and set the ctor
+ try
+ {
+ constructor = SecurityActions.getConstructor(implClass, paramClass);
+ }
+ catch (final NoSuchMethodException nsme)
+ {
+ throw new RuntimeException("Could not find constructor to be used in factory creation of a new "
+ + Deployable.class.getSimpleName(), nsme);
+ }
+
+ }
+
+ // Return
+ return constructor;
+ }
+
+ /**
+ * Obtains the class with the specified name from the TCCL
+ *
+ * @param className
+ * @return
+ */
+ private static Class<?> getClass(final String className)
+ {
+ final ClassLoader cl = SecurityActions.getThreadContextClassLoader();
+ try
+ {
+ return Class.forName(className, false, cl);
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ throw new RuntimeException("Could not find implementation class \"" + className + "\" in " + cl, cnfe);
+ }
+ }
+
+ /**
+ * Obtains the Class representing supported archive types to be used
+ * in creation of new Deployables
+ * @return
+ */
+ private synchronized static Class<?> getSupportedArchiveType()
+ {
+ // If not yet initialized/cached
+ if (supportedArchiveType == null)
+ {
+ // Load and set
+ supportedArchiveType = getClass(CLASS_NAME_ARCHIVE_TYPE);
+ }
+
+ // Return
+ return supportedArchiveType;
+ }
+}
Copied: projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/api/DeploymentException.java (from rev 91698, projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/spi/DeploymentException.java)
===================================================================
--- projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/api/DeploymentException.java (rev 0)
+++ projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/api/DeploymentException.java 2009-07-28 15:47:32 UTC (rev 91717)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.embedded.core.incubation.deployable.api;
+
+/**
+ * DeploymentException
+ *
+ * Indicates a problem encountered during deployment to the server
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class DeploymentException extends Exception
+{
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * serialVersionUID
+ */
+ private static final long serialVersionUID = 1L;
+
+ //-------------------------------------------------------------------------------------||
+ // Constructors -----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ *
+ */
+ public DeploymentException()
+ {
+ super();
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public DeploymentException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ /**
+ * @param message
+ */
+ public DeploymentException(String message)
+ {
+ super(message);
+ }
+
+ /**
+ * @param cause
+ */
+ public DeploymentException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Copied: projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/api/SecurityActions.java (from rev 91698, projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/spi/SecurityActions.java)
===================================================================
--- projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/api/SecurityActions.java (rev 0)
+++ projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/api/SecurityActions.java 2009-07-28 15:47:32 UTC (rev 91717)
@@ -0,0 +1,108 @@
+package org.jboss.embedded.core.incubation.deployable.api;
+
+import java.lang.reflect.Constructor;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * SecurityActions
+ *
+ * A set of privileged actions that are not to leak out
+ * of this package
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+class SecurityActions
+{
+
+ //-------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * No external instantiation
+ */
+ private SecurityActions()
+ {
+
+ }
+
+ //-------------------------------------------------------------------------------||
+ // Utility Methods --------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * Obtains the Thread Context ClassLoader
+ */
+ static ClassLoader getThreadContextClassLoader()
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+ {
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+
+ /**
+ * Obtains the constructor for the specified class with the specified param types
+ * according to the contract of {@link Class#getConstructor(Class...)}
+ *
+ * @param clazz
+ * @param paramTypes
+ * @return
+ * @throws NoSuchMethodException
+ * @throws SecurityException
+ * @throws IllegalArgumentException If the class or param types were not specified
+ */
+ static Constructor<?> getConstructor(final Class<?> clazz, final Class<?>... paramTypes)
+ throws NoSuchMethodException, SecurityException, IllegalArgumentException
+ {
+ // Precondition checks
+ if (clazz == null)
+ {
+ throw new IllegalArgumentException("class must be specified");
+ }
+ if (paramTypes == null)
+ {
+ throw new IllegalArgumentException("param types must be specified");
+ }
+
+ try
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Constructor<?>>()
+ {
+
+ @Override
+ public Constructor<?> run() throws Exception
+ {
+ return clazz.getConstructor(paramTypes);
+ }
+ });
+ }
+ catch (final PrivilegedActionException pae)
+ {
+ // Throw nsme and se
+ final Throwable unwrapped = pae.getCause();
+ if (unwrapped instanceof NoSuchMethodException)
+ {
+ final NoSuchMethodException nsme = (NoSuchMethodException) unwrapped;
+ throw nsme;
+ }
+ if (unwrapped instanceof SecurityException)
+ {
+ final SecurityException se = (SecurityException) unwrapped;
+ throw se;
+ }
+
+ // Throw the cause as encountered
+ throw new RuntimeException("Error in obtaining constructor", unwrapped);
+
+ }
+ }
+
+}
Property changes on: projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/api/SecurityActions.java
___________________________________________________________________
Name: svn:executable
+ *
Deleted: projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/spi/Deployable.java
===================================================================
--- projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/spi/Deployable.java 2009-07-28 15:31:56 UTC (rev 91716)
+++ projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/spi/Deployable.java 2009-07-28 15:47:32 UTC (rev 91717)
@@ -1,39 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.embedded.core.incubation.deployable.spi;
-
-/**
- * Deployable
- *
- * Represents an entity which is eligible for deployment into an
- * Embedded Server.
- *
- * In practice, this is a marker interface, where an embedded server may
- * support a finite set of the children of this type.
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public interface Deployable
-{
-
-}
Deleted: projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/spi/DeployableFactory.java
===================================================================
--- projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/spi/DeployableFactory.java 2009-07-28 15:31:56 UTC (rev 91716)
+++ projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/spi/DeployableFactory.java 2009-07-28 15:47:32 UTC (rev 91717)
@@ -1,232 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.embedded.core.incubation.deployable.spi;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-
-import org.jboss.embedded.core.incubation.virtual.spi.ExtensibleVirtualArchive;
-import org.jboss.logging.Logger;
-
-/**
- * DeployableFactory
- *
- * Factory to create {@link Deployable} instances from
- * {@link ExtensibleVirtualArchive}s. This removes the API
- * dependency upon internals for the client view and additionally
- * acts as a convenience mechanism.
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class DeployableFactory
-{
-
- //-------------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Logger
- */
- private static final Logger log = Logger.getLogger(DeployableFactory.class);
-
- /**
- * FQN of implementation Class used in creating new Deployables
- */
- private static final String CLASS_NAME_VFS_VDF_DEPLOYABLE = "org.jboss.embedded.core.incubation.deployable.impl.vdf.VfsVdfDeployable";
-
- /**
- * FQN of type of parameter to implementation class constructor
- */
- private static final String CLASS_NAME_CTOR_PARAMETER = "org.jboss.embedded.core.incubation.virtual.spi.vfs.VirtualVfsArchive";
-
- /**
- * FQN of the archive type actually supported by {@link DeployableFactory#createDeployable(ExtensibleVirtualArchive)}
- */
- private static final String CLASS_NAME_ARCHIVE_TYPE = "org.jboss.embedded.core.incubation.virtual.spi.vfs.VirtualVfsArchive";
-
- /**
- * Constructor used in creating new {@link Deployable} instances
- */
- private static Constructor<?> constructor;
-
- /**
- * The actual type expected of archives passed to
- * {@link DeployableFactory#createDeployable(ExtensibleVirtualArchive)};
- * used here to do runtime type checking so we hide the internals and don't
- * leak out APIs to the client. Will have FQN of {@link DeployableFactory#CLASS_NAME_ARCHIVE_TYPE}.
- */
- private static Class<?> supportedArchiveType;
-
- //-------------------------------------------------------------------------------------||
- // Constructor ------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Internal Constructor to prohibit external
- * instantiation
- */
- private DeployableFactory()
- {
- }
-
- //-------------------------------------------------------------------------------------||
- // Functional Methods -----------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Creates a {@link Deployable} from the specified archive
- *
- * @param archive
- * @throws IllegalArgumentException If the archive is not specified or an unsupported type
- */
- public static Deployable createDeployable(final ExtensibleVirtualArchive<?> archive) throws IllegalArgumentException
- {
- // Precondition check
- final Class<?> supportedArchiveType = getSupportedArchiveType();
- if (!supportedArchiveType.isAssignableFrom(archive.getClass()))
- {
- final ClassLoader archiveCl = archive.getClass().getClassLoader();
- final ClassLoader supportedCl = supportedArchiveType.getClassLoader();
- log.warn("Archive CL: " + archiveCl);
- log.warn("Expected CL: " + supportedCl);
- throw new IllegalArgumentException("Specified archive must be of type " + supportedArchiveType.getName()
- + "; was instead: " + archive);
- }
-
- // Get the implementation ctor
- final Constructor<?> constructor = getConstructor();
-
- // Make a new instance
- final Object obj;
- try
- {
- obj = constructor.newInstance(archive);
- if (log.isTraceEnabled())
- {
- log.trace("Created: " + obj);
- }
- }
- catch (final InstantiationException e)
- {
- throw new RuntimeException("Error in creating new " + Deployable.class.getName(), e);
- }
- catch (final IllegalAccessException e)
- {
- throw new RuntimeException("Error in creating new " + Deployable.class.getName(), e);
- }
- catch (final InvocationTargetException e)
- {
- throw new RuntimeException("Error in creating new " + Deployable.class.getName(), e);
- }
-
- // Cast
- final Deployable deployable;
- try
- {
- deployable = Deployable.class.cast(obj);
- }
- catch (final ClassCastException cce)
- {
- throw new RuntimeException("New instance should be of type " + Deployable.class.getName(), cce);
- }
-
- // Return
- return deployable;
- }
-
- //-------------------------------------------------------------------------------------||
- // Internal Helper Methods ------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Obtains the constructor used in creating new Deployable instances.
- * Uses a cached copy unless not yet initialized.
- */
- private synchronized static Constructor<?> getConstructor()
- {
- // If we haven't yet cached the ctor
- if (constructor == null)
- {
- // Load the impl class
- final String implClassName = CLASS_NAME_VFS_VDF_DEPLOYABLE;
- final Class<?> implClass = getDeployableImplementationClass(implClassName);
-
- // Load the ctor param class
- final String paramClassName = CLASS_NAME_CTOR_PARAMETER;
- final Class<?> paramClass = getDeployableImplementationClass(paramClassName);
-
- // Get and set the ctor
- try
- {
- constructor = SecurityActions.getConstructor(implClass, paramClass);
- }
- catch (final NoSuchMethodException nsme)
- {
- throw new RuntimeException("Could not find constructor to be used in factory creation of a new "
- + Deployable.class.getSimpleName(), nsme);
- }
-
- }
-
- // Return
- return constructor;
- }
-
- /**
- * Obtains the implementation class to use in creating new Deployables
- *
- * @param className
- * @return
- */
- private static Class<?> getDeployableImplementationClass(final String className)
- {
- final ClassLoader cl = SecurityActions.getThreadContextClassLoader();
- try
- {
- return Class.forName(className, false, cl);
- }
- catch (ClassNotFoundException cnfe)
- {
- throw new RuntimeException("Could not find implementation class \"" + className + "\" in " + cl, cnfe);
- }
- }
-
- /**
- * Obtains the Class representing supported archive types to be used
- * in creation of new Deployables
- * @return
- */
- private synchronized static Class<?> getSupportedArchiveType()
- {
- // If not yet initialized/cached
- if (supportedArchiveType == null)
- {
- // Load and set
- supportedArchiveType = getDeployableImplementationClass(CLASS_NAME_ARCHIVE_TYPE);
- }
-
- // Return
- return supportedArchiveType;
- }
-}
Deleted: projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/spi/DeploymentException.java
===================================================================
--- projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/spi/DeploymentException.java 2009-07-28 15:31:56 UTC (rev 91716)
+++ projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/spi/DeploymentException.java 2009-07-28 15:47:32 UTC (rev 91717)
@@ -1,79 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.embedded.core.incubation.deployable.spi;
-
-/**
- * DeploymentException
- *
- * Indicates a problem encountered during deployment to the server
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class DeploymentException extends Exception
-{
- //-------------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * serialVersionUID
- */
- private static final long serialVersionUID = 1L;
-
- //-------------------------------------------------------------------------------------||
- // Constructors -----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- *
- */
- public DeploymentException()
- {
- super();
- }
-
- /**
- * @param message
- * @param cause
- */
- public DeploymentException(String message, Throwable cause)
- {
- super(message, cause);
- }
-
- /**
- * @param message
- */
- public DeploymentException(String message)
- {
- super(message);
- }
-
- /**
- * @param cause
- */
- public DeploymentException(Throwable cause)
- {
- super(cause);
- }
-}
Deleted: projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/spi/SecurityActions.java
===================================================================
--- projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/spi/SecurityActions.java 2009-07-28 15:31:56 UTC (rev 91716)
+++ projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/spi/SecurityActions.java 2009-07-28 15:47:32 UTC (rev 91717)
@@ -1,108 +0,0 @@
-package org.jboss.embedded.core.incubation.deployable.spi;
-
-import java.lang.reflect.Constructor;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-
-/**
- * SecurityActions
- *
- * A set of privileged actions that are not to leak out
- * of this package
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-class SecurityActions
-{
-
- //-------------------------------------------------------------------------------||
- // Constructor ------------------------------------------------------------------||
- //-------------------------------------------------------------------------------||
-
- /**
- * No external instantiation
- */
- private SecurityActions()
- {
-
- }
-
- //-------------------------------------------------------------------------------||
- // Utility Methods --------------------------------------------------------------||
- //-------------------------------------------------------------------------------||
-
- /**
- * Obtains the Thread Context ClassLoader
- */
- static ClassLoader getThreadContextClassLoader()
- {
- return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
- {
- public ClassLoader run()
- {
- return Thread.currentThread().getContextClassLoader();
- }
- });
- }
-
- /**
- * Obtains the constructor for the specified class with the specified param types
- * according to the contract of {@link Class#getConstructor(Class...)}
- *
- * @param clazz
- * @param paramTypes
- * @return
- * @throws NoSuchMethodException
- * @throws SecurityException
- * @throws IllegalArgumentException If the class or param types were not specified
- */
- static Constructor<?> getConstructor(final Class<?> clazz, final Class<?>... paramTypes)
- throws NoSuchMethodException, SecurityException, IllegalArgumentException
- {
- // Precondition checks
- if (clazz == null)
- {
- throw new IllegalArgumentException("class must be specified");
- }
- if (paramTypes == null)
- {
- throw new IllegalArgumentException("param types must be specified");
- }
-
- try
- {
- return AccessController.doPrivileged(new PrivilegedExceptionAction<Constructor<?>>()
- {
-
- @Override
- public Constructor<?> run() throws Exception
- {
- return clazz.getConstructor(paramTypes);
- }
- });
- }
- catch (final PrivilegedActionException pae)
- {
- // Throw nsme and se
- final Throwable unwrapped = pae.getCause();
- if (unwrapped instanceof NoSuchMethodException)
- {
- final NoSuchMethodException nsme = (NoSuchMethodException) unwrapped;
- throw nsme;
- }
- if (unwrapped instanceof SecurityException)
- {
- final SecurityException se = (SecurityException) unwrapped;
- throw se;
- }
-
- // Throw the cause as encountered
- throw new RuntimeException("Error in obtaining constructor", unwrapped);
-
- }
- }
-
-}
Modified: projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/spi/vdf/VdfDeployable.java
===================================================================
--- projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/spi/vdf/VdfDeployable.java 2009-07-28 15:31:56 UTC (rev 91716)
+++ projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/deployable/spi/vdf/VdfDeployable.java 2009-07-28 15:47:32 UTC (rev 91717)
@@ -22,7 +22,7 @@
package org.jboss.embedded.core.incubation.deployable.spi.vdf;
import org.jboss.deployers.client.spi.Deployment;
-import org.jboss.embedded.core.incubation.deployable.spi.Deployable;
+import org.jboss.embedded.core.incubation.deployable.api.Deployable;
/**
* VdfDeployable
Added: projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/api/SecurityActions.java
===================================================================
--- projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/api/SecurityActions.java (rev 0)
+++ projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/api/SecurityActions.java 2009-07-28 15:47:32 UTC (rev 91717)
@@ -0,0 +1,108 @@
+package org.jboss.embedded.core.incubation.virtual.api;
+
+import java.lang.reflect.Constructor;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * SecurityActions
+ *
+ * A set of privileged actions that are not to leak out
+ * of this package
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+class SecurityActions
+{
+
+ //-------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * No external instantiation
+ */
+ private SecurityActions()
+ {
+
+ }
+
+ //-------------------------------------------------------------------------------||
+ // Utility Methods --------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * Obtains the Thread Context ClassLoader
+ */
+ static ClassLoader getThreadContextClassLoader()
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+ {
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+
+ /**
+ * Obtains the constructor for the specified class with the specified param types
+ * according to the contract of {@link Class#getConstructor(Class...)}
+ *
+ * @param clazz
+ * @param paramTypes
+ * @return
+ * @throws NoSuchMethodException
+ * @throws SecurityException
+ * @throws IllegalArgumentException If the class or param types were not specified
+ */
+ static Constructor<?> getConstructor(final Class<?> clazz, final Class<?>... paramTypes)
+ throws NoSuchMethodException, SecurityException, IllegalArgumentException
+ {
+ // Precondition checks
+ if (clazz == null)
+ {
+ throw new IllegalArgumentException("class must be specified");
+ }
+ if (paramTypes == null)
+ {
+ throw new IllegalArgumentException("param types must be specified");
+ }
+
+ try
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Constructor<?>>()
+ {
+
+ @Override
+ public Constructor<?> run() throws Exception
+ {
+ return clazz.getConstructor(paramTypes);
+ }
+ });
+ }
+ catch (final PrivilegedActionException pae)
+ {
+ // Throw nsme and se
+ final Throwable unwrapped = pae.getCause();
+ if (unwrapped instanceof NoSuchMethodException)
+ {
+ final NoSuchMethodException nsme = (NoSuchMethodException) unwrapped;
+ throw nsme;
+ }
+ if (unwrapped instanceof SecurityException)
+ {
+ final SecurityException se = (SecurityException) unwrapped;
+ throw se;
+ }
+
+ // Throw the cause as encountered
+ throw new RuntimeException("Error in obtaining constructor", unwrapped);
+
+ }
+ }
+
+}
Property changes on: projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/api/SecurityActions.java
___________________________________________________________________
Name: svn:executable
+ *
Copied: projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/api/VirtualArchive.java (from rev 91697, projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/spi/ExtensibleVirtualArchive.java)
===================================================================
--- projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/api/VirtualArchive.java (rev 0)
+++ projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/api/VirtualArchive.java 2009-07-28 15:47:32 UTC (rev 91717)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.embedded.core.incubation.virtual.api;
+
+import java.net.URL;
+
+/**
+ * VirtualArchive
+ *
+ * Represents a single in-memory collection of resources which may
+ * be constructed declaratively / programmatically.
+ *
+ * @see {@link VirtualDeploymentGroup}
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @author <a href="bill at jboss.com">Bill Burke</a>
+ * @author adrian at jboss.org
+ * @version $Revision: $
+ */
+public interface VirtualArchive
+{
+ //-------------------------------------------------------------------------------------||
+ // Contracts --------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Adds the specified Class to the archive
+ *
+ * @param The class to add
+ * @return This virtual deployment
+ * @throws IllegalArgumentException If no class was specified
+ */
+ VirtualArchive addClass(Class<?> clazz) throws IllegalArgumentException;
+
+ /**
+ * Adds the specified Classes to the archive.
+ *
+ * @param classes
+ * @return This virtual deployment
+ * @throws IllegalArgumentException If no classes were specified
+ */
+ VirtualArchive addClasses(Class<?>... classes) throws IllegalArgumentException;
+
+ /**
+ * Adds the resource with the specified name to the
+ * deployment. The resource name must be visible to the ClassLoader
+ * of the archive
+ *
+ * @param name
+ * @return
+ * @throws IllegalArgumentException If the name was not specified
+ */
+ VirtualArchive addResource(String name) throws IllegalArgumentException;
+
+ /**
+ * Adds the specified resource to the archive, using the specified ClassLoader
+ * to load the resource
+ *
+ * @param name
+ * @param cl
+ * @return
+ * @throws IllegalArgumentException If either the name or ClassLoader is not specified
+ */
+ VirtualArchive addResource(String name, ClassLoader cl) throws IllegalArgumentException;
+
+ /**
+ * Adds the resource located at the specified URL to the archive
+ *
+ * @param location
+ * @return
+ * @throws IllegalArgumentException If the location is not specified
+ */
+ VirtualArchive addResource(URL location) throws IllegalArgumentException;
+
+ /**
+ * Adds the resource located at the specified URL to
+ * the archive at the specified path.
+ *
+ * @param location
+ * @param newPath The new path to assign, or null if
+ * the path portion of the location should be used
+ * @return
+ * @throws IllegalArgumentException If the location is not specified
+ */
+ VirtualArchive addResource(URL location, String newPath) throws IllegalArgumentException;
+
+ /**
+ * Returns a multiline "ls -l"-equse output of the contents of
+ * this deployment and (recursively) its children if the verbosity
+ * flag is set to "true". Otherwise the no-arg version is invoked
+ *
+ * @return
+ */
+ String toString(boolean verbose);
+
+}
Added: projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/api/VirtualArchiveFactory.java
===================================================================
--- projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/api/VirtualArchiveFactory.java (rev 0)
+++ projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/api/VirtualArchiveFactory.java 2009-07-28 15:47:32 UTC (rev 91717)
@@ -0,0 +1,202 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.embedded.core.incubation.virtual.api;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.logging.Logger;
+
+/**
+ * VirtualArchiveFactory
+ *
+ * Factory to create {@link VirtualArchive} instances.
+ * This removes the API dependency upon internals for the
+ * client view and additionally
+ * acts as a convenience mechanism.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class VirtualArchiveFactory
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(VirtualArchiveFactory.class);
+
+ /**
+ * FQN of implementation Class used in creating new archives
+ */
+ private static final String CLASS_NAME_ARCHIVE_IMPL = "org.jboss.embedded.core.incubation.virtual.impl.vfs.VirtualVfsArchiveImpl";
+
+ /**
+ * FQNs of type of parameters to implementation class constructor
+ */
+ private static final String[] CLASS_NAMES_CTOR_PARAMETERS =
+ {String.class.getName()};
+
+ /**
+ * Constructor used in creating new {@link VirtualArchive} instances
+ */
+ private static Constructor<?> constructor;
+
+ //-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ //-------------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Internal Constructor to prohibit external
+ * instantiation
+ */
+ private VirtualArchiveFactory()
+ {
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Functional Methods -----------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Creates a new {@link VirtualArchive} with the specified name.
+ *
+ * @param name
+ * @throws IllegalArgumentException If the name is not specified
+ */
+ public static VirtualArchive createVirtualArchive(final String name) throws IllegalArgumentException
+ {
+ // Precondition check
+ if (name == null || name.length() == 0)
+ {
+ throw new IllegalArgumentException("name must be specified");
+ }
+
+ // Get constructor
+ final Constructor<?> ctor = getConstructor();
+
+ // Create new instance
+ final Object obj;
+ try
+ {
+ obj = ctor.newInstance(name);
+ }
+ catch (final InstantiationException e)
+ {
+ throw new RuntimeException("Error in creating new " + VirtualArchive.class.getName(), e);
+ }
+ catch (final IllegalAccessException e)
+ {
+ throw new RuntimeException("Error in creating new " + VirtualArchive.class.getName(), e);
+ }
+ catch (final InvocationTargetException e)
+ {
+ throw new RuntimeException("Error in creating new " + VirtualArchive.class.getName(), e);
+ }
+
+ // Cast
+ final VirtualArchive archive;
+ try
+ {
+ archive = VirtualArchive.class.cast(obj);
+ }
+ catch (final ClassCastException cce)
+ {
+ throw new RuntimeException("New instance should be of type " + VirtualArchive.class.getName(), cce);
+ }
+
+ // Return
+ return archive;
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Internal Helper Methods ------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Obtains the constructor used in creating new archive instances.
+ * Uses a cached copy unless not yet initialized.
+ */
+ private synchronized static Constructor<?> getConstructor()
+ {
+ // If we haven't yet cached the ctor
+ if (constructor == null)
+ {
+ // Load the impl class
+ final String implClassName = CLASS_NAME_ARCHIVE_IMPL;
+ final Class<?> implClass = getClass(implClassName);
+
+ // Load the ctor param classes
+ final List<Class<?>> paramClasses = new ArrayList<Class<?>>();
+ for (final String paramClassName : CLASS_NAMES_CTOR_PARAMETERS)
+ {
+ paramClasses.add(getClass(paramClassName));
+ }
+ final Class<?>[] paramClassesArray = paramClasses.toArray(new Class<?>[]
+ {});
+
+ // Get and set the ctor
+ try
+ {
+ constructor = SecurityActions.getConstructor(implClass, paramClassesArray);
+ log.debug("Set the " + VirtualArchive.class.getName() + " type constructor: " + constructor);
+ }
+ catch (final NoSuchMethodException nsme)
+ {
+ throw new RuntimeException("Could not find constructor to be used in factory creation of a new "
+ + VirtualArchive.class.getSimpleName(), nsme);
+ }
+ }
+
+ // Return
+ return constructor;
+ }
+
+ /**
+ * Obtains the class with the specified name from the TCCL
+ *
+ * @param className
+ * @return
+ */
+ private static Class<?> getClass(final String className)
+ {
+ final ClassLoader cl = SecurityActions.getThreadContextClassLoader();
+ try
+ {
+ return Class.forName(className, false, cl);
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ throw new RuntimeException("Could not find implementation class \"" + className + "\" in " + cl, cnfe);
+ }
+ }
+}
Modified: projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/impl/base/AbstractVirtualArchive.java
===================================================================
--- projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/impl/base/AbstractVirtualArchive.java 2009-07-28 15:31:56 UTC (rev 91716)
+++ projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/impl/base/AbstractVirtualArchive.java 2009-07-28 15:47:32 UTC (rev 91717)
@@ -27,21 +27,19 @@
import java.net.URL;
import java.net.URLConnection;
-import org.jboss.embedded.core.incubation.virtual.spi.ExtensibleVirtualArchive;
+import org.jboss.embedded.core.incubation.virtual.api.VirtualArchive;
import org.jboss.logging.Logger;
/**
* AbstractVirtualDeployment
*
- * Base implementation of {@link ExtensibleVirtualArchive}
+ * Base implementation of {@link VirtualArchive}
*
- * @see {@link ExtensibleVirtualArchive}
+ * @see {@link VirtualArchive}
* @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
* @version $Revision: $
*/
-public abstract class AbstractVirtualArchive<T extends ExtensibleVirtualArchive<T>>
- implements
- ExtensibleVirtualArchive<T>
+public abstract class AbstractVirtualArchive implements VirtualArchive
{
//-------------------------------------------------------------------------------------||
@@ -125,12 +123,12 @@
// Required Implementations -----------------------------------------------------------||
//-------------------------------------------------------------------------------------||
- /*
+ /**
* (non-Javadoc)
- * @see org.jboss.embedded.core.deployment.VirtualDeployment#addClass(java.lang.Class)
+ * @see org.jboss.embedded.core.incubation.virtual.api.VirtualArchive#addClass(java.lang.Class)
*/
@Override
- public T addClass(final Class<?> clazz) throws IllegalArgumentException
+ public VirtualArchive addClass(final Class<?> clazz) throws IllegalArgumentException
{
// Precondition check
if (clazz == null)
@@ -152,12 +150,11 @@
return this.addResource(name, cl);
}
- /*
- * (non-Javadoc)
- * @see org.jboss.embedded.core.deployment.VirtualDeployment#addClasses(java.lang.Class<?>[])
+ /**
+ * @see org.jboss.embedded.core.incubation.virtual.spi.VirtualArchive#addClasses(java.lang.Class<?>[])
*/
@Override
- public T addClasses(final Class<?>... classes) throws IllegalArgumentException
+ public VirtualArchive addClasses(final Class<?>... classes) throws IllegalArgumentException
{
// Precondition check
if (classes == null || classes.length == 0)
@@ -172,25 +169,34 @@
}
// Return
- return this.covarientReturn();
+ return this;
}
- /* (non-Javadoc)
- * @see org.jboss.embedded.core.deployment.VirtualDeployment#addResource(java.lang.String)
+ /**
+ * @see org.jboss.embedded.core.incubation.virtual.api.VirtualArchive#addResource(java.lang.String)
*/
@Override
- public T addResource(final String name) throws IllegalArgumentException
+ public VirtualArchive addResource(final String name) throws IllegalArgumentException
{
return this.addResource(name, this.getClassLoader());
}
- /*
- * (non-Javadoc)
- * @see org.jboss.embedded.core.virtual.spi.ExtensibleVirtualArchive#addResource(java.lang.String, java.lang.ClassLoader)
+ /**
+ * @see org.jboss.embedded.core.incubation.virtual.api.VirtualArchive#addResource(java.net.URL)
*/
@Override
- public final T addResource(final String name, final ClassLoader cl) throws IllegalArgumentException
+ public VirtualArchive addResource(final URL location) throws IllegalArgumentException
{
+ // Delegate to the other implementation
+ return this.addResource(location, null);
+ }
+
+ /**
+ * @see org.jboss.embedded.core.incubation.virtual.api.VirtualArchive#addResource(java.lang.String, java.lang.ClassLoader)
+ */
+ @Override
+ public final VirtualArchive addResource(final String name, final ClassLoader cl) throws IllegalArgumentException
+ {
// Precondition check
if (name == null || name.length() == 0)
{
@@ -216,14 +222,14 @@
this.addContent(content, name);
// Return
- return this.covarientReturn();
+ return this;
}
- /* (non-Javadoc)
- * @see org.jboss.embedded.core.incubation.virtual.spi.ExtensibleVirtualArchive#addResource(java.net.URL, java.lang.String)
+ /**
+ * @see org.jboss.embedded.core.incubation.virtual.api.VirtualArchive#addResource(java.net.URL, java.lang.String)
*/
@Override
- public T addResource(final URL location, final String newPath) throws IllegalArgumentException
+ public VirtualArchive addResource(final URL location, final String newPath) throws IllegalArgumentException
{
// Precondition check
if (location == null)
@@ -257,7 +263,7 @@
this.addContent(content, path);
// Return
- return this.covarientReturn();
+ return this;
}
//-------------------------------------------------------------------------------------||
@@ -265,14 +271,6 @@
//-------------------------------------------------------------------------------------||
/**
- * Obtains the actual class (type) of this instance, used
- * in covarient return (casting)
- *
- * @return the actualClass
- */
- protected abstract Class<T> getActualClass();
-
- /**
* Adds the specified content to the archive at the specified location
*
* @param content
@@ -309,27 +307,6 @@
}
/**
- * Returns this instance as a typed server (as specified by K),
- * throwing a descriptive error message in case the server is not assignable
- */
- protected final T covarientReturn()
- {
- // Get the actual class
- final Class<T> actualClass = this.getActualClass();
-
- // Cast
- try
- {
- return actualClass.cast(this);
- }
- catch (ClassCastException cce)
- {
- throw new RuntimeException("Actual class is incorrect and " + actualClass
- + " was not assignable to this instance: " + this, cce);
- }
- }
-
- /**
* Copies and returns the specified URL. Used
* to ensure we don't export mutable URLs
*
Modified: projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/impl/vfs/VirtualVfsArchiveImpl.java
===================================================================
--- projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/impl/vfs/VirtualVfsArchiveImpl.java 2009-07-28 15:31:56 UTC (rev 91716)
+++ projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/impl/vfs/VirtualVfsArchiveImpl.java 2009-07-28 15:47:32 UTC (rev 91717)
@@ -41,7 +41,7 @@
* @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
* @version $Revision: $
*/
-public class VirtualVfsArchiveImpl extends AbstractVirtualArchive<VirtualVfsArchive> implements VirtualVfsArchive
+public class VirtualVfsArchiveImpl extends AbstractVirtualArchive implements VirtualVfsArchive
{
//-------------------------------------------------------------------------------------||
@@ -155,16 +155,6 @@
/*
* (non-Javadoc)
- * @see org.jboss.embedded.core.deployment.AbstractVirtualDeployment#getActualClass()
- */
- @Override
- protected Class<VirtualVfsArchive> getActualClass()
- {
- return VirtualVfsArchive.class;
- }
-
- /*
- * (non-Javadoc)
* @see org.jboss.embedded.core.deployment.ExtensibleVirtualVfsArchive#getRoot()
*/
@Override
@@ -213,16 +203,6 @@
}
/* (non-Javadoc)
- * @see org.jboss.embedded.core.incubation.virtual.spi.ExtensibleVirtualArchive#addResource(java.net.URL)
- */
- @Override
- public VirtualVfsArchive addResource(final URL location) throws IllegalArgumentException
- {
- // Delegate to the other implementation
- return this.addResource(location, null);
- }
-
- /* (non-Javadoc)
* @see org.jboss.embedded.core.deployment.ExtensibleVirtualDeployment#toString(boolean)
*/
@Override
Deleted: projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/spi/ExtensibleVirtualArchive.java
===================================================================
--- projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/spi/ExtensibleVirtualArchive.java 2009-07-28 15:31:56 UTC (rev 91716)
+++ projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/spi/ExtensibleVirtualArchive.java 2009-07-28 15:47:32 UTC (rev 91717)
@@ -1,116 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.embedded.core.incubation.virtual.spi;
-
-import java.net.URL;
-
-import org.jboss.embedded.core.incubation.virtual.tempdev.VirtualDeploymentGroup;
-
-/**
- * ExtensibleVirtualArchive
- *
- * Represents a single in-memory collection of resources which may
- * be constructed declaratively / programmatically.
- *
- * @see {@link VirtualDeploymentGroup}
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @author <a href="bill at jboss.com">Bill Burke</a>
- * @author adrian at jboss.org
- * @version $Revision: $
- */
-public interface ExtensibleVirtualArchive<T extends ExtensibleVirtualArchive<T>>
-{
- //-------------------------------------------------------------------------------------||
- // Contracts --------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Adds the specified Class to the archive
- *
- * @param The class to add
- * @return This virtual deployment
- * @throws IllegalArgumentException If no class was specified
- */
- T addClass(Class<?> clazz) throws IllegalArgumentException;
-
- /**
- * Adds the specified Classes to the archive.
- *
- * @param classes
- * @return This virtual deployment
- * @throws IllegalArgumentException If no classes were specified
- */
- T addClasses(Class<?>... classes) throws IllegalArgumentException;
-
- /**
- * Adds the resource with the specified name to the
- * deployment. The resource name must be visible to the ClassLoader
- * of the archive
- *
- * @param name
- * @return
- * @throws IllegalArgumentException If the name was not specified
- */
- T addResource(String name) throws IllegalArgumentException;
-
- /**
- * Adds the specified resource to the archive, using the specified ClassLoader
- * to load the resource
- *
- * @param name
- * @param cl
- * @return
- * @throws IllegalArgumentException If either the name or ClassLoader is not specified
- */
- T addResource(String name, ClassLoader cl) throws IllegalArgumentException;
-
- /**
- * Adds the resource located at the specified URL to the archive
- *
- * @param location
- * @return
- * @throws IllegalArgumentException If the location is not specified
- */
- T addResource(URL location) throws IllegalArgumentException;
-
- /**
- * Adds the resource located at the specified URL to
- * the archive at the specified path.
- *
- * @param location
- * @param newPath The new path to assign, or null if
- * the path portion of the location should be used
- * @return
- * @throws IllegalArgumentException If the location is not specified
- */
- T addResource(URL location, String newPath) throws IllegalArgumentException;
-
- /**
- * Returns a multiline "ls -l"-equse output of the contents of
- * this deployment and (recursively) its children if the verbosity
- * flag is set to "true". Otherwise the no-arg version is invoked
- *
- * @return
- */
- String toString(boolean verbose);
-
-}
Deleted: projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/spi/vfs/ExtensibleVirtualVfsArchive.java
===================================================================
--- projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/spi/vfs/ExtensibleVirtualVfsArchive.java 2009-07-28 15:31:56 UTC (rev 91716)
+++ projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/spi/vfs/ExtensibleVirtualVfsArchive.java 2009-07-28 15:47:32 UTC (rev 91717)
@@ -1,52 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.embedded.core.incubation.virtual.spi.vfs;
-
-import org.jboss.embedded.core.incubation.virtual.spi.ExtensibleVirtualArchive;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * ExtensibleVirtualVfsArchive
- *
- * An in-memory collection of resources backed by
- * JBoss VFS (Virtual File System) which may be extended
- * to provide true typesafe covarient return in method chaining
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public interface ExtensibleVirtualVfsArchive<T extends ExtensibleVirtualVfsArchive<T>>
- extends
- ExtensibleVirtualArchive<T>
-{
- //-------------------------------------------------------------------------------------||
- // Contracts --------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Obtains the VFS file which is the root level
- * of this deployment
- *
- * @return
- */
- VirtualFile getRoot();
-}
Modified: projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/spi/vfs/VirtualVfsArchive.java
===================================================================
--- projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/spi/vfs/VirtualVfsArchive.java 2009-07-28 15:31:56 UTC (rev 91716)
+++ projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/incubation/virtual/spi/vfs/VirtualVfsArchive.java 2009-07-28 15:47:32 UTC (rev 91717)
@@ -21,21 +21,30 @@
*/
package org.jboss.embedded.core.incubation.virtual.spi.vfs;
+import org.jboss.embedded.core.incubation.virtual.api.VirtualArchive;
+import org.jboss.virtual.VirtualFile;
/**
* VirtualVfsArchive
*
- * Represents a single in-memory collectdeploymention
+ * Represents a single in-memory collection
* of resources which may
* be constructed declaratively / programmatically.
*
* @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
* @version $Revision: $
*/
-public interface VirtualVfsArchive extends ExtensibleVirtualVfsArchive<VirtualVfsArchive>
+public interface VirtualVfsArchive extends VirtualArchive
{
- /*
- * API inherited; this type in
- * place to define generics
+ //-------------------------------------------------------------------------------------||
+ // Contracts --------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Obtains the VFS file which is the root level
+ * of this deployment
+ *
+ * @return
*/
+ VirtualFile getRoot();
}
Modified: projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/server/JBossASEmbeddedServer.java
===================================================================
--- projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/server/JBossASEmbeddedServer.java 2009-07-28 15:31:56 UTC (rev 91716)
+++ projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/server/JBossASEmbeddedServer.java 2009-07-28 15:47:32 UTC (rev 91717)
@@ -23,8 +23,8 @@
import org.jboss.bootstrap.spi.as.config.JBossASServerConfig;
import org.jboss.bootstrap.spi.as.server.JBossASBasedServer;
-import org.jboss.embedded.core.incubation.deployable.spi.Deployable;
-import org.jboss.embedded.core.incubation.deployable.spi.DeploymentException;
+import org.jboss.embedded.core.incubation.deployable.api.Deployable;
+import org.jboss.embedded.core.incubation.deployable.api.DeploymentException;
/**
* JBossASEmbeddedServer
Modified: projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/server/JBossASEmbeddedServerImpl.java
===================================================================
--- projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/server/JBossASEmbeddedServerImpl.java 2009-07-28 15:31:56 UTC (rev 91716)
+++ projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/server/JBossASEmbeddedServerImpl.java 2009-07-28 15:47:32 UTC (rev 91717)
@@ -36,8 +36,8 @@
import org.jboss.dependency.spi.ControllerState;
import org.jboss.deployers.client.spi.Deployment;
import org.jboss.deployers.client.spi.main.MainDeployer;
-import org.jboss.embedded.core.incubation.deployable.spi.Deployable;
-import org.jboss.embedded.core.incubation.deployable.spi.DeploymentException;
+import org.jboss.embedded.core.incubation.deployable.api.Deployable;
+import org.jboss.embedded.core.incubation.deployable.api.DeploymentException;
import org.jboss.embedded.core.incubation.deployable.spi.vdf.VdfDeployable;
import org.jboss.embedded.core.lifecycle.IgnoreXbUnorderedSequenceLifecycleEventHandler;
import org.jboss.embedded.core.lifecycle.InitLoggingManagerLifecycleEventHandler;
@@ -160,7 +160,7 @@
*/
@Override
public void deploy(final Deployable... deployables)
- throws org.jboss.embedded.core.incubation.deployable.spi.DeploymentException, IllegalArgumentException
+ throws org.jboss.embedded.core.incubation.deployable.api.DeploymentException, IllegalArgumentException
{
// Precondition checks and obtain as VDF impls
final Collection<VdfDeployable> vdfDeployables = this.asVdfDeployables(deployables);
@@ -208,7 +208,7 @@
*/
@Override
public void undeploy(final Deployable... deployables)
- throws org.jboss.embedded.core.incubation.deployable.spi.DeploymentException, IllegalArgumentException
+ throws org.jboss.embedded.core.incubation.deployable.api.DeploymentException, IllegalArgumentException
{
/*
* Precondition checks
Modified: projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/incubation/deployable/vfs/VfsVdfDeployableFactoryTestCase.java
===================================================================
--- projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/incubation/deployable/vfs/VfsVdfDeployableFactoryTestCase.java 2009-07-28 15:31:56 UTC (rev 91716)
+++ projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/incubation/deployable/vfs/VfsVdfDeployableFactoryTestCase.java 2009-07-28 15:47:32 UTC (rev 91717)
@@ -23,11 +23,11 @@
import junit.framework.Assert;
+import org.jboss.embedded.core.incubation.deployable.api.Deployable;
+import org.jboss.embedded.core.incubation.deployable.api.DeployableFactory;
import org.jboss.embedded.core.incubation.deployable.impl.vdf.VfsVdfDeployableImpl;
-import org.jboss.embedded.core.incubation.deployable.spi.Deployable;
-import org.jboss.embedded.core.incubation.deployable.spi.DeployableFactory;
+import org.jboss.embedded.core.incubation.virtual.api.VirtualArchive;
import org.jboss.embedded.core.incubation.virtual.impl.vfs.VirtualVfsArchiveImpl;
-import org.jboss.embedded.core.incubation.virtual.spi.vfs.VirtualVfsArchive;
import org.jboss.logging.Logger;
import org.jboss.virtual.VFS;
import org.junit.BeforeClass;
@@ -83,7 +83,7 @@
log.info("testDeployableFactory");
// Make an archive
- final VirtualVfsArchive archive = new VirtualVfsArchiveImpl("test.jar").addClass(this.getClass());
+ final VirtualArchive archive = new VirtualVfsArchiveImpl("test.jar").addClass(this.getClass());
// Make a Deployable
final Deployable deployable = DeployableFactory.createDeployable(archive);
Added: projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/incubation/virtual/vfs/VirtualVfsArchiveFactoryTestCase.java
===================================================================
--- projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/incubation/virtual/vfs/VirtualVfsArchiveFactoryTestCase.java (rev 0)
+++ projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/incubation/virtual/vfs/VirtualVfsArchiveFactoryTestCase.java 2009-07-28 15:47:32 UTC (rev 91717)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.embedded.core.incubation.virtual.vfs;
+
+import junit.framework.Assert;
+
+import org.jboss.embedded.core.incubation.virtual.api.VirtualArchive;
+import org.jboss.embedded.core.incubation.virtual.api.VirtualArchiveFactory;
+import org.jboss.embedded.core.incubation.virtual.spi.vfs.VirtualVfsArchive;
+import org.jboss.logging.Logger;
+import org.jboss.virtual.VFS;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * VirtualVfsArchiveFactoryTestCase
+ *
+ * Test Cases to assert that the {@link VirtualArchiveFactory} is
+ * working correctly
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class VirtualVfsArchiveFactoryTestCase
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(VirtualVfsArchiveFactoryTestCase.class);
+
+ //-------------------------------------------------------------------------------------||
+ // Lifecycle --------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Initializes the virtual file system
+ */
+ @BeforeClass
+ public static void initVfs() throws Exception
+ {
+ // Init VFS
+ VFS.init();
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Tests ------------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Tests that using a {@link testVirtualArchiveFactory} to create
+ * an archive results in a new type backed by VFS
+ */
+ @Test
+ public void testVirtualArchiveFactory() throws Exception
+ {
+ // Log
+ log.info("testVirtualArchiveFactory");
+
+ // Make an archive
+ final VirtualArchive archive = VirtualArchiveFactory.createVirtualArchive("testArchive.jar");
+ log.info("Archive: " + archive.toString(true));
+
+ // Ensure exists
+ Assert.assertNotNull("Archive was not created/null", archive);
+ Assert.assertTrue("Created archive was not of expected type", archive instanceof VirtualVfsArchive);
+ }
+}
Modified: projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/incubation/virtual/vfs/VirtualVfsArchiveTestCase.java
===================================================================
--- projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/incubation/virtual/vfs/VirtualVfsArchiveTestCase.java 2009-07-28 15:31:56 UTC (rev 91716)
+++ projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/incubation/virtual/vfs/VirtualVfsArchiveTestCase.java 2009-07-28 15:47:32 UTC (rev 91717)
@@ -24,8 +24,8 @@
import java.net.URL;
import org.jboss.bootstrap.impl.as.lifecycle.VfsInitializingLifecycleEventHandler;
+import org.jboss.embedded.core.incubation.virtual.api.VirtualArchive;
import org.jboss.embedded.core.incubation.virtual.impl.vfs.VirtualVfsArchiveImpl;
-import org.jboss.embedded.core.incubation.virtual.spi.vfs.VirtualVfsArchive;
import org.jboss.logging.Logger;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -113,7 +113,7 @@
final String newPath = PATH_WEB_INF + SEPARATOR + FILENAME_WEB_XML;
// Make a virtual archive
- final VirtualVfsArchive archive = new VirtualVfsArchiveImpl("something.war").addResource(location, newPath);
+ final VirtualArchive archive = new VirtualVfsArchiveImpl("something.war").addResource(location, newPath);
log.info(archive.toString(true));
//TODO Actually test something when we have better hooks to examine archive contents
Modified: projects/embedded/trunk/testsuite-full-dep/src/test/java/org/jboss/ServerTestCase.java
===================================================================
--- projects/embedded/trunk/testsuite-full-dep/src/test/java/org/jboss/ServerTestCase.java 2009-07-28 15:31:56 UTC (rev 91716)
+++ projects/embedded/trunk/testsuite-full-dep/src/test/java/org/jboss/ServerTestCase.java 2009-07-28 15:47:32 UTC (rev 91717)
@@ -53,10 +53,10 @@
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.jboss.bootstrap.spi.lifecycle.LifecycleState;
-import org.jboss.embedded.core.incubation.deployable.spi.Deployable;
-import org.jboss.embedded.core.incubation.deployable.spi.DeployableFactory;
-import org.jboss.embedded.core.incubation.virtual.impl.vfs.VirtualVfsArchiveImpl;
-import org.jboss.embedded.core.incubation.virtual.spi.vfs.VirtualVfsArchive;
+import org.jboss.embedded.core.incubation.deployable.api.Deployable;
+import org.jboss.embedded.core.incubation.deployable.api.DeployableFactory;
+import org.jboss.embedded.core.incubation.virtual.api.VirtualArchive;
+import org.jboss.embedded.core.incubation.virtual.api.VirtualArchiveFactory;
import org.jboss.embedded.core.server.JBossASEmbeddedServer;
import org.jboss.embedded.core.server.JBossASEmbeddedServerImpl;
import org.jboss.embedded.testsuite.fulldep.ejb3.mdb.MessageStoringMdb;
@@ -244,7 +244,7 @@
// Make a deployment
final String name = "slsb.jar";
- final VirtualVfsArchive archive = new VirtualVfsArchiveImpl(name).addClasses(OutputBean.class,
+ final VirtualArchive archive = VirtualArchiveFactory.createVirtualArchive(name).addClasses(OutputBean.class,
OutputLocalBusiness.class);
log.info(archive.toString(true));
final Deployable deployable = DeployableFactory.createDeployable(archive);
@@ -293,8 +293,8 @@
final String appName = "testServletJsp";
final String name = appName + ".war";
final Class<?> servletClass = JspForwardingServlet.class;
- final VirtualVfsArchive archive = new VirtualVfsArchiveImpl(name).addResource(locationWebXml, newPathWebXml)
- .addResource(locationJsp, PATH_JSP).addClass(servletClass);
+ final VirtualArchive archive = VirtualArchiveFactory.createVirtualArchive(name).addResource(locationWebXml,
+ newPathWebXml).addResource(locationJsp, PATH_JSP).addClass(servletClass);
log.info(archive.toString(true));
final Deployable deployable = DeployableFactory.createDeployable(archive);
@@ -347,7 +347,8 @@
log.info("testJmsAndMdb");
// Create a virtual archive for the MDB deployment
- final VirtualVfsArchive archive = new VirtualVfsArchiveImpl("jms-mdb-test.jar").addClass(MessageStoringMdb.class)
+ final String name = "jms-mdb-test.jar";
+ final VirtualArchive archive = VirtualArchiveFactory.createVirtualArchive(name).addClass(MessageStoringMdb.class)
.addResource(new URL(this.getBase(), PATH_QUEUE_SERVICE_XML), FILENAME_QUEUE_SERVICE_XML);
// Deploy
More information about the jboss-cvs-commits
mailing list