[jbossws-commits] JBossWS SVN: r11616 - in common/trunk/src/main/java/org/jboss: wsf/common/integration and 1 other directory.
jbossws-commits at lists.jboss.org
jbossws-commits at lists.jboss.org
Thu Feb 18 12:38:25 EST 2010
Author: alessio.soldano at jboss.com
Date: 2010-02-18 12:38:24 -0500 (Thu, 18 Feb 2010)
New Revision: 11616
Added:
common/trunk/src/main/java/org/jboss/ws/core/utils/SecurityActions.java
common/trunk/src/main/java/org/jboss/wsf/common/integration/AbstractDeploymentAspect.java
common/trunk/src/main/java/org/jboss/wsf/common/integration/SecurityActions.java
Modified:
common/trunk/src/main/java/org/jboss/ws/core/utils/JBossWSEntityResolver.java
Log:
[JBWS-2895] Merging from jaxrpc-cxf branch, adding support for JAXRPC with CXF and Metro stack
Modified: common/trunk/src/main/java/org/jboss/ws/core/utils/JBossWSEntityResolver.java
===================================================================
--- common/trunk/src/main/java/org/jboss/ws/core/utils/JBossWSEntityResolver.java 2010-02-18 17:35:11 UTC (rev 11615)
+++ common/trunk/src/main/java/org/jboss/ws/core/utils/JBossWSEntityResolver.java 2010-02-18 17:38:24 UTC (rev 11616)
@@ -66,7 +66,7 @@
super();
Properties props = null;
- ClassLoader loader = this.getClass().getClassLoader();
+ ClassLoader loader = SecurityActions.getContextClassLoader();
Map<String, Properties> map = propertiesMap.get(loader);
if (map != null && map.containsKey(entitiesResource))
{
@@ -80,7 +80,7 @@
propertiesMap.put(loader, map);
}
// load entities
- props = loadEntitiesMappingFromClasspath(entitiesResource);
+ props = loadEntitiesMappingFromClasspath(entitiesResource, loader);
if (props.size() == 0)
throw new IllegalArgumentException("No entities mapping defined in resource file: " + entitiesResource);
map.put(entitiesResource, props);
@@ -97,13 +97,13 @@
}
}
- private Properties loadEntitiesMappingFromClasspath(final String entitiesResource)
+ private Properties loadEntitiesMappingFromClasspath(final String entitiesResource, final ClassLoader classLoader)
{
return AccessController.doPrivileged(new PrivilegedAction<Properties>()
{
public Properties run()
{
- InputStream is = this.getClass().getClassLoader().getResourceAsStream(entitiesResource);
+ InputStream is = classLoader.getResourceAsStream(entitiesResource);
// get stream
if (is == null)
throw new IllegalArgumentException("Resource " + entitiesResource + " not found");
Copied: common/trunk/src/main/java/org/jboss/ws/core/utils/SecurityActions.java (from rev 11607, common/branches/jaxrpc-cxf/src/main/java/org/jboss/ws/core/utils/SecurityActions.java)
===================================================================
--- common/trunk/src/main/java/org/jboss/ws/core/utils/SecurityActions.java (rev 0)
+++ common/trunk/src/main/java/org/jboss/ws/core/utils/SecurityActions.java 2010-02-18 17:38:24 UTC (rev 11616)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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;
+
+/**
+ *
+ * @author alessio.soldano at jboss.com
+ * @since 17-Feb-2010
+ *
+ */
+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 classloader
+ */
+ static void setContextClassLoader(final ClassLoader classLoader)
+ {
+ if (System.getSecurityManager() == null)
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ }
+ else
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>()
+ {
+ public Object run()
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ return null;
+ }
+ });
+ }
+ }
+
+}
Copied: common/trunk/src/main/java/org/jboss/wsf/common/integration/AbstractDeploymentAspect.java (from rev 11607, common/branches/jaxrpc-cxf/src/main/java/org/jboss/wsf/common/integration/AbstractDeploymentAspect.java)
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/integration/AbstractDeploymentAspect.java (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/common/integration/AbstractDeploymentAspect.java 2010-02-18 17:38:24 UTC (rev 11616)
@@ -0,0 +1,160 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.integration;
+
+import java.lang.ref.WeakReference;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.DeploymentAspect;
+
+/**
+ * Abstract deployment aspect every other one extends
+ *
+ * @author alessio.soldano at jboss.com
+ * @since 21-Jan-2010
+ *
+ */
+public class AbstractDeploymentAspect implements DeploymentAspect
+{
+ // provide logging
+ protected final Logger log = Logger.getLogger(getClass());
+
+ private String provides;
+ private String requires;
+ private int relativeOrder;
+ private boolean isLast;
+ private boolean isForJaxWs = true;
+ private boolean isForJaxRpc = true;
+ private WeakReference<ClassLoader> loader;
+
+ public AbstractDeploymentAspect()
+ {
+ this.loader = new WeakReference<ClassLoader>(SecurityActions.getContextClassLoader());
+ }
+
+ public ClassLoader getLoader()
+ {
+ return loader != null ? loader.get() : null;
+ }
+
+ public void setLast(boolean isLast)
+ {
+ this.isLast = isLast;
+ }
+
+ public boolean isLast()
+ {
+ return this.isLast;
+ }
+
+ public String getProvides()
+ {
+ return provides;
+ }
+
+ public void setProvides(String provides)
+ {
+ this.provides = provides;
+ }
+
+ public String getRequires()
+ {
+ return requires;
+ }
+
+ public void setRequires(String requires)
+ {
+ this.requires = requires;
+ }
+
+ public void setRelativeOrder(int relativeOrder)
+ {
+ this.relativeOrder = relativeOrder;
+ }
+
+ public int getRelativeOrder()
+ {
+ return this.relativeOrder;
+ }
+
+ public void start(Deployment dep)
+ {
+ }
+
+ public void stop(Deployment dep)
+ {
+ }
+
+ public Set<String> getProvidesAsSet()
+ {
+ Set<String> condset = new HashSet<String>();
+ if (provides != null)
+ {
+ StringTokenizer st = new StringTokenizer(provides, ", \r\n\t");
+ while (st.hasMoreTokens())
+ condset.add(st.nextToken());
+ }
+ return condset;
+ }
+
+ public Set<String> getRequiresAsSet()
+ {
+ Set<String> condset = new HashSet<String>();
+ if (requires != null)
+ {
+ StringTokenizer st = new StringTokenizer(requires, ", \r\n\t");
+ while (st.hasMoreTokens())
+ condset.add(st.nextToken());
+ }
+ return condset;
+ }
+
+ public boolean canHandle(Deployment dep)
+ {
+ return (this.isForJaxWs && WSHelper.isJaxwsDeployment(dep) ||
+ this.isForJaxRpc && WSHelper.isJaxrpcDeployment(dep));
+ }
+
+ public boolean isForJaxWs()
+ {
+ return isForJaxWs;
+ }
+
+ public void setForJaxWs(boolean isForJaxWs)
+ {
+ this.isForJaxWs = isForJaxWs;
+ }
+
+ public boolean isForJaxRpc()
+ {
+ return isForJaxRpc;
+ }
+
+ public void setForJaxRpc(boolean isForJaxRpc)
+ {
+ this.isForJaxRpc = isForJaxRpc;
+ }
+}
Copied: common/trunk/src/main/java/org/jboss/wsf/common/integration/SecurityActions.java (from rev 11607, common/branches/jaxrpc-cxf/src/main/java/org/jboss/wsf/common/integration/SecurityActions.java)
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/integration/SecurityActions.java (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/common/integration/SecurityActions.java 2010-02-18 17:38:24 UTC (rev 11616)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.integration;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ *
+ * @author alessio.soldano at jboss.com
+ * @since 17-Feb-2010
+ *
+ */
+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 classloader
+ */
+ static void setContextClassLoader(final ClassLoader classLoader)
+ {
+ if (System.getSecurityManager() == null)
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ }
+ else
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>()
+ {
+ public Object run()
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ return null;
+ }
+ });
+ }
+ }
+
+}
More information about the jbossws-commits
mailing list