You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2006/08/11 11:01:47 UTC
svn commit: r430728 -
/incubator/tuscany/java/sca/spi/src/main/java/org/apache/tuscany/spi/extension/TargetInvokerExtension.java
Author: antelder
Date: Fri Aug 11 02:01:47 2006
New Revision: 430728
URL: http://svn.apache.org/viewvc?rev=430728&view=rev
Log:
Add an SPI extension class to simplify implementing a TargetInvoker
Added:
incubator/tuscany/java/sca/spi/src/main/java/org/apache/tuscany/spi/extension/TargetInvokerExtension.java
Added: incubator/tuscany/java/sca/spi/src/main/java/org/apache/tuscany/spi/extension/TargetInvokerExtension.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/spi/src/main/java/org/apache/tuscany/spi/extension/TargetInvokerExtension.java?rev=430728&view=auto
==============================================================================
--- incubator/tuscany/java/sca/spi/src/main/java/org/apache/tuscany/spi/extension/TargetInvokerExtension.java (added)
+++ incubator/tuscany/java/sca/spi/src/main/java/org/apache/tuscany/spi/extension/TargetInvokerExtension.java Fri Aug 11 02:01:47 2006
@@ -0,0 +1,63 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation or its licensors as applicable
+ *
+ * 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.tuscany.spi.extension;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * The default implementation of a TargetInvoker
+ */
+public abstract class TargetInvokerExtension implements TargetInvoker {
+
+ private boolean cacheable;
+
+ public TargetInvokerExtension() {
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ try {
+ Object resp = invokeTarget(msg.getBody());
+ msg.setBody(resp);
+ } catch (InvocationTargetException e) {
+ msg.setBody(e.getCause());
+ }
+ return msg;
+ }
+
+ public boolean isCacheable() {
+ return cacheable;
+ }
+
+ public void setCacheable(boolean cacheable) {
+ this.cacheable = cacheable;
+ }
+
+ public boolean isOptimizable() {
+ return isCacheable();
+ }
+
+ public Object clone() throws CloneNotSupportedException {
+ TargetInvokerExtension clonedInvoker = (TargetInvokerExtension) super.clone();
+ clonedInvoker.cacheable = this.cacheable;
+ return clonedInvoker;
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org