axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chinth...@apache.org
Subject svn commit: r421899 - in /webservices/axis2/trunk/java/modules/core/src/org/apache/axis2: Service.java engine/DependencyManager.java
Date Fri, 14 Jul 2006 13:27:45 GMT
Author: chinthaka
Date: Fri Jul 14 06:27:45 2006
New Revision: 421899

URL: http://svn.apache.org/viewvc?rev=421899&view=rev
Log:
Adding an interface so that service authors can implement to get information from Axis2. see
http://marc.theaimsgroup.com/?l=axis-user&m=115286531111675&w=2

Added:
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/Service.java
Modified:
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/DependencyManager.java

Added: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/Service.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/Service.java?rev=421899&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/Service.java (added)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/Service.java Fri Jul 14
06:27:45 2006
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2004,2005 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.axis2;
+
+import org.apache.axis2.context.OperationContext;
+
+/**
+ * This class *may* be implemented by any service which require some information from Axis2
engine,
+ * but its not a must.
+ */
+public interface Service {
+
+    /**
+     * This will pass the operation context to the service implementation class and will
be called
+     * by the in-built Axis2 message receivers.
+     * @param operationContext
+     */
+    public void setOperationContext(OperationContext operationContext);
+}

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/DependencyManager.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/DependencyManager.java?rev=421899&r1=421898&r2=421899&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/DependencyManager.java
(original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/DependencyManager.java
Fri Jul 14 06:27:45 2006
@@ -18,6 +18,7 @@
 package org.apache.axis2.engine;
 
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.Service;
 import org.apache.axis2.context.OperationContext;
 import org.apache.axis2.context.ServiceContext;
 import org.apache.axis2.context.ServiceGroupContext;
@@ -44,18 +45,26 @@
                                                       OperationContext opCtx)
             throws AxisFault {
         try {
-            Class classToLoad = obj.getClass();
-            // We can not call classToLoad.getDeclaredMethed() , since there
-            //  can be insatnce where mutiple services extends using one class
-            // just for init and other reflection methods
-            Method[] methods = classToLoad.getMethods();
-
-            for (int i = 0; i < methods.length; i++) {
-                if (MESSAGE_CONTEXT_INJECTION_METHOD.equals(methods[i].getName())
-                        && (methods[i].getParameterTypes().length == 1)
-                        && (methods[i].getParameterTypes()[0] == OperationContext.class))
{
-                    methods[i].invoke(obj, new Object[]{opCtx});
-                    break;
+
+            // if this service is implementing the o.a.a.Service interface, then use that
fact to invoke the
+            // proper method.
+            if (obj instanceof Service) {
+                ((Service) obj).setOperationContext(opCtx);
+            } else {
+                Class classToLoad = obj.getClass();
+
+                // We can not call classToLoad.getDeclaredMethed() , since there
+                //  can be insatnce where mutiple services extends using one class
+                // just for init and other reflection methods
+                Method[] methods = classToLoad.getMethods();
+
+                for (int i = 0; i < methods.length; i++) {
+                    if (MESSAGE_CONTEXT_INJECTION_METHOD.equals(methods[i].getName())
+                            && (methods[i].getParameterTypes().length == 1)
+                            && (methods[i].getParameterTypes()[0] == OperationContext.class))
{
+                        methods[i].invoke(obj, new Object[]{opCtx});
+                        break;
+                    }
                 }
             }
         } catch (SecurityException e) {



---------------------------------------------------------------------
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