You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sc...@apache.org on 2007/11/27 20:08:57 UTC
svn commit: r598734 - in /webservices/axis2/trunk/java/modules:
jaxws/src/org/apache/axis2/jaxws/core/
jaxws/src/org/apache/axis2/jaxws/core/controller/
jaxws/src/org/apache/axis2/jaxws/handler/
kernel/src/org/apache/axis2/context/
Author: scheu
Date: Tue Nov 27 11:08:54 2007
New Revision: 598734
URL: http://svn.apache.org/viewvc?rev=598734&view=rev
Log:
AXIS2-3267
Contributor:Rich Scheuerle
Performance Analysis:David Strite
Summary of Changes:
* Added a new getLocalProperty method on the MessageContext that can be used to
access the MessageContext properties (and avoid the option properties).
* Improved the processing of the get/setProperty methods on the JAX-WS MessageContext to
use the new getLocalProperty method.
* Added a containsKey(..) method to the JAX-WS MessageContext.
* Eliminated a lot of historical code in the JAX-WS MessageContext to improve readability.
* Changed several classes in JAX-WS to use the new containsKey(..) method. (This is more
efficient. The old algorithm created copies of the map.)
Modified:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/MessageContext.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/MEPContext.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/MessageContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/MessageContext.java?rev=598734&r1=598733&r2=598734&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/MessageContext.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/MessageContext.java Tue Nov 27 11:08:54 2007
@@ -52,7 +52,6 @@
private InvocationContext invocationCtx;
private org.apache.axis2.context.MessageContext axisMsgCtx;
- private Map<String, Object> properties;
private EndpointDescription endpointDesc;
private OperationDescription operationDesc;
private QName operationName; //FIXME: This should become the OperationDescription
@@ -61,10 +60,6 @@
private boolean isOutbound; // Outbound or inbound message context
private boolean isServer = false; // Indicate if server role, default is false
- // TODO: flag to set whether we delegate property setting up to the
- // axis2 message context object or keep it local
- private boolean DELEGATE_TO_AXISMC = true;
-
/*
* JAXWS runtime uses a request and response mc, but we need to know the pair.
* We will use this mepCtx as a wrapper to the request and response message contexts
@@ -85,10 +80,6 @@
public MessageContext() {
axisMsgCtx = new org.apache.axis2.context.MessageContext();
isOutbound = true;
- if (!DELEGATE_TO_AXISMC) {
- properties = new HashMap<String, Object>();
- }
-
}
/**
@@ -98,9 +89,6 @@
* @throws WebServiceException
*/
public MessageContext(org.apache.axis2.context.MessageContext mc) throws WebServiceException {
- if (!DELEGATE_TO_AXISMC) {
- properties = new HashMap<String, Object>();
- }
// Assume inbound (caller must setOutbound)
isOutbound = false;
@@ -130,65 +118,41 @@
}
public Map<String, Object> getProperties() {
- if (DELEGATE_TO_AXISMC) {
- // only use properties that are local to the axis2 MC,
- // not the options bag. See org.apache.axis2.context.AbstractContext
- Iterator names = axisMsgCtx.getPropertyNames();
- HashMap tempProps = new HashMap<String, Object>();
- for (; names.hasNext();) {
- String name = (String)names.next();
- tempProps.put(name, axisMsgCtx.getProperty(name));
- }
- //return new ReadOnlyProperties(tempProps);
- return tempProps;
+ // only use properties that are local to the axis2 MC,
+ // not the options bag. See org.apache.axis2.context.AbstractContext
+ Iterator names = axisMsgCtx.getPropertyNames();
+ HashMap tempProps = new HashMap<String, Object>();
+ for (; names.hasNext();) {
+ String name = (String)names.next();
+ tempProps.put(name, axisMsgCtx.getProperty(name));
}
- return properties;
+ //return new ReadOnlyProperties(tempProps);
+ return tempProps;
}
public void setProperties(Map<String, Object> _properties) {
- if (DELEGATE_TO_AXISMC) {
- // make sure copy is made, not just reference:
- _properties.put(org.apache.axis2.context.MessageContext.COPY_PROPERTIES, true);
- axisMsgCtx.setProperties(_properties);
- } else {
- getProperties().putAll(_properties);
- }
+ // make sure copy is made, not just reference:
+ _properties.put(org.apache.axis2.context.MessageContext.COPY_PROPERTIES, true);
+ axisMsgCtx.setProperties(_properties);
}
public Object getProperty(String key) {
- if (DELEGATE_TO_AXISMC) {
- // only use properties that are local to the axis2 MC,
- // not the options bag. See org.apache.axis2.context.AbstractContext
- Iterator names = axisMsgCtx.getPropertyNames();
- for (; names.hasNext();) {
- String name = (String)names.next();
- if (name.equals(key)) {
- return axisMsgCtx.getProperty(key);
- }
- }
- return null;
- }
- return getProperties().get(key);
+ // only use properties that are local to the axis2 MC.
+ return axisMsgCtx.getLocalProperty(key, false);
+ }
+
+ public boolean containsKey(Object key) {
+ // Only use properties that are local to the axis2 MC.
+ // @see getProperty(String key)
+ return (key instanceof String && getProperty((String)key) != null);
}
// acts like Map.put(key, value)
public Object setProperty(String key, Object value) {
- if (DELEGATE_TO_AXISMC) {
- // only use properties that are local to the axis2 MC,
- // not the options bag. See org.apache.axis2.context.AbstractContext
- Object retval = null;
- Iterator names = axisMsgCtx.getPropertyNames();
- for (; names.hasNext();) {
- String name = (String)names.next();
- if (name.equals(key)) {
- retval = axisMsgCtx.getProperty(key);
- }
- }
- axisMsgCtx.setProperty(key, value);
- return retval;
- } else {
- return getProperties().put(key, value);
- }
+ // only use properties that are local to the axis2 MC
+ Object retval = axisMsgCtx.getLocalProperty(key, false);
+ axisMsgCtx.setProperty(key, value);
+ return retval;
}
public EndpointDescription getEndpointDescription() {
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java?rev=598734&r1=598733&r2=598734&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java Tue Nov 27 11:08:54 2007
@@ -482,7 +482,6 @@
* of performance.
*/
private void setupProperties(MessageContext mc) {//, Options ops) {
- Map<String, Object> properties = mc.getProperties();
// Enable MTOM
Message msg = mc.getMessage();
@@ -497,16 +496,16 @@
// Check to see if BASIC_AUTH is enabled. If so, make sure
// the properties are setup correctly.
- if (properties.containsKey(BindingProvider.USERNAME_PROPERTY) &&
- properties.containsKey(BindingProvider.PASSWORD_PROPERTY)) {
+ if (mc.containsKey(BindingProvider.USERNAME_PROPERTY) &&
+ mc.containsKey(BindingProvider.PASSWORD_PROPERTY)) {
- String userId = (String)properties.get(BindingProvider.USERNAME_PROPERTY);
+ String userId = (String)mc.getProperty(BindingProvider.USERNAME_PROPERTY);
if (userId == null || userId == "") {
throw ExceptionFactory
.makeWebServiceException(Messages.getMessage("checkUserName"));
}
- String password = (String)properties.get(BindingProvider.PASSWORD_PROPERTY);
+ String password = (String)mc.getProperty(BindingProvider.PASSWORD_PROPERTY);
if (password == null || password == "") {
throw ExceptionFactory
.makeWebServiceException(Messages.getMessage("checkPassword"));
@@ -514,8 +513,8 @@
URL url = null;
try {
- url = new URL((String)mc.getProperties()
- .get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY));
+ url = new URL((String)mc
+ .getProperty(BindingProvider.ENDPOINT_ADDRESS_PROPERTY));
}
catch (MalformedURLException e) {
throw ExceptionFactory.makeWebServiceException(e);
@@ -530,10 +529,10 @@
basicAuthentication.setPreemptiveAuthentication(true);
mc.setProperty(HTTPConstants.AUTHENTICATE, basicAuthentication);
- } else if ((!properties.containsKey(BindingProvider.USERNAME_PROPERTY) &&
- properties.containsKey(BindingProvider.PASSWORD_PROPERTY)) ||
- (properties.containsKey(BindingProvider.USERNAME_PROPERTY) &&
- !properties.containsKey(BindingProvider.PASSWORD_PROPERTY))) {
+ } else if ((!mc.containsKey(BindingProvider.USERNAME_PROPERTY) &&
+ mc.containsKey(BindingProvider.PASSWORD_PROPERTY)) ||
+ (mc.containsKey(BindingProvider.USERNAME_PROPERTY) &&
+ !mc.containsKey(BindingProvider.PASSWORD_PROPERTY))) {
throw ExceptionFactory
.makeWebServiceException(Messages.getMessage("checkUsernameAndPassword"));
}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/MEPContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/MEPContext.java?rev=598734&r1=598733&r2=598734&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/MEPContext.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/MEPContext.java Tue Nov 27 11:08:54 2007
@@ -160,13 +160,13 @@
return getApplicationScopedProperties().containsKey(key);
}
if (responseMC != null) {
- boolean containsKey = responseMC.getProperties().containsKey(key) || requestMC.getProperties().containsKey(key);
+ boolean containsKey = responseMC.containsKey(key) || requestMC.containsKey(key);
if ((getScope((String)key) == Scope.APPLICATION) || (!isApplicationAccessLocked())) {
return containsKey;
}
}
if ((getScope((String)key) == Scope.APPLICATION) || (!isApplicationAccessLocked())) {
- return requestMC.getProperties().containsKey(key);
+ return requestMC.containsKey(key);
}
return false;
}
@@ -239,7 +239,7 @@
if (scopes.get(key) == null) { // check the scopes object directly, not through getScope()!!
setScope(key, Scope.HANDLER);
}
- if (requestMC.getProperties().containsKey(key)) {
+ if (requestMC.containsKey(key)) {
return requestMC.setProperty(key, value);
}
if (responseMC != null) {
@@ -273,6 +273,7 @@
}
// yes, remove from both and return the right object
+ // TODO This won't work because getProperties returns a temporary map
Object retVal = null;
if (responseMC != null) {
retVal = responseMC.getProperties().remove(key);
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java?rev=598734&r1=598733&r2=598734&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java Tue Nov 27 11:08:54 2007
@@ -861,12 +861,15 @@
/**
* Retrieves a property value. The order of search is as follows: search in
- * my own options and then look locally. Does not search up the hierarchy.
+ * my own map and then look at my options. Does not search up the hierarchy.
*
* @param name name of the property to search for
* @return the value of the property, or null if the property is not found
*/
public Object getLocalProperty(String name) {
+ return getLocalProperty(name, true);
+ }
+ public Object getLocalProperty(String name, boolean searchOptions) {
if (LoggingControl.debugLoggingAllowed) {
checkActivateWarning("getProperty");
}
@@ -877,9 +880,11 @@
return obj;
}
- obj = options.getProperty(name);
- if (obj != null) {
- return obj;
+ if (searchOptions) {
+ obj = options.getProperty(name);
+ if (obj != null) {
+ return obj;
+ }
}
// tough
@@ -888,9 +893,10 @@
/**
* Retrieves a property value. The order of search is as follows: search in
- * my own options and then look in my context hierarchy. Since its possible
+ * my own map and then look in my context hierarchy, and then in options.
+ * Since its possible
* that the entire hierarchy is not present, I will start at whatever level
- * has been set and start there.
+ * has been set.
*
* @param name name of the property to search for
* @return the value of the property, or null if the property is not found
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org