Author: ips
Date: Fri May 20 14:48:39 2005
New Revision: 171161
URL: http://svn.apache.org/viewcvs?rev=171161&view=rev
Log:
better exception handling
Added:
incubator/apollo/trunk/src/java/org/apache/ws/resource/faults/ResourceKeyHeaderNotFoundFaultException.java
Modified:
incubator/apollo/trunk/src/java/org/apache/ws/resource/ResourceHome.java
incubator/apollo/trunk/src/java/org/apache/ws/resource/handler/ResourceHandler.java
incubator/apollo/trunk/src/java/org/apache/ws/resource/handler/axis/AxisResourceContext.java
incubator/apollo/trunk/src/java/org/apache/ws/resource/handler/axis/GenericAxisHandler.java
incubator/apollo/trunk/src/java/org/apache/ws/resource/handler/axis/ResourceProvider.java
incubator/apollo/trunk/src/java/org/apache/ws/resource/i18n/Keys.java
incubator/apollo/trunk/src/java/org/apache/ws/resource/impl/AbstractResourceContext.java
Modified:
incubator/apollo/trunk/src/java/org/apache/ws/resource/ResourceHome.java
URL:
http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/resource/ResourceHome.java?rev=171161&r1=171160&r2=171161&view=diff
==============================================================================
--- incubator/apollo/trunk/src/java/org/apache/ws/resource/ResourceHome.java
(original)
+++ incubator/apollo/trunk/src/java/org/apache/ws/resource/ResourceHome.java
Fri May 20 14:48:39 2005
@@ -77,21 +77,21 @@
void setServiceClassName( String className );
/**
- * Returns the Service Impl's .Class
+ * Returns the name of the Service class.
*
- * @return Class of the Service Impl.
+ * @return the name of the Service class
*/
String getServiceClassName();
/**
- * Set the target namespace of the wsdl of this home's service
+ * Sets the target namespace of the WSDL of this home's service.
*
* @param targetNamespace
*/
void setWsdlTargetNamespace( String targetNamespace );
/**
- * Returns the Target Namespace of the WSDL
+ * Returns the target namespace of the WSDL.
*
* @return The String of the targetnamespace
*/
Added:
incubator/apollo/trunk/src/java/org/apache/ws/resource/faults/ResourceKeyHeaderNotFoundFaultException.java
URL:
http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/resource/faults/ResourceKeyHeaderNotFoundFaultException.java?rev=171161&view=auto
==============================================================================
---
incubator/apollo/trunk/src/java/org/apache/ws/resource/faults/ResourceKeyHeaderNotFoundFaultException.java
(added)
+++
incubator/apollo/trunk/src/java/org/apache/ws/resource/faults/ResourceKeyHeaderNotFoundFaultException.java
Fri May 20 14:48:39 2005
@@ -0,0 +1,48 @@
+/*=============================================================================*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+
*=============================================================================*/
+package org.apache.ws.resource.faults;
+
+import org.apache.ws.Soap1_1Constants;
+import org.apache.ws.resource.i18n.Keys;
+import org.apache.ws.resource.i18n.MessagesImpl;
+import org.apache.ws.util.i18n.Messages;
+
+import javax.xml.namespace.QName;
+
+/**
+ * A fault that is thrown when the expected resource identifier header element
+ * is not found in a SOAP request Header. The name of the header element that
+ * is expected for a particular type of resource is configured via the
+ * resourceKeyName parameter for that resource's home in the Apache WSRF
+ * JNDI configuration file.
+ */
+public class ResourceKeyHeaderNotFoundFaultException
+ extends FaultException
+{
+
+ private static final Messages MSG = MessagesImpl.getInstance();
+
+ /**
+ * Creates a new [EMAIL PROTECTED]
ResourceKeyHeaderNotFoundFaultException} object.
+ *
+ * @param expectedHeaderName DOCUMENT_ME
+ */
+ public ResourceKeyHeaderNotFoundFaultException( QName expectedHeaderName )
+ {
+ super( Soap1_1Constants.FAULT_CLIENT, MSG.getMessage(
Keys.EXPECTED_ADDRESSING_HEADER, String.valueOf( expectedHeaderName ) ) );
+ }
+
+}
\ No newline at end of file
Modified:
incubator/apollo/trunk/src/java/org/apache/ws/resource/handler/ResourceHandler.java
URL:
http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/resource/handler/ResourceHandler.java?rev=171161&r1=171160&r2=171161&view=diff
==============================================================================
---
incubator/apollo/trunk/src/java/org/apache/ws/resource/handler/ResourceHandler.java
(original)
+++
incubator/apollo/trunk/src/java/org/apache/ws/resource/handler/ResourceHandler.java
Fri May 20 14:48:39 2005
@@ -54,7 +54,8 @@
import java.util.Map;
/**
- * LOG-DONE Base class for platform-specific providers; also is a JAX-RPC
Handler for more flexibility.
+ * Base class for platform-specific providers; also is a JAX-RPC Handler to
make it
+ * easier to port to different SOAP platforms.
*
* @author Ian Springer
* @author Sal Campana
@@ -123,7 +124,7 @@
SOAPEnvelope envelope =
soapMsgContext.getMessage().getSOAPPart().getEnvelope();
if ( LOG.isDebugEnabled() )
{
- LOG.debug( "The request envelope: \n" + envelope );
+ LOG.debug( "Received SOAP request: \n" + envelope );
}
org.apache.ws.util.soap.Body body = getSoapBody( envelope );
@@ -190,7 +191,7 @@
}
catch ( Exception e )
{
- handleInternalServerError( e );
+ handleException( e );
}
return false; // short-circuit any remaining Handlers in chain
}
@@ -226,12 +227,12 @@
}
if ( LOG.isDebugEnabled() )
{
- LOG.debug( "The response envelope: \n" +
responseEnvelope.toString() );
+ LOG.debug( "Sending SOAP response: \n" + responseEnvelope );
}
}
catch ( Exception e )
{
- handleInternalServerError( e );
+ handleException( e );
}
return false; // short-circuit any remaining Handlers in chain
}
@@ -269,12 +270,10 @@
LOG.debug( MSG.getMessage( Keys.RETRIEVED_SERVICE_CLASSNAME,
serviceClassName ) );
if ( serviceClassName == null )
{
- throw new JAXRPCException( MSG.getMessage(
Keys.SERVICE_OPT_UNDEFINED_IN_HOME,
+ throw new IllegalStateException( MSG.getMessage(
Keys.SERVICE_OPT_UNDEFINED_IN_HOME,
SERVICE_OPT_SERVICE_CLASS_NAME ) );
}
-
- Class serviceClass = Class.forName( serviceClassName );
- return serviceClass;
+ return Class.forName( serviceClassName );
}
/**
@@ -348,7 +347,7 @@
}
}
- private void handleInternalServerError( Exception e )
+ private void handleException( Exception e )
{
if ( e instanceof SOAPFaultException )
{
@@ -483,7 +482,7 @@
serviceMethod.getName(),
serviceClass.getName(),
ite.getCause() ) );
- throw (Exception) ExceptionUtils.getRootCause( ite );
+ throw (Exception)ite.getCause();
}
return responseXBean;
}
@@ -618,20 +617,25 @@
private WsrfService createService( Class serviceClass,
ResourceContext resourceContext )
- throws NoSuchMethodException,
- InstantiationException,
- IllegalAccessException,
- InvocationTargetException
+ throws Exception
{
LOG.debug( MSG.getMessage( Keys.CREATING_INSTANCE_OF_SERVICE,
serviceClass ) );
Constructor serviceCtor = serviceClass.getConstructor( new Class[]
{
ResourceContext.class
} );
- WsrfService service = (WsrfService) serviceCtor.newInstance( new
Object[]
+ WsrfService service = null;
+ try
{
- resourceContext
- } );
+ service = (WsrfService) serviceCtor.newInstance( new Object[]
+ {
+ resourceContext
+ } );
+ }
+ catch ( InvocationTargetException ite )
+ {
+ throw (Exception)ite.getCause();
+ }
return service;
}
Modified:
incubator/apollo/trunk/src/java/org/apache/ws/resource/handler/axis/AxisResourceContext.java
URL:
http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/resource/handler/axis/AxisResourceContext.java?rev=171161&r1=171160&r2=171161&view=diff
==============================================================================
---
incubator/apollo/trunk/src/java/org/apache/ws/resource/handler/axis/AxisResourceContext.java
(original)
+++
incubator/apollo/trunk/src/java/org/apache/ws/resource/handler/axis/AxisResourceContext.java
Fri May 20 14:48:39 2005
@@ -28,7 +28,6 @@
import javax.xml.rpc.JAXRPCException;
import javax.xml.rpc.handler.MessageContext;
import javax.xml.rpc.handler.soap.SOAPMessageContext;
-import javax.xml.soap.SOAPMessage;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Hashtable;
@@ -56,28 +55,16 @@
/**
* Creates a new [EMAIL PROTECTED] AxisResourceContext} object.
*
- * @param ctx SOAPMessageContext
+ * @param msgContext SOAPMessageContext
*/
- public AxisResourceContext( SOAPMessageContext ctx )
+ public AxisResourceContext( SOAPMessageContext msgContext )
{
- super( ctx );
- mergeServiceOptions( ctx );
+ super( msgContext );
+ mergeServiceOptions( msgContext );
setResourceIdKeyInformation( );
}
/**
- * Creates a new [EMAIL PROTECTED] AxisResourceContext} object.
- *
- * @param ctx SOAPMessageContext
- * @param msg SOAPMessage
- */
- public AxisResourceContext( SOAPMessageContext ctx,
- SOAPMessage msg )
- {
- super( ctx, msg );
- }
-
- /**
* Returns the Service name from the Axis MessageContext [EMAIL PROTECTED]
org.apache.axis.MessageContext#getTargetService()}
*
* @param msgContext Jax-RPC MessageContext
@@ -90,9 +77,7 @@
{
throw new IllegalArgumentException(
MSG.getMessage(Keys.MESSAGECONTEXT_NULL) );
}
-
org.apache.axis.MessageContext axisMsgContext =
(org.apache.axis.MessageContext) msgContext;
-
return axisMsgContext.getTargetService( );
}
@@ -108,11 +93,9 @@
{
if ( msgContext == null )
{
- throw new IllegalArgumentException( "nullArgument: ctx" );
+ throw new IllegalArgumentException( "Null parameter: msgContext" );
}
-
org.apache.axis.MessageContext axisMsgContext =
(org.apache.axis.MessageContext) msgContext;
-
try
{
return new URL( (String) axisMsgContext.getProperty(
org.apache.axis.MessageContext.TRANS_URL ) );
Modified:
incubator/apollo/trunk/src/java/org/apache/ws/resource/handler/axis/GenericAxisHandler.java
URL:
http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/resource/handler/axis/GenericAxisHandler.java?rev=171161&r1=171160&r2=171161&view=diff
==============================================================================
---
incubator/apollo/trunk/src/java/org/apache/ws/resource/handler/axis/GenericAxisHandler.java
(original)
+++
incubator/apollo/trunk/src/java/org/apache/ws/resource/handler/axis/GenericAxisHandler.java
Fri May 20 14:48:39 2005
@@ -18,9 +18,9 @@
import org.apache.axis.AxisFault;
import org.apache.axis.handlers.BasicHandler;
+import javax.xml.namespace.QName;
import javax.xml.rpc.handler.Handler;
import javax.xml.rpc.handler.HandlerInfo;
-import javax.xml.namespace.QName;
/**
* TODO
@@ -43,8 +43,8 @@
}
/**
- * Impl of [EMAIL PROTECTED] org.apache.axis.Handler#init()} that
delegates to JAX-RPC
- * [EMAIL PROTECTED] Handler#init(javax.xml.rpc.handler.HandlerInfo)}.
+ * Impl of [EMAIL PROTECTED] org.apache.axis.Handler#init()} that
delegates to JAX-RPC [EMAIL PROTECTED]
+ * Handler#init(javax.xml.rpc.handler.HandlerInfo)}.
*/
public void init()
{
@@ -61,13 +61,20 @@
public void invoke( org.apache.axis.MessageContext msgContext )
throws AxisFault
{
- if ( !msgContext.getPastPivot() )
+ try
{
- jaxRpcHandler.handleRequest( msgContext );
+ if ( !msgContext.getPastPivot() )
+ {
+ jaxRpcHandler.handleRequest( msgContext );
+ }
+ else
+ {
+ jaxRpcHandler.handleResponse( msgContext );
+ }
}
- else
+ catch ( RuntimeException re )
{
- jaxRpcHandler.handleResponse( msgContext );
+ throw AxisFault.makeFault( re );
}
}
Modified:
incubator/apollo/trunk/src/java/org/apache/ws/resource/handler/axis/ResourceProvider.java
URL:
http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/resource/handler/axis/ResourceProvider.java?rev=171161&r1=171160&r2=171161&view=diff
==============================================================================
---
incubator/apollo/trunk/src/java/org/apache/ws/resource/handler/axis/ResourceProvider.java
(original)
+++
incubator/apollo/trunk/src/java/org/apache/ws/resource/handler/axis/ResourceProvider.java
Fri May 20 14:48:39 2005
@@ -16,10 +16,11 @@
package org.apache.ws.resource.handler.axis;
import org.apache.axis.AxisFault;
+import org.apache.axis.Constants;
import org.apache.axis.Handler;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
-import org.apache.axis.Constants;
+import org.apache.axis.encoding.SerializationContext;
import org.apache.axis.handlers.soap.SOAPService;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.commons.logging.Log;
@@ -37,16 +38,13 @@
import javax.xml.namespace.QName;
import javax.xml.rpc.handler.soap.SOAPMessageContext;
-import javax.xml.rpc.handler.HandlerInfo;
-import javax.xml.rpc.soap.SOAPFaultException;
-import javax.xml.soap.Detail;
-import javax.xml.soap.DetailEntry;
import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPMessage;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.ArrayList;
import java.util.Hashtable;
-import java.util.Iterator;
import java.util.List;
-import java.util.ArrayList;
/**
* LOG-DONE Axis provider that dispatches requests to WS-Resources.
@@ -58,7 +56,9 @@
implements Handler
{
private static final Log LOG = LogFactory.getLog( ResourceProvider.class );
- public static final Messages MSG = MessagesImpl.getInstance();
+ private static final Messages MSG = MessagesImpl.getInstance();
+ public static final String SYSPROP_AXIS_FAULT_DEBUG = "axis.fault.debug";
+
private GenericAxisHandler m_axisHelperHandler = new GenericAxisHandler(
this );
public void init()
@@ -205,29 +205,30 @@
handleRequest( msgContext );
handleResponse( msgContext );
}
- catch ( SOAPFaultException soapfe )
- {
- throw toAxisFault( soapfe );
- }
- catch (RuntimeException re)
+ catch ( RuntimeException re )
{
- throw AxisFault.makeFault(re);
+ throw AxisFault.makeFault( re );
}
}
- catch (AxisFault axisFault)
+ catch ( AxisFault axisFault )
{
- if (LOG.isDebugEnabled())
+ // only include hostname and stack trace in fault Detail if
sysprop axis.fault.debug="true"
+ if ( ! Boolean.getBoolean( SYSPROP_AXIS_FAULT_DEBUG ) )
{
- LOG.debug("Fault: \n" + axisFault.dumpToString());
+ axisFault.removeHostname();
+ axisFault.removeFaultDetail(
Constants.QNAME_FAULTDETAIL_STACKTRACE );
}
-
-
- if (System.getProperty("AXIS_FAULT_DEBUG") == null)
+ if ( LOG.isDebugEnabled() )
{
- axisFault.removeHostname();
-
axisFault.removeFaultDetail(Constants.QNAME_FAULTDETAIL_STACKTRACE);
+ try
+ {
+ LOG.debug( "Sending SOAP fault: \n" + toXML( axisFault,
msgContext ) );
+ }
+ catch ( Exception e )
+ {
+ LOG.error( "Failed to serialize AxisFault: " + e );
+ }
}
-
throw axisFault;
}
}
@@ -252,14 +253,13 @@
protected SOAPMessage getResponseMessage( SOAPMessageContext
soapMsgContext )
{
MessageContext axisMsgContext = ( (MessageContext) soapMsgContext );
- Message responseMessage = axisMsgContext.getResponseMessage();
- if ( responseMessage == null )
+ Message responseMsg = axisMsgContext.getResponseMessage();
+ if ( responseMsg == null )
{
- responseMessage = createMessage( axisMsgContext );
- axisMsgContext.setResponseMessage( responseMessage );
+ responseMsg = createMessage( axisMsgContext );
+ axisMsgContext.setResponseMessage( responseMsg );
}
-
- return responseMessage;
+ return responseMsg;
}
/**
@@ -286,16 +286,16 @@
List bodyElems = new ArrayList();
Node node = responseBodyElem.newDomNode();
NodeList childNodes = node.getChildNodes();
- for (int i = 0; i < childNodes.getLength(); i++)
+ for ( int i = 0; i < childNodes.getLength(); i++ )
{
- Node child = childNodes.item(i);
+ Node child = childNodes.item( i );
//add all child elements
- if(child.getNodeType() == Node.ELEMENT_NODE)
+ if ( child.getNodeType() == Node.ELEMENT_NODE )
{
- bodyElems.add(new
org.apache.axis.message.SOAPBodyElement((Element)child));
+ bodyElems.add( new org.apache.axis.message.SOAPBodyElement(
(Element) child ) );
}
}
- return (SOAPBodyElement[])bodyElems.toArray(new SOAPBodyElement[0]);
+ return (SOAPBodyElement[]) bodyElems.toArray( new SOAPBodyElement[0] );
}
private Message createMessage( MessageContext axisMsgContext )
@@ -306,20 +306,13 @@
return new Message( envelope );
}
- private AxisFault toAxisFault( SOAPFaultException soapfe )
+ private String toXML( AxisFault axisFault, MessageContext msgContext )
throws Exception
{
- AxisFault axisFault =
- new AxisFault( soapfe.getFaultCode(),
- soapfe.getFaultString(),
- soapfe.getFaultActor(), null );
- Detail detail = soapfe.getDetail();
- Iterator detailEntryIter = detail.getDetailEntries();
- while ( detailEntryIter.hasNext() )
- {
- DetailEntry detailEntry = (DetailEntry) detailEntryIter.next();
- axisFault.addFaultDetail( detailEntry );
- }
- return ( axisFault );
+ Writer writer = new StringWriter();
+ axisFault.output( new SerializationContext( writer, msgContext ) );
+ String xml = writer.toString();
+ writer.close();
+ return xml;
}
}
Modified: incubator/apollo/trunk/src/java/org/apache/ws/resource/i18n/Keys.java
URL:
http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/resource/i18n/Keys.java?rev=171161&r1=171160&r2=171161&view=diff
==============================================================================
--- incubator/apollo/trunk/src/java/org/apache/ws/resource/i18n/Keys.java
(original)
+++ incubator/apollo/trunk/src/java/org/apache/ws/resource/i18n/Keys.java Fri
May 20 14:48:39 2005
@@ -180,12 +180,12 @@
String FOUND_RESP_ELEMS = "FOUND_RESP_ELEMS";
/**
- * @msg Retrieved Service Class name: {0} from ResourceHome.
+ * @msg Retrieved service classname: {0} from resource home.
*/
String RETRIEVED_SERVICE_CLASSNAME = "RETRIEVED_SERVICE_CLASSNAME";
/**
- * @msg {0}: service param not defined in resource home.
+ * @msg Required parameter {0} not defined in resource home.
*/
String SERVICE_OPT_UNDEFINED_IN_HOME = "SERVICE_OPT_UNDEFINED_IN_HOME";
Modified:
incubator/apollo/trunk/src/java/org/apache/ws/resource/impl/AbstractResourceContext.java
URL:
http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/resource/impl/AbstractResourceContext.java?rev=171161&r1=171160&r2=171161&view=diff
==============================================================================
---
incubator/apollo/trunk/src/java/org/apache/ws/resource/impl/AbstractResourceContext.java
(original)
+++
incubator/apollo/trunk/src/java/org/apache/ws/resource/impl/AbstractResourceContext.java
Fri May 20 14:48:39 2005
@@ -15,11 +15,18 @@
*=============================================================================*/
package org.apache.ws.resource.impl;
-import org.apache.axis.message.addressing.AddressingHeaders;
import org.apache.axis.message.addressing.Action;
+import org.apache.axis.message.addressing.AddressingHeaders;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.ws.resource.*;
+import org.apache.ws.resource.JndiConstants;
+import org.apache.ws.resource.NoResourceHomeException;
+import org.apache.ws.resource.Resource;
+import org.apache.ws.resource.ResourceContext;
+import org.apache.ws.resource.ResourceContextException;
+import org.apache.ws.resource.ResourceException;
+import org.apache.ws.resource.ResourceHome;
+import org.apache.ws.resource.ResourceKey;
import org.apache.ws.resource.faults.ResourceKeyHeaderNotFoundFaultException;
import org.apache.ws.resource.i18n.Keys;
import org.apache.ws.resource.i18n.MessagesImpl;
@@ -31,7 +38,12 @@
import javax.xml.rpc.JAXRPCException;
import javax.xml.rpc.handler.MessageContext;
import javax.xml.rpc.handler.soap.SOAPMessageContext;
-import javax.xml.soap.*;
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPHeader;
+import javax.xml.soap.SOAPHeaderElement;
+import javax.xml.soap.SOAPMessage;
import java.lang.reflect.Constructor;
import java.net.MalformedURLException;
import java.net.URL;
@@ -41,531 +53,516 @@
import java.util.Map;
/**
- * LOG-DONE
- * DOCUMENT_ME
+ * LOG-DONE DOCUMENT_ME
*/
public abstract class AbstractResourceContext
- extends ResourceContext
+ extends ResourceContext
{
- private static final Log LOG = LogFactory.getLog(
AbstractResourceContext.class.getName() );
- public static final Messages MSG = MessagesImpl.getInstance();
+ private static final Log LOG = LogFactory.getLog(
AbstractResourceContext.class.getName() );
+ private static final Messages MSG = MessagesImpl.getInstance();
- private SOAPMessage m_msg;
- private ResourceHome m_home;
- private String m_homeLocation;
- private String m_serviceName;
- private URL m_serviceURL;
- private Map m_propsMap = Collections.synchronizedMap( new HashMap() );
- private String m_resourceKeyQname;
- private Class m_resourceKeyClass;
- private ResourceKey m_resourceKey;
+ private SOAPMessage m_msg;
+ private ResourceHome m_home;
+ private String m_homeLocation;
+ private String m_serviceName;
+ private URL m_serviceURL;
+ private Map m_propsMap = Collections.synchronizedMap( new HashMap() );
+ private String m_resourceKeyQname;
+ private Class m_resourceKeyClass;
+ private ResourceKey m_resourceKey;
private String m_baseURL;
private String m_action;
/**
- * Creates a new [EMAIL PROTECTED] AbstractResourceContext} object.
- *
- * @param soapMsgContext DOCUMENT_ME
- */
- public AbstractResourceContext( SOAPMessageContext soapMsgContext )
- {
- if ( soapMsgContext == null )
- {
- throw new IllegalArgumentException( MSG.getMessage(
Keys.NULL_SOAPMSGCTX ));
- }
-
- m_msg = soapMsgContext.getMessage();
- extractFields( soapMsgContext );
- }
-
- /**
- * Creates a new [EMAIL PROTECTED] AbstractResourceContext} object.
- *
- * @param soapMsgContext DOCUMENT_ME
- * @param msg DOCUMENT_ME
- */
- public AbstractResourceContext( SOAPMessageContext soapMsgContext,
- SOAPMessage msg )
- {
- if ( soapMsgContext == null )
- {
- throw new IllegalArgumentException( MSG.getMessage(
Keys.NULL_SOAPMSGCTX) );
- }
-
- extractFields( soapMsgContext );
- m_msg = msg;
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param name DOCUMENT_ME
- * @param value DOCUMENT_ME
- */
- public void setProperty( String name,
- Object value )
- {
- m_propsMap.put( name, value );
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param name DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- */
- public Object getProperty( String name )
- {
- return this.m_propsMap.get( name );
- }
-
- /**
- * DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- */
- public Iterator getPropertyNames()
- {
- return this.m_propsMap.keySet().iterator();
- }
-
- /**
- * DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- *
- * @throws ResourceContextException DOCUMENT_ME
- * @throws ResourceException DOCUMENT_ME
- */
- public Resource getResource()
- throws ResourceContextException,
- ResourceException
- {
- ResourceHome home = getResourceHome();
- Class resourceKeyClass = null;
+ * Creates a new [EMAIL PROTECTED] AbstractResourceContext} object.
+ *
+ * @param soapMsgContext DOCUMENT_ME
+ */
+ public AbstractResourceContext( SOAPMessageContext soapMsgContext )
+ {
+ if ( soapMsgContext == null )
+ {
+ throw new IllegalArgumentException( MSG.getMessage(
Keys.NULL_SOAPMSGCTX ) );
+ }
+ m_msg = soapMsgContext.getMessage();
+ extractFields( soapMsgContext );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param name DOCUMENT_ME
+ * @param value DOCUMENT_ME
+ */
+ public void setProperty( String name,
+ Object value )
+ {
+ m_propsMap.put( name, value );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param name DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public Object getProperty( String name )
+ {
+ return this.m_propsMap.get( name );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public Iterator getPropertyNames()
+ {
+ return this.m_propsMap.keySet().iterator();
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ *
+ * @throws ResourceContextException DOCUMENT_ME
+ * @throws ResourceException DOCUMENT_ME
+ */
+ public Resource getResource()
+ throws ResourceContextException,
+ ResourceException
+ {
+ ResourceHome home = getResourceHome();
+ Class resourceKeyClass = null;
String resourceKeyClassName = null;
- try
- {
- resourceKeyClassName = home.getResourceKeyClassName();
- resourceKeyClass = Class.forName(resourceKeyClassName);
- }
- catch (ClassNotFoundException e)
- {
- throw new ResourceException(e);
- }
-
- String resourceKeyName = home.getResourceKeyName();
- QName keyName = null;
- if(resourceKeyName != null)
- {
- keyName = QName.valueOf(resourceKeyName);
- }
-
- ResourceKey key = getResourceKey( keyName, resourceKeyClass);
- LOG.debug( MSG.getMessage( Keys.LOOKUP_RESOURCE_FOR_KEY,
String.valueOf(key)));
- Resource resource = home.find( key );
- LOG.debug( MSG.getMessage( Keys.FOUND_RESOURCE, resource ));
- return resource;
- }
-
- /**
- * DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- *
- * @throws NoResourceHomeException DOCUMENT_ME
- * @throws ResourceContextException DOCUMENT_ME
- */
- public synchronized ResourceHome getResourceHome()
- throws ResourceContextException
- {
- if ( m_home == null )
- {
- try
- {
- m_home = (ResourceHome) new InitialContext().lookup(
getResourceHomeLocation() );
- }
- catch ( NamingException ne )
- {
- ne.printStackTrace( );
- throw new ResourceContextException( ne );
- }
- }
-
- return m_home;
- }
-
- /**
- * DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- */
- public synchronized String getResourceHomeLocation()
- {
- if ( m_homeLocation == null )
- {
- m_homeLocation = JndiConstants.CONTEXT_NAME_SERVICES + "/" +
getServiceName() + "/" + JndiConstants.ATOMIC_NAME_HOME;
- }
- LOG.debug(MSG.getMessage( Keys.JNDI_HOME_LOCATION,m_homeLocation));
- return m_homeLocation;
- }
-
- /**
- * DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- *
- * @throws ResourceContextException DOCUMENT_ME
- */
- public ResourceKey getResourceKey()
- throws ResourceContextException
- {
- if ( m_resourceKey == null )
- {
- ResourceHome resourceHome = getResourceHome();
- Class resourceKeyClass = null;
- String resourceKeyClassName = null;
- try
- {
- resourceKeyClassName = resourceHome.getResourceKeyClassName();
- resourceKeyClass = Class.forName(resourceKeyClassName);
- }
- catch (ClassNotFoundException e)
- {
- throw new ResourceContextException(e);
- }
- String resourceKeyName = resourceHome.getResourceKeyName();
-
- QName resourceKeyQName = resourceKeyName != null ?
QName.valueOf(resourceKeyName) : null;
- m_resourceKey = getResourceKey( resourceKeyQName,resourceKeyClass);
-
- }
-
- LOG.debug(MSG.getMessage( Keys.RESOURCE_KEY,
String.valueOf(m_resourceKey)));
-
- return m_resourceKey;
- }
-
- /**
- * Creates a resource key for the current request.
- *
- * @param keyName DOCUMENT_ME
- * @param keyClass DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- *
- * @throws ResourceContextException DOCUMENT_ME
- */
- public ResourceKey getResourceKey( QName keyName,
- Class keyClass )
- throws ResourceContextException,
- ResourceKeyHeaderNotFoundFaultException
- {
- if ( keyName == null )
- {
- LOG.debug( MSG.getMessage( Keys.NULL_RESOURCE_NAME) );
- return null;
- }
-
- SOAPHeaderElement headerElem = getResourceKeyHeader( keyName );
- if ( headerElem == null )
- {
- throw new ResourceKeyHeaderNotFoundFaultException( keyName );
- }
-
- try
- {
- Constructor constructor = keyClass.getConstructor(new
Class[]{SOAPHeaderElement.class});
- return (ResourceKey)constructor.newInstance(new
Object[]{headerElem});
- }
- catch ( Exception e )
- {
- throw new ResourceContextException( e );
- }
- }
-
- /**
- * DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- *
- * @throws ResourceContextException DOCUMENT_ME
- */
- public SOAPHeaderElement getResourceKeyHeader()
- throws ResourceContextException
- {
- ResourceHome home = getResourceHome();
- QName keyName = QName.valueOf(home.getResourceKeyName());
- return ( keyName == null ) ? null : getResourceKeyHeader( keyName );
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param keyName DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- *
- * @throws ResourceContextException DOCUMENT_ME
- */
- public SOAPHeaderElement getResourceKeyHeader( QName keyName )
- throws ResourceContextException
- {
- try
- {
- return AbstractResourceContext.getResourceKeyHeader( this.m_msg,
keyName, null );
- }
- catch ( SOAPException e )
- {
- throw new ResourceContextException( e );
- }
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param msg DOCUMENT_ME
- * @param keyName DOCUMENT_ME
- * @param actorURI DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- *
- * @throws SOAPException DOCUMENT_ME
- * @throws IllegalArgumentException DOCUMENT_ME
- */
- public static SOAPHeaderElement getResourceKeyHeader( SOAPMessage msg,
- QName keyName,
- String actorURI )
- throws SOAPException
- {
- LOG.debug(MSG.getMessage( Keys.GET_RESOURCEKEY_HEADER,
keyName.toString()));
- if ( msg == null )
- {
- throw new IllegalArgumentException( MSG.getMessage(
Keys.NULL_SOAPMSGCTX) );
- }
-
- if ( keyName == null )
- {
- throw new IllegalArgumentException( MSG.getMessage(
Keys.NULL_RESOURCEKEY_QNAME) );
- }
-
- SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
- SOAPHeader header = env.getHeader();
-
- if ( header == null )
- {
- return null;
- }
-
- Iterator iter = header.examineHeaderElements( actorURI );
- while ( iter.hasNext() )
- {
- SOAPHeaderElement headerElem = (SOAPHeaderElement) iter.next();
- Name headerName = headerElem.getElementName();
-
- if ( headerName.getLocalName().equals( keyName.getLocalPart() )
- && headerName.getURI().equals( keyName.getNamespaceURI() ) )
- {
- // found my header element;
- return headerElem;
- }
- }
-
- return null;
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param resourceKeyClass DOCUMENT_ME
- */
- public void setResourceKeyClass( Class resourceKeyClass )
- {
- m_resourceKeyClass = resourceKeyClass;
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param resourceKeyQname DOCUMENT_ME
- */
- public void setResourceKeyQname( String resourceKeyQname )
- {
- m_resourceKeyQname = resourceKeyQname;
- }
-
- /**
- * DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- */
- public SOAPMessage getSOAPMessage()
- {
- return m_msg;
- }
-
- /**
- * Returns target m_serviceName associated with this context.
- *
- * @return the target m_serviceName that was set with [EMAIL PROTECTED]
#setServiceName(String) setService()}. If set to
- * <code>null</code> or not set at all, by default it returns the
target m_serviceName associated with the
- * underlying SOAP m_msg context.
- */
- public String getServiceName()
- {
- return m_serviceName;
- }
-
- /**
- * DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- */
- public URL getServiceURL()
- {
- return m_serviceURL;
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param name DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- */
- public boolean containsProperty( String name )
- {
- return this.m_propsMap.containsKey( name );
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param name DOCUMENT_ME
- */
- public void removeProperty( String name )
- {
- this.m_propsMap.remove( name );
- }
-
- /**
- * Sets the target m_serviceName of this context.
- *
- * @param serviceName m_serviceName name.
- */
- protected void setServiceName( String serviceName )
- {
- m_serviceName = serviceName;
-
- // reset in case
- synchronized ( this )
- {
- m_home = null;
- m_homeLocation = null;
- }
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param msgContext DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- */
- protected String getServiceName( MessageContext msgContext )
- {
- URL serviceURL = ( m_serviceURL != null ) ? m_serviceURL :
getServiceURL();
- return serviceURL.getFile();
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param msgContext DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- */
- protected URL getServiceURL( MessageContext msgContext )
- {
- if ( msgContext == null )
- {
- throw new IllegalArgumentException( MSG.getMessage( Keys.NULL_MSGCTX
));
- }
-
- AddressingHeaders addrHeaders =
- (AddressingHeaders) msgContext.getProperty(
org.apache.axis.message.addressing.Constants.ENV_ADDRESSING_REQUEST_HEADERS );
-
- try
- {
- String serviceUrl = addrHeaders.getTo().toString();
- LOG.debug(MSG.getMessage( Keys.GET_SERVICE_URL_FROM_ADDR_HDR,
serviceUrl));
- return new URL( serviceUrl );
- }
- catch ( MalformedURLException murle )
- {
- throw new JAXRPCException( murle );
- }
- }
-
- /**
- * Returns the WS-Addressing Action Header
- *
- * @param msgContext
- * @return
- */
- protected String getAddressingAction( MessageContext msgContext )
- {
- if (msgContext == null)
- {
- throw new
IllegalArgumentException(MSG.getMessage(Keys.NULL_MSGCTX));
- }
-
- AddressingHeaders addrHeaders =
- (AddressingHeaders)
msgContext.getProperty(org.apache.axis.message.addressing.Constants.ENV_ADDRESSING_REQUEST_HEADERS);
- if(addrHeaders == null)
- {
- LOG.debug(MSG.getMessage(Keys.NO_ADDR_HDR));
- return null;
- }
-
- Action headerAction = addrHeaders.getAction();
- if(headerAction == null)
- {
- LOG.debug(MSG.getMessage(Keys.NO_ACTION_IN_ADDR_HDR));
- return null;
- }
- String action = headerAction.toString();
- LOG.debug(MSG.getMessage(Keys.GET_ACTION_FROM_ADDR_HDR, action));
- return action;
- }
- private void extractFields( MessageContext msgContext )
- {
- m_serviceURL = getServiceURL( msgContext );
- m_serviceName = getServiceName( msgContext );
- m_baseURL = getBaseURL(m_serviceURL);
- m_action = getAddressingAction(msgContext);
- extractProperties( msgContext );
- }
+ try
+ {
+ resourceKeyClassName = home.getResourceKeyClassName();
+ resourceKeyClass = Class.forName( resourceKeyClassName );
+ }
+ catch ( ClassNotFoundException e )
+ {
+ throw new ResourceException( e );
+ }
+
+ String resourceKeyName = home.getResourceKeyName();
+ QName keyName = null;
+ if ( resourceKeyName != null )
+ {
+ keyName = QName.valueOf( resourceKeyName );
+ }
+
+ ResourceKey key = getResourceKey( keyName, resourceKeyClass );
+ LOG.debug( MSG.getMessage( Keys.LOOKUP_RESOURCE_FOR_KEY,
String.valueOf( key ) ) );
+ Resource resource = home.find( key );
+ LOG.debug( MSG.getMessage( Keys.FOUND_RESOURCE, resource ) );
+ return resource;
+ }
- private String getBaseURL(URL serviceURL)
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ *
+ * @throws NoResourceHomeException DOCUMENT_ME
+ * @throws ResourceContextException DOCUMENT_ME
+ */
+ public synchronized ResourceHome getResourceHome()
+ throws ResourceContextException
+ {
+ if ( m_home == null )
+ {
+ try
+ {
+ m_home = (ResourceHome) new InitialContext().lookup(
getResourceHomeLocation() );
+ }
+ catch ( NamingException ne )
+ {
+ ne.printStackTrace();
+ throw new ResourceContextException( ne );
+ }
+ }
+
+ return m_home;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public synchronized String getResourceHomeLocation()
+ {
+ if ( m_homeLocation == null )
+ {
+ m_homeLocation = JndiConstants.CONTEXT_NAME_SERVICES + "/" +
getServiceName() + "/" +
+ JndiConstants.ATOMIC_NAME_HOME;
+ }
+ LOG.debug( MSG.getMessage( Keys.JNDI_HOME_LOCATION, m_homeLocation ) );
+ return m_homeLocation;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ *
+ * @throws ResourceContextException DOCUMENT_ME
+ */
+ public ResourceKey getResourceKey()
+ throws ResourceContextException
+ {
+ if ( m_resourceKey == null )
+ {
+ ResourceHome resourceHome = getResourceHome();
+ Class resourceKeyClass = null;
+ String resourceKeyClassName = null;
+ try
+ {
+ resourceKeyClassName = resourceHome.getResourceKeyClassName();
+ resourceKeyClass = Class.forName( resourceKeyClassName );
+ }
+ catch ( ClassNotFoundException e )
+ {
+ throw new ResourceContextException( e );
+ }
+ String resourceKeyName = resourceHome.getResourceKeyName();
+
+ QName resourceKeyQName = resourceKeyName != null ? QName.valueOf(
resourceKeyName ) : null;
+ m_resourceKey = getResourceKey( resourceKeyQName, resourceKeyClass
);
+
+ }
+
+ LOG.debug( MSG.getMessage( Keys.RESOURCE_KEY, String.valueOf(
m_resourceKey ) ) );
+
+ return m_resourceKey;
+ }
+
+ /**
+ * Creates a resource key for the current request.
+ *
+ * @param keyName DOCUMENT_ME
+ * @param keyClass DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ *
+ * @throws ResourceContextException DOCUMENT_ME
+ */
+ public ResourceKey getResourceKey( QName keyName,
+ Class keyClass )
+ throws ResourceContextException,
+ ResourceKeyHeaderNotFoundFaultException
+ {
+ if ( keyName == null )
+ {
+ LOG.debug( MSG.getMessage( Keys.NULL_RESOURCE_NAME ) );
+ return null;
+ }
+
+ SOAPHeaderElement headerElem = getResourceKeyHeader( keyName );
+ if ( headerElem == null )
+ {
+ throw new ResourceKeyHeaderNotFoundFaultException( keyName );
+ }
+
+ try
+ {
+ Constructor constructor = keyClass.getConstructor( new
Class[]{SOAPHeaderElement.class} );
+ return (ResourceKey) constructor.newInstance( new
Object[]{headerElem} );
+ }
+ catch ( Exception e )
+ {
+ throw new ResourceContextException( e );
+ }
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ *
+ * @throws ResourceContextException DOCUMENT_ME
+ */
+ public SOAPHeaderElement getResourceKeyHeader()
+ throws ResourceContextException
+ {
+ ResourceHome home = getResourceHome();
+ QName keyName = QName.valueOf( home.getResourceKeyName() );
+ return ( keyName == null ) ? null : getResourceKeyHeader( keyName );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param keyName DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ *
+ * @throws ResourceContextException DOCUMENT_ME
+ */
+ public SOAPHeaderElement getResourceKeyHeader( QName keyName )
+ throws ResourceContextException
+ {
+ try
+ {
+ return AbstractResourceContext.getResourceKeyHeader( this.m_msg,
keyName, null );
+ }
+ catch ( SOAPException e )
+ {
+ throw new ResourceContextException( e );
+ }
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param msg DOCUMENT_ME
+ * @param keyName DOCUMENT_ME
+ * @param actorURI DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ *
+ * @throws SOAPException DOCUMENT_ME
+ * @throws IllegalArgumentException DOCUMENT_ME
+ */
+ public static SOAPHeaderElement getResourceKeyHeader( SOAPMessage msg,
+ QName keyName,
+ String actorURI )
+ throws SOAPException
+ {
+ LOG.debug( MSG.getMessage( Keys.GET_RESOURCEKEY_HEADER,
keyName.toString() ) );
+ if ( msg == null )
+ {
+ throw new IllegalArgumentException( MSG.getMessage(
Keys.NULL_SOAPMSGCTX ) );
+ }
+
+ if ( keyName == null )
+ {
+ throw new IllegalArgumentException( MSG.getMessage(
Keys.NULL_RESOURCEKEY_QNAME ) );
+ }
+
+ SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
+ SOAPHeader header = env.getHeader();
+
+ if ( header == null )
+ {
+ return null;
+ }
+
+ Iterator iter = header.examineHeaderElements( actorURI );
+ while ( iter.hasNext() )
+ {
+ SOAPHeaderElement headerElem = (SOAPHeaderElement) iter.next();
+ Name headerName = headerElem.getElementName();
+
+ if ( headerName.getLocalName().equals( keyName.getLocalPart() )
+ && headerName.getURI().equals( keyName.getNamespaceURI() )
)
+ {
+ // found my header element;
+ return headerElem;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param resourceKeyClass DOCUMENT_ME
+ */
+ public void setResourceKeyClass( Class resourceKeyClass )
+ {
+ m_resourceKeyClass = resourceKeyClass;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param resourceKeyQname DOCUMENT_ME
+ */
+ public void setResourceKeyQname( String resourceKeyQname )
+ {
+ m_resourceKeyQname = resourceKeyQname;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public SOAPMessage getSOAPMessage()
+ {
+ return m_msg;
+ }
+
+ /**
+ * Returns target m_serviceName associated with this context.
+ *
+ * @return the target m_serviceName that was set with [EMAIL PROTECTED]
#setServiceName(String) setService()}. If set to
+ * <code>null</code> or not set at all, by default it returns the
target m_serviceName associated with the
+ * underlying SOAP m_msg context.
+ */
+ public String getServiceName()
+ {
+ return m_serviceName;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public URL getServiceURL()
+ {
+ return m_serviceURL;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param name DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public boolean containsProperty( String name )
+ {
+ return this.m_propsMap.containsKey( name );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param name DOCUMENT_ME
+ */
+ public void removeProperty( String name )
+ {
+ this.m_propsMap.remove( name );
+ }
+
+ /**
+ * Sets the target m_serviceName of this context.
+ *
+ * @param serviceName m_serviceName name.
+ */
+ protected void setServiceName( String serviceName )
+ {
+ m_serviceName = serviceName;
+
+ // reset in case
+ synchronized ( this )
+ {
+ m_home = null;
+ m_homeLocation = null;
+ }
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param msgContext DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ protected String getServiceName( MessageContext msgContext )
+ {
+ URL serviceURL = ( m_serviceURL != null ) ? m_serviceURL :
getServiceURL();
+ return serviceURL.getFile();
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param msgContext DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ protected URL getServiceURL( MessageContext msgContext )
+ {
+ if ( msgContext == null )
+ {
+ throw new IllegalArgumentException( MSG.getMessage(
Keys.NULL_MSGCTX ) );
+ }
+
+ AddressingHeaders addrHeaders =
+ (AddressingHeaders) msgContext.getProperty(
+
org.apache.axis.message.addressing.Constants.ENV_ADDRESSING_REQUEST_HEADERS );
+
+ try
+ {
+ String serviceUrl = addrHeaders.getTo().toString();
+ LOG.debug( MSG.getMessage( Keys.GET_SERVICE_URL_FROM_ADDR_HDR,
serviceUrl ) );
+ return new URL( serviceUrl );
+ }
+ catch ( MalformedURLException murle )
+ {
+ throw new JAXRPCException( murle );
+ }
+ }
+
+ /**
+ * Returns the WS-Addressing Action Header
+ *
+ * @param msgContext
+ *
+ * @return
+ */
+ protected String getAddressingAction( MessageContext msgContext )
+ {
+ if ( msgContext == null )
+ {
+ throw new IllegalArgumentException( MSG.getMessage(
Keys.NULL_MSGCTX ) );
+ }
+
+ AddressingHeaders addrHeaders =
+ (AddressingHeaders) msgContext.getProperty(
+
org.apache.axis.message.addressing.Constants.ENV_ADDRESSING_REQUEST_HEADERS );
+ if ( addrHeaders == null )
+ {
+ LOG.debug( MSG.getMessage( Keys.NO_ADDR_HDR ) );
+ return null;
+ }
+
+ Action headerAction = addrHeaders.getAction();
+ if ( headerAction == null )
+ {
+ LOG.debug( MSG.getMessage( Keys.NO_ACTION_IN_ADDR_HDR ) );
+ return null;
+ }
+ String action = headerAction.toString();
+ LOG.debug( MSG.getMessage( Keys.GET_ACTION_FROM_ADDR_HDR, action ) );
+ return action;
+ }
+
+ private void extractFields( MessageContext msgContext )
+ {
+ m_serviceURL = getServiceURL( msgContext );
+ m_serviceName = getServiceName( msgContext );
+ m_baseURL = getBaseURL( m_serviceURL );
+ m_action = getAddressingAction( msgContext );
+ extractProperties( msgContext );
+ }
+
+ private String getBaseURL( URL serviceURL )
{
String s = serviceURL.toString();
- s= s.substring(0, s.lastIndexOf("/"));
+ s = s.substring( 0, s.lastIndexOf( "/" ) );
return s;
}
private void extractProperties( MessageContext msgContext )
- {
- Iterator propertyNames = msgContext.getPropertyNames();
- while ( propertyNames.hasNext() )
- {
- String keyName = (String) propertyNames.next();
- m_propsMap.put( keyName,
- msgContext.getProperty( keyName ) );
- }
- }
+ {
+ Iterator propertyNames = msgContext.getPropertyNames();
+ while ( propertyNames.hasNext() )
+ {
+ String keyName = (String) propertyNames.next();
+ m_propsMap.put( keyName,
+ msgContext.getProperty( keyName ) );
+ }
+ }
public String getBaseURL()
{
@@ -576,4 +573,5 @@
{
return m_action;
}
-}
\ No newline at end of file
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]