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/03/28 19:13:36 UTC
svn commit: r389546 - in /beehive/trunk/controls:
src/runtime/org/apache/beehive/controls/runtime/generator/
test/src/junit-controls/org/apache/beehive/controls/test/controls/methodOverride/
test/src/junit-tests/org/apache/beehive/controls/test/junit/
Author: cschoett
Date: Tue Mar 28 09:13:34 2006
New Revision: 389546
URL: http://svn.apache.org/viewcvs?rev=389546&view=rev
Log:
Fix for BEEHIVE 1086, modified AptMethodSet to check for overrriden methods.
Added new unit tests for this case.
Added:
beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/methodOverride/
beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/methodOverride/BaseExtCtrl.java (with props)
beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/methodOverride/BaseExtImpl.java (with props)
beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/methodOverride/CustomerDao.java (with props)
beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/methodOverride/ICustomerDao.java (with props)
beehive/trunk/controls/test/src/junit-tests/org/apache/beehive/controls/test/junit/MethodOverrideAptTest.java (with props)
Modified:
beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptMethodSet.java
Modified: beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptMethodSet.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptMethodSet.java?rev=389546&r1=389545&r2=389546&view=diff
==============================================================================
--- beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptMethodSet.java (original)
+++ beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptMethodSet.java Tue Mar 28 09:13:34 2006
@@ -17,20 +17,9 @@
* $Header:$
*/
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.Collection;
-import com.sun.mirror.declaration.ClassDeclaration;
-import com.sun.mirror.declaration.MethodDeclaration;
-import com.sun.mirror.declaration.ParameterDeclaration;
-import com.sun.mirror.type.ClassType;
-import com.sun.mirror.type.PrimitiveType;
-import com.sun.mirror.type.ReferenceType;
-import com.sun.mirror.type.TypeMirror;
-
-import org.apache.beehive.controls.api.packaging.FeatureInfo;
-
/**
* The AptMethodSet method represents a collection of AptMethod objects. It contains special
@@ -47,8 +36,13 @@
*/
public void add(T method)
{
+ // check for overridden method
+ if (isOverrideMethod(method)) {
+ return;
+ }
+
// Add to the list of managed methods
- _methods.add(method);
+ _methods.put(method.getName() + method.getArgTypes(), method);
// Ensure that all added methods have a unique index
Object nameValue = _nameMap.get(method.getName());
@@ -77,16 +71,33 @@
}
}
+ /**
+ * Get the collection of methods in this set.
+ */
public Collection<T> getMethods()
{
- return _methods;
+ return _methods.values();
}
+ /**
+ * Get the number of methods in this set.
+ */
public int size()
{
return _methods.size();
}
+
+ /**
+ * Determine of the method overrides a previously added method.
+ * @param method Method to check.
+ * @return true if method is an override to an existing method and does not need to be added
+ * to this method set.
+ */
+ private boolean isOverrideMethod(T method)
+ {
+ return _methods.containsKey(method.getName() + method.getArgTypes());
+ }
- HashMap _nameMap = new HashMap(); // method name -> a single (unique) AptMethod or next index
- ArrayList<T> _methods = new ArrayList<T>();
+ private HashMap _nameMap = new HashMap(); // method name -> a single (unique) AptMethod or next index
+ private HashMap<String, T> _methods = new HashMap<String, T>(); // method name + arg types -> AptMethod
}
Added: beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/methodOverride/BaseExtCtrl.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/methodOverride/BaseExtCtrl.java?rev=389546&view=auto
==============================================================================
--- beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/methodOverride/BaseExtCtrl.java (added)
+++ beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/methodOverride/BaseExtCtrl.java Tue Mar 28 09:13:34 2006
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2006 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.methodOverride;
+
+import org.apache.beehive.controls.api.bean.ControlInterface;
+
+/**
+ */
+@ControlInterface
+public interface BaseExtCtrl {
+
+}
Propchange: beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/methodOverride/BaseExtCtrl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/methodOverride/BaseExtImpl.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/methodOverride/BaseExtImpl.java?rev=389546&view=auto
==============================================================================
--- beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/methodOverride/BaseExtImpl.java (added)
+++ beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/methodOverride/BaseExtImpl.java Tue Mar 28 09:13:34 2006
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2006 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.methodOverride;
+
+import org.apache.beehive.controls.api.bean.ControlImplementation;
+import org.apache.beehive.controls.api.bean.Extensible;
+
+import java.lang.reflect.Method;
+
+/**
+ */
+@ControlImplementation(isTransient=true)
+public class BaseExtImpl implements BaseExtCtrl, Extensible {
+
+
+ /**
+ * Called by the Controls runtime to handle calls to methods of an
+ * extensible control.
+ * <p/>
+ *
+ * @param method The extended operation that was called.
+ * @param args Parameters of the operation.
+ * @return The value that should be returned by the operation.
+ * @throws Throwable any exception declared on the extended operation may be
+ * thrown. If a checked exception is thrown from the implementation that is not declared
+ * on the original interface, it will be wrapped in a ControlException.
+ */
+ public Object invoke(Method method, Object[] args) throws Throwable {
+ return null;
+ }
+}
Propchange: beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/methodOverride/BaseExtImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/methodOverride/CustomerDao.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/methodOverride/CustomerDao.java?rev=389546&view=auto
==============================================================================
--- beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/methodOverride/CustomerDao.java (added)
+++ beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/methodOverride/CustomerDao.java Tue Mar 28 09:13:34 2006
@@ -0,0 +1,14 @@
+package org.apache.beehive.controls.test.controls.methodOverride;
+
+import org.apache.beehive.controls.api.bean.ControlExtension;
+
+@ControlExtension
+public interface CustomerDao extends BaseExtCtrl, ICustomerDao {
+ static final long serialVersionUID = 1L;
+
+ public int countCustomers(String bar);
+
+ public String getCustomer();
+
+ public String[] getCustomerRange(int start, int finish);
+}
Propchange: beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/methodOverride/CustomerDao.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/methodOverride/ICustomerDao.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/methodOverride/ICustomerDao.java?rev=389546&view=auto
==============================================================================
--- beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/methodOverride/ICustomerDao.java (added)
+++ beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/methodOverride/ICustomerDao.java Tue Mar 28 09:13:34 2006
@@ -0,0 +1,28 @@
+/*
+ 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.
+
+ $Header:$
+*/
+package org.apache.beehive.controls.test.controls.methodOverride;
+
+public interface ICustomerDao {
+ public int countCustomers(String foo);
+
+ public String getCustomer();
+
+ public String getCustomer(String name);
+
+ public String[] getCustomerRange(int begin, int end);
+}
Propchange: beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/methodOverride/ICustomerDao.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/controls/test/src/junit-tests/org/apache/beehive/controls/test/junit/MethodOverrideAptTest.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/src/junit-tests/org/apache/beehive/controls/test/junit/MethodOverrideAptTest.java?rev=389546&view=auto
==============================================================================
--- beehive/trunk/controls/test/src/junit-tests/org/apache/beehive/controls/test/junit/MethodOverrideAptTest.java (added)
+++ beehive/trunk/controls/test/src/junit-tests/org/apache/beehive/controls/test/junit/MethodOverrideAptTest.java Tue Mar 28 09:13:34 2006
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2006 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.junit;
+
+import org.apache.beehive.controls.api.bean.Control;
+import org.apache.beehive.controls.test.controls.methodOverride.CustomerDao;
+
+/**
+ * Junit tests for making sure that APT can properly generate a control bean when
+ * the control's interface overrides methods in a super interface.
+ *
+ * If this doesn't work compilation will fail, all thats really necessary here is
+ * to verify the controls can be initialized.
+ */
+public class MethodOverrideAptTest
+ extends ControlTestCase {
+
+ @Control
+ private CustomerDao _customer;
+
+ public void testMethodOverride() {
+ assertNotNull(_customer);
+ }
+}
Propchange: beehive/trunk/controls/test/src/junit-tests/org/apache/beehive/controls/test/junit/MethodOverrideAptTest.java
------------------------------------------------------------------------------
svn:eol-style = native