You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ng...@apache.org on 2007/03/15 01:31:34 UTC

svn commit: r518394 - in /webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/migrator: ./ ContextPropertyMigrator.java ContextPropertyMigratorUtil.java

Author: ngallardo
Date: Wed Mar 14 17:31:33 2007
New Revision: 518394

URL: http://svn.apache.org/viewvc?view=rev&rev=518394
Log:
AXIS2-2317

The APIs for the migrator.

Added:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/migrator/
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/migrator/ContextPropertyMigrator.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/migrator/ContextPropertyMigratorUtil.java

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/migrator/ContextPropertyMigrator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/migrator/ContextPropertyMigrator.java?view=auto&rev=518394
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/migrator/ContextPropertyMigrator.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/migrator/ContextPropertyMigrator.java Wed Mar 14 17:31:33 2007
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.axis2.jaxws.spi.migrator;
+
+import java.util.Map;
+
+import org.apache.axis2.jaxws.core.MessageContext;
+
+/**
+ * The ContextPropertyMigrator is a utility interface that can be implemented to handle any 
+ * transformation or migration that needs to happen between the internal JAX-WS MessageContext 
+ * for a request or a response and the associated context for the client or the server.
+ * 
+ * client - On the client side, this will be called with the request or response context 
+ *          from the BindingProvider instance.
+ *          
+ * server - On the server side, this will be called with the javax.xml.ws.handler.MessageContext
+ *          instance that the service endpoint will see.  This is the same context that will
+ *          be injected 
+ *
+ */
+public interface ContextPropertyMigrator {
+    
+    /**
+     * Is called to handle property migration FROM the user context (BindingProvider client context or server
+     * MessageContext) TO a target internal org.apache.axis2.jaxws.core.MessageContext.
+     * 
+     * @param userContext    - The source context that contains the user context properties.
+     * @param messageContext - The target MessageContext to receive the properties.
+     */
+    public void migratePropertiesToMessageContext(Map<String, Object> userContext, MessageContext messageContext);
+    
+    /**
+     * Is called to handle property migratom FROM the internal org.apache.axis2.jaxws.core.MessageContext TO a 
+     * target user context (BindingProvider client context or server MessageContext) that the user will access.
+     * 
+     * @param userContext     - The target user context to receive the properties.
+     * @param messageContext  - The source MessageContext that contains the property values.
+     */
+    public void migratePropertiesFromMessageContext(Map<String, Object> userContext, MessageContext messageContext);
+
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/migrator/ContextPropertyMigratorUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/migrator/ContextPropertyMigratorUtil.java?view=auto&rev=518394
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/migrator/ContextPropertyMigratorUtil.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/migrator/ContextPropertyMigratorUtil.java Wed Mar 14 17:31:33 2007
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.axis2.jaxws.spi.migrator;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.core.MessageContext;
+
+public class ContextPropertyMigratorUtil {
+    
+    /**
+     * Register a new ContextPropertyMigrator.
+     * 
+     * @param configurationContext
+     * @param contextMigratorListID The name of the property in the
+     *                              ConfigurationContext that contains
+     *                              the list of migrators.
+     * @param migrator
+     */
+    public static void addContextPropertyMigrator(ConfigurationContext configurationContext, 
+                                                  String contextMigratorListID, 
+                                                  ContextPropertyMigrator migrator) {
+        List<ContextPropertyMigrator> migratorList = (List<ContextPropertyMigrator>) configurationContext.getProperty(contextMigratorListID);
+
+        if (migratorList == null) {
+            migratorList = new LinkedList<ContextPropertyMigrator>();
+            configurationContext.setProperty(contextMigratorListID, migratorList);
+        }
+      
+        migratorList.add(migrator);
+    }
+
+    /**
+     * 
+     * @param contextMigratorListID
+     * @param requestContext
+     * @param messageContext
+     */
+    public static void performMigrationToMessageContext(String contextMigratorListID,
+                                                        Map<String, Object> requestContext,
+                                                        MessageContext messageContext) {
+        if (messageContext == null) {
+            throw ExceptionFactory.makeWebServiceException("Null MessageContext");
+        }
+        
+        ConfigurationContext configCtx = messageContext.getServiceDescription().getAxisConfigContext();
+        List<ContextPropertyMigrator> migratorList = (List<ContextPropertyMigrator>) configCtx.getProperty(contextMigratorListID);
+        
+        if (migratorList != null) {
+            ListIterator<ContextPropertyMigrator> itr = migratorList.listIterator();
+            while (itr.hasNext()) {
+                ContextPropertyMigrator cpm = itr.next();
+                cpm.migratePropertiesToMessageContext(requestContext, messageContext);
+            }
+        }        
+    }
+    
+    /**
+     * 
+     * @param contextMigratorListID
+     * @param responseContext
+     * @param messageContext
+     */
+    public static void performMigrationFromMessageContext(String contextMigratorListID,
+                                                          Map<String, Object> responseContext,
+                                                          MessageContext messageContext) {
+        if (messageContext == null) {
+            throw ExceptionFactory.makeWebServiceException("Null MessageContext");
+        }
+        
+        ConfigurationContext configCtx = messageContext.getServiceDescription().getAxisConfigContext();
+        List<ContextPropertyMigrator> migratorList = (List<ContextPropertyMigrator>) configCtx.getProperty(contextMigratorListID);
+        
+        if (migratorList != null) {
+            ListIterator<ContextPropertyMigrator> itr = migratorList.listIterator();
+            while (itr.hasNext()) {
+                ContextPropertyMigrator cpm = itr.next();
+                cpm.migratePropertiesFromMessageContext(responseContext, messageContext);
+            }
+        }        
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org