JBossWS SVN: r10504 - stack/native/trunk/modules/testsuite.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2009-08-07 10:21:17 -0400 (Fri, 07 Aug 2009)
New Revision: 10504
Modified:
stack/native/trunk/modules/testsuite/pom.xml
Log:
[JBWS-2719] Adding profile for remote management
Modified: stack/native/trunk/modules/testsuite/pom.xml
===================================================================
--- stack/native/trunk/modules/testsuite/pom.xml 2009-08-07 12:02:53 UTC (rev 10503)
+++ stack/native/trunk/modules/testsuite/pom.xml 2009-08-07 14:21:17 UTC (rev 10504)
@@ -18,6 +18,7 @@
<surefire.security.args>-Djava.security.manager -Djava.security.policy=src/test/etc/tst.policy</surefire.security.args>
<surefire.jdwp.args>-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005</surefire.jdwp.args>
<surefire.gc.args>-Xmx512m -XX:MaxPermSize=256m</surefire.gc.args>
+ <surefire.management.args>-Dcom.sun.management.jmxremote</surefire.management.args>
<test.archive.directory>${project.build.directory}/test-libs</test.archive.directory>
<test.classes.directory>${project.build.directory}/test-classes</test.classes.directory>
<test.resources.directory>${project.build.directory}/test-resources</test.resources.directory>
@@ -270,6 +271,33 @@
</profile>
<!--
+ Name: management
+ Descr: Enable remote jmx management (useful to attach JConsole, for instance)
+ -->
+ <profile>
+ <id>management</id>
+ <activation>
+ <property>
+ <name>management</name>
+ </property>
+ </activation>
+ <properties>
+ <surefire.jvm.management.args>${surefire.management.args}</surefire.jvm.management.args>
+ </properties>
+ </profile>
+ <profile>
+ <id>no-management</id>
+ <activation>
+ <property>
+ <name>!management</name>
+ </property>
+ </activation>
+ <properties>
+ <surefire.jvm.management.args> </surefire.jvm.management.args>
+ </properties>
+ </profile>
+
+ <!--
Name: hudson
Descr: Ignore test failures on hudson
-->
@@ -347,7 +375,7 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <argLine>${surefire.jvm.args} -Djava.endorsed.dirs=${jboss500.home}/lib/endorsed</argLine>
+ <argLine>${surefire.jvm.args} ${surefire.jvm.management.args} -Djava.endorsed.dirs=${jboss500.home}/lib/endorsed</argLine>
<!-- TODO: replace with maven dependencies -->
<additionalClasspathElements>
<additionalClasspathElement>${jboss.home}/client/jbossall-client.jar</additionalClasspathElement>
@@ -419,7 +447,7 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <argLine>${surefire.jvm.args} -Djava.endorsed.dirs=${jboss501.home}/lib/endorsed</argLine>
+ <argLine>${surefire.jvm.args} ${surefire.jvm.management.args} -Djava.endorsed.dirs=${jboss501.home}/lib/endorsed</argLine>
<!-- TODO: replace with maven dependencies -->
<additionalClasspathElements>
<additionalClasspathElement>${jboss.home}/client/jbossall-client.jar</additionalClasspathElement>
@@ -480,7 +508,7 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <argLine>${surefire.jvm.args} -Djava.endorsed.dirs=${jboss510.home}/lib/endorsed</argLine>
+ <argLine>${surefire.jvm.args} ${surefire.jvm.management.args} -Djava.endorsed.dirs=${jboss510.home}/lib/endorsed</argLine>
<!-- TODO: replace with maven dependencies -->
<additionalClasspathElements>
<additionalClasspathElement>${jboss.home}/client/jbossall-client.jar</additionalClasspathElement>
@@ -551,7 +579,7 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <argLine>${surefire.jvm.args} -Djava.endorsed.dirs=${jboss520.home}/lib/endorsed</argLine>
+ <argLine>${surefire.jvm.args} ${surefire.jvm.management.args} -Djava.endorsed.dirs=${jboss520.home}/lib/endorsed</argLine>
<!-- TODO: replace with maven dependencies -->
<additionalClasspathElements>
<additionalClasspathElement>${jboss.home}/client/jbossall-client.jar</additionalClasspathElement>
@@ -622,7 +650,7 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <argLine>${surefire.jvm.args} -Djava.endorsed.dirs=${jboss600.home}/lib/endorsed</argLine>
+ <argLine>${surefire.jvm.args} ${surefire.jvm.management.args} -Djava.endorsed.dirs=${jboss600.home}/lib/endorsed</argLine>
<!-- TODO: replace with maven dependencies -->
<additionalClasspathElements>
<additionalClasspathElement>${jboss.home}/client/jbossall-client.jar</additionalClasspathElement>
15 years, 1 month
JBossWS SVN: r10503 - container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2009-08-07 08:02:53 -0400 (Fri, 07 Aug 2009)
New Revision: 10503
Modified:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/AbstractInvocationHandler.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerEJB21.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerEJB3.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerJAXRPC.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerJSE.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerMDB21.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerMDB3.java
Log:
[JBWS-2332] refactoring
Modified: container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/AbstractInvocationHandler.java
===================================================================
--- container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/AbstractInvocationHandler.java 2009-08-07 10:10:51 UTC (rev 10502)
+++ container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/AbstractInvocationHandler.java 2009-08-07 12:02:53 UTC (rev 10503)
@@ -24,6 +24,9 @@
import java.lang.reflect.Method;
import org.jboss.wsf.common.JavaUtils;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.invocation.Invocation;
+import org.jboss.wsf.spi.invocation.InvocationContext;
import org.jboss.wsf.spi.invocation.InvocationHandler;
/**
@@ -32,6 +35,16 @@
*/
public abstract class AbstractInvocationHandler extends InvocationHandler
{
+
+ public Invocation createInvocation()
+ {
+ return new Invocation();
+ }
+
+ public void init(Endpoint ep)
+ {
+ }
+
protected Method getImplMethod(Class implClass, Method seiMethod) throws ClassNotFoundException, NoSuchMethodException
{
String methodName = seiMethod.getName();
@@ -50,4 +63,26 @@
Method implMethod = implClass.getMethod(methodName, paramTypes);
return implMethod;
}
+
+ protected Object getTargetBean(Endpoint ep, Invocation epInv) throws Exception
+ {
+ InvocationContext invCtx = epInv.getInvocationContext();
+ Object targetBean = invCtx.getTargetBean();
+ if (targetBean == null)
+ {
+ try
+ {
+ Class<?> epImpl = ep.getTargetBeanClass();
+ targetBean = epImpl.newInstance();
+ invCtx.setTargetBean(targetBean);
+ }
+ catch (Exception ex)
+ {
+ throw new IllegalStateException("Cannot get target bean instance", ex);
+ }
+ }
+
+ return targetBean;
+ }
+
}
Modified: container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerEJB21.java
===================================================================
--- container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerEJB21.java 2009-08-07 10:10:51 UTC (rev 10502)
+++ container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerEJB21.java 2009-08-07 12:02:53 UTC (rev 10503)
@@ -49,7 +49,6 @@
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.invocation.HandlerCallback;
import org.jboss.wsf.spi.invocation.Invocation;
-import org.jboss.wsf.spi.invocation.InvocationHandler;
import org.jboss.wsf.spi.invocation.SecurityAdaptor;
import org.jboss.wsf.spi.invocation.SecurityAdaptorFactory;
import org.jboss.wsf.spi.metadata.j2ee.EJBArchiveMetaData;
@@ -61,7 +60,7 @@
* @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
* @author <a href="mailto:tdiesler@redhat.com">Thomas Diesler</a>
*/
-public class InvocationHandlerEJB21 extends InvocationHandler
+public class InvocationHandlerEJB21 extends AbstractInvocationHandler
{
// provide logging
private static final Logger log = Logger.getLogger(InvocationHandlerEJB21.class);
@@ -74,11 +73,6 @@
{
}
- public Invocation createInvocation()
- {
- return new Invocation();
- }
-
public void init(Endpoint ep)
{
String ejbName = ep.getShortName();
Modified: container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerEJB3.java
===================================================================
--- container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerEJB3.java 2009-08-07 10:10:51 UTC (rev 10502)
+++ container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerEJB3.java 2009-08-07 12:02:53 UTC (rev 10503)
@@ -52,16 +52,10 @@
houston = KernelLocator.getKernel().getController();
}
- public Invocation createInvocation()
- {
- return new Invocation();
- }
-
public void init(Endpoint ep)
{
containerName = (String)ep.getProperty(InvocationHandlerEJB3.CONTAINER_NAME);
assert containerName != null : "Target container name not set";
-
}
private ServiceEndpointContainer lazyInitializeInvocationTarget()
Modified: container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerJAXRPC.java
===================================================================
--- container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerJAXRPC.java 2009-08-07 10:10:51 UTC (rev 10502)
+++ container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerJAXRPC.java 2009-08-07 12:02:53 UTC (rev 10503)
@@ -40,6 +40,7 @@
{
try
{
+ // TODO: is it bug or feature? We're doing resource injection on JAXRPC endpoints.
Object targetBean = getTargetBean(ep, epInv);
InvocationContext invContext = epInv.getInvocationContext();
@@ -48,6 +49,8 @@
ServletEndpointContext sepContext = invContext.getAttachment(ServletEndpointContext.class);
if (sepContext != null)
((ServiceLifecycle)targetBean).init(sepContext);
+ // TODO: shouldn't we call init method also in case ServletEndpointContext
+ // TODO: isn't available to ensure lifecycle method calls?
}
try
@@ -58,6 +61,7 @@
{
if (targetBean instanceof ServiceLifecycle)
{
+ // TODO: This is bug! we're calling endpoint destroy method after each JAXRPC endpoint invocation.
((ServiceLifecycle)targetBean).destroy();
}
}
Modified: container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerJSE.java
===================================================================
--- container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerJSE.java 2009-08-07 10:10:51 UTC (rev 10502)
+++ container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerJSE.java 2009-08-07 12:02:53 UTC (rev 10503)
@@ -25,7 +25,6 @@
import javax.xml.ws.WebServiceContext;
-import org.jboss.wsf.common.JavaUtils;
import org.jboss.wsf.common.injection.InjectionHelper;
import org.jboss.wsf.common.injection.PreDestroyHolder;
import org.jboss.wsf.spi.SPIProvider;
@@ -33,7 +32,6 @@
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.invocation.Invocation;
import org.jboss.wsf.spi.invocation.InvocationContext;
-import org.jboss.wsf.spi.invocation.InvocationHandler;
import org.jboss.wsf.spi.invocation.ResourceInjector;
import org.jboss.wsf.spi.invocation.ResourceInjectorFactory;
import org.jboss.wsf.spi.metadata.injection.InjectionsMetaData;
@@ -44,43 +42,23 @@
* @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
* @author <a href="mailto:tdiesler@redhat.com">Thomas Diesler</a>
*/
-public class InvocationHandlerJSE extends InvocationHandler
+public class InvocationHandlerJSE extends AbstractInvocationHandler
{
- private SPIProvider spiProvider;
+
private ResourceInjectorFactory resourceInjectorFactory;
public InvocationHandlerJSE()
{
- spiProvider = SPIProviderResolver.getInstance().getProvider();
+ SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
resourceInjectorFactory = spiProvider.getSPI(ResourceInjectorFactory.class);
}
- public Invocation createInvocation()
- {
- return new Invocation();
- }
-
- public void init(Endpoint ep)
- {
- }
-
protected Object getTargetBean(Endpoint ep, Invocation epInv) throws Exception
{
- InvocationContext invCtx = epInv.getInvocationContext();
- Object targetBean = invCtx.getTargetBean();
- if (targetBean == null)
- {
- try
- {
- Class<?> epImpl = ep.getTargetBeanClass();
- targetBean = epImpl.newInstance();
- invCtx.setTargetBean(targetBean);
- }
- catch (Exception ex)
- {
- throw new IllegalStateException("Cannot get target bean instance", ex);
- }
+ Object targetBean = super.getTargetBean(ep, epInv);
+ if (ep.getAttachment(PreDestroyHolder.class) == null)
+ {
InjectionHelper.injectResources(targetBean, ep.getAttachment(InjectionsMetaData.class));
InjectionHelper.callPostConstructMethod(targetBean);
ep.addAttachment(PreDestroyHolder.class, new PreDestroyHolder(targetBean));
@@ -93,13 +71,14 @@
{
try
{
- Object targetBean = getTargetBean(ep, epInv);
+ Object targetBean = this.getTargetBean(ep, epInv);
InvocationContext invContext = epInv.getInvocationContext();
WebServiceContext wsContext = invContext.getAttachment(WebServiceContext.class);
ResourceInjector injector = null;
if (wsContext != null)
{
+ // TODO: is it bug or feature? We're doing WebServiceContext injection on JAXRPC endpoints too?
injector = resourceInjectorFactory.newResourceInjector();
injector.inject(targetBean, wsContext);
}
@@ -118,22 +97,4 @@
}
}
- protected Method getImplMethod(Class<?> implClass, Method seiMethod) throws ClassNotFoundException, NoSuchMethodException
- {
- String methodName = seiMethod.getName();
- Class<?>[] paramTypes = seiMethod.getParameterTypes();
- for (int i = 0; i < paramTypes.length; i++)
- {
- Class<?> paramType = paramTypes[i];
- if (JavaUtils.isPrimitive(paramType) == false)
- {
- String paramTypeName = paramType.getName();
- paramType = JavaUtils.loadJavaType(paramTypeName);
- paramTypes[i] = paramType;
- }
- }
-
- Method implMethod = implClass.getMethod(methodName, paramTypes);
- return implMethod;
- }
}
Modified: container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerMDB21.java
===================================================================
--- container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerMDB21.java 2009-08-07 10:10:51 UTC (rev 10502)
+++ container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerMDB21.java 2009-08-07 12:02:53 UTC (rev 10503)
@@ -23,10 +23,8 @@
import java.lang.reflect.Method;
-import org.jboss.logging.Logger;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.invocation.Invocation;
-import org.jboss.wsf.spi.invocation.InvocationContext;
/**
* Handles invocations on MDB EJB21 endpoints.
@@ -36,41 +34,14 @@
*/
public class InvocationHandlerMDB21 extends AbstractInvocationHandler
{
- // provide logging
- private static final Logger log = Logger.getLogger(InvocationHandlerMDB21.class);
- public Invocation createInvocation()
- {
- return new Invocation();
- }
-
- public void init(Endpoint ep)
- {
-
- }
-
public void invoke(Endpoint ep, Invocation epInv) throws Exception
{
- log.debug("Invoke: " + epInv.getJavaMethod().getName());
-
try
{
- InvocationContext invCtx = epInv.getInvocationContext();
- Object targetBean = invCtx.getTargetBean();
- if (targetBean == null)
- {
- try
- {
- Class epImpl = ep.getTargetBeanClass();
- targetBean = epImpl.newInstance();
- invCtx.setTargetBean(targetBean);
- }
- catch (Exception ex)
- {
- throw new IllegalStateException("Canot get target bean instance", ex);
- }
- }
- Class implClass = targetBean.getClass();
+ Object targetBean = super.getTargetBean(ep, epInv);
+
+ Class<?> implClass = targetBean.getClass();
Method seiMethod = epInv.getJavaMethod();
Method implMethod = getImplMethod(implClass, seiMethod);
@@ -83,4 +54,5 @@
handleInvocationException(e);
}
}
+
}
Modified: container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerMDB3.java
===================================================================
--- container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerMDB3.java 2009-08-07 10:10:51 UTC (rev 10502)
+++ container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerMDB3.java 2009-08-07 12:02:53 UTC (rev 10503)
@@ -23,10 +23,8 @@
import java.lang.reflect.Method;
-import org.jboss.logging.Logger;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.invocation.Invocation;
-import org.jboss.wsf.spi.invocation.InvocationContext;
/**
* Handles invocations on MDB EJB3 endpoints.
@@ -36,41 +34,14 @@
*/
public class InvocationHandlerMDB3 extends AbstractInvocationHandler
{
- // provide logging
- private static final Logger log = Logger.getLogger(InvocationHandlerMDB3.class);
- public Invocation createInvocation()
- {
- return new Invocation();
- }
-
- public void init(Endpoint ep)
- {
-
- }
-
public void invoke(Endpoint ep, Invocation epInv) throws Exception
{
- log.debug("Invoke: " + epInv.getJavaMethod().getName());
-
try
{
- InvocationContext invCtx = epInv.getInvocationContext();
- Object targetBean = invCtx.getTargetBean();
- if (targetBean == null)
- {
- try
- {
- Class epImpl = ep.getTargetBeanClass();
- targetBean = epImpl.newInstance();
- invCtx.setTargetBean(targetBean);
- }
- catch (Exception ex)
- {
- throw new IllegalStateException("Canot get target bean instance", ex);
- }
- }
- Class implClass = targetBean.getClass();
+ Object targetBean = super.getTargetBean(ep, epInv);
+
+ Class<?> implClass = targetBean.getClass();
Method seiMethod = epInv.getJavaMethod();
Method implMethod = getImplMethod(implClass, seiMethod);
@@ -83,4 +54,5 @@
handleInvocationException(e);
}
}
+
}
15 years, 1 month
JBossWS SVN: r10502 - container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2009-08-07 06:10:51 -0400 (Fri, 07 Aug 2009)
New Revision: 10502
Modified:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerJSE.java
Log:
[JBWS-2662] sync with trunk before refactoring invocation layer
Modified: container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerJSE.java
===================================================================
--- container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerJSE.java 2009-08-07 10:01:42 UTC (rev 10501)
+++ container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerJSE.java 2009-08-07 10:10:51 UTC (rev 10502)
@@ -97,15 +97,20 @@
InvocationContext invContext = epInv.getInvocationContext();
WebServiceContext wsContext = invContext.getAttachment(WebServiceContext.class);
+ ResourceInjector injector = null;
if (wsContext != null)
{
- ResourceInjector injector = resourceInjectorFactory.newResourceInjector();
+ injector = resourceInjectorFactory.newResourceInjector();
injector.inject(targetBean, wsContext);
}
Method method = getImplMethod(targetBean.getClass(), epInv.getJavaMethod());
Object retObj = method.invoke(targetBean, epInv.getArgs());
epInv.setReturnValue(retObj);
+ if (wsContext != null) //JBWS-2662
+ {
+ injector.inject(targetBean, null);
+ }
}
catch (Exception e)
{
15 years, 1 month
JBossWS SVN: r10501 - container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2009-08-07 06:01:42 -0400 (Fri, 07 Aug 2009)
New Revision: 10501
Modified:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/AbstractSecurityMetaDataAccessorEJB.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/SecurityMetaDataAccessorEJB.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/SecurityMetaDataAccessorEJB3.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataCreatingDeploymentAspect.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataCreator.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataHelper.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataModifier.java
Log:
[JBWS-2332] finalizing tomcat integration package refactoring
Modified: container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/AbstractSecurityMetaDataAccessorEJB.java
===================================================================
--- container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/AbstractSecurityMetaDataAccessorEJB.java 2009-08-07 09:46:12 UTC (rev 10500)
+++ container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/AbstractSecurityMetaDataAccessorEJB.java 2009-08-07 10:01:42 UTC (rev 10501)
@@ -71,7 +71,7 @@
/**
* @see org.jboss.webservices.integration.tomcat.SecurityMetaDataAccessorEJB#getAuthMethod(Endpoint)
- *
+ *
* @param endpoint EJB webservice endpoint
* @return authentication method or null if not specified
*/
@@ -85,7 +85,7 @@
/**
* @see org.jboss.webservices.integration.tomcat.SecurityMetaDataAccessorEJB#isSecureWsdlAccess(Endpoint)
- *
+ *
* @param endpoint EJB webservice endpoint
* @return whether WSDL access have to be secured
*/
@@ -99,7 +99,7 @@
/**
* @see org.jboss.webservices.integration.tomcat.SecurityMetaDataAccessorEJB#getTransportGuarantee(Endpoint)
- *
+ *
* @param endpoint EJB webservice endpoint
* @return transport guarantee or null if not specified
*/
@@ -113,8 +113,8 @@
/**
* Gets EJB security meta data if associated with EJB endpoint.
- *
- * @param endpoint EJB webservice endpoint
+ *
+ * @param endpoint EJB webservice endpoint
* @return EJB security meta data or null
*/
private EJBSecurityMetaData getEjbSecurityMetaData(final Endpoint endpoint)
Modified: container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/SecurityMetaDataAccessorEJB.java
===================================================================
--- container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/SecurityMetaDataAccessorEJB.java 2009-08-07 09:46:12 UTC (rev 10500)
+++ container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/SecurityMetaDataAccessorEJB.java 2009-08-07 10:01:42 UTC (rev 10501)
@@ -51,24 +51,24 @@
SecurityRolesMetaData getSecurityRoles(Deployment dep);
/**
- * Whether WSDL access have to be secured.
- *
+ * Whether WSDL access have to be secured.
+ *
* @param endpoint webservice EJB endpoint
* @return authentication method or null if not specified
*/
boolean isSecureWsdlAccess(Endpoint endpoint);
/**
- * Gets EJB authentication method.
- *
+ * Gets EJB authentication method.
+ *
* @param endpoint webservice EJB endpoint
* @return authentication method or null if not specified
*/
String getAuthMethod(Endpoint endpoint);
/**
- * Gets EJB transport guarantee.
- *
+ * Gets EJB transport guarantee.
+ *
* @param endpoint webservice EJB endpoint
* @return transport guarantee or null if not specified
*/
Modified: container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/SecurityMetaDataAccessorEJB3.java
===================================================================
--- container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/SecurityMetaDataAccessorEJB3.java 2009-08-07 09:46:12 UTC (rev 10500)
+++ container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/SecurityMetaDataAccessorEJB3.java 2009-08-07 10:01:42 UTC (rev 10501)
@@ -110,7 +110,7 @@
/**
* @see org.jboss.webservices.integration.tomcat.SecurityMetaDataAccessorEJB#getAuthMethod(Endpoint)
- *
+ *
* @param endpoint EJB webservice endpoint
* @return authentication method or null if not specified
*/
@@ -124,7 +124,7 @@
/**
* @see org.jboss.webservices.integration.tomcat.SecurityMetaDataAccessorEJB#isSecureWsdlAccess(Endpoint)
- *
+ *
* @param endpoint EJB webservice endpoint
* @return whether WSDL access have to be secured
*/
@@ -138,7 +138,7 @@
/**
* @see org.jboss.webservices.integration.tomcat.SecurityMetaDataAccessorEJB#getTransportGuarantee(Endpoint)
- *
+ *
* @param endpoint EJB webservice endpoint
* @return transport guarantee or null if not specified
*/
Modified: container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataCreatingDeploymentAspect.java
===================================================================
--- container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataCreatingDeploymentAspect.java 2009-08-07 09:46:12 UTC (rev 10500)
+++ container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataCreatingDeploymentAspect.java 2009-08-07 10:01:42 UTC (rev 10501)
@@ -27,7 +27,7 @@
/**
* A deployment aspect that generates web app meta data for EJB endpoints.
- *
+ *
* @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
* @author <a href="mailto:tdiesler@redhat.com">Thomas Diesler</a>
*/
Modified: container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataCreator.java
===================================================================
--- container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataCreator.java 2009-08-07 09:46:12 UTC (rev 10500)
+++ container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataCreator.java 2009-08-07 10:01:42 UTC (rev 10501)
@@ -36,13 +36,17 @@
import org.jboss.wsf.spi.deployment.Endpoint;
/**
- * Creator of web app meta data for EJB endpoints.
+ * Creator of web app meta data for EJB endpoints.
*
* @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
* @author <a href="mailto:tdiesler@redhat.com">Thomas Diesler</a>
*/
final class WebMetaDataCreator
{
+
+ /** Our Realm. */
+ private static final String EJB_WEBSERVICE_REALM = "EJBWebServiceEndpointServlet Realm";
+
/** EJB 21 security meta data builder. */
private final SecurityMetaDataAccessorEJB ejb21SecurityAccessor = new SecurityMetaDataAccessorEJB21();
@@ -62,71 +66,45 @@
*
* @param dep webservice deployment
*/
- public void create(final Deployment dep)
+ void create(final Deployment dep)
{
final DeploymentUnit unit = WSHelper.getRequiredAttachment(dep, DeploymentUnit.class);
- final JBossWebMetaData jbossWebMD = this.createWebMetaData(dep);
+ final JBossWebMetaData jbossWebMD = new JBossWebMetaData();
+ this.createWebAppDescriptor(dep, jbossWebMD);
+ this.createJBossWebAppDescriptor(dep, jbossWebMD);
+
dep.addAttachment(JBossWebMetaData.class, jbossWebMD);
unit.addAttachment(JBossWebMetaData.class, jbossWebMD);
}
/**
- * Creates web meta data for EJB deployment.
- *
+ * Creates web.xml descriptor meta data.
+ *
* @param dep webservice deployment
- * @return web meta data for EJB deployment
+ * @param jbossWebMD jboss web meta data
*/
- private JBossWebMetaData createWebMetaData(final Deployment dep)
- {
- final JBossWebMetaData jbossWebMD = new JBossWebMetaData();
-
- this.createWebAppDescriptor(dep, jbossWebMD);
- this.createJBossWebAppDescriptor(dep, jbossWebMD);
-
- return jbossWebMD;
- }
-
private void createWebAppDescriptor(final Deployment dep, final JBossWebMetaData jbossWebMD)
{
this.createServlets(dep, jbossWebMD);
this.createServletMappings(dep, jbossWebMD);
this.createSecurityConstraints(dep, jbossWebMD);
-
- // Optional login-config/auth-method
- final String authMethod = this.getAuthMethodForDeployment(dep);
-
- if (authMethod != null)
- {
- LoginConfigMetaData loginConfig = jbossWebMD.getLoginConfig();
- if (loginConfig == null)
- {
- loginConfig = new LoginConfigMetaData();
- jbossWebMD.setLoginConfig(loginConfig);
- }
- loginConfig.setAuthMethod(authMethod);
- loginConfig.setRealmName("EJBServiceEndpointServlet Realm"); // TODO: review if still necessary and what it means
-
- final SecurityMetaDataAccessorEJB ejbMDAccessor = this.getEjbSecurityMetaDataAccessor(dep);
- final SecurityRolesMetaData securityRolesMD = ejbMDAccessor.getSecurityRoles(dep);
-
- if (securityRolesMD != null)
- {
- jbossWebMD.setSecurityRoles(securityRolesMD);
- }
- }
+ this.createLoginConfig(dep, jbossWebMD);
+ this.createSecurityRoles(dep, jbossWebMD);
}
/**
- * Creates jboss-web meta data.
- *
- * <jboss-web>
- * <security-domain>java:/jaas/custom-security-domain</security-domain>
- * <context-root>/custom-context-root</context-root>
- * <virtual-host>custom-virtual-host-1</virtual-host>
+ * Creates jboss-web.xml descriptor meta data.
+ *
+ * <pre>
+ * <jboss-web>
+ * <security-domain>java:/jaas/custom-security-domain</security-domain>
+ * <context-root>/custom-context-root</context-root>
+ * <virtual-host>host1</virtual-host>
* ...
- * <virtual-host>custom-virtual-host-N</virtual-host>
- * </jboss-web>
+ * <virtual-host>hostN</virtual-host>
+ * </jboss-web>
+ * </pre>
*
* @param dep webservice deployment
* @param jbossWebMD jboss web meta data
@@ -158,11 +136,11 @@
*
* <pre>
* <servlet>
- * <servlet-name>WSEndpointShortName</servlet-name>
- * <servlet-class>WSEndpointTargetBeanName</servlet-class>
+ * <servlet-name>EJBEndpointShortName</servlet-name>
+ * <servlet-class>EJBEndpointTargetBeanName</servlet-class>
* </servlet>
* </pre>
- *
+ *
* @param dep webservice deployment
* @param jbossWebMD jboss web meta data
*/
@@ -184,11 +162,11 @@
*
* <pre>
* <servlet-mapping>
- * <servlet-name>WSEndpointShortName</servlet-name>
- * <url-pattern>WSEndpointURLPattern</url-pattern>
+ * <servlet-name>EJBEndpointShortName</servlet-name>
+ * <url-pattern>EJBEndpointURLPattern</url-pattern>
* </servlet-mapping>
* </pre>
- *
+ *
* @param dep webservice deployment
* @param jbossWebMD jboss web meta data
*/
@@ -207,22 +185,23 @@
/**
* Creates security constraints part of web.xml descriptor.
- *
*
- * <security-constraint>
- * <web-resource-collection>
- * <web-resource-name>TestUnAuthPort</web-resource-name>
- * <url-pattern>/HSTestRoot/TestUnAuth/*</url-pattern>
- * <http-method>GET</http-method>
- * <http-method>POST</http-method>
- * </web-resource-collection>
- * <auth-constraint>
- * <role-name>*</role-name>
- * </auth-constraint>
- * <user-data-constraint>
- * <transport-guarantee>NONE</transport-guarantee>
- * </user-data-constraint>
- * </security-constraint>
+ * <pre>
+ * <security-constraint>
+ * <web-resource-collection>
+ * <web-resource-name>EJBEndpointShortName</web-resource-name>
+ * <url-pattern>EJBEndpointURLPattern</url-pattern>
+ * <http-method>GET</http-method>
+ * <http-method>POST</http-method>
+ * </web-resource-collection>
+ * <auth-constraint>
+ * <role-name>*</role-name>
+ * </auth-constraint>
+ * <user-data-constraint>
+ * <transport-guarantee>EjbTransportGuarantee</transport-guarantee>
+ * </user-data-constraint>
+ * </security-constraint>
+ * </pre>
*
* @param dep webservice deployemnt
* @param jbossWebMD jboss web meta data
@@ -235,27 +214,31 @@
{
final boolean secureWsdlAccess = ejbMDAccessor.isSecureWsdlAccess(ejbEndpoint);
final String transportGuarantee = ejbMDAccessor.getTransportGuarantee(ejbEndpoint);
- final String beanAuthMethod = ejbMDAccessor.getAuthMethod(ejbEndpoint);
+ final boolean hasTransportGuarantee = transportGuarantee != null;
+ final String authMethod = ejbMDAccessor.getAuthMethod(ejbEndpoint);
+ final boolean hasAuthMethod = authMethod != null;
- if (beanAuthMethod != null || transportGuarantee != null)
+ if (hasAuthMethod || hasTransportGuarantee)
{
- // Security constraint
final List<SecurityConstraintMetaData> securityConstraints = WebMetaDataHelper.getSecurityConstraints(jbossWebMD);
+
+ // security-constraint
final SecurityConstraintMetaData securityConstraint = WebMetaDataHelper.newSecurityConstraint(securityConstraints);
- // Resource collection
- final WebResourceCollectionsMetaData resourceCollections = WebMetaDataHelper.getWebResourceCollections(securityConstraint);
+ // web-resource-collection
+ final WebResourceCollectionsMetaData webResourceCollections = WebMetaDataHelper.getWebResourceCollections(securityConstraint);
final String endpointName = ejbEndpoint.getShortName();
final String urlPattern = ejbEndpoint.getURLPattern();
- WebMetaDataHelper.newWebResourceCollection(endpointName, urlPattern, secureWsdlAccess, resourceCollections);
+ WebMetaDataHelper.newWebResourceCollection(endpointName, urlPattern, secureWsdlAccess, webResourceCollections);
- // Optional auth-constraint
- if (beanAuthMethod != null)
+ // auth-constraint
+ if (hasAuthMethod)
{
WebMetaDataHelper.newAuthConstraint(WebMetaDataHelper.getAllRoles(), securityConstraint);
}
- // Optional user-data-constraint
- if (transportGuarantee != null)
+
+ // user-data-constraint
+ if (hasTransportGuarantee)
{
WebMetaDataHelper.newUserDataConstraint(transportGuarantee, securityConstraint);
}
@@ -263,9 +246,72 @@
}
}
- // Only the first auth-method gives the war login-config/auth-method
- private String getAuthMethodForDeployment(final Deployment dep)
+ /**
+ * Creates login-config part of web.xml descriptor.
+ *
+ * <pre>
+ * <login-config>
+ * <auth-method>EjbDeploymentAuthMethod</auth-method>
+ * <realm-name>EJBWebServiceEndpointServlet Realm</realm-name>
+ * </login-config>
+ * </pre>
+ *
+ * @param dep webservice deployment
+ * @param jbossWebMD jboss web meta data
+ */
+ private void createLoginConfig(final Deployment dep, final JBossWebMetaData jbossWebMD)
{
+ final String authMethod = this.getAuthMethod(dep);
+ final boolean hasAuthMethod = authMethod != null;
+
+ if (hasAuthMethod)
+ {
+ final LoginConfigMetaData loginConfig = WebMetaDataHelper.getLoginConfig(jbossWebMD);
+ loginConfig.setRealmName(WebMetaDataCreator.EJB_WEBSERVICE_REALM);
+ loginConfig.setAuthMethod(authMethod);
+ }
+ }
+
+ /**
+ * Creates security roles part of web.xml descriptor.
+ *
+ * <pre>
+ * <security-role>
+ * <role-name>role1</role-name>
+ * ...
+ * <role-name>roleN</role-name>
+ * </security-role>
+ * </pre>
+ *
+ * @param dep webservice deployment
+ * @param jbossWebMD jboss web meta data
+ */
+ private void createSecurityRoles(final Deployment dep, final JBossWebMetaData jbossWebMD)
+ {
+ final String authMethod = this.getAuthMethod(dep);
+ final boolean hasAuthMethod = authMethod != null;
+
+ if (hasAuthMethod)
+ {
+ final SecurityMetaDataAccessorEJB ejbMDAccessor = this.getEjbSecurityMetaDataAccessor(dep);
+ final SecurityRolesMetaData securityRolesMD = ejbMDAccessor.getSecurityRoles(dep);
+ final boolean hasSecurityRolesMD = securityRolesMD != null;
+
+ if (hasSecurityRolesMD)
+ {
+ jbossWebMD.setSecurityRoles(securityRolesMD);
+ }
+ }
+ }
+
+ /**
+ * Returns deployment authentication method.
+ *
+ * @param dep webservice deployment
+ * @return deployment authentication method
+ */
+ private String getAuthMethod(final Deployment dep)
+ {
final SecurityMetaDataAccessorEJB ejbMDAccessor = this.getEjbSecurityMetaDataAccessor(dep);
for (final Endpoint ejbEndpoint : dep.getService().getEndpoints())
@@ -275,6 +321,7 @@
if (hasBeanAuthMethod)
{
+ // First found auth-method defines war login-config/auth-method
return beanAuthMethod;
}
}
@@ -284,7 +331,7 @@
/**
* Returns security builder associated with EJB deployment.
- *
+ *
* @param dep webservice EJB deployment
* @return security builder for EJB deployment
*/
Modified: container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataHelper.java
===================================================================
--- container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataHelper.java 2009-08-07 09:46:12 UTC (rev 10500)
+++ container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataHelper.java 2009-08-07 10:01:42 UTC (rev 10501)
@@ -21,17 +21,19 @@
*/
package org.jboss.webservices.integration.tomcat;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
+import org.jboss.metadata.javaee.spec.ParamValueMetaData;
import org.jboss.metadata.web.jboss.JBossServletMetaData;
import org.jboss.metadata.web.jboss.JBossServletsMetaData;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
import org.jboss.metadata.web.spec.AuthConstraintMetaData;
+import org.jboss.metadata.web.spec.LoginConfigMetaData;
import org.jboss.metadata.web.spec.SecurityConstraintMetaData;
import org.jboss.metadata.web.spec.ServletMappingMetaData;
+import org.jboss.metadata.web.spec.ServletMetaData;
import org.jboss.metadata.web.spec.TransportGuaranteeType;
import org.jboss.metadata.web.spec.UserDataConstraintMetaData;
import org.jboss.metadata.web.spec.WebResourceCollectionMetaData;
@@ -84,151 +86,330 @@
}
/**
- * Gests servlets meta data from jboss web meta data.
+ * Creates URL pattern list from passed string.
+ *
+ * @param urlPattern URL pattern
+ * @return list wrapping passed parameter
+ */
+ static List<String> getUrlPatterns(final String urlPattern)
+ {
+ final List<String> linkedList = new LinkedList<String>();
+
+ linkedList.add(urlPattern);
+
+ return linkedList;
+ }
+
+ /**
+ * If WSDL access is secured, it returns both POST and GET methods, otherwise only POST method.
+ *
+ * @param secureWsdlAccess whether WSDL is secured
+ * @return web access methods
+ */
+ static List<String> getHttpMethods(final boolean secureWsdlAccess)
+ {
+ return secureWsdlAccess ? WebMetaDataHelper.getAndPostMethods : WebMetaDataHelper.onlyPostMethod;
+ }
+
+ /**
+ * Returns all role list.
+ *
+ * @return all role list
+ */
+ static List<String> getAllRoles()
+ {
+ return WebMetaDataHelper.allRoles;
+ }
+
+ /**
+ * Gests servlets meta data from jboss web meta data.
* If not found it creates new servlets meta data
* and associates them with jboss web meta data.
- *
+ *
* @param jbossWebMD jboss web meta data
* @return servlets meta data
*/
static JBossServletsMetaData getServlets(final JBossWebMetaData jbossWebMD)
{
- JBossServletsMetaData servlets = jbossWebMD.getServlets();
- if (servlets == null)
+ JBossServletsMetaData servletsMD = jbossWebMD.getServlets();
+
+ if (servletsMD == null)
{
- servlets = new JBossServletsMetaData();
- jbossWebMD.setServlets(servlets);
+ servletsMD = new JBossServletsMetaData();
+ jbossWebMD.setServlets(servletsMD);
}
- return servlets;
+ return servletsMD;
}
/**
- * Gests servlet mappings meta data from jboss web meta data.
+ * Gests servlet mappings meta data from jboss web meta data.
* If not found it creates new servlet mappings meta data
* and associates them with jboss web meta data.
- *
+ *
* @param jbossWebMD jboss web meta data
* @return servlet mappings meta data
*/
static List<ServletMappingMetaData> getServletMappings(final JBossWebMetaData jbossWebMD)
{
- List<ServletMappingMetaData> servletMappings = jbossWebMD.getServletMappings();
- if (servletMappings == null)
+ List<ServletMappingMetaData> servletMappingsMD = jbossWebMD.getServletMappings();
+
+ if (servletMappingsMD == null)
{
- servletMappings = new ArrayList<ServletMappingMetaData>();
- jbossWebMD.setServletMappings(servletMappings);
+ servletMappingsMD = new LinkedList<ServletMappingMetaData>();
+ jbossWebMD.setServletMappings(servletMappingsMD);
}
- return servletMappings;
+ return servletMappingsMD;
}
/**
- * Gests security constraints meta data from jboss web meta data.
+ * Gests security constraints meta data from jboss web meta data.
* If not found it creates new security constraints meta data
* and associates them with jboss web meta data.
- *
+ *
* @param jbossWebMD jboss web meta data
* @return security constraints meta data
*/
static List<SecurityConstraintMetaData> getSecurityConstraints(final JBossWebMetaData jbossWebMD)
{
- List<SecurityConstraintMetaData> securityConstraints = jbossWebMD.getSecurityContraints();
- if (securityConstraints == null)
+ List<SecurityConstraintMetaData> securityConstraintsMD = jbossWebMD.getSecurityContraints();
+
+ if (securityConstraintsMD == null)
{
- securityConstraints = new ArrayList<SecurityConstraintMetaData>();
- jbossWebMD.setSecurityContraints(securityConstraints);
+ securityConstraintsMD = new LinkedList<SecurityConstraintMetaData>();
+ jbossWebMD.setSecurityContraints(securityConstraintsMD);
}
- return securityConstraints;
+ return securityConstraintsMD;
}
- static WebResourceCollectionsMetaData getWebResourceCollections(final SecurityConstraintMetaData securityConstraint)
+ /**
+ * Gests login config meta data from jboss web meta data.
+ * If not found it creates new login config meta data
+ * and associates them with jboss web meta data.
+ *
+ * @param jbossWebMD jboss web meta data
+ * @return login config meta data
+ */
+ static LoginConfigMetaData getLoginConfig(final JBossWebMetaData jbossWebMD)
{
- WebResourceCollectionsMetaData webResourceCollections = securityConstraint.getResourceCollections();
- if (webResourceCollections == null)
+ LoginConfigMetaData loginConfigMD = jbossWebMD.getLoginConfig();
+
+ if (loginConfigMD == null)
{
- webResourceCollections = new WebResourceCollectionsMetaData();
- securityConstraint.setResourceCollections(webResourceCollections);
+ loginConfigMD = new LoginConfigMetaData();
+ jbossWebMD.setLoginConfig(loginConfigMD);
}
- return webResourceCollections;
+ return loginConfigMD;
}
- static SecurityConstraintMetaData newSecurityConstraint(final List<SecurityConstraintMetaData> securityConstraints)
+ /**
+ * Gests context parameters meta data from jboss web meta data.
+ * If not found it creates new context parameters meta data
+ * and associates them with jboss web meta data.
+ *
+ * @param jbossWebMD jboss web meta data
+ * @return context parameters meta data
+ */
+ static List<ParamValueMetaData> getContextParams(final JBossWebMetaData jbossWebMD)
{
- final SecurityConstraintMetaData securityConstraint = new SecurityConstraintMetaData();
- securityConstraints.add(securityConstraint);
+ List<ParamValueMetaData> contextParamsMD = jbossWebMD.getContextParams();
- return securityConstraint;
+ if (contextParamsMD == null)
+ {
+ contextParamsMD = new LinkedList<ParamValueMetaData>();
+ jbossWebMD.setContextParams(contextParamsMD);
+ }
+
+ return contextParamsMD;
}
- static WebResourceCollectionMetaData newWebResourceCollection(final String servletName, final String urlPattern, final boolean secure,
- final WebResourceCollectionsMetaData webResourceCollections)
+ /**
+ * Gests web resource collections meta data from security constraint meta data.
+ * If not found it creates new web resource collections meta data
+ * and associates them with security constraint meta data.
+ *
+ * @param securityConstraintMD security constraint meta data
+ * @return web resource collections meta data
+ */
+ static WebResourceCollectionsMetaData getWebResourceCollections(final SecurityConstraintMetaData securityConstraintMD)
{
- final WebResourceCollectionMetaData webResourceCollection = new WebResourceCollectionMetaData();
- webResourceCollection.setWebResourceName(servletName);
- webResourceCollection.setUrlPatterns(WebMetaDataHelper.getUrlPatterns(urlPattern));
- webResourceCollection.setHttpMethods(WebMetaDataHelper.getHttpMethods(secure));
- webResourceCollections.add(webResourceCollection);
+ WebResourceCollectionsMetaData webResourceCollectionsMD = securityConstraintMD.getResourceCollections();
- return webResourceCollection;
+ if (webResourceCollectionsMD == null)
+ {
+ webResourceCollectionsMD = new WebResourceCollectionsMetaData();
+ securityConstraintMD.setResourceCollections(webResourceCollectionsMD);
+ }
+
+ return webResourceCollectionsMD;
}
- static JBossServletMetaData newServlet(final String servletName, final String servletClass, final JBossServletsMetaData servlets)
+ /**
+ * Gests init parameters meta data from servlet meta data.
+ * If not found it creates new init parameters meta data
+ * and associates them with servlet meta data.
+ *
+ * @param servletMD servlet meta data
+ * @return init parameters meta data
+ */
+ static List<ParamValueMetaData> getServletInitParams(final ServletMetaData servletMD)
{
- final JBossServletMetaData servlet = new JBossServletMetaData();
- servlet.setServletName(servletName);
- servlet.setServletClass(servletClass);
- servlets.add(servlet);
+ List<ParamValueMetaData> initParamsMD = servletMD.getInitParam();
- return servlet;
+ if (initParamsMD == null)
+ {
+ initParamsMD = new LinkedList<ParamValueMetaData>();
+ servletMD.setInitParam(initParamsMD);
+ }
+
+ return initParamsMD;
}
- static ServletMappingMetaData newServletMapping(final String servletName, final List<String> urlPatterns, final List<ServletMappingMetaData> servletMappings)
+ /**
+ * Creates new security constraint meta data and associates them with security constraints meta data.
+ *
+ * @param securityConstraintsMD security constraints meta data
+ * @return new security constraing meta data
+ */
+ static SecurityConstraintMetaData newSecurityConstraint(final List<SecurityConstraintMetaData> securityConstraintsMD)
{
- final ServletMappingMetaData servletMapping = new ServletMappingMetaData();
- servletMapping.setServletName(servletName);
- servletMapping.setUrlPatterns(urlPatterns);
- servletMappings.add(servletMapping);
+ final SecurityConstraintMetaData securityConstraintMD = new SecurityConstraintMetaData();
- return servletMapping;
+ securityConstraintsMD.add(securityConstraintMD);
+
+ return securityConstraintMD;
}
- static AuthConstraintMetaData newAuthConstraint(final List<String> roleNames, final SecurityConstraintMetaData securityConstraint)
+ /**
+ * Creates new web resource collection meta data and associates them with web resource collections meta data.
+ *
+ * @param servletName servlet name
+ * @param urlPattern URL pattern
+ * @param securedWsdl whether WSDL access is secured
+ * @param webResourceCollectionsMD web resource collections meta data
+ * @return new web resource collection meta data
+ */
+ static WebResourceCollectionMetaData newWebResourceCollection(final String servletName, final String urlPattern, final boolean securedWsdl,
+ final WebResourceCollectionsMetaData webResourceCollectionsMD)
{
- final AuthConstraintMetaData authConstraint = new AuthConstraintMetaData();
- authConstraint.setRoleNames(roleNames);
- securityConstraint.setAuthConstraint(authConstraint);
+ final WebResourceCollectionMetaData webResourceCollectionMD = new WebResourceCollectionMetaData();
- return authConstraint;
+ webResourceCollectionMD.setWebResourceName(servletName);
+ webResourceCollectionMD.setUrlPatterns(WebMetaDataHelper.getUrlPatterns(urlPattern));
+ webResourceCollectionMD.setHttpMethods(WebMetaDataHelper.getHttpMethods(securedWsdl));
+ webResourceCollectionsMD.add(webResourceCollectionMD);
+
+ return webResourceCollectionMD;
}
- static UserDataConstraintMetaData newUserDataConstraint(final String transportGuarantee, final SecurityConstraintMetaData securityConstraint)
+ /**
+ * Creates new servlet meta data and associates them with servlets meta data.
+ *
+ * @param servletName servlet name
+ * @param servletClass servlet class name
+ * @param servletsMD servlets meta data
+ * @return new servlet meta data
+ */
+ static JBossServletMetaData newServlet(final String servletName, final String servletClass, final JBossServletsMetaData servletsMD)
{
- final UserDataConstraintMetaData userDataConstraint = new UserDataConstraintMetaData();
- final TransportGuaranteeType transportGuaranteeValue = TransportGuaranteeType.valueOf(transportGuarantee);
- userDataConstraint.setTransportGuarantee(transportGuaranteeValue);
- securityConstraint.setUserDataConstraint(userDataConstraint);
+ final JBossServletMetaData servletMD = new JBossServletMetaData();
- return userDataConstraint;
+ servletMD.setServletName(servletName);
+ servletMD.setServletClass(servletClass);
+ servletsMD.add(servletMD);
+
+ return servletMD;
}
- static List<String> getUrlPatterns(final String urlPattern)
+ /**
+ * Creates new servlet mapping meta data and associates them with servlet mappings meta data.
+ *
+ * @param servletName servlet name
+ * @param urlPatterns URL patterns
+ * @param servletMappingsMD servlet mapping meta data
+ * @return new servlet mapping meta data
+ */
+ static ServletMappingMetaData newServletMapping(final String servletName, final List<String> urlPatterns, final List<ServletMappingMetaData> servletMappingsMD)
{
- final List<String> linkedList = new LinkedList<String>();
- linkedList.add(urlPattern);
- return linkedList;
+ final ServletMappingMetaData servletMappingMD = new ServletMappingMetaData();
+
+ servletMappingMD.setServletName(servletName);
+ servletMappingMD.setUrlPatterns(urlPatterns);
+ servletMappingsMD.add(servletMappingMD);
+
+ return servletMappingMD;
}
- static List<String> getHttpMethods(final boolean secureWsdlAccess)
+ /**
+ * Creates new authentication constraint and associates it with security constraint meta data.
+ *
+ * @param roleNames roles
+ * @param securityConstraintMD security constraint meta data
+ * @return new authentication constraint meta data
+ */
+ static AuthConstraintMetaData newAuthConstraint(final List<String> roleNames, final SecurityConstraintMetaData securityConstraintMD)
{
- return secureWsdlAccess ? WebMetaDataHelper.getAndPostMethods : WebMetaDataHelper.onlyPostMethod;
+ final AuthConstraintMetaData authConstraintMD = new AuthConstraintMetaData();
+
+ authConstraintMD.setRoleNames(roleNames);
+ securityConstraintMD.setAuthConstraint(authConstraintMD);
+
+ return authConstraintMD;
}
- static List<String> getAllRoles()
+ /**
+ * Creates new user constraint meta data and associates it with security constraint meta data.
+ *
+ * @param transportGuarantee transport guarantee value
+ * @param securityConstraintMD security constraint meta data
+ * @return new user data constraint meta data
+ */
+ static UserDataConstraintMetaData newUserDataConstraint(final String transportGuarantee, final SecurityConstraintMetaData securityConstraintMD)
{
- return WebMetaDataHelper.allRoles;
+ final UserDataConstraintMetaData userDataConstraintMD = new UserDataConstraintMetaData();
+ final TransportGuaranteeType transportGuaranteeValue = TransportGuaranteeType.valueOf(transportGuarantee);
+
+ userDataConstraintMD.setTransportGuarantee(transportGuaranteeValue);
+ securityConstraintMD.setUserDataConstraint(userDataConstraintMD);
+
+ return userDataConstraintMD;
}
+ /**
+ * Creates new parameter meta data and associates it with parameters meta data.
+ *
+ * @param key parameter key
+ * @param value parameter value
+ * @param paramsMD parameters meta data
+ * @return new parameter meta data
+ */
+ static ParamValueMetaData newParamValue(final String key, final String value, final List<ParamValueMetaData> paramsMD)
+ {
+ final ParamValueMetaData paramValueMD = WebMetaDataHelper.newParamValue(key, value);
+
+ paramsMD.add(paramValueMD);
+
+ return paramValueMD;
+ }
+
+ /**
+ * Creates new parameter with specified key and value.
+ *
+ * @param key the key
+ * @param value the value
+ * @return new parameter
+ */
+ private static ParamValueMetaData newParamValue(final String key, final String value)
+ {
+ final ParamValueMetaData paramMD = new ParamValueMetaData();
+
+ paramMD.setParamName(key);
+ paramMD.setParamValue(value);
+
+ return paramMD;
+ }
+
}
Modified: container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataModifier.java
===================================================================
--- container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataModifier.java 2009-08-07 09:46:12 UTC (rev 10500)
+++ container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataModifier.java 2009-08-07 10:01:42 UTC (rev 10501)
@@ -21,7 +21,6 @@
*/
package org.jboss.webservices.integration.tomcat;
-import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -50,7 +49,7 @@
/**
* Constructor.
*/
- public WebMetaDataModifier()
+ WebMetaDataModifier()
{
super();
}
@@ -60,7 +59,7 @@
*
* @param dep webservice deployment
*/
- public void modify(final Deployment dep)
+ void modify(final Deployment dep)
{
final JBossWebMetaData jbossWebMD = WSHelper.getRequiredAttachment(dep, JBossWebMetaData.class);
@@ -81,12 +80,11 @@
if (stackContextParams != null)
{
- final List<ParamValueMetaData> contextParams = this.getContextParams(jbossWebMD);
+ final List<ParamValueMetaData> contextParams = WebMetaDataHelper.getContextParams(jbossWebMD);
for (Map.Entry<String, String> entry : stackContextParams.entrySet())
{
- final ParamValueMetaData newParam = this.newParameter(entry.getKey(), entry.getValue());
- contextParams.add(newParam);
+ WebMetaDataHelper.newParamValue(entry.getKey(), entry.getValue(), contextParams);
}
}
}
@@ -114,10 +112,9 @@
// configure webservice endpoint
final String endpointClassName = servletMD.getServletClass();
- final List<ParamValueMetaData> initParams = this.getServletInitParams(servletMD);
- final ParamValueMetaData endpointParam = this.newParameter(Endpoint.SEPID_DOMAIN_ENDPOINT, endpointClassName);
+ final List<ParamValueMetaData> initParams = WebMetaDataHelper.getServletInitParams(servletMD);
- initParams.add(endpointParam);
+ WebMetaDataHelper.newParamValue(Endpoint.SEPID_DOMAIN_ENDPOINT, endpointClassName, initParams);
}
}
}
@@ -141,58 +138,4 @@
return transportClassName;
}
- /**
- * Creates new parameter with specified key and value.
- *
- * @param key the key
- * @param value the value
- * @return new parameter
- */
- private ParamValueMetaData newParameter(final String key, final String value)
- {
- final ParamValueMetaData paramMD = new ParamValueMetaData();
- paramMD.setParamName(key);
- paramMD.setParamValue(value);
-
- return paramMD;
- }
-
- /**
- * Gets servlet init params list. Constructs new init params list if it does not exist yet.
- *
- * @param servletMD servlet meta data
- * @return servlet init params list
- */
- private List<ParamValueMetaData> getServletInitParams(final ServletMetaData servletMD)
- {
- List<ParamValueMetaData> initParams = servletMD.getInitParam();
-
- if (initParams == null)
- {
- initParams = new ArrayList<ParamValueMetaData>();
- servletMD.setInitParam(initParams);
- }
-
- return initParams;
- }
-
- /**
- * Gets context params list. Constructs new context params list if it does not exist yet.
- *
- * @param jbossWebMD web meta data
- * @return context params list
- */
- private List<ParamValueMetaData> getContextParams(final JBossWebMetaData jbossWebMD)
- {
- List<ParamValueMetaData> contextParams = jbossWebMD.getContextParams();
-
- if (contextParams == null)
- {
- contextParams = new ArrayList<ParamValueMetaData>();
- jbossWebMD.setContextParams(contextParams);
- }
-
- return contextParams;
- }
-
}
15 years, 1 month
JBossWS SVN: r10500 - in container/jboss50/branches: jbossws-jboss501/src/main/java/org/jboss/webservices/integration/invocation and 1 other directories.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2009-08-07 05:46:12 -0400 (Fri, 07 Aug 2009)
New Revision: 10500
Modified:
container/jboss50/branches/jbossws-jboss500/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerJSE.java
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerJSE.java
container/jboss50/branches/jbossws-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerJSE.java
Log:
[JBWS-2662] Reducing memory usage cleaning ws context reference from the cached target bean, considering it will always be re-injected later
Modified: container/jboss50/branches/jbossws-jboss500/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerJSE.java
===================================================================
--- container/jboss50/branches/jbossws-jboss500/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerJSE.java 2009-08-07 08:35:19 UTC (rev 10499)
+++ container/jboss50/branches/jbossws-jboss500/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerJSE.java 2009-08-07 09:46:12 UTC (rev 10500)
@@ -97,15 +97,20 @@
InvocationContext invContext = epInv.getInvocationContext();
WebServiceContext wsContext = invContext.getAttachment(WebServiceContext.class);
+ ResourceInjector injector = null;
if (wsContext != null)
{
- ResourceInjector injector = resourceInjectorFactory.newResourceInjector();
+ injector = resourceInjectorFactory.newResourceInjector();
injector.inject(targetBean, wsContext);
}
Method method = getImplMethod(targetBean.getClass(), epInv.getJavaMethod());
Object retObj = method.invoke(targetBean, epInv.getArgs());
epInv.setReturnValue(retObj);
+ if (wsContext != null) //JBWS-2662
+ {
+ injector.inject(targetBean, null);
+ }
}
catch (Exception e)
{
Modified: container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerJSE.java
===================================================================
--- container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerJSE.java 2009-08-07 08:35:19 UTC (rev 10499)
+++ container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerJSE.java 2009-08-07 09:46:12 UTC (rev 10500)
@@ -97,15 +97,20 @@
InvocationContext invContext = epInv.getInvocationContext();
WebServiceContext wsContext = invContext.getAttachment(WebServiceContext.class);
+ ResourceInjector injector = null;
if (wsContext != null)
{
- ResourceInjector injector = resourceInjectorFactory.newResourceInjector();
+ injector = resourceInjectorFactory.newResourceInjector();
injector.inject(targetBean, wsContext);
}
Method method = getImplMethod(targetBean.getClass(), epInv.getJavaMethod());
Object retObj = method.invoke(targetBean, epInv.getArgs());
epInv.setReturnValue(retObj);
+ if (wsContext != null) //JBWS-2662
+ {
+ injector.inject(targetBean, null);
+ }
}
catch (Exception e)
{
Modified: container/jboss50/branches/jbossws-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerJSE.java
===================================================================
--- container/jboss50/branches/jbossws-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerJSE.java 2009-08-07 08:35:19 UTC (rev 10499)
+++ container/jboss50/branches/jbossws-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerJSE.java 2009-08-07 09:46:12 UTC (rev 10500)
@@ -97,15 +97,20 @@
InvocationContext invContext = epInv.getInvocationContext();
WebServiceContext wsContext = invContext.getAttachment(WebServiceContext.class);
+ ResourceInjector injector = null;
if (wsContext != null)
{
- ResourceInjector injector = resourceInjectorFactory.newResourceInjector();
+ injector = resourceInjectorFactory.newResourceInjector();
injector.inject(targetBean, wsContext);
}
Method method = getImplMethod(targetBean.getClass(), epInv.getJavaMethod());
Object retObj = method.invoke(targetBean, epInv.getArgs());
epInv.setReturnValue(retObj);
+ if (wsContext != null) //JBWS-2662
+ {
+ injector.inject(targetBean, null);
+ }
}
catch (Exception e)
{
15 years, 1 month
JBossWS SVN: r10499 - stack/native/trunk/modules/testsuite.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2009-08-07 04:35:19 -0400 (Fri, 07 Aug 2009)
New Revision: 10499
Modified:
stack/native/trunk/modules/testsuite/pom.xml
Log:
Setting back client testsuite max memory to 512MB and removing com.sun.management.jmxremote sysprop inadvertently added before
Modified: stack/native/trunk/modules/testsuite/pom.xml
===================================================================
--- stack/native/trunk/modules/testsuite/pom.xml 2009-08-07 08:31:48 UTC (rev 10498)
+++ stack/native/trunk/modules/testsuite/pom.xml 2009-08-07 08:35:19 UTC (rev 10499)
@@ -17,7 +17,7 @@
<properties>
<surefire.security.args>-Djava.security.manager -Djava.security.policy=src/test/etc/tst.policy</surefire.security.args>
<surefire.jdwp.args>-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005</surefire.jdwp.args>
- <surefire.gc.args>-Xmx768m -XX:MaxPermSize=256m -Dcom.sun.management.jmxremote</surefire.gc.args>
+ <surefire.gc.args>-Xmx512m -XX:MaxPermSize=256m</surefire.gc.args>
<test.archive.directory>${project.build.directory}/test-libs</test.archive.directory>
<test.classes.directory>${project.build.directory}/test-classes</test.classes.directory>
<test.resources.directory>${project.build.directory}/test-resources</test.resources.directory>
15 years, 1 month
JBossWS SVN: r10498 - stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2009-08-07 04:31:48 -0400 (Fri, 07 Aug 2009)
New Revision: 10498
Added:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/NettyTransportOutputStream.java
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/NettyClient.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/WSResponseHandler.java
Log:
[JBWS-2554] Improving message marshalling process to save memory (do not buffer the whole message in memory before starting sending when using chunked encoding)
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/NettyClient.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/NettyClient.java 2009-08-06 13:30:09 UTC (rev 10497)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/NettyClient.java 2009-08-07 08:31:48 UTC (rev 10498)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2009, 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.
*
@@ -26,6 +26,7 @@
import java.net.InetSocketAddress;
import java.net.MalformedURLException;
import java.net.URL;
+import java.nio.channels.ClosedChannelException;
import java.util.Map;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
@@ -43,9 +44,7 @@
import org.jboss.netty.channel.ChannelFactory;
import org.jboss.netty.channel.ChannelFuture;
import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
-import org.jboss.netty.handler.codec.http.DefaultHttpChunk;
import org.jboss.netty.handler.codec.http.DefaultHttpRequest;
-import org.jboss.netty.handler.codec.http.HttpChunk;
import org.jboss.netty.handler.codec.http.HttpHeaders;
import org.jboss.netty.handler.codec.http.HttpMessage;
import org.jboss.netty.handler.codec.http.HttpMethod;
@@ -186,12 +185,23 @@
setActualChunkedLength(request, callProps);
setAuthorization(request, callProps);
- ChannelFuture writeFuture = writeRequest(channel, request, reqMessage);
+ ChannelFuture writeFuture = null;
+ try
+ {
+ writeFuture = writeRequest(channel, request, reqMessage);
+ }
+ catch (ClosedChannelException cce)
+ {
+ log.debug("Channel closed by remote peer while sending message");
+ }
if (!waitForResponse)
{
//No need to wait for the connection to be closed, just wait for the write to be completed.
- writeFuture.awaitUninterruptibly();
+ if (writeFuture != null)
+ {
+ writeFuture.awaitUninterruptibly();
+ }
return null;
}
//Wait for the server to close the connection
@@ -267,32 +277,25 @@
}
else
{
- ChannelBuffer content = ChannelBuffers.dynamicBuffer();
- OutputStream os = new ChannelBufferOutputStream(content);
- marshaller.write(reqMessage, os);
-
int cs = chunkSize;
if (cs > 0) //chunked encoding
{
- os.flush();
request.addHeader(HttpHeaders.Names.TRANSFER_ENCODING, HttpHeaders.Values.CHUNKED);
//write headers
channel.write(request);
//write content chunks
- int size = content.readableBytes();
- int cur = 0;
- while (cur < size)
- {
- int to = Math.min(cur + cs, size);
- HttpChunk chunk = new DefaultHttpChunk(content.slice(cur, to - cur));
- channel.write(chunk);
- cur = to;
- }
- //write last chunk
- return channel.write(HttpChunk.LAST_CHUNK);
+ NettyTransportOutputStream os = new NettyTransportOutputStream(channel, cs);
+ marshaller.write(reqMessage, os);
+ os.flush();
+ os.close();
+ return os.getChannelFuture();
}
else
{
+ ChannelBuffer content = ChannelBuffers.dynamicBuffer();
+ OutputStream os = new ChannelBufferOutputStream(content);
+ marshaller.write(reqMessage, os);
+ os.flush();
request.setHeader(HttpHeaders.Names.CONTENT_LENGTH, String.valueOf(content.readableBytes()));
request.setContent(content);
return channel.write(request);
Added: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/NettyTransportOutputStream.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/NettyTransportOutputStream.java (rev 0)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/NettyTransportOutputStream.java 2009-08-07 08:31:48 UTC (rev 10498)
@@ -0,0 +1,160 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.client;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.jboss.netty.channel.Channel;
+import org.jboss.netty.channel.ChannelFuture;
+import org.jboss.netty.handler.codec.http.DefaultHttpChunk;
+import org.jboss.netty.handler.codec.http.HttpChunk;
+
+/**
+ * An output stream that sends messages using Netty.
+ * This basically adapts the output stream interface
+ * to the Netty API, to allow for marshalling and sending
+ * soap messages in one step only saving memory
+ * (especially when dealing with attachments)
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 06-Aug-2009
+ *
+ */
+public class NettyTransportOutputStream extends OutputStream
+{
+ private Channel channel;
+ private byte[] buffer;
+ private int cur;
+ private ChannelFuture future;
+ private boolean closed = false;
+
+ /**
+ * Constructor
+ *
+ * @param channel The Netty channel to send the message on
+ * @param chunkSize The chunk size (bytes) for chunked encoding (must be > 0)
+ */
+ public NettyTransportOutputStream(Channel channel, int chunkSize)
+ {
+ this.channel = channel;
+ if (chunkSize <= 0)
+ {
+ throw new IllegalArgumentException("Invalid chunk size (must be greater than 0)");
+ }
+ this.cur = 0;
+ this.buffer = new byte[chunkSize];
+ }
+
+ @Override
+ public synchronized void write(int b) throws IOException
+ {
+ this.internalWrite(b);
+ }
+
+ @Override
+ public synchronized void write(byte b[], int off, int len) throws IOException
+ {
+ if (len >= buffer.length)
+ {
+ /* If the request length exceeds the size of the output buffer,
+ flush and then write the data directly using the internalWrite */
+ flushBuffer();
+ for (int i = 0; i < len; i++)
+ {
+ internalWrite(b[off + i]);
+ }
+ return;
+ }
+ if (len > buffer.length - cur)
+ {
+ flushBuffer();
+ }
+ System.arraycopy(b, off, buffer, cur, len);
+ cur += len;
+ }
+
+ private void internalWrite(int b) throws IOException
+ {
+ if (cur >= buffer.length)
+ {
+ flushBuffer();
+ }
+ buffer[cur++] = (byte)b;
+ }
+
+ /**
+ * Flush the internal buffer
+ */
+ private void flushBuffer() throws IOException
+ {
+ if (cur > 0)
+ {
+ ChannelBuffer content = ChannelBuffers.copiedBuffer(buffer, 0, cur);
+ HttpChunk chunk = new DefaultHttpChunk(content);
+ if (future != null)
+ {
+ future.awaitUninterruptibly();
+ }
+ future = channel.write(chunk);
+ cur = 0;
+ }
+ }
+
+ @Override
+ public synchronized void flush() throws IOException
+ {
+ //NOOP: we do not flush the buffer as that would mean sending out many messages with size under the chunkSize
+ }
+
+ /**
+ * Close the stream causing the last chunk to be send on the channel (includes flushing)
+ */
+ @Override
+ public synchronized void close() throws IOException
+ {
+ flushBuffer();
+ if (future != null)
+ {
+ future.awaitUninterruptibly();
+ }
+ future = channel.write(HttpChunk.LAST_CHUNK);
+ closed = true;
+ }
+
+ /**
+ * Get the Netty channel future for the last message sent.
+ *
+ * @return The Netty channel future for the last message sent.
+ */
+ public synchronized ChannelFuture getChannelFuture()
+ {
+ if (!closed)
+ {
+ throw new IllegalStateException("Cannot get channel future before closing the stream.");
+ }
+ return future;
+ }
+
+}
Property changes on: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/NettyTransportOutputStream.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/WSResponseHandler.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/WSResponseHandler.java 2009-08-06 13:30:09 UTC (rev 10497)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/WSResponseHandler.java 2009-08-07 08:31:48 UTC (rev 10498)
@@ -28,6 +28,7 @@
import org.jboss.netty.buffer.ChannelBufferInputStream;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelPipelineCoverage;
+import org.jboss.netty.channel.ExceptionEvent;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
import org.jboss.netty.handler.codec.http.HttpResponse;
@@ -86,6 +87,15 @@
}
}
+ @Override
+ public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception
+ {
+ if (this.error != null)
+ {
+ this.error = e.getCause();
+ }
+ }
+
private void reset()
{
this.error = null;
15 years, 1 month
JBossWS SVN: r10497 - container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2009-08-06 09:30:09 -0400 (Thu, 06 Aug 2009)
New Revision: 10497
Added:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataCreator.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataHelper.java
Modified:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataCreatingDeploymentAspect.java
Log:
[JBWS-2332] another refactoring
Modified: container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataCreatingDeploymentAspect.java
===================================================================
--- container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataCreatingDeploymentAspect.java 2009-08-05 15:32:43 UTC (rev 10496)
+++ container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataCreatingDeploymentAspect.java 2009-08-06 13:30:09 UTC (rev 10497)
@@ -21,31 +21,9 @@
*/
package org.jboss.webservices.integration.tomcat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.metadata.javaee.spec.SecurityRolesMetaData;
-import org.jboss.metadata.web.jboss.JBossServletMetaData;
-import org.jboss.metadata.web.jboss.JBossServletsMetaData;
-import org.jboss.metadata.web.jboss.JBossWebMetaData;
-import org.jboss.metadata.web.spec.AuthConstraintMetaData;
-import org.jboss.metadata.web.spec.LoginConfigMetaData;
-import org.jboss.metadata.web.spec.SecurityConstraintMetaData;
-import org.jboss.metadata.web.spec.ServletMappingMetaData;
-import org.jboss.metadata.web.spec.TransportGuaranteeType;
-import org.jboss.metadata.web.spec.UserDataConstraintMetaData;
-import org.jboss.metadata.web.spec.WebResourceCollectionMetaData;
-import org.jboss.metadata.web.spec.WebResourceCollectionsMetaData;
import org.jboss.wsf.common.integration.WSHelper;
-import org.jboss.wsf.spi.annotation.WebContext;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.DeploymentAspect;
-import org.jboss.wsf.spi.deployment.Endpoint;
-import org.jboss.wsf.spi.metadata.j2ee.EJBArchiveMetaData;
-import org.jboss.wsf.spi.metadata.j2ee.EJBMetaData;
-import org.jboss.wsf.spi.metadata.j2ee.EJBSecurityMetaData;
/**
* A deployment aspect that generates web app meta data for EJB endpoints.
@@ -56,12 +34,9 @@
public final class WebMetaDataCreatingDeploymentAspect extends DeploymentAspect
{
- /** EJB 21 security meta data builder. */
- private SecurityMetaDataAccessorEJB ejb21SecurityAccessor = new SecurityMetaDataAccessorEJB21();
+ /** Web meta data creator. */
+ private WebMetaDataCreator webMetaDataCreator = new WebMetaDataCreator();
- /** EJB 3 security meta data builder. */
- private SecurityMetaDataAccessorEJB ejb3SecurityAccessor = new SecurityMetaDataAccessorEJB3();
-
/**
* Constructor.
*/
@@ -81,293 +56,8 @@
if (isEjbDeployment)
{
- final DeploymentUnit unit = WSHelper.getRequiredAttachment(dep, DeploymentUnit.class);
- final JBossWebMetaData jbossWebMD = this.createWebMetaData(dep);
-
- dep.addAttachment(JBossWebMetaData.class, jbossWebMD);
- unit.addAttachment(JBossWebMetaData.class, jbossWebMD);
+ this.webMetaDataCreator.create(dep);
}
}
- /**
- * Creates web meta data for EJB deployment.
- *
- * @param dep webservice deployment
- * @return web meta data for EJB deployment
- */
- private JBossWebMetaData createWebMetaData(final Deployment dep)
- {
- final JBossWebMetaData jbossWebMD = new JBossWebMetaData();
-
- this.createWebAppDescriptor(dep, jbossWebMD);
- this.createJBossWebAppDescriptor(dep, jbossWebMD);
-
- return jbossWebMD;
- }
-
- private void createWebAppDescriptor(final Deployment dep, final JBossWebMetaData jbossWebMD)
- {
- this.createServlets(dep, jbossWebMD);
- this.createServletMappings(dep, jbossWebMD);
-
- String authMethod = null;
-
- // Add web-app/security-constraint for each port component
- for (Endpoint ep : dep.getService().getEndpoints())
- {
- String ejbName = ep.getShortName();
-
- final SecurityMetaDataAccessorEJB ejbMDAccessor = this.getEjbSecurityMetaDataAccessor(dep);
- Boolean secureWSDLAccess = ejbMDAccessor.isSecureWsdlAccess(ep);
- String transportGuarantee = ejbMDAccessor.getTransportGuarantee(ep);
- String beanAuthMethod = ejbMDAccessor.getAuthMethod(ep);
-
- if (beanAuthMethod != null || transportGuarantee != null)
- {
- /*
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>TestUnAuthPort</web-resource-name>
- <url-pattern>/HSTestRoot/TestUnAuth/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>*</role-name>
- </auth-constraint>
- <user-data-constraint>
- <transport-guarantee>NONE</transport-guarantee>
- </user-data-constraint>
- </security-constraint>
- */
- List<SecurityConstraintMetaData> securityContraints = jbossWebMD.getSecurityContraints();
- if (securityContraints == null)
- {
- securityContraints = new ArrayList<SecurityConstraintMetaData>();
- jbossWebMD.setSecurityContraints(securityContraints);
- }
- SecurityConstraintMetaData securityConstraint = new SecurityConstraintMetaData();
- securityContraints.add(securityConstraint);
-
- WebResourceCollectionsMetaData resourceCollections = securityConstraint.getResourceCollections();
- if (resourceCollections == null)
- {
- resourceCollections = new WebResourceCollectionsMetaData();
- securityConstraint.setResourceCollections(resourceCollections);
- }
- WebResourceCollectionMetaData resourceCollection = new WebResourceCollectionMetaData();
- resourceCollections.add(resourceCollection);
-
- resourceCollection.setWebResourceName(ejbName);
- resourceCollection.setUrlPatterns(Arrays.asList(new String[] { ep.getURLPattern() }));
- ArrayList<String> httpMethods = new ArrayList<String>();
- resourceCollection.setHttpMethods(httpMethods);
- if (Boolean.TRUE.equals(secureWSDLAccess))
- {
- httpMethods.add("GET");
- }
- httpMethods.add("POST");
-
- // Optional auth-constraint
- if (beanAuthMethod != null)
- {
- // Only the first auth-method gives the war login-config/auth-method
- if (authMethod == null)
- authMethod = beanAuthMethod;
-
- AuthConstraintMetaData authConstraint = new AuthConstraintMetaData();
- authConstraint.setRoleNames(Arrays.asList(new String[] { "*" }));
- securityConstraint.setAuthConstraint(authConstraint);
- }
- // Optional user-data-constraint
- if (transportGuarantee != null)
- {
- UserDataConstraintMetaData userDataConstraint = new UserDataConstraintMetaData();
- userDataConstraint.setTransportGuarantee(TransportGuaranteeType.valueOf(transportGuarantee));
- securityConstraint.setUserDataConstraint(userDataConstraint);
- }
- }
- }
-
- // Optional login-config/auth-method
- if (authMethod != null)
- {
- LoginConfigMetaData loginConfig = jbossWebMD.getLoginConfig();
- if (loginConfig == null)
- {
- loginConfig = new LoginConfigMetaData();
- jbossWebMD.setLoginConfig(loginConfig);
- }
- loginConfig.setAuthMethod(authMethod);
- loginConfig.setRealmName("EJBServiceEndpointServlet Realm");
-
- this.setSecurityRoles(jbossWebMD, dep);
- }
- }
-
- /**
- * Creates jboss-web meta data.
- *
- * <jboss-web>
- * <security-domain>java:/jaas/custom-security-domain</security-domain>
- * <context-root>/custom-context-root</context-root>
- * <virtual-host>custom-virtual-host-1</virtual-host>
- * ...
- * <virtual-host>custom-virtual-host-N</virtual-host>
- * </jboss-web>
- *
- * @param dep webservice deployment
- * @param jbossWebMD jboss web meta data
- */
- private void createJBossWebAppDescriptor(final Deployment dep, final JBossWebMetaData jbossWebMD)
- {
- // Set security domain
- this.setSecurityDomain(jbossWebMD, dep);
-
- // Set context root
- final String contextRoot = dep.getService().getContextRoot();
- jbossWebMD.setContextRoot(contextRoot);
-
- // Set virtual hosts
- final List<String> virtualHosts = dep.getService().getVirtualHosts();
- jbossWebMD.setVirtualHosts(virtualHosts);
- }
-
- /**
- * Returns security builder associated with EJB deployment.
- *
- * @param dep webservice EJB deployment
- * @return security builder for EJB deployment
- */
- private SecurityMetaDataAccessorEJB getEjbSecurityMetaDataAccessor(final Deployment dep)
- {
- final boolean isJaxws = WSHelper.isJaxwsDeployment(dep);
-
- return isJaxws ? this.ejb3SecurityAccessor : this.ejb21SecurityAccessor;
- }
-
- /**
- * Creates servlets part of web.xml descriptor.
- *
- * <pre>
- * <servlet>
- * <servlet-name>WSEndpointShortName</servlet-name>
- * <servlet-class>WSEndpointTargetBeanName</servlet-class>
- * </servlet>
- * </pre>
- *
- * @param dep webservice deployemnt
- * @param jbossWebMD jboss web meta data
- */
- private void createServlets(final Deployment dep, final JBossWebMetaData jbossWebMD)
- {
- final JBossServletsMetaData servlets = this.getServlets(jbossWebMD);
-
- for (final Endpoint endpoint : dep.getService().getEndpoints())
- {
- final JBossServletMetaData servlet = new JBossServletMetaData();
- servlet.setServletName(endpoint.getShortName());
- servlet.setServletClass(endpoint.getTargetBeanName());
-
- servlets.add(servlet);
- }
- }
-
- /**
- * Creates servlet-mapping part of web.xml descriptor.
- *
- * <pre>
- * <servlet-mapping>
- * <servlet-name>WSEndpointShortName</servlet-name>
- * <url-pattern>WSEndpointURLPattern</url-pattern>
- * </servlet-mapping>
- * </pre>
- *
- * @param dep webservice deployemnt
- * @param jbossWebMD jboss web meta data
- */
- private void createServletMappings(final Deployment dep, final JBossWebMetaData jbossWebMD)
- {
- final List<ServletMappingMetaData> servletMappings = this.getServletMappings(jbossWebMD);
-
- for (final Endpoint ep : dep.getService().getEndpoints())
- {
- final ServletMappingMetaData servletMapping = new ServletMappingMetaData();
- servletMapping.setServletName(ep.getShortName());
- servletMapping.setUrlPatterns(Arrays.asList(new String[] { ep.getURLPattern() })); // TODO:
-
- servletMappings.add(servletMapping);
- }
- }
-
- /**
- * Gests servlets meta data from jboss web meta data.
- * If not found it creates new servlets meta data
- * and associates them with jboss web meta data.
- *
- * @param jbossWebMD jboss web meta data
- * @return servlets meta data
- */
- private JBossServletsMetaData getServlets(final JBossWebMetaData jbossWebMD)
- {
- JBossServletsMetaData servlets = jbossWebMD.getServlets();
- if (servlets == null)
- {
- servlets = new JBossServletsMetaData();
- jbossWebMD.setServlets(servlets);
- }
-
- return servlets;
- }
-
- /**
- * Gests servlet mappings meta data from jboss web meta data.
- * If not found it creates new servlet mappings meta data
- * and associates them with jboss web meta data.
- *
- * @param jbossWebMD jboss web meta data
- * @return servlet mappings meta data
- */
- private List<ServletMappingMetaData> getServletMappings(final JBossWebMetaData jbossWebMD)
- {
- List<ServletMappingMetaData> servletMappings = jbossWebMD.getServletMappings();
- if (servletMappings == null)
- {
- servletMappings = new ArrayList<ServletMappingMetaData>();
- jbossWebMD.setServletMappings(servletMappings);
- }
-
- return servletMappings;
- }
-
- /**
- * @see org.jboss.webservices.integration.tomcat.SecurityMetaDataAccessorEJB#addSecurityDomain(JBossWebMetaData, Deployment)
- *
- * @param jbossWebMD jboss web meta data
- * @param dep webservice deployment
- */
- public final void setSecurityDomain(final JBossWebMetaData jbossWebMD, final Deployment dep)
- {
- final String securityDomain = this.getEjbSecurityMetaDataAccessor(dep).getSecurityDomain(dep); // TODO: review (javadoc)
-
- if (securityDomain != null)
- {
- jbossWebMD.setSecurityDomain(securityDomain);
- }
- }
-
- /**
- * @see org.jboss.webservices.integration.tomcat.SecurityMetaDataAccessorEJB#addSecurityRoles(JBossWebMetaData, Deployment)
- *
- * @param jbossWebMD jboss web meta data
- * @param dep webservice deployment
- */
- public final void setSecurityRoles(final JBossWebMetaData jbossWebMD, final Deployment dep)
- {
- final SecurityRolesMetaData securityRolesMD = this.getEjbSecurityMetaDataAccessor(dep).getSecurityRoles(dep); // TODO: review (javadoc)
-
- if (securityRolesMD != null)
- {
- jbossWebMD.setSecurityRoles(securityRolesMD);
- }
- }
-
}
Added: container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataCreator.java
===================================================================
--- container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataCreator.java (rev 0)
+++ container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataCreator.java 2009-08-06 13:30:09 UTC (rev 10497)
@@ -0,0 +1,298 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.tomcat;
+
+import java.util.List;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.metadata.javaee.spec.SecurityRolesMetaData;
+import org.jboss.metadata.web.jboss.JBossServletsMetaData;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.metadata.web.spec.LoginConfigMetaData;
+import org.jboss.metadata.web.spec.SecurityConstraintMetaData;
+import org.jboss.metadata.web.spec.ServletMappingMetaData;
+import org.jboss.metadata.web.spec.WebResourceCollectionsMetaData;
+import org.jboss.wsf.common.integration.WSHelper;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Endpoint;
+
+/**
+ * Creator of web app meta data for EJB endpoints.
+ *
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:tdiesler@redhat.com">Thomas Diesler</a>
+ */
+final class WebMetaDataCreator
+{
+ /** EJB 21 security meta data builder. */
+ private final SecurityMetaDataAccessorEJB ejb21SecurityAccessor = new SecurityMetaDataAccessorEJB21();
+
+ /** EJB 3 security meta data builder. */
+ private final SecurityMetaDataAccessorEJB ejb3SecurityAccessor = new SecurityMetaDataAccessorEJB3();
+
+ /**
+ * Constructor.
+ */
+ WebMetaDataCreator()
+ {
+ super();
+ }
+
+ /**
+ * Creates web meta data for EJB deployments.
+ *
+ * @param dep webservice deployment
+ */
+ public void create(final Deployment dep)
+ {
+ final DeploymentUnit unit = WSHelper.getRequiredAttachment(dep, DeploymentUnit.class);
+ final JBossWebMetaData jbossWebMD = this.createWebMetaData(dep);
+
+ dep.addAttachment(JBossWebMetaData.class, jbossWebMD);
+ unit.addAttachment(JBossWebMetaData.class, jbossWebMD);
+ }
+
+ /**
+ * Creates web meta data for EJB deployment.
+ *
+ * @param dep webservice deployment
+ * @return web meta data for EJB deployment
+ */
+ private JBossWebMetaData createWebMetaData(final Deployment dep)
+ {
+ final JBossWebMetaData jbossWebMD = new JBossWebMetaData();
+
+ this.createWebAppDescriptor(dep, jbossWebMD);
+ this.createJBossWebAppDescriptor(dep, jbossWebMD);
+
+ return jbossWebMD;
+ }
+
+ private void createWebAppDescriptor(final Deployment dep, final JBossWebMetaData jbossWebMD)
+ {
+ this.createServlets(dep, jbossWebMD);
+ this.createServletMappings(dep, jbossWebMD);
+ this.createSecurityConstraints(dep, jbossWebMD);
+
+ // Optional login-config/auth-method
+ final String authMethod = this.getAuthMethodForDeployment(dep);
+
+ if (authMethod != null)
+ {
+ LoginConfigMetaData loginConfig = jbossWebMD.getLoginConfig();
+ if (loginConfig == null)
+ {
+ loginConfig = new LoginConfigMetaData();
+ jbossWebMD.setLoginConfig(loginConfig);
+ }
+ loginConfig.setAuthMethod(authMethod);
+ loginConfig.setRealmName("EJBServiceEndpointServlet Realm"); // TODO: review if still necessary and what it means
+
+ final SecurityMetaDataAccessorEJB ejbMDAccessor = this.getEjbSecurityMetaDataAccessor(dep);
+ final SecurityRolesMetaData securityRolesMD = ejbMDAccessor.getSecurityRoles(dep);
+
+ if (securityRolesMD != null)
+ {
+ jbossWebMD.setSecurityRoles(securityRolesMD);
+ }
+ }
+ }
+
+ /**
+ * Creates jboss-web meta data.
+ *
+ * <jboss-web>
+ * <security-domain>java:/jaas/custom-security-domain</security-domain>
+ * <context-root>/custom-context-root</context-root>
+ * <virtual-host>custom-virtual-host-1</virtual-host>
+ * ...
+ * <virtual-host>custom-virtual-host-N</virtual-host>
+ * </jboss-web>
+ *
+ * @param dep webservice deployment
+ * @param jbossWebMD jboss web meta data
+ */
+ private void createJBossWebAppDescriptor(final Deployment dep, final JBossWebMetaData jbossWebMD)
+ {
+ final SecurityMetaDataAccessorEJB ejbMDAccessor = this.getEjbSecurityMetaDataAccessor(dep);
+
+ // Set security domain
+ final String securityDomain = ejbMDAccessor.getSecurityDomain(dep);
+ final boolean hasSecurityDomain = securityDomain != null;
+
+ if (hasSecurityDomain)
+ {
+ jbossWebMD.setSecurityDomain(securityDomain);
+ }
+
+ // Set context root
+ final String contextRoot = dep.getService().getContextRoot();
+ jbossWebMD.setContextRoot(contextRoot);
+
+ // Set virtual hosts
+ final List<String> virtualHosts = dep.getService().getVirtualHosts();
+ jbossWebMD.setVirtualHosts(virtualHosts);
+ }
+
+ /**
+ * Creates servlets part of web.xml descriptor.
+ *
+ * <pre>
+ * <servlet>
+ * <servlet-name>WSEndpointShortName</servlet-name>
+ * <servlet-class>WSEndpointTargetBeanName</servlet-class>
+ * </servlet>
+ * </pre>
+ *
+ * @param dep webservice deployment
+ * @param jbossWebMD jboss web meta data
+ */
+ private void createServlets(final Deployment dep, final JBossWebMetaData jbossWebMD)
+ {
+ final JBossServletsMetaData servlets = WebMetaDataHelper.getServlets(jbossWebMD);
+
+ for (final Endpoint endpoint : dep.getService().getEndpoints())
+ {
+ final String endpointName = endpoint.getShortName();
+ final String endpointClassName = endpoint.getTargetBeanName();
+
+ WebMetaDataHelper.newServlet(endpointName, endpointClassName, servlets);
+ }
+ }
+
+ /**
+ * Creates servlet-mapping part of web.xml descriptor.
+ *
+ * <pre>
+ * <servlet-mapping>
+ * <servlet-name>WSEndpointShortName</servlet-name>
+ * <url-pattern>WSEndpointURLPattern</url-pattern>
+ * </servlet-mapping>
+ * </pre>
+ *
+ * @param dep webservice deployment
+ * @param jbossWebMD jboss web meta data
+ */
+ private void createServletMappings(final Deployment dep, final JBossWebMetaData jbossWebMD)
+ {
+ final List<ServletMappingMetaData> servletMappings = WebMetaDataHelper.getServletMappings(jbossWebMD);
+
+ for (final Endpoint ep : dep.getService().getEndpoints())
+ {
+ final String endpointName = ep.getShortName();
+ final List<String> urlPatterns = WebMetaDataHelper.getUrlPatterns(ep.getURLPattern());
+
+ WebMetaDataHelper.newServletMapping(endpointName, urlPatterns, servletMappings);
+ }
+ }
+
+ /**
+ * Creates security constraints part of web.xml descriptor.
+ *
+ *
+ * <security-constraint>
+ * <web-resource-collection>
+ * <web-resource-name>TestUnAuthPort</web-resource-name>
+ * <url-pattern>/HSTestRoot/TestUnAuth/*</url-pattern>
+ * <http-method>GET</http-method>
+ * <http-method>POST</http-method>
+ * </web-resource-collection>
+ * <auth-constraint>
+ * <role-name>*</role-name>
+ * </auth-constraint>
+ * <user-data-constraint>
+ * <transport-guarantee>NONE</transport-guarantee>
+ * </user-data-constraint>
+ * </security-constraint>
+ *
+ * @param dep webservice deployemnt
+ * @param jbossWebMD jboss web meta data
+ */
+ private void createSecurityConstraints(final Deployment dep, final JBossWebMetaData jbossWebMD)
+ {
+ final SecurityMetaDataAccessorEJB ejbMDAccessor = this.getEjbSecurityMetaDataAccessor(dep);
+
+ for (final Endpoint ejbEndpoint : dep.getService().getEndpoints())
+ {
+ final boolean secureWsdlAccess = ejbMDAccessor.isSecureWsdlAccess(ejbEndpoint);
+ final String transportGuarantee = ejbMDAccessor.getTransportGuarantee(ejbEndpoint);
+ final String beanAuthMethod = ejbMDAccessor.getAuthMethod(ejbEndpoint);
+
+ if (beanAuthMethod != null || transportGuarantee != null)
+ {
+ // Security constraint
+ final List<SecurityConstraintMetaData> securityConstraints = WebMetaDataHelper.getSecurityConstraints(jbossWebMD);
+ final SecurityConstraintMetaData securityConstraint = WebMetaDataHelper.newSecurityConstraint(securityConstraints);
+
+ // Resource collection
+ final WebResourceCollectionsMetaData resourceCollections = WebMetaDataHelper.getWebResourceCollections(securityConstraint);
+ final String endpointName = ejbEndpoint.getShortName();
+ final String urlPattern = ejbEndpoint.getURLPattern();
+ WebMetaDataHelper.newWebResourceCollection(endpointName, urlPattern, secureWsdlAccess, resourceCollections);
+
+ // Optional auth-constraint
+ if (beanAuthMethod != null)
+ {
+ WebMetaDataHelper.newAuthConstraint(WebMetaDataHelper.getAllRoles(), securityConstraint);
+ }
+ // Optional user-data-constraint
+ if (transportGuarantee != null)
+ {
+ WebMetaDataHelper.newUserDataConstraint(transportGuarantee, securityConstraint);
+ }
+ }
+ }
+ }
+
+ // Only the first auth-method gives the war login-config/auth-method
+ private String getAuthMethodForDeployment(final Deployment dep)
+ {
+ final SecurityMetaDataAccessorEJB ejbMDAccessor = this.getEjbSecurityMetaDataAccessor(dep);
+
+ for (final Endpoint ejbEndpoint : dep.getService().getEndpoints())
+ {
+ final String beanAuthMethod = ejbMDAccessor.getAuthMethod(ejbEndpoint);
+ final boolean hasBeanAuthMethod = beanAuthMethod != null;
+
+ if (hasBeanAuthMethod)
+ {
+ return beanAuthMethod;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns security builder associated with EJB deployment.
+ *
+ * @param dep webservice EJB deployment
+ * @return security builder for EJB deployment
+ */
+ private SecurityMetaDataAccessorEJB getEjbSecurityMetaDataAccessor(final Deployment dep)
+ {
+ final boolean isJaxws = WSHelper.isJaxwsDeployment(dep);
+
+ return isJaxws ? this.ejb3SecurityAccessor : this.ejb21SecurityAccessor;
+ }
+
+}
Added: container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataHelper.java
===================================================================
--- container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataHelper.java (rev 0)
+++ container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataHelper.java 2009-08-06 13:30:09 UTC (rev 10497)
@@ -0,0 +1,234 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.tomcat;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.jboss.metadata.web.jboss.JBossServletMetaData;
+import org.jboss.metadata.web.jboss.JBossServletsMetaData;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.metadata.web.spec.AuthConstraintMetaData;
+import org.jboss.metadata.web.spec.SecurityConstraintMetaData;
+import org.jboss.metadata.web.spec.ServletMappingMetaData;
+import org.jboss.metadata.web.spec.TransportGuaranteeType;
+import org.jboss.metadata.web.spec.UserDataConstraintMetaData;
+import org.jboss.metadata.web.spec.WebResourceCollectionMetaData;
+import org.jboss.metadata.web.spec.WebResourceCollectionsMetaData;
+
+/**
+ * Utility class that simplifies work with JBossWebMetaData object structure.
+ *
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:tdiesler@redhat.com">Thomas Diesler</a>
+ */
+final class WebMetaDataHelper
+{
+
+ /** Star utility string. */
+ private static final String STAR_STRING = "*";
+ /** GET http method utility string. */
+ private static final String GET_STRING = "GET";
+ /** POST http method utility string. */
+ private static final String POST_STRING = "POST";
+ /** GET and POST methods utility list. */
+ private static List<String> getAndPostMethods;
+ /** POST method utility list. */
+ private static List<String> onlyPostMethod;
+ /** All roles utility list. */
+ private static List<String> allRoles;
+
+ static
+ {
+ final List<String> getAndPostList = new LinkedList<String>();
+ getAndPostList.add(WebMetaDataHelper.GET_STRING);
+ getAndPostList.add(WebMetaDataHelper.POST_STRING);
+ WebMetaDataHelper.getAndPostMethods = Collections.unmodifiableList(getAndPostList);
+
+ final List<String> onlyPostList = new LinkedList<String>();
+ onlyPostList.add(WebMetaDataHelper.POST_STRING);
+ WebMetaDataHelper.onlyPostMethod = Collections.unmodifiableList(onlyPostList);
+
+ final List<String> roleNamesList = new LinkedList<String>();
+ roleNamesList.add(WebMetaDataHelper.STAR_STRING);
+ WebMetaDataHelper.allRoles = Collections.unmodifiableList(roleNamesList);
+ }
+
+ /**
+ * Constructor.
+ */
+ private WebMetaDataHelper()
+ {
+ super();
+ }
+
+ /**
+ * Gests servlets meta data from jboss web meta data.
+ * If not found it creates new servlets meta data
+ * and associates them with jboss web meta data.
+ *
+ * @param jbossWebMD jboss web meta data
+ * @return servlets meta data
+ */
+ static JBossServletsMetaData getServlets(final JBossWebMetaData jbossWebMD)
+ {
+ JBossServletsMetaData servlets = jbossWebMD.getServlets();
+ if (servlets == null)
+ {
+ servlets = new JBossServletsMetaData();
+ jbossWebMD.setServlets(servlets);
+ }
+
+ return servlets;
+ }
+
+ /**
+ * Gests servlet mappings meta data from jboss web meta data.
+ * If not found it creates new servlet mappings meta data
+ * and associates them with jboss web meta data.
+ *
+ * @param jbossWebMD jboss web meta data
+ * @return servlet mappings meta data
+ */
+ static List<ServletMappingMetaData> getServletMappings(final JBossWebMetaData jbossWebMD)
+ {
+ List<ServletMappingMetaData> servletMappings = jbossWebMD.getServletMappings();
+ if (servletMappings == null)
+ {
+ servletMappings = new ArrayList<ServletMappingMetaData>();
+ jbossWebMD.setServletMappings(servletMappings);
+ }
+
+ return servletMappings;
+ }
+
+ /**
+ * Gests security constraints meta data from jboss web meta data.
+ * If not found it creates new security constraints meta data
+ * and associates them with jboss web meta data.
+ *
+ * @param jbossWebMD jboss web meta data
+ * @return security constraints meta data
+ */
+ static List<SecurityConstraintMetaData> getSecurityConstraints(final JBossWebMetaData jbossWebMD)
+ {
+ List<SecurityConstraintMetaData> securityConstraints = jbossWebMD.getSecurityContraints();
+ if (securityConstraints == null)
+ {
+ securityConstraints = new ArrayList<SecurityConstraintMetaData>();
+ jbossWebMD.setSecurityContraints(securityConstraints);
+ }
+
+ return securityConstraints;
+ }
+
+ static WebResourceCollectionsMetaData getWebResourceCollections(final SecurityConstraintMetaData securityConstraint)
+ {
+ WebResourceCollectionsMetaData webResourceCollections = securityConstraint.getResourceCollections();
+ if (webResourceCollections == null)
+ {
+ webResourceCollections = new WebResourceCollectionsMetaData();
+ securityConstraint.setResourceCollections(webResourceCollections);
+ }
+
+ return webResourceCollections;
+ }
+
+ static SecurityConstraintMetaData newSecurityConstraint(final List<SecurityConstraintMetaData> securityConstraints)
+ {
+ final SecurityConstraintMetaData securityConstraint = new SecurityConstraintMetaData();
+ securityConstraints.add(securityConstraint);
+
+ return securityConstraint;
+ }
+
+ static WebResourceCollectionMetaData newWebResourceCollection(final String servletName, final String urlPattern, final boolean secure,
+ final WebResourceCollectionsMetaData webResourceCollections)
+ {
+ final WebResourceCollectionMetaData webResourceCollection = new WebResourceCollectionMetaData();
+ webResourceCollection.setWebResourceName(servletName);
+ webResourceCollection.setUrlPatterns(WebMetaDataHelper.getUrlPatterns(urlPattern));
+ webResourceCollection.setHttpMethods(WebMetaDataHelper.getHttpMethods(secure));
+ webResourceCollections.add(webResourceCollection);
+
+ return webResourceCollection;
+ }
+
+ static JBossServletMetaData newServlet(final String servletName, final String servletClass, final JBossServletsMetaData servlets)
+ {
+ final JBossServletMetaData servlet = new JBossServletMetaData();
+ servlet.setServletName(servletName);
+ servlet.setServletClass(servletClass);
+ servlets.add(servlet);
+
+ return servlet;
+ }
+
+ static ServletMappingMetaData newServletMapping(final String servletName, final List<String> urlPatterns, final List<ServletMappingMetaData> servletMappings)
+ {
+ final ServletMappingMetaData servletMapping = new ServletMappingMetaData();
+ servletMapping.setServletName(servletName);
+ servletMapping.setUrlPatterns(urlPatterns);
+ servletMappings.add(servletMapping);
+
+ return servletMapping;
+ }
+
+ static AuthConstraintMetaData newAuthConstraint(final List<String> roleNames, final SecurityConstraintMetaData securityConstraint)
+ {
+ final AuthConstraintMetaData authConstraint = new AuthConstraintMetaData();
+ authConstraint.setRoleNames(roleNames);
+ securityConstraint.setAuthConstraint(authConstraint);
+
+ return authConstraint;
+ }
+
+ static UserDataConstraintMetaData newUserDataConstraint(final String transportGuarantee, final SecurityConstraintMetaData securityConstraint)
+ {
+ final UserDataConstraintMetaData userDataConstraint = new UserDataConstraintMetaData();
+ final TransportGuaranteeType transportGuaranteeValue = TransportGuaranteeType.valueOf(transportGuarantee);
+ userDataConstraint.setTransportGuarantee(transportGuaranteeValue);
+ securityConstraint.setUserDataConstraint(userDataConstraint);
+
+ return userDataConstraint;
+ }
+
+ static List<String> getUrlPatterns(final String urlPattern)
+ {
+ final List<String> linkedList = new LinkedList<String>();
+ linkedList.add(urlPattern);
+ return linkedList;
+ }
+
+ static List<String> getHttpMethods(final boolean secureWsdlAccess)
+ {
+ return secureWsdlAccess ? WebMetaDataHelper.getAndPostMethods : WebMetaDataHelper.onlyPostMethod;
+ }
+
+ static List<String> getAllRoles()
+ {
+ return WebMetaDataHelper.allRoles;
+ }
+
+}
15 years, 1 month