[jboss-svn-commits] JBoss Common SVN: r3460 - in declarchive/trunk: api/src/main/java/org/jboss/declarchive/api/mightmoveordelete and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Aug 17 07:01:52 EDT 2009
Author: ALRubinger
Date: 2009-08-17 07:01:52 -0400 (Mon, 17 Aug 2009)
New Revision: 3460
Added:
declarchive/trunk/api/src/main/java/org/jboss/declarchive/api/mightmoveordelete/SecurityActions.java
declarchive/trunk/api/src/main/java/org/jboss/declarchive/api/mightmoveordelete/VfsMemoryArchiveFactory.java
Removed:
declarchive/trunk/api/src/main/java/org/jboss/declarchive/api/SecurityActions.java
declarchive/trunk/api/src/main/java/org/jboss/declarchive/api/VfsMemoryArchiveFactory.java
Modified:
declarchive/trunk/impl-vfs/src/test/java/org/jboss/declarchive/impl/vfs/VfsMemoryArchiveFactoryTestCase.java
Log:
[TMPARCH-6] Clear the way for Aslak and Container IFs
Deleted: declarchive/trunk/api/src/main/java/org/jboss/declarchive/api/SecurityActions.java
===================================================================
--- declarchive/trunk/api/src/main/java/org/jboss/declarchive/api/SecurityActions.java 2009-08-17 10:59:12 UTC (rev 3459)
+++ declarchive/trunk/api/src/main/java/org/jboss/declarchive/api/SecurityActions.java 2009-08-17 11:01:52 UTC (rev 3460)
@@ -1,124 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.declarchive.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);
-
- }
- }
-
-}
Deleted: declarchive/trunk/api/src/main/java/org/jboss/declarchive/api/VfsMemoryArchiveFactory.java
===================================================================
--- declarchive/trunk/api/src/main/java/org/jboss/declarchive/api/VfsMemoryArchiveFactory.java 2009-08-17 10:59:12 UTC (rev 3459)
+++ declarchive/trunk/api/src/main/java/org/jboss/declarchive/api/VfsMemoryArchiveFactory.java 2009-08-17 11:01:52 UTC (rev 3460)
@@ -1,200 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.declarchive.api;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * VfsMemoryArchiveFactory
- *
- * Factory to create {@link Archive} instances, backed
- * by a VFS in-memory implementation.
- * 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: $
- */
-/*
- * TODO
- *
- * Break this up into a much more generic approach, then
- * make factories for each underlying implementation type
- */
-public class VfsMemoryArchiveFactory
-{
-
- //-------------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Logger
- */
- private static final Logger log = Logger.getLogger(VfsMemoryArchiveFactory.class.getName());
-
- /**
- * FQN of implementation Class used in creating new archives
- */
- private static final String CLASS_NAME_ARCHIVE_IMPL = "org.jboss.declarchive.impl.vfs.MemoryArchiveImpl";
-
- /**
- * 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 Archive} instances
- */
- private static Constructor<?> constructor;
-
- //-------------------------------------------------------------------------------------||
- // Constructor ------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Internal Constructor to prohibit external
- * instantiation
- */
- private VfsMemoryArchiveFactory()
- {
- }
-
- //-------------------------------------------------------------------------------------||
- // Functional Methods -----------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Creates a new {@link Archive} with the specified name.
- *
- * @param name
- * @throws IllegalArgumentException If the name is not specified
- */
- public static <T extends Archive<T>> T createArchive(final String name, final Class<T> archiveType)
- 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 " + Archive.class.getName(), e);
- }
- catch (final IllegalAccessException e)
- {
- throw new RuntimeException("Error in creating new " + Archive.class.getName(), e);
- }
- catch (final InvocationTargetException e)
- {
- throw new RuntimeException("Error in creating new " + Archive.class.getName(), e);
- }
-
- // Cast
- final T archive;
- try
- {
- archive = archiveType.cast(obj);
- }
- catch (final ClassCastException cce)
- {
- throw new RuntimeException("New instance should be of type " + Archive.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.log(Level.FINE, "Set the " + Archive.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 "
- + Archive.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);
- }
- }
-}
Copied: declarchive/trunk/api/src/main/java/org/jboss/declarchive/api/mightmoveordelete/SecurityActions.java (from rev 3458, declarchive/trunk/api/src/main/java/org/jboss/declarchive/api/SecurityActions.java)
===================================================================
--- declarchive/trunk/api/src/main/java/org/jboss/declarchive/api/mightmoveordelete/SecurityActions.java (rev 0)
+++ declarchive/trunk/api/src/main/java/org/jboss/declarchive/api/mightmoveordelete/SecurityActions.java 2009-08-17 11:01:52 UTC (rev 3460)
@@ -0,0 +1,124 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.declarchive.api.mightmoveordelete;
+
+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: declarchive/trunk/api/src/main/java/org/jboss/declarchive/api/mightmoveordelete/SecurityActions.java
___________________________________________________________________
Name: svn:executable
+ *
Copied: declarchive/trunk/api/src/main/java/org/jboss/declarchive/api/mightmoveordelete/VfsMemoryArchiveFactory.java (from rev 3458, declarchive/trunk/api/src/main/java/org/jboss/declarchive/api/VfsMemoryArchiveFactory.java)
===================================================================
--- declarchive/trunk/api/src/main/java/org/jboss/declarchive/api/mightmoveordelete/VfsMemoryArchiveFactory.java (rev 0)
+++ declarchive/trunk/api/src/main/java/org/jboss/declarchive/api/mightmoveordelete/VfsMemoryArchiveFactory.java 2009-08-17 11:01:52 UTC (rev 3460)
@@ -0,0 +1,202 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.declarchive.api.mightmoveordelete;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.jboss.declarchive.api.Archive;
+
+/**
+ * VfsMemoryArchiveFactory
+ *
+ * Factory to create {@link Archive} instances, backed
+ * by a VFS in-memory implementation.
+ * 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: $
+ */
+/*
+ * TODO
+ *
+ * Break this up into a much more generic approach, then
+ * make factories for each underlying implementation type
+ */
+public class VfsMemoryArchiveFactory
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(VfsMemoryArchiveFactory.class.getName());
+
+ /**
+ * FQN of implementation Class used in creating new archives
+ */
+ private static final String CLASS_NAME_ARCHIVE_IMPL = "org.jboss.declarchive.impl.vfs.MemoryArchiveImpl";
+
+ /**
+ * 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 Archive} instances
+ */
+ private static Constructor<?> constructor;
+
+ //-------------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Internal Constructor to prohibit external
+ * instantiation
+ */
+ private VfsMemoryArchiveFactory()
+ {
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Functional Methods -----------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Creates a new {@link Archive} with the specified name.
+ *
+ * @param name
+ * @throws IllegalArgumentException If the name is not specified
+ */
+ public static <T extends Archive<T>> T createArchive(final String name, final Class<T> archiveType)
+ 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 " + Archive.class.getName(), e);
+ }
+ catch (final IllegalAccessException e)
+ {
+ throw new RuntimeException("Error in creating new " + Archive.class.getName(), e);
+ }
+ catch (final InvocationTargetException e)
+ {
+ throw new RuntimeException("Error in creating new " + Archive.class.getName(), e);
+ }
+
+ // Cast
+ final T archive;
+ try
+ {
+ archive = archiveType.cast(obj);
+ }
+ catch (final ClassCastException cce)
+ {
+ throw new RuntimeException("New instance should be of type " + Archive.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.log(Level.FINE, "Set the " + Archive.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 "
+ + Archive.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: declarchive/trunk/impl-vfs/src/test/java/org/jboss/declarchive/impl/vfs/VfsMemoryArchiveFactoryTestCase.java
===================================================================
--- declarchive/trunk/impl-vfs/src/test/java/org/jboss/declarchive/impl/vfs/VfsMemoryArchiveFactoryTestCase.java 2009-08-17 10:59:12 UTC (rev 3459)
+++ declarchive/trunk/impl-vfs/src/test/java/org/jboss/declarchive/impl/vfs/VfsMemoryArchiveFactoryTestCase.java 2009-08-17 11:01:52 UTC (rev 3460)
@@ -20,7 +20,7 @@
import junit.framework.Assert;
-import org.jboss.declarchive.api.VfsMemoryArchiveFactory;
+import org.jboss.declarchive.api.mightmoveordelete.VfsMemoryArchiveFactory;
import org.jboss.declarchive.spi.vfs.VfsArchive;
import org.jboss.virtual.VFS;
import org.junit.BeforeClass;
More information about the jboss-svn-commits
mailing list