You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2013/09/16 15:04:29 UTC
svn commit: r1523620 -
/webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/locator/Activator.java
Author: veithen
Date: Mon Sep 16 13:04:29 2013
New Revision: 1523620
URL: http://svn.apache.org/r1523620
Log:
In an OSGi environment, we should use factoryPerClassLoader=false.
Modified:
webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/locator/Activator.java
Modified: webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/locator/Activator.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/locator/Activator.java?rev=1523620&r1=1523619&r2=1523620&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/locator/Activator.java (original)
+++ webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/locator/Activator.java Mon Sep 16 13:04:29 2013
@@ -20,6 +20,7 @@ package org.apache.axiom.locator;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMMetaFactoryLocator;
+import org.apache.axiom.om.util.StAXUtils;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
@@ -38,10 +39,18 @@ public class Activator implements Bundle
OMAbstractFactory.setMetaFactoryLocator(locator);
tracker = new BundleTracker(context, Bundle.ACTIVE, locator);
tracker.open();
+ // In an OSGi environment, the thread context class loader is generally not set in a meaningful way.
+ // Therefore we should use singleton factories. Note that if the StAX API is provided by Geronimo's or
+ // Servicemix's StAX bundle, then this actually doesn't change much because the factory locator code in
+ // these bundles don't care about the thread context class loader anyway. Nevertheless, it prevents
+ // Axiom from creating new factory instances unnecessarily. The setting may be more relevant if the
+ // StAX API is provided by the JRE.
+ StAXUtils.setFactoryPerClassLoader(false);
}
public void stop(BundleContext context) throws Exception {
tracker.close();
OMAbstractFactory.setMetaFactoryLocator(null);
+ StAXUtils.setFactoryPerClassLoader(true);
}
}