From dcb47f0fe406c5d926c2d0e654b6690a15111cf1 Mon Sep 17 00:00:00 2001 From: Patrick Linskey Date: Fri, 25 Aug 2006 07:33:50 +0000 Subject: [PATCH] OPENJPA-14. Use the class's classloader in environments when service lookups should be looking in the OpenJPA distribution. This imposes the restriction that OpenJPA will only find services in the same classloader as the OpenJPA jars themselves, which is a much better restriction than requiring that the classes be in the thread's context classloader. git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@436694 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/openjpa/conf/ProductDerivations.java | 3 ++- .../src/main/java/org/apache/openjpa/enhance/PCEnhancer.java | 2 +- .../main/java/org/apache/openjpa/kernel/QueryLanguages.java | 2 +- .../src/main/java/org/apache/openjpa/lib/ant/AbstractTask.java | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/conf/ProductDerivations.java b/openjpa-kernel/src/main/java/org/apache/openjpa/conf/ProductDerivations.java index 7674119f3..4cdc99fd9 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/conf/ProductDerivations.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/conf/ProductDerivations.java @@ -36,7 +36,8 @@ public class ProductDerivations { private static final ProductDerivation[] _derivations; static { - Class[] pdcls = Services.getImplementorClasses(ProductDerivation.class); + Class[] pdcls = Services.getImplementorClasses(ProductDerivation.class, + ProductDerivations.class.getClassLoader()); List derivations = new ArrayList(pdcls.length); for (int i = 0; i < pdcls.length; i++) { try { diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java index 79a33df10..ec647d96f 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java @@ -2617,7 +2617,7 @@ public class PCEnhancer { if (_auxEnhancers == null) { try { Class[] classes = Services.getImplementorClasses - (AuxiliaryEnhancer.class); + (AuxiliaryEnhancer.class, getClass().getClassLoader()); _auxEnhancers = new AuxiliaryEnhancer[classes.length]; for (int i = 0; i < _auxEnhancers.length; i++) _auxEnhancers[i] = (AuxiliaryEnhancer) classes[i]. diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryLanguages.java b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryLanguages.java index 9764c1739..c0889210b 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryLanguages.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryLanguages.java @@ -34,7 +34,7 @@ public class QueryLanguages { static { // Load and cache all the query languages available in the system. Class[] classes = Services.getImplementorClasses( - ExpressionParser.class); + ExpressionParser.class, QueryLanguages.class.getClassLoader()); for (int i = 0; i < classes.length; i++) { ExpressionParser ep; try { diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/ant/AbstractTask.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/ant/AbstractTask.java index 94e1f3e28..d21378312 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/ant/AbstractTask.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/ant/AbstractTask.java @@ -42,7 +42,7 @@ import org.apache.openjpa.lib.util.Localizer; * </mytask&rt; * * - * The defailt configuration for the system will be used if the + * The default configuration for the system will be used if the * <config&rt; subtask is excluded. * * @nojavadoc