axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdani...@apache.org
Subject svn commit: r611827 - in /webservices/axis2/trunk/java/modules/kernel: src/org/apache/axis2/description/AxisDescription.java src/org/apache/axis2/description/ParameterObserver.java test/org/apache/axis2/description/AxisServiceTest.java
Date Mon, 14 Jan 2008 15:13:33 GMT
Author: gdaniels
Date: Mon Jan 14 07:13:27 2008
New Revision: 611827

URL: http://svn.apache.org/viewvc?rev=611827&view=rev
Log:
Introduce ParameterObserver, so that we can set up watchers for AxisDescription params.

Added:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/ParameterObserver.java
Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisDescription.java
    webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/description/AxisServiceTest.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisDescription.java?rev=611827&r1=611826&r2=611827&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisDescription.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisDescription.java
Mon Jan 14 07:13:27 2008
@@ -54,6 +54,9 @@
 
     protected Map engagedModules;
 
+    /** List of ParameterObservers who want to be notified of changes */
+    protected List parameterObservers = null;
+
     private OMFactory omFactory = OMAbstractFactory.getOMFactory();
 
     // Holds the documentation details for each element
@@ -67,6 +70,18 @@
         children = new HashMap();
     }
 
+    public void addParameterObserver(ParameterObserver observer) {
+        if (parameterObservers == null)
+            parameterObservers = new ArrayList();
+        parameterObservers.add(observer);
+    }
+
+    public void removeParameterObserver(ParameterObserver observer) {
+        if (parameterObservers != null) {
+            parameterObservers.remove(observer);
+        }
+    }
+
     public void addParameter(Parameter param) throws AxisFault {
         if (param == null) {
             return;
@@ -78,6 +93,14 @@
         }
 
         parameterInclude.addParameter(param);
+
+        // Tell anyone who wants to know
+        if (parameterObservers != null) {
+            for (Iterator i = parameterObservers.iterator(); i.hasNext();) {
+                ParameterObserver observer = (ParameterObserver)i.next();
+                observer.parameterChanged(param.getName(), param.getValue());
+            }
+        }
     }
 
     public void addParameter(String name, Object value) throws AxisFault {

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/ParameterObserver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/ParameterObserver.java?rev=611827&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/ParameterObserver.java
(added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/ParameterObserver.java
Mon Jan 14 07:13:27 2008
@@ -0,0 +1,23 @@
+package org.apache.axis2.description;
+/*
+ * 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.
+ */
+
+public interface ParameterObserver {
+    void parameterChanged(String name, Object value);
+}

Modified: webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/description/AxisServiceTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/description/AxisServiceTest.java?rev=611827&r1=611826&r2=611827&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/description/AxisServiceTest.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/description/AxisServiceTest.java
Mon Jan 14 07:13:27 2008
@@ -23,6 +23,19 @@
 import junit.framework.TestCase;
 
 public class AxisServiceTest extends TestCase {
+    public static final String PARAM_NAME = "CustomParameter";
+    public static final Object PARAM_VALUE = new Object();
+
+    class MyObserver implements ParameterObserver {
+        public boolean gotIt = false;
+
+        public void parameterChanged(String name, Object value) {
+            if (PARAM_NAME.equals(name)) {
+                assertEquals("Wrong value", PARAM_VALUE, value);
+                gotIt = true;
+            }
+        }
+    }
 
     public void testAddMessageElementQNameToOperationMappingBasic() {
         AxisService service = new AxisService();
@@ -71,5 +84,13 @@
         
         assertEquals(null, service.getOperationByMessageElementQName(opName));       
     }
-    
+
+    public void testParameterObserver() throws Exception {
+        AxisService service = new AxisService();
+
+        MyObserver observer = new MyObserver();
+        service.addParameterObserver(observer);
+        service.addParameter(PARAM_NAME, PARAM_VALUE);
+        assertTrue("Didn't get notification", observer.gotIt);
+    }
 }



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


Mime
View raw message