openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From curti...@apache.org
Subject svn commit: r1197994 [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, 05 Nov 2011 17:17:33 GMT
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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -32,7 +32,7 @@ import serp.util.Strings;
  *
  * @author Abe White
  */
-public class StringListValue extends Value<String[]> {
+public class StringListValue extends Value {
 
     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(String[].class, prop);
+        super(prop);
     }
 
     /**
@@ -60,6 +60,10 @@ 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
@@ -130,7 +134,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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -25,12 +25,16 @@ import org.apache.commons.lang.StringUti
  *
  * @author Marc Prud'hommeaux
  */
-public class StringValue extends Value<String> {
+public class StringValue extends Value {
 
     private String value;
 
     public StringValue(String prop) {
-        super(String.class, prop);
+        super(prop);
+    }
+
+    public Class<String> getValueType() {
+        return String.class;
     }
 
     /**
@@ -60,7 +64,11 @@ public class StringValue extends Value<S
     }
     
     protected void setInternalObject(Object obj) {
-        set(obj == null ? null : obj.toString());
+        if (obj instanceof String) {
+            set((String) obj);
+        } else {
+            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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -31,69 +31,44 @@ import org.apache.openjpa.lib.util.Local
 import org.apache.openjpa.lib.util.ParseException;
 
 /**
- * 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. 
+ * A configuration value.
  *
  * @author Marc Prud'hommeaux
  * @author Pinaki Poddar
  */
-public abstract class Value<T> implements Cloneable {
+public abstract class Value implements Cloneable {
 
-    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 String[] EMPTY_ALIASES = new String[0];
     private static final Localizer s_loc = Localizer.forPackage(Value.class);
+    public static final String INVISIBLE = "******";
     
-    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;
+    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;
     
     /**
+     * Default constructor.
+     */
+    public Value() {
+    }
+
+    /**
      * Constructor. Supply the property name.
      *
      * @see #setProperty
      */
-    public Value(Class<T> type, String prop) {
-    	_type = type;
-        _prop  = prop;
+    public Value(String prop) {
+        setProperty(prop);
     }
 
     /**
@@ -101,10 +76,18 @@ public abstract class Value<T> implement
      * 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. 
      * 
@@ -123,7 +106,8 @@ public abstract class Value<T> implement
      * @since 2.0.0
      */
     public Set<String> getEquivalentKeys() {
-        return otherNames == null ? EMPTY_SET : Collections.unmodifiableSet(otherNames);
+        return otherNames == null ? Collections.EMPTY_SET 
+            : Collections.unmodifiableSet(otherNames);
     }
     
     /**
@@ -134,7 +118,8 @@ public abstract class Value<T> implement
      * @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);
@@ -164,8 +149,9 @@ public abstract class Value<T> implement
      * already loaded key. 
      */
     public void setLoadKey(String key) {
-        if (loadKey != null && key != null && !loadKey.equals(key)) 
-            throw new ParseException(s_loc.get("multiple-load-key", loadKey, key));
+        if (this.loadKey != null && key != null && !this.loadKey.equals(key)) 
+            throw new ParseException(s_loc.get("multiple-load-key", 
+                loadKey, key));
         loadKey = key;
     }
 
@@ -197,7 +183,7 @@ public abstract class Value<T> implement
     public void setAlias(String key, String value) {
         aliases = setAlias(key, value, aliases);
     }
-    
+
     /**
      * Set an alias into a current alias list, returning the new list.
      */
@@ -224,7 +210,7 @@ public abstract class Value<T> implement
      * value. If so, an error will be generated when attempting to invoke
      * any method on this value with an unknown option.
      */
-    public final boolean isAliasListComprehensive() {
+    public boolean isAliasListComprehensive() {
         return aliasListComprehensive;
     }
 
@@ -233,7 +219,7 @@ public abstract class Value<T> implement
      * value. If so, an error will be generated when attempting to invoke
      * any method on this value with an unknown option.
      */
-    public final void setAliasListComprehensive(boolean aliasListIsComprehensive) {
+    public void setAliasListComprehensive(boolean aliasListIsComprehensive) {
         this.aliasListComprehensive = aliasListIsComprehensive;
     }
 
@@ -309,7 +295,7 @@ public abstract class Value<T> implement
 
     /**
      * 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;
@@ -331,7 +317,7 @@ public abstract class Value<T> implement
      * be used by the configuration framework to look up metadata about
      * the value.
      */
-    public Class<?> getScope() {
+    public Class getScope() {
         return scope;
     }
 
@@ -340,7 +326,7 @@ public abstract class Value<T> implement
      * 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;
     }
 
@@ -355,7 +341,7 @@ public abstract class Value<T> implement
     /**
      * 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
@@ -376,7 +362,7 @@ public abstract class Value<T> implement
         } catch (ParseException pe) {
             throw pe;
         } catch (RuntimeException re) {
-            throw new ParseException(_prop + ": " + val, re);
+            throw new ParseException(prop + ": " + val, re);
         }
     }
 
@@ -390,11 +376,11 @@ public abstract class Value<T> implement
      * {@link #isDynamic() dynamic}. 
      * 
      */
-    public void setObject(T obj) {
+    public void setObject(Object 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)) {
@@ -403,7 +389,7 @@ public abstract class Value<T> implement
             } catch (ParseException pe) {
                 throw pe;
             } catch (RuntimeException re) {
-                throw new ParseException(_prop + ": " + obj, re);
+                throw new ParseException(prop + ": " + obj, re);
             }
         }
     }
@@ -427,12 +413,25 @@ public abstract class Value<T> implement
     /**
      * Returns the type of the property that this Value represents.
      */
-    public final Class<T> getValueType() {
-    	return _type;
-    }
+    public abstract Class<?> getValueType();
+
+    /**
+     * Return the internal string form of this value.
+     */
+    protected abstract String getInternalString();
 
     /**
-     * Gets unmodifiable list of listeners for value changes.
+     * 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);
+
+    /**
+     * Gets unmodifable list of listeners for value changes.
      */
     public List<ValueListener> getListeners() {
         return Collections.unmodifiableList(this.listeners);
@@ -500,7 +499,7 @@ public abstract class Value<T> implement
      *  
      * @since 1.1.0
      */
-    public final void setDynamic(boolean flag) {
+    public void setDynamic(boolean flag) {
     	isDynamic = flag;
     }
     
@@ -510,7 +509,7 @@ public abstract class Value<T> implement
      *  
      * @since 1.1.0
      */
-    public final boolean isDynamic() {
+    public boolean isDynamic() {
     	return isDynamic; 
     }
 
@@ -523,7 +522,7 @@ public abstract class Value<T> implement
     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;
     }
 
@@ -539,11 +538,11 @@ public abstract class Value<T> implement
         if (!(other instanceof Value))
             return false;
 
-        Value<T> o = (Value<T>) other;
+        Value o = (Value) 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);
     }
 
@@ -567,7 +566,7 @@ public abstract class Value<T> implement
     /**
      * Hides the value of this Value from being output to the caller.
      */
-    public final void hide() {
+    public void hide() {
         _hidden = true;
     }
     
@@ -575,49 +574,23 @@ public abstract class Value<T> implement
      * Affirms if this Value is used for internal purpose only and not exposed as a supported property.
      * @see Configuration#getPropertyKeys()
      */
-    public final boolean isPrivate() {
+    public boolean isPrivate() {
         return _private;
     }
 
     /**
      * Marks this Value for internal purpose only.
      */
-    public final void makePrivate() {
+    public void makePrivate() {
         _private = true;
     }
     
     /**
-     * Gets the external visible form of this value.
-     * @return
+     * Get the actual data stored in this value.
      */
-    public Object getExternal() {
-    	return _hidden ? INVISIBLE : get();
-    }
+    public abstract Object get();
     
     public String toString() {
-        return getProperty() + "<" + getValueType().getSimpleName() + ">:" + get();
+        return getProperty()+ ":" + get() + "[" + getValueType().getName() + "]";
     }
-    
-    
-    /**
-     * 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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -38,7 +38,7 @@ public abstract class AbstractInstrument
     private Map<String, Instrument> _instruments = new ConcurrentHashMap<String, Instrument>();
     
     private boolean _started = false;
-    private PluginListValue<Instrument> _instrumentValues;
+    private PluginListValue _instrumentValues;
     private String _options;
     private Configuration _config;
 
@@ -57,13 +57,13 @@ public abstract class AbstractInstrument
     }
     
     public void setInstrument(String instrument) {
-        _instrumentValues = new PluginListValue<Instrument>(Instrument[].class, "Instrument");
+        _instrumentValues = new PluginListValue("Instrument");
         if (getInstrumentAliases() != null) {
             _instrumentValues.setAliases(getInstrumentAliases());
         }
         _instrumentValues.setString(instrument);
         
-        Instrument[] instruments = _instrumentValues.instantiate(_config);
+        Instrument[] instruments = (Instrument[])_instrumentValues.instantiate(Instrument.class, _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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -36,15 +36,16 @@ 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(ClassLoader loader) {
-    	super(loader);
+    public CFMetaDataParser() {
         setParseText(false);
     }
 
@@ -281,7 +282,8 @@ public class CFMetaDataParser extends XM
         throws SAXException {
         if (name == null)
             return null;
-        Class<?> cls = classForName(name, _package, resolve, getClassLoader());
+        Class<?> cls =
+            classForName(name, _package, resolve, currentClassLoader());
         if (cls == null)
             throw getException(_loc.get("invalid-class", name).getMessage());
         return cls;
@@ -296,6 +298,9 @@ 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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -66,13 +66,15 @@ 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.
@@ -104,14 +106,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);
                 }
             }
@@ -119,15 +121,21 @@ 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();
         }
     }
 
@@ -205,12 +213,10 @@ 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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -21,7 +21,6 @@ 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;
@@ -56,7 +55,16 @@ 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, ClassLoader loader, boolean topDown) {
+    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) {
         // skip classes that can't have metadata
         if (cls != null && (cls.isPrimitive()
             || cls.getName().startsWith("java.")
@@ -72,8 +80,11 @@ public class ClassMetaDataIterator imple
             multi.addClassLoader(MultiClassLoader.SYSTEM_LOADER);
             multi.addClassLoader(MultiClassLoader.THREAD_LOADER);
             multi.addClassLoader(getClass().getClassLoader());
-            if (cls != null) {
-                ClassLoader clsLoader = AccessController.doPrivileged(J2DoPrivHelper.getClassLoaderAction(cls));
+            if (cls != null)
+            {
+                ClassLoader clsLoader = (ClassLoader)
+                    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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -33,6 +33,12 @@ 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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -47,14 +47,30 @@ 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) {
@@ -87,7 +103,8 @@ 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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -22,7 +22,7 @@ import java.io.File;
 
 /**
  * Interface that can optionally be implemented by metadata
- * to include the source URL from which the metadata was originally parsed.
+ * to include the source file 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 URL from which this instance was parsed.
+     * Return the file 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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -55,9 +55,6 @@ 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
@@ -65,7 +62,8 @@ 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 {
@@ -73,8 +71,9 @@ 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;
@@ -83,8 +82,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 Set<String> _parsed = null;
-    
+    private Map<ClassLoader, Set<String>> _parsed = null;
+
     private Log _log = null;
     private boolean _validating = true;
     private boolean _systemId = true;
@@ -92,8 +91,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();
@@ -108,12 +107,17 @@ public abstract class XMLMetaDataParser 
     private int _ignore = Integer.MAX_VALUE;
 
     private boolean _parsing = false;
-    private final ClassLoader _loader;
     
-    protected XMLMetaDataParser(ClassLoader loader) {
-    	_loader = loader;
-    }
+    private boolean _overrideContextClassloader = false;
     
+    public boolean getOverrideContextClassloader() {
+        return _overrideContextClassloader;
+    }
+
+    public void setOverrideContextClassloader(boolean overrideCCL) {
+        _overrideContextClassloader = overrideCCL;
+    }
+
     /*
      * Whether the parser is currently parsing.
      */
@@ -263,16 +267,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)
@@ -293,7 +297,8 @@ 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;
@@ -302,9 +307,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, _loader, topDown), !topDown);
+        parse(new ClassMetaDataIterator(cls, suff, topDown), !topDown);
     }
 
     public void parse(Reader xml, String sourceName) throws IOException {
@@ -364,7 +369,8 @@ 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 {
@@ -372,8 +378,22 @@ 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) {
@@ -383,12 +403,16 @@ 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);
@@ -401,6 +425,19 @@ 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();
@@ -415,9 +452,15 @@ public abstract class XMLMetaDataParser 
         if (!_caching)
             return false;
         if (_parsed == null)
-            _parsed = new HashSet<String>();
+            _parsed = new HashMap<ClassLoader, Set<String>>();
 
-        boolean added = _parsed.add(src);
+        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);
         if (!added && _log != null && _log.isTraceEnabled())
             _log.trace(_loc.get("already-parsed", src));
         return !added;
@@ -551,7 +594,7 @@ public abstract class XMLMetaDataParser 
      */
     protected void reset() {
         _curResults.clear();
-//        _curLoader = null;
+        _curLoader = null;
         _sourceName = null;
         _sourceFile = null;
         _depth = -1;
@@ -647,13 +690,14 @@ 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.
@@ -700,12 +744,4 @@ 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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -18,9 +18,6 @@
  */
 package org.apache.openjpa.lib.meta;
 
-import java.util.LinkedHashSet;
-import java.util.Set;
-
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 
@@ -37,18 +34,16 @@ 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);
@@ -66,10 +61,8 @@ public class XMLVersionParser extends XM
             // save the version and schema location attributes
             _version = attrs.getValue("", VERSION_ATTR);
             _schemaLocation = attrs.getValue(XSI_NS, SCHEMA_LOCATION);
-        } else if (name.equals("persistence-unit")) {
-        	 _unitNames.add(attrs.getValue("name"));
-             // ignore remaining content
-             ignoreContent(true);
+            // ignore remaining content
+            ignoreContent(true);
         }
         return false;
     }
@@ -89,8 +82,4 @@ 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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -24,8 +24,7 @@ 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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -23,7 +23,6 @@ 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;
@@ -48,10 +47,11 @@ 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<ClassLoader> _loaders = new ArrayList<ClassLoader>(5);
+    private List _loaders = new ArrayList(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<ClassLoader> itr = _loaders.iterator();
+        Iterator itr = _loaders.iterator();
         for (int i = 0; i < loaders.length; i++) {
-            loader = itr.next();
-            if (loader == THREAD_LOADER) {
-                loader = AccessController.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction());
-            }
+            loader = (ClassLoader) 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 = _loaders.get(index);
-        if (loader == THREAD_LOADER) {
-            loader = AccessController.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction());
-        }
+        ClassLoader loader = (ClassLoader) _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<ClassLoader> itr = multi._loaders.iterator(); itr.hasNext();) {
-            if (addClassLoader(index, itr.next())) {
+        for (Iterator itr = multi._loaders.iterator(); itr.hasNext();) {
+            if (addClassLoader(index, (ClassLoader) 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<ClassLoader> itr = multi._loaders.iterator(); itr.hasNext();)
-            added = addClassLoader(itr.next()) || added;
+        for (Iterator itr = multi._loaders.iterator(); itr.hasNext();)
+            added = addClassLoader((ClassLoader) itr.next()) || added;
         return added;
     }
 
@@ -195,18 +195,19 @@ public class MultiClassLoader extends Cl
     }
 
     /**
-     * Return true if there are no internal class loaders.
+     * Return true if there are no internal class laoders.
      */
     public boolean isEmpty() {
         return _loaders.isEmpty();
     }
 
-    protected Class<?> findClass(String name) throws ClassNotFoundException {
+    protected Class findClass(String name) throws ClassNotFoundException {
         ClassLoader loader;
-        for (Iterator<ClassLoader> itr = _loaders.iterator(); itr.hasNext();) {
-            loader = itr.next();
+        for (Iterator itr = _loaders.iterator(); itr.hasNext();) {
+            loader = (ClassLoader) 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) {
@@ -218,15 +219,17 @@ public class MultiClassLoader extends Cl
     protected URL findResource(String name) {
         ClassLoader loader;
         URL rsrc;
-        for (Iterator<ClassLoader> itr = _loaders.iterator(); itr.hasNext();) {
-            loader = itr.next();
+        for (Iterator itr = _loaders.iterator(); itr.hasNext();) {
+            loader = (ClassLoader) 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;
         }
@@ -235,19 +238,21 @@ public class MultiClassLoader extends Cl
 
     protected Enumeration findResources(String name) throws IOException {
         ClassLoader loader;
-        Enumeration<?> rsrcs;
+        Enumeration rsrcs;
         Object rsrc;
-        Vector<Object> all = new Vector<Object>();
-        for (Iterator<ClassLoader> itr = _loaders.iterator(); itr.hasNext();) {
-            loader = itr.next();
+        Vector all = new Vector();
+        for (Iterator itr = _loaders.iterator(); itr.hasNext();) {
+            loader = (ClassLoader) 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))
@@ -271,8 +276,4 @@ 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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 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,7 +67,8 @@ 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);
     }
 
@@ -85,15 +86,22 @@ public class Services {
      * implementors of the specified class name, as resolved by the specified
      * {@link ClassLoader}.
      */
-    public static String[] getImplementors(String serviceName, ClassLoader loader) {
+    public static String[] getImplementors(String serviceName,
+        ClassLoader loader) {
+        if (loader == null)
+            loader = AccessController.doPrivileged(
+                J2DoPrivHelper.getContextClassLoaderAction());
+
         try {
-            Set<String> resourceList = new TreeSet<String>();
-            Enumeration resources = AccessController.doPrivileged(J2DoPrivHelper.getResourcesAction(loader,
+            Set resourceList = new TreeSet();
+            Enumeration resources = AccessController.doPrivileged(
+                J2DoPrivHelper.getResourcesAction(loader,
                         PREFIX + serviceName));
-            while (resources.hasMoreElements()) {
+            while (resources.hasMoreElements())
                 addResources((URL) resources.nextElement(), resourceList);
-            }
-            return resourceList.toArray(new String[resourceList.size()]);
+
+            return (String[]) resourceList.toArray(new String[resourceList
+                .size()]);
         } catch (PrivilegedActionException pae) {
             // silently swallow all exceptions.
         } catch (IOException ioe) {
@@ -107,10 +115,11 @@ public class Services {
      * Set. Class names are separated by lines. Lines starting with '#' are
      * ignored.
      */
-    private static void addResources(URL url, Set<String> set) throws IOException {
+    private static void addResources(URL url, Set set) throws IOException {
         InputStream in = null;
         BufferedReader reader = null;
         URLConnection urlCon = null;
+
         try {
             urlCon = url.openConnection();
             urlCon.setUseCaches(false);
@@ -128,10 +137,8 @@ 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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -51,17 +51,15 @@ 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. The classloader used is \
-	"{3}"
+	class may not be available in the class path.
 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}. The classloader used is "{4}".
+	plugin are: {3}
 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}.\
-	The classloader used is "{5}"
+	not be available in the class path.  Valid aliases for this plugin are: {3}
 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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -22,13 +22,13 @@ import junit.framework.TestCase;
 
 public class TestValue extends TestCase {
     
-    private static class SimpleValue extends Value<String> {
+    private static class SimpleValue extends Value {
 
-        public SimpleValue(String prop) {
-			super(String.class, prop);
-		}
+        protected String getInternalString() {
+            return null;
+        }
 
-		protected String getInternalString() {
+        public Class getValueType() {
             return null;
         }
 
@@ -39,7 +39,7 @@ public class TestValue extends TestCase 
         protected void setInternalString(String str) {
         }
         
-        public String get() {
+        public Object get() {
             return null;
         }
         
@@ -51,7 +51,7 @@ public class TestValue extends TestCase 
         String bName = "Pete";
         String [] aStrings = { alias, aName };
         
-        SimpleValue sValue = new SimpleValue("test");
+        SimpleValue sValue = new SimpleValue();
         sValue.setAliases(aStrings);
         sValue.setAlias(alias, bName);
         assertEquals("Did not set the new alias", bName, 
@@ -60,7 +60,8 @@ public class TestValue extends TestCase 
     }
     
     public void testEquivalentValueCanBeSet() {
-        SimpleValue v = new SimpleValue("main");
+        SimpleValue v = new SimpleValue();
+        v.setProperty("main");
         v.addEquivalentKey("eqivalent1");
         v.addEquivalentKey("eqivalent2");
         assertEquals(2, v.getEquivalentKeys().size());
@@ -74,7 +75,8 @@ public class TestValue extends TestCase 
     }
     
     public void testEquivalentValuesAreUnmodifable() {
-        SimpleValue v = new SimpleValue("main");
+        SimpleValue v = new SimpleValue();
+        v.setProperty("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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -21,7 +21,6 @@ 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;
 
@@ -30,7 +29,6 @@ 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
@@ -53,18 +51,19 @@ public class ConfigurationTestProductDer
         closed = true;
     }
 
-    public ConfigurationProvider loadGlobals()
+    public ConfigurationProvider loadGlobals(ClassLoader loader)
         throws IOException {
-        return load(null);
+        return load(null, loader);
     }
 
-    public ConfigurationProvider load(String rsrc) throws IOException {
+    public ConfigurationProvider load(String rsrc, ClassLoader loader)
+        throws IOException {
         if (rsrc == null)
             rsrc = System.getProperty("openjpatest.properties");
         if (rsrc == null || !rsrc.endsWith(".properties"))
             return null;
 
-        URL url = findResource(rsrc);
+        URL url = findResource(rsrc, loader);
         if (url == null)
             throw new MissingResourceException(rsrc, getClass().getName(), 
                 rsrc);
@@ -85,9 +84,8 @@ public class ConfigurationTestProductDer
     /**
      * Locate the given resource.
      */
-    private URL findResource(String rsrc)
+    private URL findResource(String rsrc, ClassLoader loader)
         throws IOException {
-        ClassLoader loader = Thread.currentThread().getContextClassLoader();
         if (loader != null)
             return loader.getResource(rsrc);
 
@@ -97,6 +95,7 @@ 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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -256,8 +256,8 @@ public class TestConfigurationImpl exten
 
         private final StringValue _testKey;
         private final StringValue _sysKey;
-        private final PluginValue<Object> _pluginKey;
-        private final ObjectValue<Object> _objectKey;
+        private final PluginValue _pluginKey;
+        private final ObjectValue _objectKey;
 
         public ConfigurationTest() {
             this(true);
@@ -267,8 +267,8 @@ public class TestConfigurationImpl exten
             super(false);
             _testKey = addString("testKey");
             _sysKey = addString("sysKey");
-            _pluginKey = addPlugin(Object.class, "pluginKey", canSetPlugin);
-            _objectKey = addObject(Object.class, "objectKey");
+            _pluginKey = addPlugin("pluginKey", canSetPlugin);
+            _objectKey = addObject("objectKey");
         }
 
         public String getTestKey() {
@@ -297,7 +297,7 @@ public class TestConfigurationImpl exten
 
         public Object getPluginKeyInstance() {
             if (_pluginKey.get() == null)
-                return _pluginKey.instantiate(this);
+                return _pluginKey.instantiate(Object.class, 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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -38,9 +38,9 @@ public class TestPluginValue extends Abs
 
     public void testDefault() {
         defaultTest(new StringValue("testKey"));
-        defaultTest(new PluginValue<String>(String.class, "testKey", true));
-        defaultTest(new PluginListValue<String>(String[].class, "testKey"));
-        pluginDefaultTest(new PluginValue<String>(String.class, "testKey", true));
+        defaultTest(new PluginValue("testKey", true));
+        defaultTest(new PluginListValue("testKey"));
+        pluginDefaultTest(new PluginValue("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<String>(String.class, "testKey", true));
-        aliasTest(new PluginListValue<String>(String[].class, "testKey"));
+        aliasTest(new PluginValue("testKey", true));
+        aliasTest(new PluginListValue("testKey"));
         emptyAliasTest(new StringValue("testKey"));
         emptyAliasTest(new StringValue("testKey"));
-        pluginAliasTest(new PluginValue<String>(String.class, "testKey", true));
-        pluginAliasTest(new PluginListValue<String>(String[].class, "testKey"));
-        pluginListAliasTest(new PluginListValue<String>(String[].class, "testKey"));
+        pluginAliasTest(new PluginValue("testKey", true));
+        pluginAliasTest(new PluginListValue("testKey"));
+        pluginListAliasTest(new PluginListValue("testKey"));
     }
 
     private void aliasTest(Value val) {
@@ -132,7 +132,7 @@ public class TestPluginValue extends Abs
     }
 
     public void testPluginListParsing() {
-        PluginListValue<String> val = new PluginListValue<String>(String[].class, "testKey");
+        PluginListValue val = new PluginListValue("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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -77,14 +77,20 @@ 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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -418,7 +418,7 @@ public class XMLPersistenceMappingParser
      */
     private boolean startSecondaryTable(Attributes attrs)
         throws SAXException {
-        _secondaryTable = toTableIdentifier(getSchemaName(attrs),
+        _secondaryTable = toTableIdentifier(attrs.getValue("schema"),
             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(getSchemaName(attrs),
+        seq.setTableIdentifier(toTableIdentifier(attrs.getValue("schema"),
             attrs.getValue("table")));
         seq.setPrimaryKeyColumnIdentifier(DBIdentifier.newColumn(attrs.getValue("pk-column-name"), delimit())); 
         seq.setSequenceColumnIdentifier(DBIdentifier.newColumn(attrs.getValue("value-column-name"), delimit())); 
@@ -486,21 +486,6 @@ 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.
@@ -811,7 +796,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(getSchemaName(attrs)),
+        DBIdentifier table = toTableIdentifier(attrs.getValue("schema"),
             attrs.getValue("name"));
         if (!DBIdentifier.isNull(table))
             mapping.getMappingInfo().setTableIdentifier(table);
@@ -823,7 +808,7 @@ public class XMLPersistenceMappingParser
      */
     private boolean startJoinTable(Attributes attrs)
         throws SAXException {
-        DBIdentifier sTable = toTableIdentifier(getSchemaName(attrs),
+        DBIdentifier sTable = toTableIdentifier(attrs.getValue("schema"),
             attrs.getValue("name"));
         if (!DBIdentifier.isNull(sTable)) {
             Object elem = currentElement();
@@ -1071,7 +1056,7 @@ public class XMLPersistenceMappingParser
 
     private DBIdentifier parseCollectionTable(Attributes attrs) {
         String tVal = attrs.getValue("name");
-        String sVal = getSchemaName(attrs);
+        String sVal = attrs.getValue("schema");
         return toTableIdentifier(sVal, tVal); 
     }
 

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/AbstractUnenhancedClassTest.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/AbstractUnenhancedClassTest.java?rev=1197994&r1=1197993&r2=1197994&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/AbstractUnenhancedClassTest.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/AbstractUnenhancedClassTest.java Sat Nov  5 17:17:26 2011
@@ -51,12 +51,11 @@ public abstract class AbstractUnenhanced
     //   * Java 6
     //   * Java 5 with javaagent
     //   * Java 5 without javaagent
-    OpenJPAConfiguration _conf;
+
     public void setUp() {
         setUp(getUnenhancedClass(), getUnenhancedSubclass(), CLEAR_TABLES);
         // trigger class redefinition
         emf.createEntityManager().close();
-        _conf = emf.getConfiguration();
         _log = emf.getConfiguration().getLog(OpenJPAConfiguration.LOG_ENHANCE);
     }
 
@@ -77,7 +76,7 @@ public abstract class AbstractUnenhanced
     public void testMetaData() {
         ClassMetaData meta = JPAFacadeHelper.getMetaData(emf,
             getUnenhancedClass());
-        assertEquals(ClassRedefiner.canRedefineClasses(_conf), meta
+        assertEquals(ClassRedefiner.canRedefineClasses(_log), meta
             .isIntercepting());
     }
 
@@ -265,7 +264,7 @@ public abstract class AbstractUnenhanced
 
     public void testEnhancer() throws IOException {
         List<Class<?>> subs =  ManagedClassSubclasser.prepareUnenhancedClasses(
-            emf.getConfiguration(), Collections.singleton(getUnenhancedClass()));
+            emf.getConfiguration(), Collections.singleton(getUnenhancedClass()), null);
         Class sub = subs.get(0);
         assertNotNull(sub);
         assertEquals("org.apache.openjpa.enhance."
@@ -312,7 +311,7 @@ public abstract class AbstractUnenhanced
 
         // we only expect lazy loading to work when we can redefine classes
         // or when accessing a property-access record that OpenJPA created.
-        if (ClassRedefiner.canRedefineClasses(_conf)
+        if (ClassRedefiner.canRedefineClasses(_log)
             || (!userDefined 
             	&& AccessCode.isProperty(sm.getMetaData().getAccessType()))) {
 
@@ -364,7 +363,7 @@ public abstract class AbstractUnenhanced
 
         // we only expect lazy loading to work when we can redefine classes
         // or when accessing a property-access record that OpenJPA created.
-        if (ClassRedefiner.canRedefineClasses(_conf)
+        if (ClassRedefiner.canRedefineClasses(_log)
             || AccessCode.isProperty(sm.getMetaData().getAccessType())) {
             assertFalse(sm.getLoaded()
                 .get(sm.getMetaData().getField("lazyField").getIndex()));
@@ -589,13 +588,14 @@ public abstract class AbstractUnenhanced
         ClassMetaData meta = JPAFacadeHelper.getMetaData(emf,
             getUnenhancedClass());
         List<Class<?>> subs =  ManagedClassSubclasser.prepareUnenhancedClasses(
-            emf.getConfiguration(), Collections.singleton(getUnenhancedClass()));
+            emf.getConfiguration(), Collections.singleton(getUnenhancedClass()),
+            null);
         assertSame(meta, JPAFacadeHelper.getMetaData(emf, subs.get(0)));
 
         meta = JPAFacadeHelper.getMetaData(emf, getUnenhancedSubclass());
         subs =  ManagedClassSubclasser.prepareUnenhancedClasses(
             emf.getConfiguration(),
-            Collections.singleton(getUnenhancedSubclass()));
+            Collections.singleton(getUnenhancedSubclass()), null);
         assertSame(meta, JPAFacadeHelper.getMetaData(emf, subs.get(0)));
     }
 

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/RestrictedMetaDataRepository.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/RestrictedMetaDataRepository.java?rev=1197994&r1=1197993&r2=1197994&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/RestrictedMetaDataRepository.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/RestrictedMetaDataRepository.java Sat Nov  5 17:17:26 2011
@@ -48,8 +48,8 @@ public class RestrictedMetaDataRepositor
         }
     }
     
-    public Set<String> getPersistentTypeNames(boolean devpath) {
-        Set<String> types = super.getPersistentTypeNames(devpath);
+    public Set<String> getPersistentTypeNames(boolean devpath, ClassLoader envLoader) {
+        Set<String> types = super.getPersistentTypeNames(devpath, envLoader);
         String[] typeArray = types.toArray(new String[types.size()]);
         for (String type : typeArray) {
             if(_excludedTypes.contains(type)) {

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestEnhancementWithMultiplePUs.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestEnhancementWithMultiplePUs.java?rev=1197994&r1=1197993&r2=1197994&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestEnhancementWithMultiplePUs.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestEnhancementWithMultiplePUs.java Sat Nov  5 17:17:26 2011
@@ -26,7 +26,6 @@ import java.util.List;
 
 import org.apache.openjpa.conf.OpenJPAConfiguration;
 import org.apache.openjpa.conf.OpenJPAConfigurationImpl;
-import org.apache.openjpa.enhance.PCEnhancer.Flags;
 import org.apache.openjpa.lib.conf.Configurations;
 import org.apache.openjpa.lib.util.BytecodeWriter;
 import org.apache.openjpa.lib.util.J2DoPrivHelper;
@@ -47,13 +46,13 @@ public class TestEnhancementWithMultiple
         ClassLoader loader = AccessController
             .doPrivileged(J2DoPrivHelper.newTemporaryClassLoaderAction(
                 getClass().getClassLoader()));
-        conf.addClassLoader(loader);
         Project project = new Project();
 
-        String className = "org.apache.openjpa.enhance.UnenhancedBootstrapInstance";
+        String className =
+            "org.apache.openjpa.enhance.UnenhancedBootstrapInstance";
         BCClass bc = assertNotPC(loader, project, className);
 
-        PCEnhancer enhancer = new PCEnhancer(conf, bc, repos);
+        PCEnhancer enhancer = new PCEnhancer(conf, bc, repos, loader);
 
         assertEquals(PCEnhancer.ENHANCE_PC, enhancer.run());
         assertTrue(Arrays.asList(bc.getInterfaceNames()).contains(
@@ -80,11 +79,11 @@ public class TestEnhancementWithMultiple
         ClassLoader loader = AccessController
             .doPrivileged(J2DoPrivHelper.newTemporaryClassLoaderAction(
                 getClass().getClassLoader()));
-        conf.addClassLoader(loader);
         Project project = new Project();
 
         // make sure that the class is not already enhanced for some reason
-        String className = "org.apache.openjpa.enhance.UnenhancedBootstrapInstance";
+        String className =
+            "org.apache.openjpa.enhance.UnenhancedBootstrapInstance";
         BCClass bc = assertNotPC(loader, project, className);
 
         // build up a writer that just stores to a list so that we don't
@@ -99,7 +98,8 @@ public class TestEnhancementWithMultiple
             }
         };
 
-        PCEnhancer.run(conf, null, new PCEnhancer.Flags(), repos, writer);
+        PCEnhancer.run(conf, null, new PCEnhancer.Flags(), repos, writer,
+            loader);
 
         // ensure that we don't attempt to process classes listed in other PUs
         assertEquals(1, written.size());
@@ -108,13 +108,7 @@ public class TestEnhancementWithMultiple
         assertTrue(written.contains(className));
     }
 
-    
-    
-    /**
-     * This test is retired due to <A href="https://issues.apache.org/jira/browse/OPENJPA-2057">
-     * classloading changes</A>.
-     */
-    public void xtestEnhancementOfAllPUsWithinAResource()
+    public void testEnhancementOfAllPUsWithinAResource()
         throws IOException {
         OpenJPAConfiguration conf = new OpenJPAConfigurationImpl();
         Options opts = new Options();
@@ -124,7 +118,6 @@ public class TestEnhancementWithMultiple
         ClassLoader loader = AccessController
             .doPrivileged(J2DoPrivHelper.newTemporaryClassLoaderAction(
                 getClass().getClassLoader()));
-        conf.addClassLoader(loader);
         Project project = new Project();
 
         // make sure that the classes is not already enhanced for some reason
@@ -154,14 +147,8 @@ public class TestEnhancementWithMultiple
         opts.setProperty("MetaDataRepository", 
             "org.apache.openjpa.enhance.RestrictedMetaDataRepository(excludedTypes=" +
             "org.apache.openjpa.persistence.jdbc.annotations.UnenhancedMixedAccess)");
-        RestrictedMetaDataRepository rmdr = new RestrictedMetaDataRepository();
-        rmdr.setConfiguration(conf);
-        rmdr.setMetaDataFactory(repos.getMetaDataFactory());
-        
-        rmdr.setExcludedTypes("org.apache.openjpa.persistence.jdbc.annotations.UnenhancedMixedAccess");
         opts.put(PCEnhancer.class.getName() + "#bytecodeWriter", writer);
-        PCEnhancer.run(conf, null, new Flags(), rmdr, writer);
-//        PCEnhancer.run(null, opts);
+        PCEnhancer.run(null, opts);
 
         // ensure that we do process the classes listed in the PUs
         assertTrue(written.contains(

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/kernel/TestJDBCStoreOptSelect.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/kernel/TestJDBCStoreOptSelect.java?rev=1197994&r1=1197993&r2=1197994&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/kernel/TestJDBCStoreOptSelect.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/kernel/TestJDBCStoreOptSelect.java Sat Nov  5 17:17:26 2011
@@ -73,7 +73,7 @@ public class TestJDBCStoreOptSelect exte
             // Check to see how many fks(intermediate fields) we selected.
             StateManagerImpl smi = ((StateManagerImpl) ((PersistenceCapable) ee1).pcGetStateManager());
             ClassMetaData cmd =
-                em.getConfiguration().getMetaDataRepositoryInstance().getMetaData(OptSelectEntity.class, true);
+                em.getConfiguration().getMetaDataRepositoryInstance().getMetaData(OptSelectEntity.class, null, true);
             int fks = 0;
             for (FieldMetaData fmd : cmd.getFields()) {
                 if (smi.getIntermediate(fmd.getIndex()) != null) {
@@ -97,7 +97,7 @@ public class TestJDBCStoreOptSelect exte
         FetchPlan fp = em.pushFetchPlan();
         fp.removeFetchGroups(fp.getFetchGroups());
         for (Class<?> cls : new Class<?>[] { OptSelectEntity.class }) {
-            ClassMetaData cmd = mdr.getMetaData(cls, true);
+            ClassMetaData cmd = mdr.getMetaData(cls, null, true);
             for (FieldMetaData fmd : cmd.getFields()) {
                 fp.addField(cls, fmd.getName());
             }



Mime
View raw message