You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by cs...@apache.org on 2006/01/11 21:31:06 UTC

svn commit: r368120 - in /beehive/trunk/controls: src/runtime/org/apache/beehive/controls/runtime/generator/ test/src/controls/org/apache/beehive/controls/test/controls/serialization/ test/src/units/org/apache/beehive/controls/test/java/s11n/

Author: cschoett
Date: Wed Jan 11 12:30:54 2006
New Revision: 368120

URL: http://svn.apache.org/viewcvs?rev=368120&view=rev
Log:
Fix for beehive-762, updated AptControlImplentation to check for java.io.Serializable on super classes.  Also added new DRT to test this functionality.

Added:
    beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/serialization/HelloControlChild.java   (with props)
    beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/serialization/HelloControlChildImpl.jcs
Modified:
    beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlImplementation.java
    beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/s11n/DeclarativeTest.java

Modified: beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlImplementation.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlImplementation.java?rev=368120&r1=368119&r2=368120&view=diff
==============================================================================
--- beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlImplementation.java (original)
+++ beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlImplementation.java Wed Jan 11 12:30:54 2006
@@ -82,17 +82,7 @@
         ControlImplementation implAnnot = _implDecl.getAnnotation(ControlImplementation.class);
         if (!implAnnot.isTransient())
         {
-            boolean isSerializable = false;
-            for (InterfaceType superIntf: _implDecl.getSuperinterfaces())
-            {
-                if (superIntf.toString().equals("java.io.Serializable"))
-                {
-                    isSerializable = true;
-                    break;
-                }
-            }
-
-            if (!isSerializable)
+            if (!isSerializable())
             {
                 _ap.printError( decl, "control.implementation.unserializable" );
             }
@@ -476,6 +466,22 @@
             _ap.printError( _implDecl, "versionsupported.failed", _implDecl.getSimpleName(), majorSupported, minorSupported,
                             majorPresent, minorPresent );
         }
+    }
+
+    /**
+     * Does this control impl on one of it superclasses implement java.io.Serializable?
+     * @return true if this control impl or one of its superclasses implements java.io.Serializable.
+     */
+    protected boolean isSerializable() {
+
+        for (InterfaceType superIntf: _implDecl.getSuperinterfaces()) {
+            if (superIntf.toString().equals("java.io.Serializable")) {
+                return true;
+            }
+        }
+
+        // check to see if the superclass is serializable
+        return _superClass != null && _superClass.isSerializable();
     }
 
     private ClassDeclaration                _implDecl;

Added: beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/serialization/HelloControlChild.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/serialization/HelloControlChild.java?rev=368120&view=auto
==============================================================================
--- beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/serialization/HelloControlChild.java (added)
+++ beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/serialization/HelloControlChild.java Wed Jan 11 12:30:54 2006
@@ -0,0 +1,37 @@
+/*
+ * Copyright 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.
+ *
+ * $Header:$
+ */
+
+package org.apache.beehive.controls.test.controls.serialization;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.apache.beehive.controls.api.bean.ControlInterface;
+import org.apache.beehive.controls.api.properties.PropertySet;
+
+
+/**
+ * A control interface with propertySet
+ */
+@ControlInterface
+public interface HelloControlChild extends HelloControl
+{
+    public String hello();
+
+}

Propchange: beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/serialization/HelloControlChild.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/serialization/HelloControlChildImpl.jcs
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/serialization/HelloControlChildImpl.jcs?rev=368120&view=auto
==============================================================================
--- beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/serialization/HelloControlChildImpl.jcs (added)
+++ beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/serialization/HelloControlChildImpl.jcs Wed Jan 11 12:30:54 2006
@@ -0,0 +1,34 @@
+/*
+ * Copyright 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.
+ *
+ * $Header:$
+ */
+ 
+package org.apache.beehive.controls.test.controls.serialization;
+
+import java.io.Serializable;
+import org.apache.beehive.controls.api.bean.ControlImplementation;
+
+/**
+ * A simple control impl
+ */
+@ControlImplementation
+public class HelloControlChildImpl extends HelloControlImpl implements HelloControlChild
+{
+    public String hello()
+    {
+		return "Hi";
+    }
+}

Modified: beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/s11n/DeclarativeTest.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/s11n/DeclarativeTest.java?rev=368120&r1=368119&r2=368120&view=diff
==============================================================================
--- beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/s11n/DeclarativeTest.java (original)
+++ beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/s11n/DeclarativeTest.java Wed Jan 11 12:30:54 2006
@@ -29,6 +29,7 @@
 
 import org.apache.beehive.controls.api.bean.Control;
 import org.apache.beehive.controls.test.controls.serialization.HelloControlBean;
+import org.apache.beehive.controls.test.controls.serialization.HelloControlChildBean;
 
 import org.apache.beehive.test.tools.mantis.annotations.tch.Freq;
 
@@ -47,9 +48,19 @@
     @Control
     private HelloControlBean myHelloBean;
 
+    /** A simple subclass of HelloControl, it doesn't explicitly declare its
+     * self as serializable but its superclass does (JIRA 762).
+     */
+    @Control
+    private HelloControlChildBean myHelloChildBean;
+
     public DeclarativeTest(String name)
         throws Exception {
 		super(name);
+    }
+
+    public void testChildControl() throws Exception {
+        Assert.assertEquals("Hi", myHelloChildBean.hello());
     }
 
     public void testWriteRead()