openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r1190716 [7/10] - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ openjpa-jdbc/src/main/java/org/...
Date Sat, 29 Oct 2011 00:44:18 GMT
Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivations.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivations.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivations.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivations.java Sat Oct 29 00:44:11 2011
@@ -34,7 +34,6 @@ import java.util.TreeSet;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.openjpa.lib.util.J2DoPrivHelper;
-import org.apache.openjpa.lib.util.JavaVersions;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.lib.util.MultiClassLoader;
 import org.apache.openjpa.lib.util.Services;
@@ -48,8 +47,7 @@ import org.apache.openjpa.lib.util.Servi
  */
 public class ProductDerivations {
 
-    private static final Localizer _loc = Localizer.forPackage
-        (ProductDerivations.class);
+    private static final Localizer _loc = Localizer.forPackage(ProductDerivations.class);
 
     private static final ProductDerivation[] _derivations;
     private static final String[] _derivationNames;
@@ -62,22 +60,25 @@ public class ProductDerivations {
         l.addClassLoader(1, AccessController.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction()));
         _derivationNames = Services.getImplementors(ProductDerivation.class, l);
         _derivationErrors = new Throwable[_derivationNames.length];
-        List<ProductDerivation> derivations =
-            new ArrayList<ProductDerivation>(_derivationNames.length);
+        List<ProductDerivation> derivations = new ArrayList<ProductDerivation>(_derivationNames.length);
         boolean errors = false; 
         for (int i = 0; i < _derivationNames.length; i++) {
             try {
                 ProductDerivation d = (ProductDerivation)
-                    AccessController.doPrivileged(
-                        J2DoPrivHelper.newInstanceAction(
+                    AccessController.doPrivileged(J2DoPrivHelper.newInstanceAction(
                             Class.forName(_derivationNames[i], true, l)));
                 d.validate();
                 derivations.add(d);
             } catch (Throwable t) {
-                if (t instanceof PrivilegedActionException)
-                    t = ((PrivilegedActionException) t).getException();
-                _derivationErrors[i] = t;
-                errors = true;
+                if (t instanceof BootstrapException && !((BootstrapException)t).isFatal()) {
+                	// do nothing
+                } else {
+	                if (t instanceof PrivilegedActionException) {
+	                    t = ((PrivilegedActionException) t).getException();
+	                }
+	                _derivationErrors[i] = t;
+	                errors = true;
+                }
             }
         }
 
@@ -92,14 +93,11 @@ public class ProductDerivations {
 
         // if some derivations weren't instantiable, warn
         if (errors)
-            System.err.println(_loc.get("bad-product-derivations",
-                ProductDerivations.class.getName()));
+            System.err.println(_loc.get("bad-product-derivations", ProductDerivations.class.getName()));
         for (int i = 0; i < _derivationErrors.length; i++) {
-            if (_derivationErrors[i] == null)
-                continue;
-            System.err.println(_derivationNames[i] + ":" +
-                    _derivationErrors[i]);
-            break;
+            if (_derivationErrors[i] != null) {
+                System.err.println(_derivationNames[i] + ":" + _derivationErrors[i]);
+            }
         }
 
         Collections.sort(derivations, new ProductDerivationComparator());
@@ -160,22 +158,18 @@ public class ProductDerivations {
         for (int i = 0; map != null && i < _prefixes.length; i++) {
             String fullKey = _prefixes[i] + "." + partialKey;
             if (map.containsKey(fullKey)) {
-                if (firstKey == null) 
+                if (firstKey == null) {
                     firstKey = fullKey;
-                else {
+                } else {
                     // if we've already found a property with a previous 
                     // prefix, then this is a collision.
-                    throw new IllegalStateException(_loc.get(
-                        "dup-with-different-prefixes", firstKey, fullKey)
+                    throw new IllegalStateException(_loc.get("dup-with-different-prefixes", firstKey, fullKey)
                         .getMessage());
                 }
             }
         }
         
-        if (firstKey == null)
-            return _prefixes[0] + "." + partialKey;
-        else
-            return firstKey;
+        return (firstKey == null) ?  _prefixes[0] + "." + partialKey : firstKey;
     }
 
     /**
@@ -258,20 +252,16 @@ public class ProductDerivations {
      * @param anchor optional named anchor within a multiple-configuration
      * resource
      */
-    public static ConfigurationProvider load(String resource, String anchor, 
-        ClassLoader loader) {
+    public static ConfigurationProvider load(String resource, String anchor) {
         if (StringUtils.isEmpty(resource))
             return null;
-        if (loader == null)
-            loader = AccessController.doPrivileged(
-                J2DoPrivHelper.getContextClassLoaderAction());
         ConfigurationProvider provider = null;
         StringBuilder errs = null;
         // most specific to least
         Throwable err = null;
         for (int i = _derivations.length - 1; i >= 0; i--) {
             try {
-                provider = _derivations[i].load(resource, anchor, loader);
+                provider = _derivations[i].load(resource, anchor);
                 if (provider != null)
                     return provider;
             } catch (Throwable t) {
@@ -294,13 +284,9 @@ public class ProductDerivations {
      *
      * @param anchor optional named anchor within a multiple-configuration file
      */
-    public static ConfigurationProvider load(File file, String anchor, 
-        ClassLoader loader) {
+    public static ConfigurationProvider load(File file, String anchor) {
         if (file == null)
             return null;
-        if (loader == null)
-            loader = AccessController.doPrivileged(
-                J2DoPrivHelper.getContextClassLoaderAction());
         ConfigurationProvider provider = null;
         StringBuilder errs = null;
         Throwable err = null;
@@ -329,26 +315,21 @@ public class ProductDerivations {
     /**
      * Return a {@link ConfigurationProvider} that has parsed system defaults.
      */
-    public static ConfigurationProvider loadDefaults(ClassLoader loader) {
-        return load(loader, false);
+    public static ConfigurationProvider loadDefaults() {
+        return load(false);
     }
 
     /**
      * Return a {@link ConfigurationProvider} that has parsed system globals.
      */
-    public static ConfigurationProvider loadGlobals(ClassLoader loader) {
-        return load(loader, true);
+    public static ConfigurationProvider loadGlobals() {
+        return load(true);
     }
             
     /**
      * Load a built-in resource location.
      */
-    private static ConfigurationProvider load(ClassLoader loader, 
-       boolean globals) {
-        if (loader == null)
-            loader = AccessController.doPrivileged(
-                J2DoPrivHelper.getContextClassLoaderAction());
-        
+    private static ConfigurationProvider load(boolean globals) {
         ConfigurationProvider provider = null;
         StringBuilder errs = null;
         String type = (globals) ? "globals" : "defaults";
@@ -356,8 +337,8 @@ public class ProductDerivations {
         // most specific to least
         for (int i = _derivations.length - 1; i >= 0; i--) {
             try {
-                provider = (globals) ? _derivations[i].loadGlobals(loader) 
-                    : _derivations[i].loadDefaults(loader);
+                provider = (globals) ? _derivations[i].loadGlobals() 
+                    : _derivations[i].loadDefaults();
                 if (provider != null)
                    return provider;
             } catch (Throwable t) {
@@ -398,47 +379,39 @@ public class ProductDerivations {
         StringBuilder errs = null;
         Throwable err = null;
         for (int i = _derivations.length - 1; i >= 0; i--) {
+        	ProductDerivation d = _derivations[i];
             try {
                 if (propertiesLocation == null) {
-                    String loc = _derivations[i].getDefaultResourceLocation();
-                    addAll(fqAnchors, loc,
-                        _derivations[i].getAnchorsInResource(loc));
+                    String loc = d.getDefaultResourceLocation();
+                    addAll(fqAnchors, loc, d.getAnchorsInResource(loc));
                     continue;
                 }
 
                 File f = new File(propertiesLocation);
-                if (((Boolean) J2DoPrivHelper.isFileAction(f).run())
-                    .booleanValue()) {
-                    addAll(fqAnchors, propertiesLocation,
-                        _derivations[i].getAnchorsInFile(f));
+                if (J2DoPrivHelper.isFileAction(f).run().booleanValue()) {
+                    addAll(fqAnchors, propertiesLocation, d.getAnchorsInFile(f));
                 } else {
-                    f = new File("META-INF" + File.separatorChar
-                        + propertiesLocation);
-                    if (((Boolean) J2DoPrivHelper.isFileAction(f).run())
-                        .booleanValue()) {
-                        addAll(fqAnchors, propertiesLocation,
-                            _derivations[i].getAnchorsInFile(f));
+                    f = new File("META-INF" + File.separatorChar + propertiesLocation);
+                    if (J2DoPrivHelper.isFileAction(f).run().booleanValue()) {
+                        addAll(fqAnchors, propertiesLocation, d.getAnchorsInFile(f));
                     } else {
-                        addAll(fqAnchors, propertiesLocation,
-                            _derivations[i].getAnchorsInResource(
-                                propertiesLocation));
+                        addAll(fqAnchors, propertiesLocation, d.getAnchorsInResource(propertiesLocation));
                     }
                 }
             } catch (Throwable t) {
                 err = t;
                 errs = (errs == null) ? new StringBuilder() : errs.append("\n");
-                errs.append(_derivations[i].getClass().getName() + ":" + t);
+                errs.append(d.getClass().getName() + ":" + t);
             }
         }
         reportErrors(errs, propertiesLocation, err);
         return fqAnchors;
     }
 
-    private static void addAll(Collection collection, String base,
-        Collection newMembers) {
+    private static void addAll(Collection<String> collection, String base,  Collection<String> newMembers) {
         if (newMembers == null || collection == null)
             return;
-        for (Iterator iter = newMembers.iterator(); iter.hasNext(); ) {
+        for (Iterator<String> iter = newMembers.iterator(); iter.hasNext(); ) {
             String fqLoc = base + "#" + iter.next();
             if (!collection.contains(fqLoc))
                 collection.add(fqLoc);

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringListValue.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringListValue.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringListValue.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringListValue.java Sat Oct 29 00:44:11 2011
@@ -32,7 +32,7 @@ import serp.util.Strings;
  *
  * @author Abe White
  */
-public class StringListValue extends Value {
+public class StringListValue extends Value<String[]> {
 
     public static final String[] EMPTY = new String[0];
     private static final Localizer s_loc = Localizer.forPackage
@@ -41,7 +41,7 @@ public class StringListValue extends Val
     private String[] _values = EMPTY;
 
     public StringListValue(String prop) {
-        super(prop);
+        super(String[].class, prop);
     }
 
     /**
@@ -60,10 +60,6 @@ public class StringListValue extends Val
         return _values;
     }
 
-    public Class<String []> getValueType() {
-        return String[].class;
-    }
-    
     /**
      * Unalias the value list.  This method defers to super.unalias()
      * UNLESS the string passed is a list of values for a property that
@@ -134,7 +130,7 @@ public class StringListValue extends Val
     }
 
     protected void setInternalObject(Object obj) {
-        set((String[]) obj);
+        set((String[])obj);
     }
     
     protected List<String> getAliasList() {

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringValue.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringValue.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringValue.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringValue.java Sat Oct 29 00:44:11 2011
@@ -25,16 +25,12 @@ import org.apache.commons.lang.StringUti
  *
  * @author Marc Prud'hommeaux
  */
-public class StringValue extends Value {
+public class StringValue extends Value<String> {
 
     private String value;
 
     public StringValue(String prop) {
-        super(prop);
-    }
-
-    public Class<String> getValueType() {
-        return String.class;
+        super(String.class, prop);
     }
 
     /**
@@ -64,11 +60,7 @@ public class StringValue extends Value {
     }
     
     protected void setInternalObject(Object obj) {
-        if (obj instanceof String) {
-            set((String) obj);
-        } else {
-            set(obj == null ? null : obj.toString());
-        }
+        set(obj == null ? null : obj.toString());
     }
 }
 

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Value.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Value.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Value.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Value.java Sat Oct 29 00:44:11 2011
@@ -31,44 +31,69 @@ import org.apache.openjpa.lib.util.Local
 import org.apache.openjpa.lib.util.ParseException;
 
 /**
- * A configuration value.
+ * A value of a user-configurable property.
+ * The runtime {@link Configuration configuration} is essentially comprised of a set of values.
+ * <br>
+ * Each Value is identified by a property key. A value can also have other {@link #getEquivalentKeys() equivalent 
+ * keys}. The user can configure using either the primary or the equivalent keys. For example, the user can configure
+ * the JDBC driver either by <tt>openjpa.ConnectionDriverName</tt> or <tt>javax.persistence.jdbc.driver</tt>.
+ * <br>
+ * A Value can be aliased. For example, a value of a fully qualified class name 
+ * <tt>org.apache.openjpa.ee.ManagedRuntime</tt> can be aliased simply as <tt>managed</tt>.
+ * Some values can have a {@link #isAliasListComprehensive() fixed} set of aliases such as values that represents
+ * an enumeration. 
+ * <br>
+ * A Value may have a {@link #getDefault() default} value. Setting a default value does not imply that the vale is 
+ * set to the default value. The value is explicitly set by {@link #setObject(Object) set} method. 
+ * <br>
+ * The values are often printed on console etc. hence the values that carry sensitive information such as 
+ * password can be {@link #hide() hidden}.
+ * <br>
+ * Most values get frozen after an OpenJPA runtime is initialized. However, a value can be modified at runtime
+ * only if it is declared as {@link #setDynamic(boolean) dynamic}. Dynamic change of a value is significant because
+ * the identity of a OpenJPA runtime is hash code of {@link Configuration configuration} which, in turn, is hash code
+ * of its values. This identity is critical to locate a OpenJPA runtime. The dynamic values remember their original 
+ * value and that original value is used its hash code computation.
+ * <br>
+ * Listeners can be {@link #addListener(ValueListener) added} to a value to be notified of changes.
+ * <p>
+ * Value is made generic since version 2.2.0. The generic type implies the type of value e.g. Value&ltInteger&gt; 
+ * holds integer value. 
  *
  * @author Marc Prud'hommeaux
  * @author Pinaki Poddar
  */
-public abstract class Value implements Cloneable {
+public abstract class Value<T> implements Cloneable {
 
-    private static final String[] EMPTY_ALIASES = new String[0];
-    private static final Localizer s_loc = Localizer.forPackage(Value.class);
+    private static final String[] EMPTY_ALIASES  = new String[0];
+    private static final Set<String> EMPTY_SET = Collections.emptySet();
+    
     public static final String INVISIBLE = "******";
+    private static final Localizer s_loc = Localizer.forPackage(Value.class);
     
-    private String prop = null;
-    private String loadKey = null;
-    private String def = null;
-    private String[] aliases = null;
-    private String getter = null;
-    private List<ValueListener> listeners = null;
-    private boolean aliasListComprehensive = false;
-    private Class scope = null;
-    private boolean isDynamic = false;
-    private String originalValue = null;
-    private Set<String> otherNames = null;
-    private boolean _hidden  = false;
-    private boolean _private = false;
+    private final String _prop;
+    private final Class<T> _type;
+    private String loadKey;
+    private String def;
+    private String[] aliases;
+    private String getter;
+    private List<ValueListener> listeners;
+    private boolean aliasListComprehensive;
+    private Class<?> scope;
+    private boolean isDynamic;
+    private String originalValue;
+    private Set<String> otherNames;
+    private boolean _hidden;
+    private boolean _private;
     
     /**
-     * Default constructor.
-     */
-    public Value() {
-    }
-
-    /**
      * Constructor. Supply the property name.
      *
      * @see #setProperty
      */
-    public Value(String prop) {
-        setProperty(prop);
+    public Value(Class<T> type, String prop) {
+    	_type = type;
+        _prop  = prop;
     }
 
     /**
@@ -76,18 +101,10 @@ public abstract class Value implements C
      * getting this value in a {@link Map}.
      */
     public String getProperty() {
-        return prop;
+        return _prop;
     }
 
     /**
-     * The property name that will be used when setting or
-     * getting this value in a {@link Map}.
-     */
-    public void setProperty(String prop) {
-        this.prop = prop;
-    }
-    
-    /**
      * Adds a moniker that is equivalent to the original property key used
      * during construction. 
      * 
@@ -106,8 +123,7 @@ public abstract class Value implements C
      * @since 2.0.0
      */
     public Set<String> getEquivalentKeys() {
-        return otherNames == null ? Collections.EMPTY_SET 
-            : Collections.unmodifiableSet(otherNames);
+        return otherNames == null ? EMPTY_SET : Collections.unmodifiableSet(otherNames);
     }
     
     /**
@@ -118,8 +134,7 @@ public abstract class Value implements C
      * @since 2.0.0
      */
     public List<String> getPropertyKeys() {
-        List<String> result = new ArrayList<String>(1 + 
-            (otherNames ==null ? 0 : otherNames.size()));
+        List<String> result = new ArrayList<String>(1 + (otherNames ==null ? 0 : otherNames.size()));
         result.add(getProperty());
         if (otherNames != null)
             result.addAll(otherNames);
@@ -149,9 +164,8 @@ public abstract class Value implements C
      * already loaded key. 
      */
     public void setLoadKey(String key) {
-        if (this.loadKey != null && key != null && !this.loadKey.equals(key)) 
-            throw new ParseException(s_loc.get("multiple-load-key", 
-                loadKey, key));
+        if (loadKey != null && key != null && !loadKey.equals(key)) 
+            throw new ParseException(s_loc.get("multiple-load-key", loadKey, key));
         loadKey = key;
     }
 
@@ -183,7 +197,7 @@ public abstract class Value implements C
     public void setAlias(String key, String value) {
         aliases = setAlias(key, value, aliases);
     }
-
+    
     /**
      * Set an alias into a current alias list, returning the new list.
      */
@@ -210,7 +224,7 @@ public abstract class Value implements C
      * value. If so, an error will be generated when attempting to invoke
      * any method on this value with an unknown option.
      */
-    public boolean isAliasListComprehensive() {
+    public final boolean isAliasListComprehensive() {
         return aliasListComprehensive;
     }
 
@@ -219,7 +233,7 @@ public abstract class Value implements C
      * value. If so, an error will be generated when attempting to invoke
      * any method on this value with an unknown option.
      */
-    public void setAliasListComprehensive(boolean aliasListIsComprehensive) {
+    public final void setAliasListComprehensive(boolean aliasListIsComprehensive) {
         this.aliasListComprehensive = aliasListIsComprehensive;
     }
 
@@ -295,7 +309,7 @@ public abstract class Value implements C
 
     /**
      * The name of the getter method for the instantiated value of this
-     * property(as opposed to the string value)
+     * property (as opposed to the string value)
      */
     public String getInstantiatingGetter() {
         return getter;
@@ -317,7 +331,7 @@ public abstract class Value implements C
      * be used by the configuration framework to look up metadata about
      * the value.
      */
-    public Class getScope() {
+    public Class<?> getScope() {
         return scope;
     }
 
@@ -326,7 +340,7 @@ public abstract class Value implements C
      * be used by the configuration framework to look up metadata about
      * the value.
      */
-    public void setScope(Class cls) {
+    public void setScope(Class<?> cls) {
         scope = cls;
     }
 
@@ -341,7 +355,7 @@ public abstract class Value implements C
     /**
      * Set this value from the given string. If the given string is null or
      * empty and a default is defined, the default is used. If the given
-     * string(or default) is an alias key, it will be converted to the
+     * string (or default) is an alias key, it will be converted to the
      * corresponding value internally.
      * <br>
      * If this Value is being set to a non-default value for the first time
@@ -362,7 +376,7 @@ public abstract class Value implements C
         } catch (ParseException pe) {
             throw pe;
         } catch (RuntimeException re) {
-            throw new ParseException(prop + ": " + val, re);
+            throw new ParseException(_prop + ": " + val, re);
         }
     }
 
@@ -376,11 +390,11 @@ public abstract class Value implements C
      * {@link #isDynamic() dynamic}. 
      * 
      */
-    public void setObject(Object obj) {
+    public void setObject(T obj) {
         // if setting to null set as string to get defaults into play
-        if (obj == null && def != null)
+        if (obj == null && def != null) {
             setString(null);
-        else {
+        } else {
             try {
                 setInternalObject(obj);
                 if (originalValue == null && obj != null && !isDefault(obj)) {
@@ -389,7 +403,7 @@ public abstract class Value implements C
             } catch (ParseException pe) {
                 throw pe;
             } catch (RuntimeException re) {
-                throw new ParseException(prop + ": " + obj, re);
+                throw new ParseException(_prop + ": " + obj, re);
             }
         }
     }
@@ -413,25 +427,12 @@ public abstract class Value implements C
     /**
      * Returns the type of the property that this Value represents.
      */
-    public abstract Class<?> getValueType();
-
-    /**
-     * Return the internal string form of this value.
-     */
-    protected abstract String getInternalString();
-
-    /**
-     * Set this value from the given string.
-     */
-    protected abstract void setInternalString(String str);
-
-    /**
-     * Set this value from an object.
-     */
-    protected abstract void setInternalObject(Object obj);
+    public final Class<T> getValueType() {
+    	return _type;
+    }
 
     /**
-     * Gets unmodifable list of listeners for value changes.
+     * Gets unmodifiable list of listeners for value changes.
      */
     public List<ValueListener> getListeners() {
         return Collections.unmodifiableList(this.listeners);
@@ -499,7 +500,7 @@ public abstract class Value implements C
      *  
      * @since 1.1.0
      */
-    public void setDynamic(boolean flag) {
+    public final void setDynamic(boolean flag) {
     	isDynamic = flag;
     }
     
@@ -509,7 +510,7 @@ public abstract class Value implements C
      *  
      * @since 1.1.0
      */
-    public boolean isDynamic() {
+    public final boolean isDynamic() {
     	return isDynamic; 
     }
 
@@ -522,7 +523,7 @@ public abstract class Value implements C
     public int hashCode() {
         String str = (isDynamic()) ? getOriginalValue() : getString();
         int strHash = (str == null) ? 0 : str.hashCode();
-        int propHash = (prop == null) ? 0 : prop.hashCode();
+        int propHash = (_prop == null) ? 0 : _prop.hashCode();
         return strHash ^ propHash;
     }
 
@@ -538,11 +539,11 @@ public abstract class Value implements C
         if (!(other instanceof Value))
             return false;
 
-        Value o = (Value) other;
+        Value<T> o = (Value<T>) other;
         String thisStr = (isDynamic()) ? getOriginalValue() : getString();
         String thatStr = (isDynamic()) ? o.getOriginalValue() : o.getString();
         return (isDynamic() == o.isDynamic())
-            && StringUtils.equals(prop, o.getProperty())
+            && StringUtils.equals(_prop, o.getProperty())
             && StringUtils.equals(thisStr, thatStr);
     }
 
@@ -566,7 +567,7 @@ public abstract class Value implements C
     /**
      * Hides the value of this Value from being output to the caller.
      */
-    public void hide() {
+    public final void hide() {
         _hidden = true;
     }
     
@@ -574,23 +575,49 @@ public abstract class Value implements C
      * Affirms if this Value is used for internal purpose only and not exposed as a supported property.
      * @see Configuration#getPropertyKeys()
      */
-    public boolean isPrivate() {
+    public final boolean isPrivate() {
         return _private;
     }
 
     /**
      * Marks this Value for internal purpose only.
      */
-    public void makePrivate() {
+    public final void makePrivate() {
         _private = true;
     }
     
     /**
-     * Get the actual data stored in this value.
+     * Gets the external visible form of this value.
+     * @return
      */
-    public abstract Object get();
+    public Object getExternal() {
+    	return _hidden ? INVISIBLE : get();
+    }
     
     public String toString() {
-        return getProperty()+ ":" + get() + "[" + getValueType().getName() + "]";
+        return getProperty() + "<" + getValueType().getSimpleName() + ">:" + get();
     }
+    
+    
+    /**
+     * Get the actual data stored in this value.
+     */
+    public abstract T get();
+    
+    /**
+     * Return the internal string form of this value.
+     */
+    protected abstract String getInternalString();
+
+    /**
+     * Set this value from the given string.
+     */
+    protected abstract void setInternalString(String str);
+
+    /**
+     * Set this value from an object.
+     */
+    protected abstract void setInternalObject(Object obj);
+
+
 }

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ValueListener.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ValueListener.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ValueListener.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ValueListener.java Sat Oct 29 00:44:11 2011
@@ -28,5 +28,5 @@ public interface ValueListener {
     /**
      * Callback used by {@link Value} objects to notify listener of change.
      */
-    public void valueChanged(Value val);
+    public void valueChanged(Value<?> val);
 }

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/instrumentation/AbstractInstrumentationProvider.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/instrumentation/AbstractInstrumentationProvider.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/instrumentation/AbstractInstrumentationProvider.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/instrumentation/AbstractInstrumentationProvider.java Sat Oct 29 00:44:11 2011
@@ -38,7 +38,7 @@ public abstract class AbstractInstrument
     private Map<String, Instrument> _instruments = new ConcurrentHashMap<String, Instrument>();
     
     private boolean _started = false;
-    private PluginListValue _instrumentValues;
+    private PluginListValue<Instrument> _instrumentValues;
     private String _options;
     private Configuration _config;
 
@@ -57,13 +57,13 @@ public abstract class AbstractInstrument
     }
     
     public void setInstrument(String instrument) {
-        _instrumentValues = new PluginListValue("Instrument");
+        _instrumentValues = new PluginListValue<Instrument>(Instrument[].class, "Instrument");
         if (getInstrumentAliases() != null) {
             _instrumentValues.setAliases(getInstrumentAliases());
         }
         _instrumentValues.setString(instrument);
         
-        Instrument[] instruments = (Instrument[])_instrumentValues.instantiate(Instrument.class, _config);
+        Instrument[] instruments = _instrumentValues.instantiate(_config);
         for (Instrument inst : instruments) {
             inst.setProvider(this);
             _instruments.put(inst.getName(), inst);

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/CFMetaDataParser.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/CFMetaDataParser.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/CFMetaDataParser.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/CFMetaDataParser.java Sat Oct 29 00:44:11 2011
@@ -36,16 +36,15 @@ import serp.util.Strings;
  */
 public class CFMetaDataParser extends XMLMetaDataParser {
 
-    static final String[] PACKAGES = new String[]{
-        "java.lang.", "java.util.", "java.math." };
-    private static final Localizer _loc = Localizer.forPackage
-        (CFMetaDataParser.class);
+    static final String[] PACKAGES = new String[]{"java.lang.", "java.util.", "java.math." };
+    private static final Localizer _loc = Localizer.forPackage(CFMetaDataParser.class);
 
     // the current package and class being parsed
     private String _package = null;
     private String _class = null;
 
-    public CFMetaDataParser() {
+    public CFMetaDataParser(ClassLoader loader) {
+    	super(loader);
         setParseText(false);
     }
 
@@ -282,8 +281,7 @@ public class CFMetaDataParser extends XM
         throws SAXException {
         if (name == null)
             return null;
-        Class<?> cls =
-            classForName(name, _package, resolve, currentClassLoader());
+        Class<?> cls = classForName(name, _package, resolve, getClassLoader());
         if (cls == null)
             throw getException(_loc.get("invalid-class", name).getMessage());
         return cls;
@@ -298,9 +296,6 @@ public class CFMetaDataParser extends XM
         if (StringUtils.isEmpty(name))
             return null;
 
-        if (loader == null)
-            loader = AccessController.doPrivileged(
-                J2DoPrivHelper.getContextClassLoaderAction());
         boolean fullName = name.indexOf('.') != -1;
         boolean noPackage = StringUtils.isEmpty(pkg);
         try {

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassArgParser.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassArgParser.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassArgParser.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassArgParser.java Sat Oct 29 00:44:11 2011
@@ -66,15 +66,13 @@ public class ClassArgParser {
     private static final int TOKEN_PACKAGE_NOATTR = 3;
     private static final int TOKEN_CLASS_NOATTR = 4;
 
-    private static final Localizer _loc = Localizer.forPackage
-        (ClassArgParser.class);
+    private static final Localizer _loc = Localizer.forPackage(ClassArgParser.class);
 
     private ClassLoader _loader = null;
     private char[] _packageAttr = "name".toCharArray();
     private char[] _classAttr = "name".toCharArray();
     private char[][] _beginElements = { { 'p' }, { 'c' } };
-    private char[][] _endElements = { "ackage".toCharArray(),
-        "lass".toCharArray() };
+    private char[][] _endElements = { "ackage".toCharArray(), "lass".toCharArray() };
 
     /**
      * The class loader with which to load parsed classes.
@@ -106,14 +104,14 @@ public class ClassArgParser {
         for (; true; charIdx++) {
             for (int i = 0; i < buf.length; i++) {
                 if (i == 0) {
-                    if (charIdx == packageElementName.length())
-                        throw new UnsupportedOperationException(_loc.get
-                            ("cant-diff-elems").getMessage());
+                    if (charIdx == packageElementName.length()) {
+                        throw new UnsupportedOperationException(_loc.get("cant-diff-elems").getMessage());
+                    }
                     buf[i] = packageElementName.charAt(charIdx);
                 } else {
-                    if (charIdx == classElementNames[i - 1].length())
-                        throw new UnsupportedOperationException(_loc.get
-                            ("cant-diff-elems").getMessage());
+                    if (charIdx == classElementNames[i - 1].length()) {
+                        throw new UnsupportedOperationException(_loc.get("cant-diff-elems").getMessage());
+                    }
                     buf[i] = classElementNames[i - 1].charAt(charIdx);
                 }
             }
@@ -121,21 +119,15 @@ public class ClassArgParser {
                 break;
         }
 
-        _packageAttr = (packageAttributeName == null) ? null
-            : packageAttributeName.toCharArray();
-        _classAttr = (classAttributeName == null) ? null
-            : classAttributeName.toCharArray();
+        _packageAttr = (packageAttributeName == null) ? null : packageAttributeName.toCharArray();
+        _classAttr   = (classAttributeName == null)   ? null : classAttributeName.toCharArray();
         _beginElements = new char[classElementNames.length + 1][];
         _endElements = new char[classElementNames.length + 1][];
-        _beginElements[0] = packageElementName.substring(0, charIdx + 1).
-            toCharArray();
-        _endElements[0] = packageElementName.substring(charIdx + 1).
-            toCharArray();
+        _beginElements[0] = packageElementName.substring(0, charIdx + 1).toCharArray();
+        _endElements[0] = packageElementName.substring(charIdx + 1).toCharArray();
         for (int i = 0; i < classElementNames.length; i++) {
-            _beginElements[i + 1] = classElementNames[i].
-                substring(0, charIdx + 1).toCharArray();
-            _endElements[i + 1] = classElementNames[i].
-                substring(charIdx + 1).toCharArray();
+            _beginElements[i + 1] = classElementNames[i].substring(0, charIdx + 1).toCharArray();
+            _endElements[i + 1] = classElementNames[i].substring(charIdx + 1).toCharArray();
         }
     }
 
@@ -213,10 +205,12 @@ public class ClassArgParser {
 
         try {
             File file = Files.getFile(arg, _loader);
-            if (arg.endsWith(".class"))
+            if (arg.endsWith(".class")) {
                 return new String[]{ getFromClassFile(file) };
-            if (arg.endsWith(".java"))
+            }
+            if (arg.endsWith(".java")) {
                 return new String[]{ getFromJavaFile(file) };
+            }
             if ((AccessController.doPrivileged(
                 J2DoPrivHelper.existsAction(file))).booleanValue()) {
                 Collection<String> col = getFromMetaDataFile(file);

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassMetaDataIterator.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassMetaDataIterator.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassMetaDataIterator.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassMetaDataIterator.java Sat Oct 29 00:44:11 2011
@@ -21,6 +21,7 @@ package org.apache.openjpa.lib.meta;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.URI;
 import java.net.URL;
 import java.net.URLDecoder;
 import java.security.AccessController;
@@ -55,16 +56,7 @@ public class ClassMetaDataIterator imple
      * Constructor; supply the class whose metadata to find, the suffix
      * of metadata files, and whether to parse top-down or bottom-up.
      */
-    public ClassMetaDataIterator(Class<?> cls, String suffix, boolean topDown) {
-        this(cls, suffix, null, topDown);
-    }
-
-    /**
-     * Constructor; supply the class whose metadata to find, the suffix
-     * of metadata files, and whether to parse top-down or bottom-up.
-     */
-    public ClassMetaDataIterator(Class<?> cls, String suffix,
-            ClassLoader loader, boolean topDown) {
+    public ClassMetaDataIterator(Class<?> cls, String suffix, ClassLoader loader, boolean topDown) {
         // skip classes that can't have metadata
         if (cls != null && (cls.isPrimitive()
             || cls.getName().startsWith("java.")
@@ -80,11 +72,8 @@ public class ClassMetaDataIterator imple
             multi.addClassLoader(MultiClassLoader.SYSTEM_LOADER);
             multi.addClassLoader(MultiClassLoader.THREAD_LOADER);
             multi.addClassLoader(getClass().getClassLoader());
-            if (cls != null)
-            {
-                ClassLoader clsLoader = (ClassLoader)
-                    AccessController.doPrivileged(
-                        J2DoPrivHelper.getClassLoaderAction(cls));
+            if (cls != null) {
+                ClassLoader clsLoader = AccessController.doPrivileged(J2DoPrivHelper.getClassLoaderAction(cls));
                 if (clsLoader != null)
                     multi.addClassLoader(clsLoader);
             }

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/MetaDataParser.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/MetaDataParser.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/MetaDataParser.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/MetaDataParser.java Sat Oct 29 00:44:11 2011
@@ -33,12 +33,6 @@ import java.util.List;
 public interface MetaDataParser {
 
     /**
-     * The classloader to use to resolve resources, or null for impl-defined
-     * default.
-     */
-    public void setClassLoader(ClassLoader loader);
-
-    /**
      * Return the results from the last parse.
      */
     public List getResults();

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ResourceMetaDataIterator.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ResourceMetaDataIterator.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ResourceMetaDataIterator.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ResourceMetaDataIterator.java Sat Oct 29 00:44:11 2011
@@ -47,30 +47,14 @@ public class ResourceMetaDataIterator im
     /**
      * Constructor; supply the resource to parse.
      */
-    public ResourceMetaDataIterator(String rsrc) throws IOException {
-        this(rsrc, null);
-    }
-
-    /**
-     * Constructor; supply the resource to parse.
-     */
     public ResourceMetaDataIterator(String rsrc, ClassLoader loader)
         throws IOException {
-        if (loader == null) {
-            MultiClassLoader multi = AccessController
-                .doPrivileged(J2DoPrivHelper.newMultiClassLoaderAction());
-            multi.addClassLoader(MultiClassLoader.SYSTEM_LOADER);
-            multi.addClassLoader(MultiClassLoader.THREAD_LOADER);
-            multi.addClassLoader(getClass().getClassLoader());
-            loader = multi;
-        }
-
         try {
-            Enumeration<URL> e = AccessController.doPrivileged(
-                J2DoPrivHelper.getResourcesAction(loader, rsrc));
+            Enumeration<URL> e = AccessController.doPrivileged(J2DoPrivHelper.getResourcesAction(loader, rsrc));
             while (e.hasMoreElements()) {
-                if (_urls == null)
+                if (_urls == null) {
                     _urls = new ArrayList<URL>(3);
+                }
                 _urls.add(e.nextElement());
             }
         } catch (PrivilegedActionException pae) {
@@ -103,8 +87,7 @@ public class ResourceMetaDataIterator im
         if (_url == -1 || _url >= _urls.size())
             throw new IllegalStateException();
         File file = new File(URLDecoder.decode((_urls.get(_url)).getFile()));
-        return ((AccessController.doPrivileged(
-            J2DoPrivHelper.existsAction(file))).booleanValue()) ? file :null;
+        return ((AccessController.doPrivileged(J2DoPrivHelper.existsAction(file))).booleanValue()) ? file :null;
     }
 
     public void close() {

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/SourceTracker.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/SourceTracker.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/SourceTracker.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/SourceTracker.java Sat Oct 29 00:44:11 2011
@@ -22,7 +22,7 @@ import java.io.File;
 
 /**
  * Interface that can optionally be implemented by metadata
- * to include the source file from which the metadata was originally parsed.
+ * to include the source URL from which the metadata was originally parsed.
  *
  * @author Abe White
  */
@@ -33,7 +33,7 @@ public interface SourceTracker {
     public static final int SRC_XML = 2;
 
     /**
-     * Return the file from which this instance was parsed.
+     * Return the URL from which this instance was parsed.
      */
     public File getSourceFile();
 

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/XMLMetaDataParser.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/XMLMetaDataParser.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/XMLMetaDataParser.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/XMLMetaDataParser.java Sat Oct 29 00:44:11 2011
@@ -55,6 +55,9 @@ import org.apache.openjpa.lib.xml.XMLFac
 /**
  * Custom SAX parser used by the system to quickly parse metadata files.
  * Subclasses should handle the processing of the content.
+ * <br>
+ * The parsers may need to resolve parsed strings to actual class instances.
+ * 
  *
  * @author Abe White
  * @nojavadoc
@@ -62,8 +65,7 @@ import org.apache.openjpa.lib.xml.XMLFac
 public abstract class XMLMetaDataParser extends DefaultHandler
     implements LexicalHandler, MetaDataParser {
 
-    private static final Localizer _loc = Localizer.forPackage
-        (XMLMetaDataParser.class);
+    private static final Localizer _loc = Localizer.forPackage(XMLMetaDataParser.class);
     private static boolean _schemaBug;
 
     static {
@@ -71,9 +73,8 @@ public abstract class XMLMetaDataParser 
             // check for Xerces version 2.0.2 to see if we need to disable
             // schema validation, which works around the bug reported at:
             // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4708859
-            _schemaBug = "Xerces-J 2.0.2".equals(Class.forName
-                ("org.apache.xerces.impl.Version").getField("fVersion").
-                get(null));
+            _schemaBug = "Xerces-J 2.0.2".equals(Class.forName("org.apache.xerces.impl.Version")
+            		.getField("fVersion").get(null));
         } catch (Throwable t) {
             // Xerces might not be available
             _schemaBug = false;
@@ -82,8 +83,8 @@ public abstract class XMLMetaDataParser 
 
     // map of classloaders to sets of parsed locations, so that we don't parse
     // the same resource multiple times for the same class
-    private Map<ClassLoader, Set<String>> _parsed = null;
-
+    private Set<String> _parsed = null;
+    
     private Log _log = null;
     private boolean _validating = true;
     private boolean _systemId = true;
@@ -91,8 +92,8 @@ public abstract class XMLMetaDataParser 
     private boolean _parseText = true;
     private boolean _parseComments = true;
     private String _suffix = null;
-    private ClassLoader _loader = null;
-    private ClassLoader _curLoader = null;
+//    private ClassLoader _loader = null;
+//    private ClassLoader _curLoader = null;
 
     // state for current parse
     private final Collection _curResults = new LinkedList();
@@ -107,17 +108,12 @@ public abstract class XMLMetaDataParser 
     private int _ignore = Integer.MAX_VALUE;
 
     private boolean _parsing = false;
+    private final ClassLoader _loader;
     
-    private boolean _overrideContextClassloader = false;
-    
-    public boolean getOverrideContextClassloader() {
-        return _overrideContextClassloader;
-    }
-
-    public void setOverrideContextClassloader(boolean overrideCCL) {
-        _overrideContextClassloader = overrideCCL;
+    protected XMLMetaDataParser(ClassLoader loader) {
+    	_loader = loader;
     }
-
+    
     /*
      * Whether the parser is currently parsing.
      */
@@ -267,16 +263,16 @@ public abstract class XMLMetaDataParser 
     /**
      * Classloader to use for class name resolution.
      */
-    public ClassLoader getClassLoader() {
-        return _loader;
-    }
+//    public ClassLoader getClassLoader() {
+//        return _loader;
+//    }
 
     /**
      * Classloader to use for class name resolution.
      */
-    public void setClassLoader(ClassLoader loader) {
-        _loader = loader;
-    }
+//    public void setClassLoader(ClassLoader loader) {
+//        _loader = loader;
+//    }
 
     public List getResults() {
         if (_results == null)
@@ -297,8 +293,7 @@ public abstract class XMLMetaDataParser 
     public void parse(File file) throws IOException {
         if (file == null)
             return;
-        if (!(AccessController.doPrivileged(J2DoPrivHelper
-            .isDirectoryAction(file))).booleanValue())
+        if (!(AccessController.doPrivileged(J2DoPrivHelper.isDirectoryAction(file))).booleanValue())
             parse(new FileMetaDataIterator(file));
         else {
             String suff = (_suffix == null) ? "" : _suffix;
@@ -307,9 +302,9 @@ public abstract class XMLMetaDataParser 
         }
     }
 
-    public void parse(Class cls, boolean topDown) throws IOException {
+    public void parse(Class<?> cls, boolean topDown) throws IOException {
         String suff = (_suffix == null) ? "" : _suffix;
-        parse(new ClassMetaDataIterator(cls, suff, topDown), !topDown);
+        parse(new ClassMetaDataIterator(cls, suff, _loader, topDown), !topDown);
     }
 
     public void parse(Reader xml, String sourceName) throws IOException {
@@ -369,8 +364,7 @@ public abstract class XMLMetaDataParser 
                 _log.trace(_loc.get("parser-schema-bug"));
             schemaSource = null;
         }
-        boolean validating = _validating && (getDocType() != null 
-            || schemaSource != null);
+        boolean validating = _validating && (getDocType() != null || schemaSource != null);
 
         // parse the metadata with a SAX parser
         try {
@@ -378,22 +372,8 @@ public abstract class XMLMetaDataParser 
             _sourceName = sourceName;
             
             SAXParser parser = null;
-            boolean overrideCL = _overrideContextClassloader;
-            ClassLoader oldLoader = null;
-            ClassLoader newLoader = null;           
             
             try {
-                if (overrideCL == true) {
-                    oldLoader =
-                        (ClassLoader) AccessController.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction());
-                    newLoader = XMLMetaDataParser.class.getClassLoader();
-                    AccessController.doPrivileged(J2DoPrivHelper.setContextClassLoaderAction(newLoader));
-                    
-                    if (_log != null && _log.isTraceEnabled()) {
-                        _log.trace(_loc.get("override-contextclassloader-begin", oldLoader, newLoader));
-                    }                   
-                }
-                
                 parser = XMLFactory.getSAXParser(validating, true);
                 Object schema = null;
                 if (validating) {
@@ -403,16 +383,12 @@ public abstract class XMLMetaDataParser 
                 }
 
                 if (_parseComments || _lh != null)
-                    parser.setProperty
-                        ("http://xml.org/sax/properties/lexical-handler", this);
+                    parser.setProperty("http://xml.org/sax/properties/lexical-handler", this);
 
                 if (schema != null) {
-                    parser.setProperty
-                        ("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
+                    parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
                             "http://www.w3.org/2001/XMLSchema");
-                    parser.setProperty
-                        ("http://java.sun.com/xml/jaxp/properties/schemaSource",
-                            schema);
+                    parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", schema);
                 }
 
                 InputSource is = new InputSource(xml);
@@ -425,19 +401,6 @@ public abstract class XMLMetaDataParser 
                 ioe.initCause(se);
                 throw ioe;
             } finally {
-                if (overrideCL == true) {
-                    // Restore the old ContextClassloader
-                    try {
-                        if (_log != null && _log.isTraceEnabled()) {
-                            _log.trace(_loc.get("override-contextclassloader-end", newLoader, oldLoader));
-                        }
-                        AccessController.doPrivileged(J2DoPrivHelper.setContextClassLoaderAction(oldLoader));
-                    } catch (Throwable t) {
-                        if (_log != null && _log.isWarnEnabled()) {
-                            _log.warn(_loc.get("restore-contextclassloader-failed"));
-                        }
-                    }
-                }
             }
         } finally {
             reset();
@@ -452,15 +415,9 @@ public abstract class XMLMetaDataParser 
         if (!_caching)
             return false;
         if (_parsed == null)
-            _parsed = new HashMap<ClassLoader, Set<String>>();
+            _parsed = new HashSet<String>();
 
-        ClassLoader loader = currentClassLoader();
-        Set<String> set = _parsed.get(loader);
-        if (set == null) {
-            set = new HashSet<String>();
-            _parsed.put(loader, set);
-        }
-        boolean added = set.add(src);
+        boolean added = _parsed.add(src);
         if (!added && _log != null && _log.isTraceEnabled())
             _log.trace(_loc.get("already-parsed", src));
         return !added;
@@ -594,7 +551,7 @@ public abstract class XMLMetaDataParser 
      */
     protected void reset() {
         _curResults.clear();
-        _curLoader = null;
+//        _curLoader = null;
         _sourceName = null;
         _sourceFile = null;
         _depth = -1;
@@ -690,14 +647,13 @@ public abstract class XMLMetaDataParser 
      * Return the class loader to use when resolving resources and loading
      * classes.
      */
-    protected ClassLoader currentClassLoader() {
-        if (_loader != null)
-            return _loader;
-        if (_curLoader == null)
-            _curLoader = AccessController.doPrivileged(
-                J2DoPrivHelper.getContextClassLoaderAction());
-        return _curLoader;
-    }
+//    protected ClassLoader currentClassLoader() {
+//        if (_loader != null)
+//            return _loader;
+//        if (_curLoader == null)
+//            _curLoader = AccessController.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction());
+//        return _curLoader;
+//    }
 
     /**
      * Ignore all content below the current element.
@@ -744,4 +700,12 @@ public abstract class XMLMetaDataParser 
 
     protected void clearDeferredMetaData() {
     }
+    
+    /**
+     * Gets the class loader used by this parser to resolve classes
+     * or locate resources.
+     */
+    protected final ClassLoader getClassLoader() {
+    	return _loader;
+    }
 }

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/XMLVersionParser.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/XMLVersionParser.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/XMLVersionParser.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/XMLVersionParser.java Sat Oct 29 00:44:11 2011
@@ -18,6 +18,9 @@
  */
 package org.apache.openjpa.lib.meta;
 
+import java.util.LinkedHashSet;
+import java.util.Set;
+
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 
@@ -34,16 +37,18 @@ public class XMLVersionParser extends XM
     public static final String VERSION_2_0 = "2.0";
 
     static private final String VERSION_ATTR = "version";
-    static private final String XSI_NS =
-        "http://www.w3.org/2001/XMLSchema-instance";
+    static private final String XSI_NS = "http://www.w3.org/2001/XMLSchema-instance";
     static private final String SCHEMA_LOCATION = "schemaLocation";
 
     private String _rootElement;
     private String _version;
     private String _schemaLocation;
+    private Set<String> _unitNames;
     
     public XMLVersionParser(String rootElement) {
+    	super(null);
         _rootElement = rootElement;
+        _unitNames = new LinkedHashSet<String>();
         setCaching(false);
         setValidating(false);
         setParseText(false);
@@ -61,8 +66,10 @@ public class XMLVersionParser extends XM
             // save the version and schema location attributes
             _version = attrs.getValue("", VERSION_ATTR);
             _schemaLocation = attrs.getValue(XSI_NS, SCHEMA_LOCATION);
-            // ignore remaining content
-            ignoreContent(true);
+        } else if (name.equals("persistence-unit")) {
+        	 _unitNames.add(attrs.getValue("name"));
+             // ignore remaining content
+             ignoreContent(true);
         }
         return false;
     }
@@ -82,4 +89,8 @@ public class XMLVersionParser extends XM
     public String getSchemaLocation() {
         return _schemaLocation;
     }
+    
+    public Set<String> unitNames() {
+    	return _unitNames;
+    }
 }

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/JavaVendors.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/JavaVendors.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/JavaVendors.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/JavaVendors.java Sat Oct 29 00:44:11 2011
@@ -24,7 +24,8 @@ import java.security.AccessController;
  * Utilities for dealing with different Java vendors.
  */
 public enum JavaVendors {
-    IBM("com.ibm.tools.attach.VirtualMachine"), SUN("com.sun.tools.attach.VirtualMachine"),
+    IBM("com.ibm.tools.attach.VirtualMachine"), 
+    SUN("com.sun.tools.attach.VirtualMachine"),
     // When in doubt, try the Sun implementation.
     OTHER("com.sun.tools.attach.VirtualMachine");
 

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/MultiClassLoader.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/MultiClassLoader.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/MultiClassLoader.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/MultiClassLoader.java Sat Oct 29 00:44:11 2011
@@ -23,6 +23,7 @@ import java.net.URL;
 import java.security.AccessController;
 import java.security.PrivilegedActionException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Enumeration;
 import java.util.Iterator;
 import java.util.List;
@@ -47,11 +48,10 @@ public class MultiClassLoader extends Cl
     /**
      * The standard system class loader.
      */
-    public static final ClassLoader SYSTEM_LOADER =
-        AccessController.doPrivileged(
+    public static final ClassLoader SYSTEM_LOADER = AccessController.doPrivileged(
             J2DoPrivHelper.getSystemClassLoaderAction());
 
-    private List _loaders = new ArrayList(5);
+    private List<ClassLoader> _loaders = new ArrayList<ClassLoader>(5);
 
     /**
      * Constructor; initializes the loader with an empty list of delegates.
@@ -81,12 +81,12 @@ public class MultiClassLoader extends Cl
     public ClassLoader[] getClassLoaders() {
         ClassLoader[] loaders = new ClassLoader[size()];
         ClassLoader loader;
-        Iterator itr = _loaders.iterator();
+        Iterator<ClassLoader> itr = _loaders.iterator();
         for (int i = 0; i < loaders.length; i++) {
-            loader = (ClassLoader) itr.next();
-            if (loader == THREAD_LOADER)
-                loader = AccessController.doPrivileged(
-                    J2DoPrivHelper.getContextClassLoaderAction());
+            loader = itr.next();
+            if (loader == THREAD_LOADER) {
+                loader = AccessController.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction());
+            }
             loaders[i] = loader;
         }
         return loaders;
@@ -96,10 +96,10 @@ public class MultiClassLoader extends Cl
      * Return the class loader at the given index.
      */
     public ClassLoader getClassLoader(int index) {
-        ClassLoader loader = (ClassLoader) _loaders.get(index);
-        if (loader == THREAD_LOADER)
-            loader = AccessController.doPrivileged(
-                J2DoPrivHelper.getContextClassLoaderAction());
+        ClassLoader loader = _loaders.get(index);
+        if (loader == THREAD_LOADER) {
+            loader = AccessController.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction());
+        }
         return loader;
     }
 
@@ -125,7 +125,7 @@ public class MultiClassLoader extends Cl
         _loaders.add(index, loader);
         return true;
     }
-
+    
     /**
      * Set the class loaders of this loader to those of the given loader.
      */
@@ -146,8 +146,8 @@ public class MultiClassLoader extends Cl
 
         // use iterator so that the thread loader is not resolved
         boolean added = false;
-        for (Iterator itr = multi._loaders.iterator(); itr.hasNext();) {
-            if (addClassLoader(index, (ClassLoader) itr.next())) {
+        for (Iterator<ClassLoader> itr = multi._loaders.iterator(); itr.hasNext();) {
+            if (addClassLoader(index, itr.next())) {
                 index++;
                 added = true;
             }
@@ -166,8 +166,8 @@ public class MultiClassLoader extends Cl
 
         // use iterator so that the thread loader is not resolved
         boolean added = false;
-        for (Iterator itr = multi._loaders.iterator(); itr.hasNext();)
-            added = addClassLoader((ClassLoader) itr.next()) || added;
+        for (Iterator<ClassLoader> itr = multi._loaders.iterator(); itr.hasNext();)
+            added = addClassLoader(itr.next()) || added;
         return added;
     }
 
@@ -195,19 +195,18 @@ public class MultiClassLoader extends Cl
     }
 
     /**
-     * Return true if there are no internal class laoders.
+     * Return true if there are no internal class loaders.
      */
     public boolean isEmpty() {
         return _loaders.isEmpty();
     }
 
-    protected Class findClass(String name) throws ClassNotFoundException {
+    protected Class<?> findClass(String name) throws ClassNotFoundException {
         ClassLoader loader;
-        for (Iterator itr = _loaders.iterator(); itr.hasNext();) {
-            loader = (ClassLoader) itr.next();
+        for (Iterator<ClassLoader> itr = _loaders.iterator(); itr.hasNext();) {
+            loader = itr.next();
             if (loader == THREAD_LOADER)
-                loader = AccessController.doPrivileged(
-                    J2DoPrivHelper.getContextClassLoaderAction());
+                loader = AccessController.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction());
             try {
                 return Class.forName(name, false, loader);
             } catch (Throwable t) {
@@ -219,17 +218,15 @@ public class MultiClassLoader extends Cl
     protected URL findResource(String name) {
         ClassLoader loader;
         URL rsrc;
-        for (Iterator itr = _loaders.iterator(); itr.hasNext();) {
-            loader = (ClassLoader) itr.next();
+        for (Iterator<ClassLoader> itr = _loaders.iterator(); itr.hasNext();) {
+            loader = itr.next();
             if (loader == THREAD_LOADER)
-                loader = AccessController.doPrivileged(
-                    J2DoPrivHelper.getContextClassLoaderAction());
+                loader = AccessController.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction());
 
             if (loader == null) // skip 
                 continue;
 
-            rsrc = AccessController.doPrivileged(
-                J2DoPrivHelper.getResourceAction(loader, name)); 
+            rsrc = AccessController.doPrivileged(J2DoPrivHelper.getResourceAction(loader, name)); 
             if (rsrc != null)
                 return rsrc;
         }
@@ -238,21 +235,19 @@ public class MultiClassLoader extends Cl
 
     protected Enumeration findResources(String name) throws IOException {
         ClassLoader loader;
-        Enumeration rsrcs;
+        Enumeration<?> rsrcs;
         Object rsrc;
-        Vector all = new Vector();
-        for (Iterator itr = _loaders.iterator(); itr.hasNext();) {
-            loader = (ClassLoader) itr.next();
+        Vector<Object> all = new Vector<Object>();
+        for (Iterator<ClassLoader> itr = _loaders.iterator(); itr.hasNext();) {
+            loader = itr.next();
             if (loader == THREAD_LOADER)
-                loader = AccessController.doPrivileged(
-                    J2DoPrivHelper.getContextClassLoaderAction());
+                loader = AccessController.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction());
 
             if (loader == null) // skip
                 continue;
 
             try {
-                rsrcs = AccessController.doPrivileged(
-                    J2DoPrivHelper.getResourcesAction(loader, name)); 
+                rsrcs = AccessController.doPrivileged(J2DoPrivHelper.getResourcesAction(loader, name)); 
                 while (rsrcs.hasMoreElements()) {
                     rsrc = rsrcs.nextElement();
                     if (!all.contains(rsrc))
@@ -276,4 +271,8 @@ public class MultiClassLoader extends Cl
     public int hashCode() {
         return _loaders.hashCode();
     }
+    
+    public String toString() {
+    	return _loaders.toString();
+    }
 }

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Services.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Services.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Services.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Services.java Sat Oct 29 00:44:11 2011
@@ -59,7 +59,7 @@ public class Services {
      * Return an array of Strings of class names of all known service
      * implementors of the specified interface or class.
      */
-    public static String[] getImplementors(Class serviceClass) {
+    public static String[] getImplementors(Class<?> serviceClass) {
         return getImplementors(serviceClass, null);
     }
 
@@ -67,8 +67,7 @@ public class Services {
      * Return an array of Strings of class names of all known service
      * implementors of the specified interface or class.
      */
-    public static String[] getImplementors(Class serviceClass,
-        ClassLoader loader) {
+    public static String[] getImplementors(Class<?> serviceClass, ClassLoader loader) {
         return getImplementors(serviceClass.getName(), loader);
     }
 
@@ -86,22 +85,15 @@ public class Services {
      * implementors of the specified class name, as resolved by the specified
      * {@link ClassLoader}.
      */
-    public static String[] getImplementors(String serviceName,
-        ClassLoader loader) {
-        if (loader == null)
-            loader = AccessController.doPrivileged(
-                J2DoPrivHelper.getContextClassLoaderAction());
-
+    public static String[] getImplementors(String serviceName, ClassLoader loader) {
         try {
-            Set resourceList = new TreeSet();
-            Enumeration resources = AccessController.doPrivileged(
-                J2DoPrivHelper.getResourcesAction(loader,
+            Set<String> resourceList = new TreeSet<String>();
+            Enumeration resources = AccessController.doPrivileged(J2DoPrivHelper.getResourcesAction(loader,
                         PREFIX + serviceName));
-            while (resources.hasMoreElements())
+            while (resources.hasMoreElements()) {
                 addResources((URL) resources.nextElement(), resourceList);
-
-            return (String[]) resourceList.toArray(new String[resourceList
-                .size()]);
+            }
+            return resourceList.toArray(new String[resourceList.size()]);
         } catch (PrivilegedActionException pae) {
             // silently swallow all exceptions.
         } catch (IOException ioe) {
@@ -115,11 +107,10 @@ public class Services {
      * Set. Class names are separated by lines. Lines starting with '#' are
      * ignored.
      */
-    private static void addResources(URL url, Set set) throws IOException {
+    private static void addResources(URL url, Set<String> set) throws IOException {
         InputStream in = null;
         BufferedReader reader = null;
         URLConnection urlCon = null;
-
         try {
             urlCon = url.openConnection();
             urlCon.setUseCaches(false);
@@ -137,8 +128,10 @@ public class Services {
                     String next = tok.nextToken();
                     if (next != null) {
                         next = next.trim();
-                        if (next.length() > 0 && !next.startsWith("#"))
+                        if (next.length() > 0 && !next.startsWith("#")) {
                             set.add(next);
+                        }
+                        
                     }
                 }
             }

Modified: openjpa/trunk/openjpa-lib/src/main/resources/org/apache/openjpa/lib/conf/localizer.properties
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/resources/org/apache/openjpa/lib/conf/localizer.properties?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/resources/org/apache/openjpa/lib/conf/localizer.properties (original)
+++ openjpa/trunk/openjpa-lib/src/main/resources/org/apache/openjpa/lib/conf/localizer.properties Sat Oct 29 00:44:11 2011
@@ -51,15 +51,17 @@ invalid-property-hint: The configuration
     property called "{1}".
 invalid-plugin: Instantiation of plugin "{0}" with value "{1}" caused an \
 	error "{2}". The alias or class name may have been misspelled, or the \
-	class may not be available in the class path.
+	class may not be available in the class path. The classloader used is \
+	"{3}"
 invalid-plugin-aliases: Instantiation of plugin "{0}" with value "{1}" caused \
 	an error "{2}". The alias or class name may have been misspelled, or the \
 	class may not have be available in the class path. Valid aliases for this \
-	plugin are: {3}
+	plugin are: {3}. The classloader used is "{4}".
 invalid-plugin-aliases-hint: Instantiation of plugin "{0}" with value "{1}" \
 	caused an error "{2}". The alias or class name may have been misspelled \
 	(as it closely matches the valid plugin alias "{4}"), or the class may \
-	not be available in the class path.  Valid aliases for this plugin are: {3}
+	not be available in the class path.  Valid aliases for this plugin are: {3}.\
+	The classloader used is "{5}"
 not-singleton: You cannot set the value of property "{0}" as an object.  The \
 	property cannot use a single value; it must be recreated on each request.
 cant-set-string: Configuration property "{0}" cannot be set from a string. \

Modified: openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/TestValue.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/TestValue.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/TestValue.java (original)
+++ openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/TestValue.java Sat Oct 29 00:44:11 2011
@@ -22,13 +22,13 @@ import junit.framework.TestCase;
 
 public class TestValue extends TestCase {
     
-    private static class SimpleValue extends Value {
+    private static class SimpleValue extends Value<String> {
 
-        protected String getInternalString() {
-            return null;
-        }
+        public SimpleValue(String prop) {
+			super(String.class, prop);
+		}
 
-        public Class getValueType() {
+		protected String getInternalString() {
             return null;
         }
 
@@ -39,7 +39,7 @@ public class TestValue extends TestCase 
         protected void setInternalString(String str) {
         }
         
-        public Object get() {
+        public String get() {
             return null;
         }
         
@@ -51,7 +51,7 @@ public class TestValue extends TestCase 
         String bName = "Pete";
         String [] aStrings = { alias, aName };
         
-        SimpleValue sValue = new SimpleValue();
+        SimpleValue sValue = new SimpleValue("test");
         sValue.setAliases(aStrings);
         sValue.setAlias(alias, bName);
         assertEquals("Did not set the new alias", bName, 
@@ -60,8 +60,7 @@ public class TestValue extends TestCase 
     }
     
     public void testEquivalentValueCanBeSet() {
-        SimpleValue v = new SimpleValue();
-        v.setProperty("main");
+        SimpleValue v = new SimpleValue("main");
         v.addEquivalentKey("eqivalent1");
         v.addEquivalentKey("eqivalent2");
         assertEquals(2, v.getEquivalentKeys().size());
@@ -75,8 +74,7 @@ public class TestValue extends TestCase 
     }
     
     public void testEquivalentValuesAreUnmodifable() {
-        SimpleValue v = new SimpleValue();
-        v.setProperty("main");
+        SimpleValue v = new SimpleValue("main");
         v.addEquivalentKey("eqivalent1");
         v.addEquivalentKey("eqivalent2");
         

Modified: openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/test/ConfigurationTestProductDerivation.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/test/ConfigurationTestProductDerivation.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/test/ConfigurationTestProductDerivation.java (original)
+++ openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/test/ConfigurationTestProductDerivation.java Sat Oct 29 00:44:11 2011
@@ -21,6 +21,7 @@ package org.apache.openjpa.lib.conf.test
 import java.io.InputStream;
 import java.io.IOException;
 import java.net.URL;
+import java.security.AccessController;
 import java.util.MissingResourceException;
 import java.util.Properties;
 
@@ -29,6 +30,7 @@ import org.apache.openjpa.lib.conf.Confi
 import org.apache.openjpa.lib.conf.ConfigurationProvider;
 import org.apache.openjpa.lib.conf.MapConfigurationProvider;
 import org.apache.openjpa.lib.conf.ProductDerivation;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
 
 /**
  * A Product Derivation to test loading of global and default configuration with
@@ -51,19 +53,18 @@ public class ConfigurationTestProductDer
         closed = true;
     }
 
-    public ConfigurationProvider loadGlobals(ClassLoader loader)
+    public ConfigurationProvider loadGlobals()
         throws IOException {
-        return load(null, loader);
+        return load(null);
     }
 
-    public ConfigurationProvider load(String rsrc, ClassLoader loader)
-        throws IOException {
+    public ConfigurationProvider load(String rsrc) throws IOException {
         if (rsrc == null)
             rsrc = System.getProperty("openjpatest.properties");
         if (rsrc == null || !rsrc.endsWith(".properties"))
             return null;
 
-        URL url = findResource(rsrc, loader);
+        URL url = findResource(rsrc);
         if (url == null)
             throw new MissingResourceException(rsrc, getClass().getName(), 
                 rsrc);
@@ -84,8 +85,9 @@ public class ConfigurationTestProductDer
     /**
      * Locate the given resource.
      */
-    private URL findResource(String rsrc, ClassLoader loader)
+    private URL findResource(String rsrc)
         throws IOException {
+        ClassLoader loader = Thread.currentThread().getContextClassLoader();
         if (loader != null)
             return loader.getResource(rsrc);
 
@@ -95,7 +97,6 @@ public class ConfigurationTestProductDer
         if (loader != null)
             url = loader.getResource(rsrc);
         if (url == null) {
-            loader = Thread.currentThread().getContextClassLoader();
             if (loader != null)
                 url = loader.getResource(rsrc);
         }

Modified: openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/test/TestConfigurationImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/test/TestConfigurationImpl.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/test/TestConfigurationImpl.java (original)
+++ openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/test/TestConfigurationImpl.java Sat Oct 29 00:44:11 2011
@@ -256,8 +256,8 @@ public class TestConfigurationImpl exten
 
         private final StringValue _testKey;
         private final StringValue _sysKey;
-        private final PluginValue _pluginKey;
-        private final ObjectValue _objectKey;
+        private final PluginValue<Object> _pluginKey;
+        private final ObjectValue<Object> _objectKey;
 
         public ConfigurationTest() {
             this(true);
@@ -267,8 +267,8 @@ public class TestConfigurationImpl exten
             super(false);
             _testKey = addString("testKey");
             _sysKey = addString("sysKey");
-            _pluginKey = addPlugin("pluginKey", canSetPlugin);
-            _objectKey = addObject("objectKey");
+            _pluginKey = addPlugin(Object.class, "pluginKey", canSetPlugin);
+            _objectKey = addObject(Object.class, "objectKey");
         }
 
         public String getTestKey() {
@@ -297,7 +297,7 @@ public class TestConfigurationImpl exten
 
         public Object getPluginKeyInstance() {
             if (_pluginKey.get() == null)
-                return _pluginKey.instantiate(Object.class, this);
+                return _pluginKey.instantiate(this);
             return _pluginKey.get();
         }
 

Modified: openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/test/TestPluginValue.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/test/TestPluginValue.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/test/TestPluginValue.java (original)
+++ openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/test/TestPluginValue.java Sat Oct 29 00:44:11 2011
@@ -38,9 +38,9 @@ public class TestPluginValue extends Abs
 
     public void testDefault() {
         defaultTest(new StringValue("testKey"));
-        defaultTest(new PluginValue("testKey", true));
-        defaultTest(new PluginListValue("testKey"));
-        pluginDefaultTest(new PluginValue("testKey", true));
+        defaultTest(new PluginValue<String>(String.class, "testKey", true));
+        defaultTest(new PluginListValue<String>(String[].class, "testKey"));
+        pluginDefaultTest(new PluginValue<String>(String.class, "testKey", true));
     }
 
     private void defaultTest(Value val) {
@@ -76,13 +76,13 @@ public class TestPluginValue extends Abs
 
     public void testAlias() {
         aliasTest(new StringValue("testKey"));
-        aliasTest(new PluginValue("testKey", true));
-        aliasTest(new PluginListValue("testKey"));
+        aliasTest(new PluginValue<String>(String.class, "testKey", true));
+        aliasTest(new PluginListValue<String>(String[].class, "testKey"));
         emptyAliasTest(new StringValue("testKey"));
         emptyAliasTest(new StringValue("testKey"));
-        pluginAliasTest(new PluginValue("testKey", true));
-        pluginAliasTest(new PluginListValue("testKey"));
-        pluginListAliasTest(new PluginListValue("testKey"));
+        pluginAliasTest(new PluginValue<String>(String.class, "testKey", true));
+        pluginAliasTest(new PluginListValue<String>(String[].class, "testKey"));
+        pluginListAliasTest(new PluginListValue<String>(String[].class, "testKey"));
     }
 
     private void aliasTest(Value val) {
@@ -132,7 +132,7 @@ public class TestPluginValue extends Abs
     }
 
     public void testPluginListParsing() {
-        PluginListValue val = new PluginListValue("testKey");
+        PluginListValue<String> val = new PluginListValue<String>(String[].class, "testKey");
         assertEquals(0, val.getClassNames().length);
         val.setString("foo");
         assertEquals(1, val.getClassNames().length);

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCPersistenceProductDerivation.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCPersistenceProductDerivation.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCPersistenceProductDerivation.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCPersistenceProductDerivation.java Sat Oct 29 00:44:11 2011
@@ -77,20 +77,14 @@ public class JDBCPersistenceProductDeriv
         Specification jpa = PersistenceProductDerivation.SPEC_JPA;
         Specification ejb = PersistenceProductDerivation.ALIAS_EJB;
 
-        conf.metaFactoryPlugin.setAlias(ejb.getName(),
-            PersistenceMappingFactory.class.getName());
-        conf.metaFactoryPlugin.setAlias(jpa.getName(),
-            PersistenceMappingFactory.class.getName());
-
-        conf.mappingFactoryPlugin.setAlias(ejb.getName(),
-            PersistenceMappingFactory.class.getName());
-        conf.mappingFactoryPlugin.setAlias(jpa.getName(),
-            PersistenceMappingFactory.class.getName());
-
-        conf.mappingDefaultsPlugin.setAlias(ejb.getName(),
-            PersistenceMappingDefaults.class.getName());
-        conf.mappingDefaultsPlugin.setAlias(jpa.getName(),
-            PersistenceMappingDefaults.class.getName());
+        conf.metaFactoryPlugin.setAlias(ejb.getName(), PersistenceMappingFactory.class.getName());
+        conf.metaFactoryPlugin.setAlias(jpa.getName(), PersistenceMappingFactory.class.getName());
+
+        conf.mappingFactoryPlugin.setAlias(ejb.getName(), PersistenceMappingFactory.class.getName());
+        conf.mappingFactoryPlugin.setAlias(jpa.getName(), PersistenceMappingFactory.class.getName());
+
+        conf.mappingDefaultsPlugin.setAlias(ejb.getName(), PersistenceMappingDefaults.class.getName());
+        conf.mappingDefaultsPlugin.setAlias(jpa.getName(), PersistenceMappingDefaults.class.getName());
         
         conf.lockManagerPlugin.setAlias("mixed", "org.apache.openjpa.jdbc.kernel.MixedLockManager");
         

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java Sat Oct 29 00:44:11 2011
@@ -418,7 +418,7 @@ public class XMLPersistenceMappingParser
      */
     private boolean startSecondaryTable(Attributes attrs)
         throws SAXException {
-        _secondaryTable = toTableIdentifier(attrs.getValue("schema"),
+        _secondaryTable = toTableIdentifier(getSchemaName(attrs),
             attrs.getValue("name")).getName();
         ((ClassMapping)currentElement()).getMappingInfo()
         	.addSecondaryTable(DBIdentifier.newTable(_secondaryTable));
@@ -458,7 +458,7 @@ public class XMLPersistenceMappingParser
         SequenceMapping seq = (SequenceMapping) getRepository().
             addSequenceMetaData(name);
         seq.setSequencePlugin(SequenceMapping.IMPL_VALUE_TABLE);
-        seq.setTableIdentifier(toTableIdentifier(attrs.getValue("schema"),
+        seq.setTableIdentifier(toTableIdentifier(getSchemaName(attrs),
             attrs.getValue("table")));
         seq.setPrimaryKeyColumnIdentifier(DBIdentifier.newColumn(attrs.getValue("pk-column-name"), delimit())); 
         seq.setSequenceColumnIdentifier(DBIdentifier.newColumn(attrs.getValue("value-column-name"), delimit())); 
@@ -486,6 +486,21 @@ public class XMLPersistenceMappingParser
     private void endTableGenerator() {
     	popElement();
     }
+    
+    /**
+     * Gets the name of the schema from the given attribute value <tt>"schema"</tt>.
+     * If the value is unspecified and a default schema is specified, then
+     * gets the default schema name.
+     * @param attrs attributes of an XML element
+     * @return the schema name
+     */
+    String getSchemaName(Attributes attrs) {
+    	String name = attrs.getValue("schema");
+    	if (StringUtils.isEmpty(name) && _schema != null) {
+    		return _schema;
+    	}
+    	return name;
+    }
 
     /**
      * Parse inheritance.
@@ -796,7 +811,7 @@ public class XMLPersistenceMappingParser
         ClassMapping mapping = (ClassMapping) currentElement();
         if (mapping.isAbstract())
             throw new UserException(_loc.get("table-not-allowed", mapping));
-        DBIdentifier table = toTableIdentifier(attrs.getValue("schema"),
+        DBIdentifier table = toTableIdentifier(attrs.getValue(getSchemaName(attrs)),
             attrs.getValue("name"));
         if (!DBIdentifier.isNull(table))
             mapping.getMappingInfo().setTableIdentifier(table);
@@ -808,7 +823,7 @@ public class XMLPersistenceMappingParser
      */
     private boolean startJoinTable(Attributes attrs)
         throws SAXException {
-        DBIdentifier sTable = toTableIdentifier(attrs.getValue("schema"),
+        DBIdentifier sTable = toTableIdentifier(getSchemaName(attrs),
             attrs.getValue("name"));
         if (!DBIdentifier.isNull(sTable)) {
             Object elem = currentElement();
@@ -1056,7 +1071,7 @@ public class XMLPersistenceMappingParser
 
     private DBIdentifier parseCollectionTable(Attributes attrs) {
         String tVal = attrs.getValue("name");
-        String sVal = attrs.getValue("schema");
+        String sVal = getSchemaName(attrs);
         return toTableIdentifier(sVal, tVal); 
     }
 



Mime
View raw message