Author: thomas.diesler(a)jboss.com
Date: 2007-03-15 09:14:00 -0400 (Thu, 15 Mar 2007)
New Revision: 2621
Added:
trunk/jbossws-core/src/java/org/jboss/ws/core/server/PropertyCallback.java
Removed:
trunk/jbossws-core/src/java/org/jboss/ws/core/server/MessageContextPropertyHelper.java
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/core/CommonClient.java
trunk/jbossws-core/src/java/org/jboss/ws/core/CommonMessageContext.java
trunk/jbossws-core/src/java/org/jboss/ws/core/CommonSOAP11Binding.java
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/handler/HandlerChainExecutor.java
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/handler/LogicalMessageContextImpl.java
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/handler/MessageContextJAXWS.java
trunk/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpointManager.java
Log:
Implement scoped context properties
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/CommonClient.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/CommonClient.java 2007-03-15 10:53:17
UTC (rev 2620)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/CommonClient.java 2007-03-15 13:14:00
UTC (rev 2621)
@@ -240,14 +240,14 @@
boolean oneway = forceOneway || opMetaData.isOneWay();
// Associate a message context with the current thread
- CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
- msgContext.setOperationMetaData(opMetaData);
+ CommonMessageContext reqContext = MessageContextAssociation.peekMessageContext();
+ reqContext.setOperationMetaData(opMetaData);
// copy properties to the message context
for (String key : getRequestContext().keySet())
{
Object value = getRequestContext().get(key);
- msgContext.setProperty(key, value);
+ reqContext.setProperty(key, value);
}
// The direction of the message
@@ -281,7 +281,7 @@
String targetAddress = getTargetEndpointAddress();
// Fall back to wsa:To
- AddressingProperties addrProps =
(AddressingProperties)msgContext.getProperty(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND);
+ AddressingProperties addrProps =
(AddressingProperties)reqContext.getProperty(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND);
if (targetAddress == null && addrProps != null &&
addrProps.getTo() != null)
{
AddressingConstantsImpl ADDR = new AddressingConstantsImpl();
@@ -318,10 +318,10 @@
}
// at pivot the message context might be replaced
- msgContext = processPivotInternal(msgContext, direction);
+ reqContext = processPivotInternal(reqContext, direction);
// Associate response message with message context
- msgContext.setSOAPMessage(resMessage);
+ reqContext.setSOAPMessage(resMessage);
}
setInboundContextProperties();
@@ -337,7 +337,7 @@
if (handlerPass)
{
// unbind the return values
- SOAPMessage resMessage = msgContext.getSOAPMessage();
+ SOAPMessage resMessage = reqContext.getSOAPMessage();
binding.unbindResponseMessage(opMetaData, resMessage, epInv,
unboundHeaders);
}
@@ -346,13 +346,13 @@
// BP-1.0 R1027
if (handlerPass)
- HandlerChainBaseImpl.checkMustUnderstand(msgContext, new String[] {});
+ HandlerChainBaseImpl.checkMustUnderstand(reqContext, new String[] {});
// Check if protocol handlers modified the payload
if (((SOAPBodyImpl)reqMessage.getSOAPBody()).isModifiedFromSource())
{
- if(log.isDebugEnabled()) log.debug("Handler modified body payload,
unbind message again");
- SOAPMessage resMessage = msgContext.getSOAPMessage();
+ log.debug("Handler modified body payload, unbind message
again");
+ SOAPMessage resMessage = reqContext.getSOAPMessage();
binding.unbindResponseMessage(opMetaData, resMessage, epInv,
unboundHeaders);
}
@@ -364,7 +364,7 @@
catch (Exception ex)
{
// Reverse the message direction
- processPivotInternal(msgContext, direction);
+ processPivotInternal(reqContext, direction);
callFaultHandlerChain(portName, HandlerType.POST, ex);
callFaultHandlerChain(portName, HandlerType.ENDPOINT, ex);
@@ -373,7 +373,7 @@
}
finally
{
- resContext.putAll(msgContext.getProperties());
+ resContext.putAll(reqContext.getProperties());
closeHandlerChain(portName, HandlerType.POST);
closeHandlerChain(portName, HandlerType.ENDPOINT);
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/CommonMessageContext.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/CommonMessageContext.java 2007-03-15
10:53:17 UTC (rev 2620)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/CommonMessageContext.java 2007-03-15
13:14:00 UTC (rev 2621)
@@ -23,14 +23,19 @@
// $Id$
+import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
+import java.util.Set;
import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.handler.MessageContext.Scope;
+import org.jboss.logging.Logger;
import org.jboss.ws.core.jaxrpc.binding.SerializationContext;
-import org.jboss.ws.core.server.MessageContextPropertyHelper;
+import org.jboss.ws.core.server.PropertyCallback;
import org.jboss.ws.metadata.umdm.EndpointMetaData;
import org.jboss.ws.metadata.umdm.OperationMetaData;
import org.jboss.xb.binding.NamespaceRegistry;
@@ -41,12 +46,14 @@
* @author Thomas.Diesler(a)jboss.org
* @since 1-Sep-2006
*/
-public abstract class CommonMessageContext
+public abstract class CommonMessageContext implements Map<String, Object>
{
+ private static Logger log = Logger.getLogger(CommonMessageContext.class);
+
// expandToDOM in the SOAPContentElement should not happen during normal operation
// This property should be set the message context when it is ok to do so.
public static String ALLOW_EXPAND_TO_DOM = "org.jboss.ws.allow.expand.dom";
-
+
// The serialization context for this message ctx
private SerializationContext serContext;
// The operation for this message ctx
@@ -55,8 +62,10 @@
private OperationMetaData opMetaData;
// The SOAPMessage in this message context
private SOAPMessage soapMessage;
- // The map of the properties
- protected Map<String, Object> props = new HashMap<String, Object>();
+ // The map of scoped properties
+ protected Map<String, ScopedProperty> scopedProps = new HashMap<String,
ScopedProperty>();
+ // The current property scope
+ protected Scope currentScope = Scope.APPLICATION;
public CommonMessageContext()
{
@@ -69,9 +78,20 @@
this.opMetaData = msgContext.opMetaData;
this.soapMessage = msgContext.soapMessage;
this.serContext = msgContext.serContext;
- this.props = msgContext.props;
+ this.scopedProps = msgContext.scopedProps;
+ this.currentScope = msgContext.currentScope;
}
+ public Scope getCurrentScope()
+ {
+ return currentScope;
+ }
+
+ public void setCurrentScope(Scope currentScope)
+ {
+ this.currentScope = currentScope;
+ }
+
public EndpointMetaData getEndpointMetaData()
{
if (epMetaData == null && opMetaData != null)
@@ -113,36 +133,38 @@
}
return serContext;
}
-
+
public abstract SerializationContext createSerializationContext();
-
+
public void setSerializationContext(SerializationContext serContext)
{
this.serContext = serContext;
}
-
+
/** Gets the namespace registry for this message context */
public NamespaceRegistry getNamespaceRegistry()
{
return getSerializationContext().getNamespaceRegistry();
}
-
+
+ /** Get the message context properties */
public Map<String, Object> getProperties()
{
+ Map<String, Object> props = new HashMap<String, Object>();
+ for (String key : keySet())
+ {
+ Object value = get(key);
+ props.put(key, value);
+ }
return props;
}
- public void setProperties(Map<String, Object> props)
- {
- this.props = props;
- }
-
/**
* Returns true if the MessageContext contains a property with the specified name.
*/
public boolean containsProperty(String name)
{
- return props.containsKey(name);
+ return containsKey(name);
}
/**
@@ -150,14 +172,7 @@
*/
public Object getProperty(String name)
{
- Object value = props.get(name);
-
- if (value instanceof MessageContextPropertyHelper)
- {
- return ((MessageContextPropertyHelper)value).get();
- }
-
- return value;
+ return get(name);
}
/**
@@ -165,7 +180,7 @@
*/
public Iterator getPropertyNames()
{
- return props.keySet().iterator();
+ return keySet().iterator();
}
/**
@@ -173,7 +188,7 @@
*/
public void removeProperty(String name)
{
- props.remove(name);
+ remove(name);
}
/**
@@ -182,6 +197,194 @@
*/
public void setProperty(String name, Object value)
{
- props.put(name, value);
+ put(name, value);
}
+
+ // Map interface
+
+ public int size()
+ {
+ return scopedProps.size();
+ }
+
+ public boolean isEmpty()
+ {
+ return scopedProps.isEmpty();
+ }
+
+ public boolean containsKey(Object key)
+ {
+ ScopedProperty prop = scopedProps.get(key);
+ return isValidInScope(prop);
+ }
+
+ private boolean isValidInScope(ScopedProperty prop)
+ {
+ // A property of scope APPLICATION is always visible
+ boolean valid = (prop != null && (prop.getScope() == Scope.APPLICATION ||
currentScope == Scope.HANDLER));
+ return valid;
+ }
+
+ public boolean containsValue(Object value)
+ {
+ boolean valueFound = false;
+ for (ScopedProperty prop : scopedProps.values())
+ {
+ if (prop.getValue().equals(value) && isValidInScope(prop))
+ {
+ valueFound = true;
+ break;
+ }
+ }
+ return valueFound;
+ }
+
+ public Object get(Object key)
+ {
+ Object value = null;
+
+ ScopedProperty prop = scopedProps.get(key);
+ if (isValidInScope(prop))
+ value = prop.getValue();
+
+ return value;
+ }
+
+ public Object put(String key, Object value)
+ {
+ ScopedProperty prevProp = scopedProps.get(key);
+ if (prevProp != null && !isValidInScope(prevProp))
+ throw new IllegalArgumentException("Cannot set value for HANDLER scoped
property: " + key);
+
+ scopedProps.put(key, new ScopedProperty(key, value, currentScope));
+ return prevProp != null ? prevProp.getValue() : null;
+ }
+
+ public Object remove(Object key)
+ {
+ ScopedProperty prevProp = scopedProps.get(key);
+ if (prevProp != null && !isValidInScope(prevProp))
+ throw new IllegalArgumentException("Cannot set remove for HANDLER scoped
property: " + key);
+
+ return scopedProps.remove(key);
+ }
+
+ public void putAll(Map<? extends String, ? extends Object> srcMap)
+ {
+ for (String key : srcMap.keySet())
+ {
+ try
+ {
+ Object value = srcMap.get(key);
+ put(key, value);
+ }
+ catch (IllegalArgumentException ex)
+ {
+ log.debug("Ignore: " + ex.getMessage());
+ }
+ }
+ }
+
+ public void clear()
+ {
+ scopedProps.clear();
+ }
+
+ public Set<String> keySet()
+ {
+ return scopedProps.keySet();
+ }
+
+ public Collection<Object> values()
+ {
+ Collection<Object> values = new HashSet<Object>();
+ for (ScopedProperty prop : scopedProps.values())
+ {
+ if (isValidInScope(prop))
+ values.add(prop.getValue());
+
+ }
+ return values;
+ }
+
+ public Set<Entry<String, Object>> entrySet()
+ {
+ Set<Entry<String, Object>> entries = new HashSet<Entry<String,
Object>>();
+ for (ScopedProperty prop : scopedProps.values())
+ {
+ if (isValidInScope(prop))
+ {
+ String name = prop.getName();
+ Object value = prop.getValue();
+ Entry<String, Object> entry = new ImmutableEntry<String,
Object>(name, value);
+ entries.add(entry);
+ }
+ }
+ return entries;
+ }
+
+ private static class ImmutableEntry<K, V> implements Map.Entry<K, V>
+ {
+ final K k;
+ final V v;
+
+ ImmutableEntry(K key, V value)
+ {
+ k = key;
+ v = value;
+ }
+
+ public K getKey()
+ {
+ return k;
+ }
+
+ public V getValue()
+ {
+ return v;
+ }
+
+ public V setValue(V value)
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ public static class ScopedProperty
+ {
+ private Scope scope;
+ private String name;
+ private Object value;
+
+ public ScopedProperty(String name, Object value, Scope scope)
+ {
+ this.scope = scope;
+ this.name = name;
+ this.value = value;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public Scope getScope()
+ {
+ return scope;
+ }
+
+ public Object getValue()
+ {
+ Object realValue = value;
+ if (value instanceof PropertyCallback)
+ realValue = ((PropertyCallback)value).get();
+
+ return realValue;
+ }
+
+ public String toString()
+ {
+ return scope + ":" + name + "=" + value;
+ }
+ }
}
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/CommonSOAP11Binding.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/CommonSOAP11Binding.java 2007-03-15
10:53:17 UTC (rev 2620)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/CommonSOAP11Binding.java 2007-03-15
13:14:00 UTC (rev 2621)
@@ -26,16 +26,13 @@
import java.util.Set;
import javax.xml.namespace.QName;
-import javax.xml.rpc.soap.SOAPFaultException;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPFactory;
import javax.xml.soap.SOAPHeaderElement;
import javax.xml.soap.SOAPMessage;
import org.jboss.ws.Constants;
import org.jboss.ws.core.jaxrpc.Use;
-import org.jboss.ws.core.jaxrpc.handler.HandlerDelegateJAXRPC;
import org.jboss.ws.core.soap.MessageFactoryImpl;
import org.jboss.ws.core.soap.SOAPFaultImpl;
import org.jboss.ws.metadata.umdm.OperationMetaData;
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/handler/HandlerChainExecutor.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/handler/HandlerChainExecutor.java 2007-03-15
10:53:17 UTC (rev 2620)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/handler/HandlerChainExecutor.java 2007-03-15
13:14:00 UTC (rev 2621)
@@ -33,6 +33,7 @@
import javax.xml.ws.handler.Handler;
import javax.xml.ws.handler.LogicalHandler;
import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.MessageContext.Scope;
import org.jboss.logging.Logger;
import org.jboss.ws.core.CommonMessageContext;
@@ -296,40 +297,61 @@
throw new WebServiceException(ex);
}
- private boolean handleMessage(Handler currHandler, SOAPMessageContextJAXWS
soapContext)
+ private boolean handleMessage(Handler currHandler, SOAPMessageContextJAXWS
msgContext)
{
- MessageContext handlerContext = soapContext;
+ MessageContext handlerContext = msgContext;
if (currHandler instanceof LogicalHandler)
{
if (epMetaData.getStyle() == Style.RPC)
throw new WebServiceException("Cannot use logical handler with
RPC");
- handlerContext = new LogicalMessageContextImpl(soapContext);
+ handlerContext = new LogicalMessageContextImpl(msgContext);
}
if (closeHandlers.contains(currHandler) == false)
closeHandlers.add(currHandler);
- boolean doNext = currHandler.handleMessage(handlerContext);
+
+ boolean doNext = false;
+ Scope scope = msgContext.getCurrentScope();
+ try
+ {
+ msgContext.setCurrentScope(Scope.HANDLER);
+ doNext = currHandler.handleMessage(handlerContext);
+ }
+ finally
+ {
+ msgContext.setCurrentScope(scope);
+ }
return doNext;
}
- private boolean handleFault(Handler currHandler, SOAPMessageContextJAXWS soapContext)
+ private boolean handleFault(Handler currHandler, SOAPMessageContextJAXWS msgContext)
{
- MessageContext handlerContext = soapContext;
+ MessageContext handlerContext = msgContext;
if (currHandler instanceof LogicalHandler)
{
if (epMetaData.getStyle() == Style.RPC)
throw new WebServiceException("Cannot use logical handler with
RPC");
- handlerContext = new LogicalMessageContextImpl(soapContext);
+ handlerContext = new LogicalMessageContextImpl(msgContext);
}
if (closeHandlers.contains(currHandler) == false)
closeHandlers.add(currHandler);
- boolean doNext = currHandler.handleFault(handlerContext);
+ boolean doNext = false;
+ Scope scope = msgContext.getCurrentScope();
+ try
+ {
+ msgContext.setCurrentScope(Scope.HANDLER);
+ doNext = currHandler.handleFault(handlerContext);
+ }
+ finally
+ {
+ msgContext.setCurrentScope(scope);
+ }
return doNext;
}
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/handler/LogicalMessageContextImpl.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/handler/LogicalMessageContextImpl.java 2007-03-15
10:53:17 UTC (rev 2620)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/handler/LogicalMessageContextImpl.java 2007-03-15
13:14:00 UTC (rev 2621)
@@ -39,14 +39,12 @@
// The LogicalMessage in this message context
private LogicalMessage logicalMessage;
- /** Default ctor */
public LogicalMessageContextImpl(SOAPMessageContextJAXWS soapContext)
{
+ super(soapContext);
+
SOAPMessage soapMessage = soapContext.getMessage();
logicalMessage = new LogicalMessageImpl(soapMessage);
-
- // Copy the context properties
- setProperties(soapContext.getProperties());
}
/**
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/handler/MessageContextJAXWS.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/handler/MessageContextJAXWS.java 2007-03-15
10:53:17 UTC (rev 2620)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/handler/MessageContextJAXWS.java 2007-03-15
13:14:00 UTC (rev 2621)
@@ -24,7 +24,7 @@
// $Id: MessageContextImpl.java 275 2006-05-04 21:36:29Z jason.greene(a)jboss.com $
import java.util.Collection;
-import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -56,9 +56,6 @@
{
private static Logger log = Logger.getLogger(MessageContextJAXWS.class);
- // The map of property scopes
- private HashMap<String, Scope> scopes = new HashMap<String, Scope>();
-
public MessageContextJAXWS()
{
}
@@ -89,13 +86,21 @@
/** Sets the scope of a property. */
public void setScope(String key, Scope scope)
{
- scopes.put(key, scope);
+ ScopedProperty prop = scopedProps.get(key);
+ if (prop == null)
+ throw new IllegalArgumentException("Cannot find scoped property: " +
key);
+
+ scopedProps.put(key, new ScopedProperty(key, prop.getValue(), scope));
}
/** Gets the scope of a property. */
public Scope getScope(String key)
{
- return scopes.get(key);
+ ScopedProperty prop = scopedProps.get(key);
+ if (prop == null)
+ throw new IllegalArgumentException("Cannot find scoped property: " +
key);
+
+ return prop.getScope();
}
public static CommonMessageContext processPivot(CommonMessageContext reqContext)
@@ -104,14 +109,14 @@
// MTOM setting need to pass past pivot
boolean mtomEnabled = XOPContext.isMTOMEnabled();
-
+
// Reverse the direction
Boolean outbound =
(Boolean)reqContext.getProperty(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
outbound = new Boolean(!outbound.booleanValue());
-
+
// Preserve addressing properties
SOAPAddressingProperties addrProps =
(SOAPAddressingProperties)reqContext.getProperty(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND);
-
+
MessageContextAssociation.popMessageContext();
SOAPMessageContextJAXWS resContext = new SOAPMessageContextJAXWS(reqContext);
resContext.setSOAPMessage(null);
@@ -124,66 +129,4 @@
return resContext;
}
-
- // Map interface
-
- public int size()
- {
- return props.size();
- }
-
- public boolean isEmpty()
- {
- return props.isEmpty();
- }
-
- public boolean containsKey(Object key)
- {
- return props.containsKey(key);
- }
-
- public boolean containsValue(Object value)
- {
- return props.containsValue(value);
- }
-
- public Object get(Object key)
- {
- return props.get(key);
- }
-
- public Object put(String key, Object value)
- {
- return props.put(key, value);
- }
-
- public Object remove(Object key)
- {
- return props.remove(key);
- }
-
- public void putAll(Map<? extends String, ? extends Object> srcMap)
- {
- props.putAll(srcMap);
- }
-
- public void clear()
- {
- props.clear();
- }
-
- public Set<String> keySet()
- {
- return props.keySet();
- }
-
- public Collection<Object> values()
- {
- return props.values();
- }
-
- public Set<Entry<String, Object>> entrySet()
- {
- return props.entrySet();
- }
}
Deleted:
trunk/jbossws-core/src/java/org/jboss/ws/core/server/MessageContextPropertyHelper.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/core/server/MessageContextPropertyHelper.java 2007-03-15
10:53:17 UTC (rev 2620)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/server/MessageContextPropertyHelper.java 2007-03-15
13:14:00 UTC (rev 2621)
@@ -1,41 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.server;
-
-/**
- * Interface to be implemented by property helpers to assist the retrieval
- * of objects added to the property context.
- *
- * If an instance of MessageContextPropertyHelper is added to the
- * CommonMessageContext a call to get for the same property will return
- * the result of callig get on the helper instead of returning the helper
- * itself.
- *
- * @author darran.lofthouse(a)jboss.com
- * @since Oct 22, 2006
- */
-public interface MessageContextPropertyHelper
-{
-
- public Object get();
-
-}
Copied: trunk/jbossws-core/src/java/org/jboss/ws/core/server/PropertyCallback.java (from
rev 2616,
trunk/jbossws-core/src/java/org/jboss/ws/core/server/MessageContextPropertyHelper.java)
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/server/PropertyCallback.java
(rev 0)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/server/PropertyCallback.java 2007-03-15
13:14:00 UTC (rev 2621)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.server;
+
+/**
+ * Interface to be implemented by property helpers to assist the retrieval
+ * of objects added to the property context.
+ *
+ * If an instance of MessageContextPropertyHelper is added to the
+ * CommonMessageContext a call to get for the same property will return
+ * the result of callig get on the helper instead of returning the helper
+ * itself.
+ *
+ * @author darran.lofthouse(a)jboss.com
+ * @since Oct 22, 2006
+ */
+public interface PropertyCallback
+{
+ Object get();
+}
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpointManager.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpointManager.java 2007-03-15
10:53:17 UTC (rev 2620)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpointManager.java 2007-03-15
13:14:00 UTC (rev 2621)
@@ -402,7 +402,7 @@
ServerEndpointMetaData sepMetaData =
wsEndpoint.getServiceEndpointInfo().getServerEndpointMetaData();
Type type = sepMetaData.getType();
- MessageContextPropertyHelper httpSession = new HttpSessionPropertyHelper(context);
+ PropertyCallback httpSessionCallback = new HttpSessionPropertyCallback(context);
ServletContext servletContext = context.getServletContext();
HttpServletRequest httpRequest = context.getHttpServletRequest();
HttpServletResponse httpResponse = context.getHttpServletResponse();
@@ -416,7 +416,7 @@
msgContext.setProperty(MessageContextJAXRPC.SERVLET_CONTEXT, servletContext);
msgContext.setProperty(MessageContextJAXRPC.SERVLET_REQUEST, httpRequest);
msgContext.setProperty(MessageContextJAXRPC.SERVLET_RESPONSE, httpResponse);
- msgContext.setProperty(MessageContextJAXRPC.SERVLET_SESSION, httpSession);
+ msgContext.setProperty(MessageContextJAXRPC.SERVLET_SESSION,
httpSessionCallback);
}
else
{
@@ -705,12 +705,11 @@
return server;
}
- public static class HttpSessionPropertyHelper implements MessageContextPropertyHelper
+ public static class HttpSessionPropertyCallback implements PropertyCallback
{
-
private EndpointContext context;
- public HttpSessionPropertyHelper(final EndpointContext context)
+ public HttpSessionPropertyCallback(final EndpointContext context)
{
this.context = context;
}
@@ -719,6 +718,5 @@
{
return context.getHttpSession();
}
-
}
}