I did wonder about this, doesn't it need to be a deep copy? I don't really
understand the purpose of cacheable, but if its set on the one instance
shouldn't it be also set on the clone? And do subclasses need to copy their
fields? Say the RMI binding was using this abstract class should it setting
the remoteMethod field on the clone?

  ...ant

On 8/11/06, Jeremy Boynes <[EMAIL PROTECTED]> wrote:

On Aug 11, 2006, at 2:04 AM, ant elder wrote:

> Ok I've added a TargetInvokerExtension. The clone method doesn't seem
> perfect yet as subclasses now aren't forced to implement clone by the
> compiler.

I've not had coffee yet but AIUI you don't need to override clone in
subclasses uouldnless you need a deep copy. The way it is implemented at
the moment does an unnecessary copy of the cacheable field (as that
member will be cloned by the implementation in Object.clone()).

Something like this should work:
Index: spi/src/main/java/org/apache/tuscany/spi/extension/
TargetInvokerExtension.java
===================================================================
--- spi/src/main/java/org/apache/tuscany/spi/extension/
TargetInvokerExtension.java      (revision 430795)
+++ spi/src/main/java/org/apache/tuscany/spi/extension/
TargetInvokerExtension.java      (working copy)
@@ -54,10 +54,13 @@
          return isCacheable();
      }

-    public Object clone() throws CloneNotSupportedException {
-        TargetInvokerExtension clonedInvoker =
(TargetInvokerExtension) super.clone();
-        clonedInvoker.cacheable = this.cacheable;
-        return clonedInvoker;
+    public Object clone() {
+        try {
+            return super.clone();
+        } catch (CloneNotSupportedException e) {
+            // TargetInvoker extends Cloneable so this should not
have been thrown
+            throw new AssertionError(e);
+        }
      }
}


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to