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/09/22 15:18:17 UTC
svn commit: r290938 - in /beehive/trunk/controls:
src/runtime/org/apache/beehive/controls/runtime/generator/ test/src/controls/
Author: ekoneil
Date: Thu Sep 22 06:18:11 2005
New Revision: 290938
URL: http://svn.apache.org/viewcvs?rev=290938&view=rev
Log:
Fix a bug in control generation that allows a control interface and implementation to be stored in the default package. This required two fixes:
- adding isRootPackage methods to the JavaBeans used for Velocity code generation
- adding Velocity that checks the isRootPackage on the ControlBean / Info / ImplInitializer and only generates the package name if isRootPackage returns false
BB: self
Test: Controls DRT + BVT pass
Added:
beehive/trunk/controls/test/src/controls/ControlInDefaultPackage.java (with props)
beehive/trunk/controls/test/src/controls/ControlInDefaultPackageImpl.java (with props)
Modified:
beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ClientInitializer.java
beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.java
beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.vm
beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBeanInfo.vm
beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ImplInitializer.java
beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ImplInitializer.vm
Modified: beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ClientInitializer.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ClientInitializer.java?rev=290938&r1=290937&r2=290938&view=diff
==============================================================================
--- beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ClientInitializer.java (original)
+++ beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ClientInitializer.java Thu Sep 22 06:18:11 2005
@@ -60,7 +60,7 @@
/**
* Is the ClientInitializer in the root package?
*/
- public boolean isRootPackage() { return getPackage().equals(""); }
+ public boolean isRootPackage() { return getPackage() == null || getPackage().equals(""); }
/**
* Returns the unqualified classname of the ClientInitializer
Modified: beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.java?rev=290938&r1=290937&r2=290938&view=diff
==============================================================================
--- beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.java (original)
+++ beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.java Thu Sep 22 06:18:11 2005
@@ -38,7 +38,8 @@
{
_packageName = _controlIntf.getPackage();
_shortName = _controlIntf.getShortName() + "Bean";
- _className = _packageName + "." + _shortName;
+ _className = isRootPackage() ? _shortName : _packageName + "." + _shortName;
+
_superClass = new ControlBean(_controlIntf.getSuperClass());
}
else
@@ -48,6 +49,13 @@
_className = c.getName();
_shortName = _className.substring(_packageName.length() + 1);
}
+ }
+
+ /**
+ * Return whether the ControlBean is contained in a package.
+ */
+ public boolean isRootPackage() {
+ return _packageName == null || _packageName.trim().equals("");
}
/**
Modified: beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.vm
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.vm?rev=290938&r1=290937&r2=290938&view=diff
==============================================================================
--- beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.vm (original)
+++ beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.vm Thu Sep 22 06:18:11 2005
@@ -553,7 +553,9 @@
##
## THE CONTROLBEAN CLASS TEMPLATE
##
+#if (!$bean.isRootPackage())
package $bean.package;
+#end
import java.beans.*;
Modified: beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBeanInfo.vm
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBeanInfo.vm?rev=290938&r1=290937&r2=290938&view=diff
==============================================================================
--- beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBeanInfo.vm (original)
+++ beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBeanInfo.vm Thu Sep 22 06:18:11 2005
@@ -57,7 +57,9 @@
##
## Begin - Main body for ControlBeanInfo class template
##
+#if (!$bean.isRootPackage())
package $bean.package;
+#end
import java.beans.BeanDescriptor;
import java.beans.EventSetDescriptor;
Modified: beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ImplInitializer.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ImplInitializer.java?rev=290938&r1=290937&r2=290938&view=diff
==============================================================================
--- beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ImplInitializer.java (original)
+++ beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ImplInitializer.java Thu Sep 22 06:18:11 2005
@@ -62,6 +62,13 @@
_reflectFields.add(genField);
}
+ /*
+ * Return whether the ControlBean is contained in a package.
+ */
+ public boolean isRootPackage() {
+ return _packageName == null || _packageName.trim().equals("");
+ }
+
/**
* Returns the package name of the ImplInitializer
*/
Modified: beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ImplInitializer.vm
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ImplInitializer.vm?rev=290938&r1=290937&r2=290938&view=diff
==============================================================================
--- beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ImplInitializer.vm (original)
+++ beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ImplInitializer.vm Thu Sep 22 06:18:11 2005
@@ -235,7 +235,9 @@
##
## THE CONTROL INITIALIZER CLASS TEMPLATE
##
+#if (!$init.isRootPackage())
package $init.package;
+#end
import java.lang.reflect.Field;
import org.apache.beehive.controls.api.ControlException;
Added: beehive/trunk/controls/test/src/controls/ControlInDefaultPackage.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/src/controls/ControlInDefaultPackage.java?rev=290938&view=auto
==============================================================================
--- beehive/trunk/controls/test/src/controls/ControlInDefaultPackage.java (added)
+++ beehive/trunk/controls/test/src/controls/ControlInDefaultPackage.java Thu Sep 22 06:18:11 2005
@@ -0,0 +1,25 @@
+/*
+ * 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:$
+ */
+
+import org.apache.beehive.controls.api.bean.ControlInterface;
+
+@ControlInterface
+public interface ControlInDefaultPackage {
+
+ String sayHello();
+}
Propchange: beehive/trunk/controls/test/src/controls/ControlInDefaultPackage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/controls/test/src/controls/ControlInDefaultPackageImpl.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/src/controls/ControlInDefaultPackageImpl.java?rev=290938&view=auto
==============================================================================
--- beehive/trunk/controls/test/src/controls/ControlInDefaultPackageImpl.java (added)
+++ beehive/trunk/controls/test/src/controls/ControlInDefaultPackageImpl.java Thu Sep 22 06:18:11 2005
@@ -0,0 +1,28 @@
+/*
+ * 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:$
+ */
+
+import org.apache.beehive.controls.api.bean.ControlImplementation;
+
+@ControlImplementation(isTransient=true)
+public class ControlInDefaultPackageImpl
+ implements ControlInDefaultPackage {
+
+ public String sayHello() {
+ return "Hello!";
+ }
+}
Propchange: beehive/trunk/controls/test/src/controls/ControlInDefaultPackageImpl.java
------------------------------------------------------------------------------
svn:eol-style = native