Author: richard.opalka(a)jboss.com
Date: 2009-08-11 05:17:49 -0400 (Tue, 11 Aug 2009)
New Revision: 10516
Modified:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerFactoryImpl.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/SecurityAdapterFactoryImpl.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/SecurityAdaptorImpl.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/ServiceEndpointInterceptor.java
Log:
[JBWS-2332] refactoring + javadoc
Modified:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerFactoryImpl.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerFactoryImpl.java 2009-08-10
17:06:28 UTC (rev 10515)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerFactoryImpl.java 2009-08-11
09:17:49 UTC (rev 10516)
@@ -21,18 +21,35 @@
*/
package org.jboss.webservices.integration.invocation;
-import org.jboss.wsf.spi.invocation.*;
+import org.jboss.wsf.spi.invocation.InvocationHandler;
+import org.jboss.wsf.spi.invocation.InvocationHandlerFactory;
+import org.jboss.wsf.spi.invocation.InvocationType;
/**
- * The default invocation model factory fro AS 5.0.
+ * The default invocation model factory for JBoss AS.
*
* @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
* @author <a href="mailto:tdiesler@redhat.com">Thomas Diesler</a>
*/
-public class InvocationHandlerFactoryImpl extends InvocationHandlerFactory
+public final class InvocationHandlerFactoryImpl extends InvocationHandlerFactory
{
- public InvocationHandler newInvocationHandler(InvocationType type)
+
+ /**
+ * Constructor.
+ */
+ public InvocationHandlerFactoryImpl()
{
+ super();
+ }
+
+ /**
+ * Returns invocation handler associated with invocation type.
+ *
+ * @param type invocation type
+ * @return invocation handler
+ */
+ public InvocationHandler newInvocationHandler(final InvocationType type)
+ {
InvocationHandler handler = null;
switch (type)
@@ -55,11 +72,11 @@
case JAXWS_MDB3:
handler = new InvocationHandlerMDB3();
break;
+ default:
+ throw new IllegalArgumentException("Unable to resolve
spi.invocation.InvocationHandler for type " + type);
}
- if (null == handler)
- throw new IllegalArgumentException("Unable to resolve
spi.invocation.InvocationHandler for type " + type);
-
return handler;
}
+
}
Modified:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/SecurityAdapterFactoryImpl.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/SecurityAdapterFactoryImpl.java 2009-08-10
17:06:28 UTC (rev 10515)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/SecurityAdapterFactoryImpl.java 2009-08-11
09:17:49 UTC (rev 10516)
@@ -25,13 +25,30 @@
import org.jboss.wsf.spi.invocation.SecurityAdaptor;
/**
+ * Security adapters factory.
+ *
* @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
* @author <a href="mailto:tdiesler@redhat.com">Thomas Diesler</a>
*/
-public class SecurityAdapterFactoryImpl extends SecurityAdaptorFactory
+public final class SecurityAdapterFactoryImpl extends SecurityAdaptorFactory
{
+
+ /**
+ * Constructor.
+ */
+ public SecurityAdapterFactoryImpl()
+ {
+ super();
+ }
+
+ /**
+ * Creates new security adapter instance.
+ *
+ * @return security adapter
+ */
public SecurityAdaptor newSecurityAdapter()
{
return new SecurityAdaptorImpl();
}
+
}
Modified:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/SecurityAdaptorImpl.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/SecurityAdaptorImpl.java 2009-08-10
17:06:28 UTC (rev 10515)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/SecurityAdaptorImpl.java 2009-08-11
09:17:49 UTC (rev 10516)
@@ -21,74 +21,95 @@
*/
package org.jboss.webservices.integration.invocation;
-import org.jboss.security.SecurityAssociation;
-import org.jboss.security.SecurityContext;
-import org.jboss.security.SecurityContextAssociation;
-import org.jboss.wsf.spi.invocation.SecurityAdaptor;
-
import java.security.AccessController;
import java.security.Principal;
import java.security.PrivilegedAction;
import javax.security.auth.Subject;
+import org.jboss.security.SecurityAssociation;
+import org.jboss.security.SecurityContext;
+import org.jboss.security.SecurityContextAssociation;
+import org.jboss.wsf.spi.invocation.SecurityAdaptor;
+
/**
- * A JBoss specific SecurityAssociationAdaptor
+ * The JBoss AS specific SecurityAssociationAdaptor.
*
* @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
* @author <a href="mailto:tdiesler@redhat.com">Thomas Diesler</a>
*/
-public class SecurityAdaptorImpl implements SecurityAdaptor
+final class SecurityAdaptorImpl implements SecurityAdaptor
{
+
+ /**
+ * Constructor.
+ */
SecurityAdaptorImpl()
{
+ super();
}
+ /**
+ * @see org.jboss.wsf.spi.invocation.SecurityAdaptor#getPrincipal()
+ *
+ * @return principal
+ */
public Principal getPrincipal()
{
return SecurityAssociation.getPrincipal();
}
- public void setPrincipal(Principal pricipal)
+ /**
+ * @see org.jboss.wsf.spi.invocation.SecurityAdaptor#setPrincipal(Principal)
+ *
+ * @param principal principal
+ */
+ public void setPrincipal(final Principal principal)
{
- SecurityAssociation.setPrincipal(pricipal);
+ SecurityAssociation.setPrincipal(principal);
}
+ /**
+ * @see org.jboss.wsf.spi.invocation.SecurityAdaptor#getCredential()
+ *
+ * @return credential
+ */
public Object getCredential()
{
return SecurityAssociation.getCredential();
}
- public void setCredential(Object credential)
+ /**
+ * @see org.jboss.wsf.spi.invocation.SecurityAdaptor#setCredential(Object)
+ *
+ * @param credential credential
+ */
+ public void setCredential(final Object credential)
{
SecurityAssociation.setCredential(credential);
}
- public void pushSubjectContext(Subject subject, Principal principal, Object
credential)
+ /**
+ * @see org.jboss.wsf.spi.invocation.SecurityAdaptor#pushSubjectContext(Subject,
Principal, Object)
+ *
+ * @param subject subject
+ * @param principal principal
+ * @param credential credential
+ */
+ public void pushSubjectContext(final Subject subject, final Principal principal, final
Object credential)
{
- SecurityAdaptorImpl.pushSubjectContext(principal, credential, subject);
- }
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
- private static SecurityContext getSecurityContext()
- {
- return (SecurityContext)AccessController.doPrivileged(new PrivilegedAction() {
- public Object run()
+ public Void run()
{
- return SecurityContextAssociation.getSecurityContext();
- }
- });
- }
+ final SecurityContext securityContext =
SecurityContextAssociation.getSecurityContext();
+ if (securityContext == null)
+ {
+ throw new IllegalStateException("Security Context is null");
+ }
- private static void pushSubjectContext(final Principal p, final Object cred, final
Subject s)
- {
- AccessController.doPrivileged(new PrivilegedAction() {
+ securityContext.getUtil().createSubjectInfo(principal, credential, subject);
- public Object run()
- {
- SecurityContext sc = getSecurityContext();
- if (sc == null)
- throw new IllegalStateException("Security Context is null");
- sc.getUtil().createSubjectInfo(p, cred, s);
return null;
}
});
Modified:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/ServiceEndpointInterceptor.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/ServiceEndpointInterceptor.java 2009-08-10
17:06:28 UTC (rev 10515)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/invocation/ServiceEndpointInterceptor.java 2009-08-11
09:17:49 UTC (rev 10516)
@@ -21,17 +21,16 @@
*/
package org.jboss.webservices.integration.invocation;
+import javax.xml.rpc.handler.soap.SOAPMessageContext;
+
import org.jboss.ejb.plugins.AbstractInterceptor;
import org.jboss.invocation.InvocationKey;
-import org.jboss.logging.Logger;
import org.jboss.wsf.spi.invocation.HandlerCallback;
import org.jboss.wsf.spi.invocation.Invocation;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerMetaData.HandlerType;
-import javax.xml.rpc.handler.soap.SOAPMessageContext;
-
/**
- * This Interceptor does the ws4ee handler processing.
+ * This Interceptor does the ws4ee handler processing on EJB 21 endpoints.
*
* According to the ws4ee spec the handler logic must be invoked after the container
* applied method level security to the invocation.
@@ -39,38 +38,47 @@
* @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
* @author <a href="mailto:tdiesler@redhat.com">Thomas Diesler</a>
*/
-public class ServiceEndpointInterceptor extends AbstractInterceptor
+final class ServiceEndpointInterceptor extends AbstractInterceptor
{
- // provide logging
- private static Logger log = Logger.getLogger(ServiceEndpointInterceptor.class);
+
+ /**
+ * Constructor.
+ */
+ ServiceEndpointInterceptor()
+ {
+ super();
+ }
- // Interceptor implementation --------------------------------------
-
- /** Before and after we call the service endpoint bean, we process the handler
chains.
+ /**
+ * Before and after we call the EJB 21 service endpoint bean, we process the handler
chains.
+ *
+ * @param jbossInvocation jboss invocation
+ * @return ws invocation return value
+ * @throws Exception if any error occurs
*/
- public Object invoke(final org.jboss.invocation.Invocation jbInv) throws Exception
+ public Object invoke(final org.jboss.invocation.Invocation jbossInvocation) throws
Exception
{
- // If no msgContext, it's not for us
- SOAPMessageContext msgContext =
(SOAPMessageContext)jbInv.getPayloadValue(InvocationKey.SOAP_MESSAGE_CONTEXT);
+ final SOAPMessageContext msgContext =
(SOAPMessageContext)jbossInvocation.getPayloadValue(InvocationKey.SOAP_MESSAGE_CONTEXT);
if (msgContext == null)
{
- return getNext().invoke(jbInv);
+ // not for us
+ return this.getNext().invoke(jbossInvocation);
}
// Get the endpoint invocation
- Invocation wsInv = (Invocation)jbInv.getValue(Invocation.class.getName());
+ final Invocation wsInvocation =
(Invocation)jbossInvocation.getValue(Invocation.class.getName());
// Get the handler callback
- HandlerCallback callback =
(HandlerCallback)jbInv.getValue(HandlerCallback.class.getName());
+ final HandlerCallback callback =
(HandlerCallback)jbossInvocation.getValue(HandlerCallback.class.getName());
// Handlers need to be Tx. Therefore we must invoke the handler chain after the
TransactionInterceptor.
- if (callback != null && wsInv != null)
+ if (callback != null && wsInvocation != null)
{
try
{
// call the request handlers
- boolean handlersPass = callback.callRequestHandlerChain(wsInv,
HandlerType.ENDPOINT);
- handlersPass = handlersPass &&
callback.callRequestHandlerChain(wsInv, HandlerType.POST);
+ boolean handlersPass = callback.callRequestHandlerChain(wsInvocation,
HandlerType.ENDPOINT);
+ handlersPass = handlersPass &&
callback.callRequestHandlerChain(wsInvocation, HandlerType.POST);
// Call the next interceptor in the chain
if (handlersPass)
@@ -78,31 +86,29 @@
// The SOAPContentElements stored in the EndpointInvocation might have
changed after
// handler processing. Get the updated request payload. This should be a
noop if request
// handlers did not modify the incomming SOAP message.
- Object[] reqParams = wsInv.getArgs();
- jbInv.setArguments(reqParams);
- Object resObj = getNext().invoke(jbInv);
+ final Object[] reqParams = wsInvocation.getArgs();
+ jbossInvocation.setArguments(reqParams);
+ final Object resObj = this.getNext().invoke(jbossInvocation);
// Setting the message to null should trigger binding of the response
message
msgContext.setMessage(null);
- wsInv.setReturnValue(resObj);
+ wsInvocation.setReturnValue(resObj);
}
// call the response handlers
- handlersPass = callback.callResponseHandlerChain(wsInv, HandlerType.POST);
- handlersPass = handlersPass &&
callback.callResponseHandlerChain(wsInv, HandlerType.ENDPOINT);
+ handlersPass = callback.callResponseHandlerChain(wsInvocation,
HandlerType.POST);
+ handlersPass = handlersPass &&
callback.callResponseHandlerChain(wsInvocation, HandlerType.ENDPOINT);
// update the return value after response handler processing
- Object resObj = wsInv.getReturnValue();
-
- return resObj;
+ return wsInvocation.getReturnValue();
}
catch (Exception ex)
{
try
{
// call the fault handlers
- boolean handlersPass = callback.callFaultHandlerChain(wsInv,
HandlerType.POST, ex);
- handlersPass = handlersPass &&
callback.callFaultHandlerChain(wsInv, HandlerType.ENDPOINT, ex);
+ boolean handlersPass = callback.callFaultHandlerChain(wsInvocation,
HandlerType.POST, ex);
+ handlersPass = handlersPass &&
callback.callFaultHandlerChain(wsInvocation, HandlerType.ENDPOINT, ex);
}
catch (Exception subEx)
{
@@ -110,15 +116,11 @@
}
throw ex;
}
- finally
- {
- // do nothing
- }
}
else
{
log.warn("Handler callback not available");
- return getNext().invoke(jbInv);
+ return this.getNext().invoke(jbossInvocation);
}
}
}