You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ek...@apache.org on 2005/06/08 03:39:58 UTC
svn commit: r189487 [2/2] - in /incubator/beehive/trunk/wsm:
drt/tests/org/apache/beehive/wsm/axis/handlers/
drt/webapp/WEB-INF/src/org/apache/beehive/wsm/axis/
src/runtime/org/apache/beehive/wsm/axis/
Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/ControlProvider.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/ControlProvider.java?rev=189487&r1=189486&r2=189487&view=diff
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/ControlProvider.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/ControlProvider.java Tue Jun 7 18:39:57 2005
@@ -1,66 +1,91 @@
-/*
- * ControlProvider.java
- *
- * Copyright 2001-2004 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.
- *
- *
- * Original author: Jonathan Colwell
- */
-package org.apache.beehive.wsm.axis;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-import org.apache.axis.MessageContext;
-import org.apache.axis.providers.java.RPCProvider;
-import org.apache.beehive.controls.api.bean.Control;
-import org.apache.beehive.controls.api.context.ControlBeanContext;
-import org.apache.beehive.controls.api.context.ControlContainerContext;
-import org.apache.beehive.controls.api.context.ControlThreadContext;
-
-/**
- *
- */
-public class ControlProvider
- extends RPCProvider {
-
- /* todo: perf. consider caching fields here */
- protected Object makeNewServiceObject(MessageContext msgContext, String clsName)
- throws Exception {
-
- Object client = super.makeNewServiceObject(msgContext, clsName);
-
- Class clientClass = client.getClass();
-
- /* search for fields with @Control annotations */
- for(Field field : clientClass.getFields()) {
- if(null != field.getAnnotation(Control.class)) {
-
- /* attempt to instantiate a Beehive control using the control's ClientInitializer */
- ControlContainerContext ccc = ControlThreadContext.getContext();
- if(null == ccc)
- throw new Exception("no control container context found");
-
- Class clientInitializer = clientClass.getClassLoader().loadClass(clientClass.getName() + "ClientInitializer");
- Method init = clientInitializer.getMethod("initialize", ControlBeanContext.class, clientClass);
- /* note, the first parameter here is null because the *ClientInitializer.initialize(...) method is static */
- init.invoke(null, ccc, client);
- }
- }
-
- return client;
- }
-}
+/*
+ * ControlProvider.java
+ *
+ * Copyright 2001-2004 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.
+ *
+ *
+ * Original author: Jonathan Colwell
+ */
+package org.apache.beehive.wsm.axis;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import org.apache.axis.AxisFault;
+import org.apache.axis.MessageContext;
+import org.apache.axis.providers.java.RPCProvider;
+import org.apache.beehive.controls.api.bean.Control;
+import org.apache.beehive.controls.api.context.ControlBeanContext;
+import org.apache.beehive.controls.api.context.ControlContainerContext;
+import org.apache.beehive.controls.api.context.ControlThreadContext;
+
+/**
+ *
+ */
+public class ControlProvider extends RPCProvider {
+
+ /* todo: perf. consider caching fields here */
+ protected Object makeNewServiceObject(MessageContext msgContext, String clsName)
+ throws Exception {
+
+ Object client = super.makeNewServiceObject(msgContext, clsName);
+
+ Class clientClass = client.getClass();
+
+ /* search for fields with @Control annotations */
+ for(Field field : clientClass.getFields()) {
+ if(null != field.getAnnotation(Control.class)) {
+
+ /* attempt to instantiate a Beehive control using the control's ClientInitializer */
+ ControlContainerContext ccc = ControlThreadContext.getContext();
+ if(null == ccc)
+ throw new Exception("no control container context found");
+
+ Class clientInitializer = clientClass.getClassLoader().loadClass(clientClass.getName() + "ClientInitializer");
+ Method init = clientInitializer.getMethod("initialize", ControlBeanContext.class, clientClass);
+ /* note, the first parameter here is null because the
+ ClientInitializer.initialize(...) method is static */
+ init.invoke(null, ccc, client);
+ }
+ }
+
+ return client;
+ }
+ public void invoke(MessageContext msgContext) throws AxisFault {
+ try {
+ super.invoke(msgContext);
+ } catch (AxisFault e) {
+
+ // Before we get to here, Axis has converted all exceptions to the
+ // AxisFaults.
+ // A standard AxisFault wont serialize the exception correctly.
+ // AxisFaultAdaptor is used to intercept the serialization process
+ // and
+ // "do the right thing"
+ Throwable origExp = e.detail;
+ if (origExp == null)
+ throw e; // The original exception was AxisFault
+
+ assert !(origExp instanceof AxisFault) : "Unexpected: found AxisFault as detail of AxisFault";
+
+ if (origExp instanceof RuntimeException)
+ throw e; // Let Axis Deal with Runtime exceptions
+
+ // if we have a user defined exception then wrap it in an adaptor.
+ throw new AxisFaultAdaptor(msgContext, origExp);
+ }
+ }
+}