JBossWS SVN: r14938 - legacy/tags/jbossws-1.2.1.GA_CP06-patch-02/jbossws-core/src/java/org/jboss/ws/core/utils.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2011-09-05 10:46:47 -0400 (Mon, 05 Sep 2011)
New Revision: 14938
Added:
legacy/tags/jbossws-1.2.1.GA_CP06-patch-02/jbossws-core/src/java/org/jboss/ws/core/utils/SecurityActions.java
Modified:
legacy/tags/jbossws-1.2.1.GA_CP06-patch-02/jbossws-core/src/java/org/jboss/ws/core/utils/DOMUtils.java
Log:
[JBPAPP-7127] Caching default document builder factory to improve performances
Modified: legacy/tags/jbossws-1.2.1.GA_CP06-patch-02/jbossws-core/src/java/org/jboss/ws/core/utils/DOMUtils.java
===================================================================
--- legacy/tags/jbossws-1.2.1.GA_CP06-patch-02/jbossws-core/src/java/org/jboss/ws/core/utils/DOMUtils.java 2011-09-05 13:33:12 UTC (rev 14937)
+++ legacy/tags/jbossws-1.2.1.GA_CP06-patch-02/jbossws-core/src/java/org/jboss/ws/core/utils/DOMUtils.java 2011-09-05 14:46:47 UTC (rev 14938)
@@ -71,8 +71,28 @@
private static final String ENABLE_DOCTYPE_DECL = "org.jboss.ws.enable_doctype_decl";
private static final String DISALLOW_DOCTYPE_DECL_FEATURE = "http://apache.org/xml/features/disallow-doctype-decl";
+ private static DocumentBuilderFactory documentBuilderFactory;
+
private static final boolean enableDoctypeDeclaration = Boolean.getBoolean(ENABLE_DOCTYPE_DECL);
+
+ static
+ {
+ //load default document builder factory using the DOMUtils' defining classloader
+ final ClassLoader classLoader = SecurityActions.getContextClassLoader();
+ SecurityActions.setContextClassLoader(DOMUtils.class.getClassLoader());
+ try
+ {
+ final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ initializeFactory(factory);
+ documentBuilderFactory = factory;
+ }
+ finally
+ {
+ SecurityActions.setContextClassLoader(classLoader);
+ }
+ }
+
// All elements created by the same thread are created by the same builder and belong to the same doc
private static ThreadLocal documentThreadLocal = new ThreadLocal();
private static ThreadLocal builderThreadLocal = new ThreadLocal() {
@@ -80,13 +100,21 @@
try
{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setValidating(false);
- factory.setNamespaceAware(true);
- if (!enableDoctypeDeclaration)
+
+ //check if the factory we'd get for this thread is equivalent to the default one;
+ //in that case re-use the default one and skip the initialization, which is time-consuming
+ final DocumentBuilderFactory threadFactory ;
+ if (factory.getClass().getClassLoader() == documentBuilderFactory.getClass().getClassLoader())
{
- factory.setFeature(DISALLOW_DOCTYPE_DECL_FEATURE, true);
+ threadFactory = documentBuilderFactory ;
}
- DocumentBuilder builder = factory.newDocumentBuilder();
+ else
+ {
+ threadFactory = factory ;
+ initializeFactory(threadFactory) ;
+ }
+
+ DocumentBuilder builder = threadFactory.newDocumentBuilder();
builder.setEntityResolver(new JBossWSEntityResolver());
return builder;
}
@@ -102,6 +130,24 @@
{
}
+ private static void initializeFactory(final DocumentBuilderFactory factory)
+ {
+ factory.setValidating(false);
+ factory.setNamespaceAware(true);
+
+ try
+ {
+ if (!enableDoctypeDeclaration)
+ {
+ factory.setFeature(DISALLOW_DOCTYPE_DECL_FEATURE, true);
+ }
+ }
+ catch (ParserConfigurationException pce)
+ {
+ log.error(pce);
+ }
+ }
+
public static void clearThreadLocals()
{
documentThreadLocal.remove();
Added: legacy/tags/jbossws-1.2.1.GA_CP06-patch-02/jbossws-core/src/java/org/jboss/ws/core/utils/SecurityActions.java
===================================================================
--- legacy/tags/jbossws-1.2.1.GA_CP06-patch-02/jbossws-core/src/java/org/jboss/ws/core/utils/SecurityActions.java (rev 0)
+++ legacy/tags/jbossws-1.2.1.GA_CP06-patch-02/jbossws-core/src/java/org/jboss/ws/core/utils/SecurityActions.java 2011-09-05 14:46:47 UTC (rev 14938)
@@ -0,0 +1,135 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.core.utils;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * Security actions for this package
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 19-Jun-2009
+ *
+ */
+class SecurityActions
+{
+ /**
+ * Get context classloader.
+ *
+ * @return the current context classloader
+ */
+ static ClassLoader getContextClassLoader()
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+ }
+
+ /**
+ * Set context classloader.
+ *
+ * @param classLoader the context classloader
+ */
+ static void setContextClassLoader(final ClassLoader classLoader)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ }
+ else
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run()
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ return null;
+ }
+ });
+ }
+ }
+
+ /**
+ * Load a class using the provided classloader
+ *
+ * @param name
+ * @return
+ * @throws PrivilegedActionException
+ */
+ static Class<?> loadClass(final ClassLoader cl, final String name) throws PrivilegedActionException, ClassNotFoundException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.loadClass(name);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
+ public Class<?> run() throws PrivilegedActionException
+ {
+ try
+ {
+ return cl.loadClass(name);
+ }
+ catch (Exception e)
+ {
+ throw new PrivilegedActionException(e);
+ }
+ }
+ });
+ }
+ }
+
+ /**
+ * Return the current value of the specified system property
+ *
+ * @param name
+ * @param defaultValue
+ * @return
+ */
+ static String getSystemProperty(final String name, final String defaultValue)
+ {
+ PrivilegedAction<String> action = new PrivilegedAction<String>()
+ {
+ public String run()
+ {
+ return System.getProperty(name, defaultValue);
+ }
+ };
+ return AccessController.doPrivileged(action);
+ }
+}
\ No newline at end of file
13 years, 3 months
JBossWS SVN: r14937 - legacy/tags/jbossws-1.2.1.GA_CP06-patch-02/build.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2011-09-05 09:33:12 -0400 (Mon, 05 Sep 2011)
New Revision: 14937
Modified:
legacy/tags/jbossws-1.2.1.GA_CP06-patch-02/build/version.properties
Log:
Updating version
Modified: legacy/tags/jbossws-1.2.1.GA_CP06-patch-02/build/version.properties
===================================================================
--- legacy/tags/jbossws-1.2.1.GA_CP06-patch-02/build/version.properties 2011-09-05 13:30:38 UTC (rev 14936)
+++ legacy/tags/jbossws-1.2.1.GA_CP06-patch-02/build/version.properties 2011-09-05 13:33:12 UTC (rev 14937)
@@ -5,8 +5,8 @@
specification.vendor=JBoss (http://www.jboss.org)
specification.version=jbossws-1.2
-version.id=1.2.1.GA_CP06-patch-01
-repository.id=1.2.1.GA_CP06-patch-01
+version.id=1.2.1.GA_CP06-patch-02
+repository.id=1.2.1.GA_CP06-patch-02
implementation.title=JBoss Web Services (JBossWS)
implementation.url=http://www.jboss.org/products/jbossws
13 years, 3 months
JBossWS SVN: r14936 - legacy/tags.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2011-09-05 09:30:38 -0400 (Mon, 05 Sep 2011)
New Revision: 14936
Added:
legacy/tags/jbossws-1.2.1.GA_CP06-patch-02/
Log:
13 years, 3 months
JBossWS SVN: r14935 - common/branches/jbossws-common-1.0.0.GA_CP/src/main/java/org/jboss/wsf/common.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2011-09-05 09:21:31 -0400 (Mon, 05 Sep 2011)
New Revision: 14935
Added:
common/branches/jbossws-common-1.0.0.GA_CP/src/main/java/org/jboss/wsf/common/SecurityActions.java
Modified:
common/branches/jbossws-common-1.0.0.GA_CP/src/main/java/org/jboss/wsf/common/DOMUtils.java
Log:
[JBPAPP-7126] Caching default document builder factory to improve performances
Modified: common/branches/jbossws-common-1.0.0.GA_CP/src/main/java/org/jboss/wsf/common/DOMUtils.java
===================================================================
--- common/branches/jbossws-common-1.0.0.GA_CP/src/main/java/org/jboss/wsf/common/DOMUtils.java 2011-09-05 12:08:31 UTC (rev 14934)
+++ common/branches/jbossws-common-1.0.0.GA_CP/src/main/java/org/jboss/wsf/common/DOMUtils.java 2011-09-05 13:21:31 UTC (rev 14935)
@@ -76,7 +76,30 @@
private static final String DEFER_NODE_EXPANSION_FEATURE = "http://apache.org/xml/features/dom/defer-node-expansion";
private static final String ENABLE_DOCTYPE_DECL = "org.jboss.ws.enable_doctype_decl";
private static final String DISALLOW_DOCTYPE_DECL_FEATURE = "http://apache.org/xml/features/disallow-doctype-decl";
+
+ private static DocumentBuilderFactory documentBuilderFactory;
+
+ private static final boolean disableDeferedNodeExpansion = Boolean.getBoolean(DISABLE_DEFERRED_NODE_EXPANSION);
+ private static final boolean enableDoctypeDeclaration = Boolean.getBoolean(ENABLE_DOCTYPE_DECL);
+
+ static
+ {
+ //load default document builder factory using the DOMUtils' defining classloader
+ final ClassLoader classLoader = SecurityActions.getContextClassLoader();
+ SecurityActions.setContextClassLoader(DOMUtils.class.getClassLoader());
+ try
+ {
+ final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ initializeFactory(factory);
+ documentBuilderFactory = factory;
+ }
+ finally
+ {
+ SecurityActions.setContextClassLoader(classLoader);
+ }
+ }
+
// All elements created by the same thread are created by the same builder and belong to the same doc
private static ThreadLocal<Document> documentThreadLocal = new ThreadLocal<Document>();
private static ThreadLocal<DocumentBuilder> builderThreadLocal = new ThreadLocal<DocumentBuilder>() {
@@ -85,29 +108,21 @@
try
{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setValidating(false);
- factory.setNamespaceAware(true);
- factory.setExpandEntityReferences(false);
- try
+ //check if the factory we'd get for this thread is equivalent to the default one;
+ //in that case re-use the default one and skip the initialization, which is time-consuming
+ final DocumentBuilderFactory threadFactory ;
+ if (factory.getClass().getClassLoader() == documentBuilderFactory.getClass().getClassLoader())
{
- factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
- if (Boolean.getBoolean(DISABLE_DEFERRED_NODE_EXPANSION))
- {
- factory.setFeature(DEFER_NODE_EXPANSION_FEATURE, false);
- }
-
- if (!Boolean.getBoolean(ENABLE_DOCTYPE_DECL))
- {
- factory.setFeature(DISALLOW_DOCTYPE_DECL_FEATURE, true);
- }
+ threadFactory = documentBuilderFactory ;
}
- catch (ParserConfigurationException pce)
+ else
{
- log.error(pce);
+ threadFactory = factory ;
+ initializeFactory(threadFactory) ;
}
- DocumentBuilder builder = factory.newDocumentBuilder();
+ DocumentBuilder builder = threadFactory.newDocumentBuilder();
setEntityResolver(builder);
return builder;
}
@@ -122,7 +137,7 @@
String[] resolvers = new String[] { "org.jboss.ws.core.utils.JBossWSEntityResolver", "org.jboss.util.xml.JBossEntityResolver" };
EntityResolver entityResolver = null;
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ ClassLoader loader = SecurityActions.getContextClassLoader();
for (String resolver : resolvers)
{
try
@@ -140,7 +155,31 @@
builder.setEntityResolver(entityResolver);
}
};
+
+ private static void initializeFactory(final DocumentBuilderFactory factory)
+ {
+ factory.setValidating(false);
+ factory.setNamespaceAware(true);
+ factory.setExpandEntityReferences(false);
+ try
+ {
+ factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+ if (disableDeferedNodeExpansion)
+ {
+ factory.setFeature(DEFER_NODE_EXPANSION_FEATURE, false);
+ }
+ if (!enableDoctypeDeclaration)
+ {
+ factory.setFeature(DISALLOW_DOCTYPE_DECL_FEATURE, true);
+ }
+ }
+ catch (ParserConfigurationException pce)
+ {
+ log.error(pce);
+ }
+ }
+
public static void clearThreadLocals()
{
documentThreadLocal.remove();
Added: common/branches/jbossws-common-1.0.0.GA_CP/src/main/java/org/jboss/wsf/common/SecurityActions.java
===================================================================
--- common/branches/jbossws-common-1.0.0.GA_CP/src/main/java/org/jboss/wsf/common/SecurityActions.java (rev 0)
+++ common/branches/jbossws-common-1.0.0.GA_CP/src/main/java/org/jboss/wsf/common/SecurityActions.java 2011-09-05 13:21:31 UTC (rev 14935)
@@ -0,0 +1,135 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.common;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * Security actions for this package
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 19-Jun-2009
+ *
+ */
+class SecurityActions
+{
+ /**
+ * Get context classloader.
+ *
+ * @return the current context classloader
+ */
+ static ClassLoader getContextClassLoader()
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+ }
+
+ /**
+ * Set context classloader.
+ *
+ * @param classLoader the context classloader
+ */
+ static void setContextClassLoader(final ClassLoader classLoader)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ }
+ else
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run()
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ return null;
+ }
+ });
+ }
+ }
+
+ /**
+ * Load a class using the provided classloader
+ *
+ * @param name
+ * @return
+ * @throws PrivilegedActionException
+ */
+ static Class<?> loadClass(final ClassLoader cl, final String name) throws PrivilegedActionException, ClassNotFoundException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.loadClass(name);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
+ public Class<?> run() throws PrivilegedActionException
+ {
+ try
+ {
+ return cl.loadClass(name);
+ }
+ catch (Exception e)
+ {
+ throw new PrivilegedActionException(e);
+ }
+ }
+ });
+ }
+ }
+
+ /**
+ * Return the current value of the specified system property
+ *
+ * @param name
+ * @param defaultValue
+ * @return
+ */
+ static String getSystemProperty(final String name, final String defaultValue)
+ {
+ PrivilegedAction<String> action = new PrivilegedAction<String>()
+ {
+ public String run()
+ {
+ return System.getProperty(name, defaultValue);
+ }
+ };
+ return AccessController.doPrivileged(action);
+ }
+}
\ No newline at end of file
13 years, 3 months
JBossWS SVN: r14934 - in common/tags/jbossws-common-1.1.0.SP7-patch-02: src/main/java/org/jboss/wsf/common and 1 other directory.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2011-09-05 08:08:31 -0400 (Mon, 05 Sep 2011)
New Revision: 14934
Modified:
common/tags/jbossws-common-1.1.0.SP7-patch-02/
common/tags/jbossws-common-1.1.0.SP7-patch-02/src/main/java/org/jboss/wsf/common/DOMUtils.java
common/tags/jbossws-common-1.1.0.SP7-patch-02/src/main/java/org/jboss/wsf/common/SecurityActions.java
Log:
[JBPAPP-7109] Caching default document builder factory to improve performances
Property changes on: common/tags/jbossws-common-1.1.0.SP7-patch-02
___________________________________________________________________
Added: svn:mergeinfo
+ /common/branches/jbossws-common-1.1.0:14931
Modified: common/tags/jbossws-common-1.1.0.SP7-patch-02/src/main/java/org/jboss/wsf/common/DOMUtils.java
===================================================================
--- common/tags/jbossws-common-1.1.0.SP7-patch-02/src/main/java/org/jboss/wsf/common/DOMUtils.java 2011-09-05 12:01:18 UTC (rev 14933)
+++ common/tags/jbossws-common-1.1.0.SP7-patch-02/src/main/java/org/jboss/wsf/common/DOMUtils.java 2011-09-05 12:08:31 UTC (rev 14934)
@@ -77,59 +77,65 @@
private static final String DISALLOW_DOCTYPE_DECL_FEATURE = "http://apache.org/xml/features/disallow-doctype-decl";
private static String documentBuilderFactoryName;
+ private static DocumentBuilderFactory documentBuilderFactory;
private static final boolean alwaysResolveFactoryName = Boolean.getBoolean(Constants.ALWAYS_RESOLVE_DOCUMENT_BUILDER_FACTORY);
private static final boolean disableDeferedNodeExpansion = Boolean.getBoolean(DISABLE_DEFERRED_NODE_EXPANSION);
private static final boolean enableDoctypeDeclaration = Boolean.getBoolean(ENABLE_DOCTYPE_DECL);
+ static
+ {
+ //load default document builder factory using the DOMUtils' defining classloader
+ final ClassLoader classLoader = SecurityActions.getContextClassLoader();
+ SecurityActions.setContextClassLoader(DOMUtils.class.getClassLoader());
+ try
+ {
+ final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+
+ initializeFactory(factory);
+ documentBuilderFactoryName = factory.getClass().getCanonicalName();
+ documentBuilderFactory = factory;
+ }
+ finally
+ {
+ SecurityActions.setContextClassLoader(classLoader);
+ }
+ }
+
// All elements created by the same thread are created by the same builder and belong to the same doc
private static ThreadLocal<Document> documentThreadLocal = new ThreadLocal<Document>();
private static ThreadLocal<DocumentBuilder> builderThreadLocal = new ThreadLocal<DocumentBuilder>() {
protected DocumentBuilder initialValue()
{
- DocumentBuilderFactory factory = null;
try
{
- //slow
- //factory = DocumentBuilderFactory.newInstance();
-
- //fast (requires JDK6 or greater)
- if (documentBuilderFactoryName == null || alwaysResolveFactoryName)
+ DocumentBuilderFactory factory = null;
+ if (alwaysResolveFactoryName)
{
factory = DocumentBuilderFactory.newInstance();
- if (!alwaysResolveFactoryName)
- {
- documentBuilderFactoryName = factory.getClass().getCanonicalName();
- }
}
else
{
+ //this is faster then DocumentBuilderFactory.newInstance(); but requires JDK6 or greater
factory = DocumentBuilderFactory.newInstance(documentBuilderFactoryName, SecurityActions.getContextClassLoader());
}
-
- factory.setValidating(false);
- factory.setNamespaceAware(true);
- factory.setExpandEntityReferences(false);
-
- try
+ //check if the factory we'd get for this thread is equivalent to the default one;
+ //in that case re-use the default one and skip the initialization, which is time-consuming
+ final DocumentBuilderFactory threadFactory ;
+ if (factory.getClass().getClassLoader() == documentBuilderFactory.getClass().getClassLoader() &&
+ (!alwaysResolveFactoryName || documentBuilderFactoryName.equals(factory.getClass().getCanonicalName())))
{
- factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
- if (disableDeferedNodeExpansion)
- {
- factory.setFeature(DEFER_NODE_EXPANSION_FEATURE, false);
- }
- if (!enableDoctypeDeclaration)
- {
- factory.setFeature(DISALLOW_DOCTYPE_DECL_FEATURE, true);
- }
+ threadFactory = documentBuilderFactory ;
}
- catch (ParserConfigurationException pce)
+ else
{
- log.error(pce);
+ threadFactory = factory ;
+ initializeFactory(threadFactory) ;
+
}
- DocumentBuilder builder = factory.newDocumentBuilder();
+ DocumentBuilder builder = threadFactory.newDocumentBuilder();
setEntityResolver(builder);
return builder;
}
@@ -169,7 +175,32 @@
builder.setEntityResolver(entityResolver);
}
};
+
+ private static void initializeFactory(final DocumentBuilderFactory factory)
+ {
+ factory.setValidating(false);
+ factory.setNamespaceAware(true);
+ factory.setExpandEntityReferences(false);
+ try
+ {
+ factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+ if (disableDeferedNodeExpansion)
+ {
+ factory.setFeature(DEFER_NODE_EXPANSION_FEATURE, false);
+ }
+ if (!enableDoctypeDeclaration)
+ {
+ factory.setFeature(DISALLOW_DOCTYPE_DECL_FEATURE, true);
+ }
+ }
+ catch (ParserConfigurationException pce)
+ {
+ log.error(pce);
+ }
+ }
+
+
public static void clearThreadLocals()
{
documentThreadLocal.remove();
Modified: common/tags/jbossws-common-1.1.0.SP7-patch-02/src/main/java/org/jboss/wsf/common/SecurityActions.java
===================================================================
--- common/tags/jbossws-common-1.1.0.SP7-patch-02/src/main/java/org/jboss/wsf/common/SecurityActions.java 2011-09-05 12:01:18 UTC (rev 14933)
+++ common/tags/jbossws-common-1.1.0.SP7-patch-02/src/main/java/org/jboss/wsf/common/SecurityActions.java 2011-09-05 12:08:31 UTC (rev 14934)
@@ -59,6 +59,30 @@
}
/**
+ * Set context classloader.
+ *
+ * @param classLoader the context classloader
+ */
+ static void setContextClassLoader(final ClassLoader classLoader)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ }
+ else
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run()
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ return null;
+ }
+ });
+ }
+ }
+
+ /**
* Load a class using the provided classloader
*
* @param name
13 years, 3 months
JBossWS SVN: r14932 - common/tags.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2011-09-05 07:59:39 -0400 (Mon, 05 Sep 2011)
New Revision: 14932
Added:
common/tags/jbossws-common-1.1.0.SP7-patch-02/
Log:
13 years, 3 months
JBossWS SVN: r14931 - common/branches/jbossws-common-1.1.0/src/main/java/org/jboss/wsf/common.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2011-09-05 07:56:03 -0400 (Mon, 05 Sep 2011)
New Revision: 14931
Modified:
common/branches/jbossws-common-1.1.0/src/main/java/org/jboss/wsf/common/DOMUtils.java
common/branches/jbossws-common-1.1.0/src/main/java/org/jboss/wsf/common/SecurityActions.java
Log:
[JBPAPP-7108] Caching default document builder factory to improve performances
Modified: common/branches/jbossws-common-1.1.0/src/main/java/org/jboss/wsf/common/DOMUtils.java
===================================================================
--- common/branches/jbossws-common-1.1.0/src/main/java/org/jboss/wsf/common/DOMUtils.java 2011-09-05 08:28:04 UTC (rev 14930)
+++ common/branches/jbossws-common-1.1.0/src/main/java/org/jboss/wsf/common/DOMUtils.java 2011-09-05 11:56:03 UTC (rev 14931)
@@ -77,59 +77,65 @@
private static final String DISALLOW_DOCTYPE_DECL_FEATURE = "http://apache.org/xml/features/disallow-doctype-decl";
private static String documentBuilderFactoryName;
+ private static DocumentBuilderFactory documentBuilderFactory;
private static final boolean alwaysResolveFactoryName = Boolean.getBoolean(Constants.ALWAYS_RESOLVE_DOCUMENT_BUILDER_FACTORY);
private static final boolean disableDeferedNodeExpansion = Boolean.getBoolean(DISABLE_DEFERRED_NODE_EXPANSION);
private static final boolean enableDoctypeDeclaration = Boolean.getBoolean(ENABLE_DOCTYPE_DECL);
+ static
+ {
+ //load default document builder factory using the DOMUtils' defining classloader
+ final ClassLoader classLoader = SecurityActions.getContextClassLoader();
+ SecurityActions.setContextClassLoader(DOMUtils.class.getClassLoader());
+ try
+ {
+ final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+
+ initializeFactory(factory);
+ documentBuilderFactoryName = factory.getClass().getCanonicalName();
+ documentBuilderFactory = factory;
+ }
+ finally
+ {
+ SecurityActions.setContextClassLoader(classLoader);
+ }
+ }
+
// All elements created by the same thread are created by the same builder and belong to the same doc
private static ThreadLocal<Document> documentThreadLocal = new ThreadLocal<Document>();
private static ThreadLocal<DocumentBuilder> builderThreadLocal = new ThreadLocal<DocumentBuilder>() {
protected DocumentBuilder initialValue()
{
- DocumentBuilderFactory factory = null;
try
{
- //slow
- //factory = DocumentBuilderFactory.newInstance();
-
- //fast (requires JDK6 or greater)
- if (documentBuilderFactoryName == null || alwaysResolveFactoryName)
+ DocumentBuilderFactory factory = null;
+ if (alwaysResolveFactoryName)
{
factory = DocumentBuilderFactory.newInstance();
- if (!alwaysResolveFactoryName)
- {
- documentBuilderFactoryName = factory.getClass().getCanonicalName();
- }
}
else
{
+ //this is faster then DocumentBuilderFactory.newInstance(); but requires JDK6 or greater
factory = DocumentBuilderFactory.newInstance(documentBuilderFactoryName, SecurityActions.getContextClassLoader());
}
-
- factory.setValidating(false);
- factory.setNamespaceAware(true);
- factory.setExpandEntityReferences(false);
-
- try
+ //check if the factory we'd get for this thread is equivalent to the default one;
+ //in that case re-use the default one and skip the initialization, which is time-consuming
+ final DocumentBuilderFactory threadFactory ;
+ if (factory.getClass().getClassLoader() == documentBuilderFactory.getClass().getClassLoader() &&
+ (!alwaysResolveFactoryName || documentBuilderFactoryName.equals(factory.getClass().getCanonicalName())))
{
- factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
- if (disableDeferedNodeExpansion)
- {
- factory.setFeature(DEFER_NODE_EXPANSION_FEATURE, false);
- }
- if (!enableDoctypeDeclaration)
- {
- factory.setFeature(DISALLOW_DOCTYPE_DECL_FEATURE, true);
- }
+ threadFactory = documentBuilderFactory ;
}
- catch (ParserConfigurationException pce)
+ else
{
- log.error(pce);
+ threadFactory = factory ;
+ initializeFactory(threadFactory) ;
+
}
- DocumentBuilder builder = factory.newDocumentBuilder();
+ DocumentBuilder builder = threadFactory.newDocumentBuilder();
setEntityResolver(builder);
return builder;
}
@@ -169,7 +175,32 @@
builder.setEntityResolver(entityResolver);
}
};
+
+ private static void initializeFactory(final DocumentBuilderFactory factory)
+ {
+ factory.setValidating(false);
+ factory.setNamespaceAware(true);
+ factory.setExpandEntityReferences(false);
+ try
+ {
+ factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+ if (disableDeferedNodeExpansion)
+ {
+ factory.setFeature(DEFER_NODE_EXPANSION_FEATURE, false);
+ }
+ if (!enableDoctypeDeclaration)
+ {
+ factory.setFeature(DISALLOW_DOCTYPE_DECL_FEATURE, true);
+ }
+ }
+ catch (ParserConfigurationException pce)
+ {
+ log.error(pce);
+ }
+ }
+
+
public static void clearThreadLocals()
{
documentThreadLocal.remove();
Modified: common/branches/jbossws-common-1.1.0/src/main/java/org/jboss/wsf/common/SecurityActions.java
===================================================================
--- common/branches/jbossws-common-1.1.0/src/main/java/org/jboss/wsf/common/SecurityActions.java 2011-09-05 08:28:04 UTC (rev 14930)
+++ common/branches/jbossws-common-1.1.0/src/main/java/org/jboss/wsf/common/SecurityActions.java 2011-09-05 11:56:03 UTC (rev 14931)
@@ -59,6 +59,30 @@
}
/**
+ * Set context classloader.
+ *
+ * @param classLoader the context classloader
+ */
+ static void setContextClassLoader(final ClassLoader classLoader)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ }
+ else
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run()
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ return null;
+ }
+ });
+ }
+ }
+
+ /**
* Load a class using the provided classloader
*
* @param name
13 years, 3 months
JBossWS SVN: r14930 - in stack/cxf/branches/JBWS-3343/modules/server/src/main/java/org/jboss/wsf/stack/cxf: transport and 1 other directory.
by jbossws-commits@lists.jboss.org
Author: jim.ma
Date: 2011-09-05 04:28:04 -0400 (Mon, 05 Sep 2011)
New Revision: 14930
Modified:
stack/cxf/branches/JBWS-3343/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/DescriptorDeploymentAspect.java
stack/cxf/branches/JBWS-3343/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/Message.properties
stack/cxf/branches/JBWS-3343/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/ServletHelper.java
Log:
[JBWS-3346]:Remove DeploymentType and use EndpointType
Modified: stack/cxf/branches/JBWS-3343/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/DescriptorDeploymentAspect.java
===================================================================
--- stack/cxf/branches/JBWS-3343/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/DescriptorDeploymentAspect.java 2011-09-05 08:13:28 UTC (rev 14929)
+++ stack/cxf/branches/JBWS-3343/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/DescriptorDeploymentAspect.java 2011-09-05 08:28:04 UTC (rev 14930)
@@ -31,9 +31,9 @@
import org.jboss.ws.api.util.BundleUtils;
import org.jboss.ws.common.integration.AbstractDeploymentAspect;
import org.jboss.ws.common.integration.WSConstants;
+import org.jboss.ws.common.integration.WSHelper;
import org.jboss.wsf.spi.deployment.ArchiveDeployment;
import org.jboss.wsf.spi.deployment.Deployment;
-import org.jboss.wsf.spi.deployment.Deployment.DeploymentType;
import org.jboss.wsf.stack.cxf.client.util.SpringUtils;
import org.jboss.wsf.stack.cxf.configuration.BusHolder;
import org.jboss.wsf.stack.cxf.metadata.MetadataBuilder;
@@ -92,15 +92,14 @@
*/
private URL getCXFConfigFromDeployment(Deployment dep)
{
- DeploymentType depType = dep.getType();
String metadir;
- if (depType == DeploymentType.JAXWS_EJB3)
+ if (WSHelper.isJaxwsEjbDeployment(dep))
{
// expected resource location for EJB3 deployments
metadir = "META-INF";
}
- else if (depType == DeploymentType.JAXWS_JSE)
+ if (WSHelper.isJaxwsJseDeployment(dep))
{
// expected resource location for POJO deployments
metadir = "WEB-INF";
@@ -108,7 +107,7 @@
else
{
// only POJO and EJB3 deployments are supported
- throw new IllegalStateException(BundleUtils.getMessage(bundle, "UNSUPPORTED_DEPLOYMENT_TYPE", depType));
+ throw new IllegalStateException(BundleUtils.getMessage(bundle, "UNSUPPORTED_DEPLOYMENT_TYPE"));
}
URL cxfURL = null;
Modified: stack/cxf/branches/JBWS-3343/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/Message.properties
===================================================================
--- stack/cxf/branches/JBWS-3343/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/Message.properties 2011-09-05 08:13:28 UTC (rev 14929)
+++ stack/cxf/branches/JBWS-3343/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/Message.properties 2011-09-05 08:28:04 UTC (rev 14930)
@@ -1 +1 @@
-UNSUPPORTED_DEPLOYMENT_TYPE=Unsupported deployment type: {0}
+UNSUPPORTED_DEPLOYMENT_TYPE=JAXRPC_JSE or JAXRPC_EJB21 endpoint is not supported
Modified: stack/cxf/branches/JBWS-3343/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/ServletHelper.java
===================================================================
--- stack/cxf/branches/JBWS-3343/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/ServletHelper.java 2011-09-05 08:13:28 UTC (rev 14929)
+++ stack/cxf/branches/JBWS-3343/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/ServletHelper.java 2011-09-05 08:28:04 UTC (rev 14930)
@@ -51,8 +51,8 @@
import org.jboss.wsf.spi.SPIProvider;
import org.jboss.wsf.spi.SPIProviderResolver;
import org.jboss.wsf.spi.classloading.ClassLoaderProvider;
-import org.jboss.wsf.spi.deployment.Deployment.DeploymentType;
import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.deployment.Endpoint.EndpointType;
import org.jboss.wsf.spi.invocation.EndpointAssociation;
import org.jboss.wsf.spi.invocation.RequestHandler;
import org.jboss.wsf.spi.management.EndpointRegistry;
@@ -141,8 +141,7 @@
ServerFactoryBean factory = endpoint.getAttachment(ServerFactoryBean.class);
if (factory != null)
{
- if (DeploymentType.JAXWS_EJB3 != endpoint.getService().getDeployment().getType()
- && factory.getServiceBean() != null)
+ if (EndpointType.JAXWS_EJB3 != endpoint.getType() && factory.getServiceBean() != null)
{
InjectionHelper.callPreDestroyMethod(factory.getServiceBean());
}
13 years, 3 months
JBossWS SVN: r14929 - stack/cxf/branches.
by jbossws-commits@lists.jboss.org
Author: jim.ma
Date: 2011-09-05 04:13:28 -0400 (Mon, 05 Sep 2011)
New Revision: 14929
Added:
stack/cxf/branches/JBWS-3343/
Log:
Create JBWS-3343 workspace
13 years, 3 months