You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by gd...@apache.org on 2008/04/05 13:13:33 UTC
svn commit: r645077 [1/3] - in /geronimo/server/trunk:
assemblies/geronimo-boilerplate-minimal/
assemblies/geronimo-boilerplate-minimal/src/main/assembly/
framework/configs/j2ee-system/ framework/configs/jsr88-deploymentfactory/
framework/configs/onlin...
Author: gdamour
Date: Sat Apr 5 04:13:30 2008
New Revision: 645077
URL: http://svn.apache.org/viewvc?rev=645077&view=rev
Log:
*** Definition of annotations streamlining the definition of GBeanInfos.
* @GBean: optional annotation defining the name and j2eeType of a GBean.
If this annotation is not specified, then the default name is assumed to be
the class (simple) name and the default j2eeType is GBean.
* @Priority: optionalannotation defining the priority of a GBean.
* @ParamSpecial: annotation defining a GBean special attribute to be
injected.
* @ParamAttribute: annotation defining the GBean attribute to be injected.
* @ParamReference: annotation defining the GBean reference to be injected.
* @Persistent: annotation for setter methods turning the corresponding GBean
attributes into persistent attributes.
* @Reference: annotation for setter methods turning the corresponding GBean
attribute into a GBean reference.
Note that at most one constructor must be annotated with @ParamSpecial,
@ParamAttribute or @ParamReference.
*** Add a GBeanInfo factory strategy, GBeanInfoFactory, which allows us to
plug-in an annotation based GBeanInfo factory implementation.
*** Use annotation based GBeanInfo declaration for clustering related GBeans.
*** Use xbean-reflect to build GBean instances.
This fixes GERONIMO-3952 - Definition of GBeanInfo via annotations
Added:
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/AbstractGBeanInfoFactory.java
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/BasicGBeanInfoFactory.java
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfoFactory.java
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfoFactoryException.java
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfoFactoryRegistry.java
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/MultiGBeanInfoFactory.java
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/AnnotationGBeanInfoBuilder.java
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/AnnotationGBeanInfoFactory.java
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/GBean.java
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/GBeanAnnotationException.java
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/ParamAttribute.java
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/ParamReference.java
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/ParamSpecial.java
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/Persistent.java
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/Priority.java
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/Reference.java
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/SpecialAttributeType.java
geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/gbean/annotation/
geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/gbean/annotation/AnnotationGBeanInfoBuilderTest.java
Modified:
geronimo/server/trunk/assemblies/geronimo-boilerplate-minimal/pom.xml
geronimo/server/trunk/assemblies/geronimo-boilerplate-minimal/src/main/assembly/boilerplate.xml
geronimo/server/trunk/framework/configs/j2ee-system/pom.xml
geronimo/server/trunk/framework/configs/jsr88-deploymentfactory/pom.xml
geronimo/server/trunk/framework/configs/online-deployer/pom.xml
geronimo/server/trunk/framework/modules/geronimo-kernel/pom.xml
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanData.java
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfo.java
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GConstructorInfo.java
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/AbstractGBeanReference.java
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/GBeanAttribute.java
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/GBeanReference.java
geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/xstream/GBeanDataConverter.java
geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/gbean/runtime/GBeanAttributeTest.java
geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/ConfigTest.java
geronimo/server/trunk/framework/modules/geronimo-service-builder/src/main/java/org/apache/geronimo/deployment/service/GBeanBuilder.java
geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADICluster.java
geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManager.java
geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/RoundRobinBackingStrategyFactoryGBean.java
geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/TribesDispatcherHolder.java
geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/BasicLocalNode.java
geronimo/server/trunk/plugins/jetty/geronimo-jetty6-clustering-builder-wadi/src/main/java/org/apache/geronimo/jetty6/cluster/wadi/builder/WADIJettyClusteringBuilder.java
geronimo/server/trunk/plugins/jetty/geronimo-jetty6-clustering-wadi/src/main/java/org/apache/geronimo/jetty6/cluster/ClusteredSessionHandlerFactory.java
geronimo/server/trunk/plugins/jetty/geronimo-jetty6-clustering-wadi/src/main/java/org/apache/geronimo/jetty6/cluster/wadi/WADIClusteredPreHandlerFactory.java
geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/src/main/java/org/apache/geronimo/openejb/deployment/cluster/WADIOpenEJBClusteringBuilder.java
geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilder.java
geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/ClusteredManagerRetriever.java
geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/wadi/WADIClusteredValveRetriever.java
Modified: geronimo/server/trunk/assemblies/geronimo-boilerplate-minimal/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/assemblies/geronimo-boilerplate-minimal/pom.xml?rev=645077&r1=645076&r2=645077&view=diff
==============================================================================
--- geronimo/server/trunk/assemblies/geronimo-boilerplate-minimal/pom.xml (original)
+++ geronimo/server/trunk/assemblies/geronimo-boilerplate-minimal/pom.xml Sat Apr 5 04:13:30 2008
@@ -155,6 +155,11 @@
</dependency>
<dependency>
+ <groupId>org.apache.xbean</groupId>
+ <artifactId>xbean-reflect</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
</dependency>
Modified: geronimo/server/trunk/assemblies/geronimo-boilerplate-minimal/src/main/assembly/boilerplate.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/assemblies/geronimo-boilerplate-minimal/src/main/assembly/boilerplate.xml?rev=645077&r1=645076&r2=645077&view=diff
==============================================================================
--- geronimo/server/trunk/assemblies/geronimo-boilerplate-minimal/src/main/assembly/boilerplate.xml (original)
+++ geronimo/server/trunk/assemblies/geronimo-boilerplate-minimal/src/main/assembly/boilerplate.xml Sat Apr 5 04:13:30 2008
@@ -66,6 +66,7 @@
<include>commons-logging:commons-logging</include>
<include>log4j:log4j</include>
<include>xpp3:xpp3</include>
+ <include>org.apache.xbean:xbean-reflect</include>
<include>com.thoughtworks.xstream:xstream</include>
<include>org.apache.geronimo.framework:geronimo-cli</include>
<include>org.apache.geronimo.framework:geronimo-kernel</include>
Modified: geronimo/server/trunk/framework/configs/j2ee-system/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/configs/j2ee-system/pom.xml?rev=645077&r1=645076&r2=645077&view=diff
==============================================================================
--- geronimo/server/trunk/framework/configs/j2ee-system/pom.xml (original)
+++ geronimo/server/trunk/framework/configs/j2ee-system/pom.xml Sat Apr 5 04:13:30 2008
@@ -193,6 +193,10 @@
<artifactId>xpp3</artifactId>
</element>
<element>
+ <groupId>org.apache.xbean</groupId>
+ <artifactId>xbean-reflect</artifactId>
+ </element>
+ <element>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
</element>
Modified: geronimo/server/trunk/framework/configs/jsr88-deploymentfactory/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/configs/jsr88-deploymentfactory/pom.xml?rev=645077&r1=645076&r2=645077&view=diff
==============================================================================
--- geronimo/server/trunk/framework/configs/jsr88-deploymentfactory/pom.xml (original)
+++ geronimo/server/trunk/framework/configs/jsr88-deploymentfactory/pom.xml Sat Apr 5 04:13:30 2008
@@ -150,6 +150,10 @@
<artifactId>xpp3</artifactId>
</element>
<element>
+ <groupId>org.apache.xbean</groupId>
+ <artifactId>xbean-reflect</artifactId>
+ </element>
+ <element>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
</element>
Modified: geronimo/server/trunk/framework/configs/online-deployer/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/configs/online-deployer/pom.xml?rev=645077&r1=645076&r2=645077&view=diff
==============================================================================
--- geronimo/server/trunk/framework/configs/online-deployer/pom.xml (original)
+++ geronimo/server/trunk/framework/configs/online-deployer/pom.xml Sat Apr 5 04:13:30 2008
@@ -206,6 +206,10 @@
<artifactId>xpp3</artifactId>
</element>
<element>
+ <groupId>org.apache.xbean</groupId>
+ <artifactId>xbean-reflect</artifactId>
+ </element>
+ <element>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
</element>
Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/pom.xml?rev=645077&r1=645076&r2=645077&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/pom.xml (original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/pom.xml Sat Apr 5 04:13:30 2008
@@ -58,10 +58,15 @@
</dependency>
<dependency>
+ <groupId>org.apache.xbean</groupId>
+ <artifactId>xbean-reflect</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
</dependency>
-
+
<dependency>
<groupId>xpp3</groupId>
<artifactId>xpp3</artifactId>
Added: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/AbstractGBeanInfoFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/AbstractGBeanInfoFactory.java?rev=645077&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/AbstractGBeanInfoFactory.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/AbstractGBeanInfoFactory.java Sat Apr 5 04:13:30 2008
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.geronimo.gbean;
+
+
+
+
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public abstract class AbstractGBeanInfoFactory implements GBeanInfoFactory {
+
+ public GBeanInfo getGBeanInfo(String className, ClassLoader classLoader) throws GBeanInfoFactoryException {
+ Class clazz;
+ try {
+ clazz = classLoader.loadClass(className);
+ } catch (ClassNotFoundException e) {
+ throw new InvalidConfigurationException("Could not load class " + className, e);
+ } catch (NoClassDefFoundError e) {
+ throw new InvalidConfigurationException("Could not load class " + className, e);
+ }
+ return getGBeanInfo(clazz);
+ }
+
+}
Added: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/BasicGBeanInfoFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/BasicGBeanInfoFactory.java?rev=645077&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/BasicGBeanInfoFactory.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/BasicGBeanInfoFactory.java Sat Apr 5 04:13:30 2008
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.geronimo.gbean;
+
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public class BasicGBeanInfoFactory extends AbstractGBeanInfoFactory {
+
+ public GBeanInfo getGBeanInfo(Class clazz) throws GBeanInfoFactoryException {
+ try {
+ return GBeanInfo.getGBeanInfo(clazz.getName(), clazz.getClassLoader());
+ } catch (InvalidConfigurationException e) {
+ throw new GBeanInfoFactoryException(e);
+ }
+ }
+
+}
\ No newline at end of file
Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanData.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanData.java?rev=645077&r1=645076&r2=645077&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanData.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanData.java Sat Apr 5 04:13:30 2008
@@ -39,31 +39,52 @@
};
private GBeanInfo gbeanInfo;
+ private final GBeanInfoFactory infoFactory;
private final Map<String, Object> attributes;
private final Map<String, ReferencePatterns> references;
private final Set<ReferencePatterns> dependencies;
private AbstractName abstractName;
private int priority;
+
public GBeanData() {
attributes = new HashMap<String, Object>();
references = new HashMap<String, ReferencePatterns>();
dependencies = new HashSet<ReferencePatterns>();
+ infoFactory = newGBeanInfoFactory();
}
- public GBeanData(GBeanInfo gbeanInfo) {
+ public GBeanData(Class gbeanClass) {
this();
+
+ GBeanInfo gbeanInfo = infoFactory.getGBeanInfo(gbeanClass);
setGBeanInfo(gbeanInfo);
}
+ public GBeanData(GBeanInfo gbeanInfo) {
+ this();
+
+ setGBeanInfo(gbeanInfo);
+ }
+
public GBeanData(AbstractName abstractName, GBeanInfo gbeanInfo) {
this();
this.abstractName = abstractName;
+
setGBeanInfo(gbeanInfo);
}
+ public GBeanData(AbstractName abstractName, Class gbeanClass) {
+ this();
+ this.abstractName = abstractName;
+
+ GBeanInfo gbeanInfo = infoFactory.getGBeanInfo(gbeanClass);
+ setGBeanInfo(gbeanInfo);
+ }
+
public GBeanData(GBeanData gbeanData) {
setGBeanInfo(gbeanData.gbeanInfo);
+ infoFactory = gbeanData.infoFactory;
attributes = new HashMap<String, Object>(gbeanData.attributes);
references = new HashMap<String, ReferencePatterns>(gbeanData.references);
dependencies = new HashSet<ReferencePatterns>(gbeanData.dependencies);
@@ -260,6 +281,10 @@
public int compare(GBeanData o1, GBeanData o2) {
return o1.priority - o2.priority;
}
+ }
+
+ protected GBeanInfoFactory newGBeanInfoFactory() {
+ return new MultiGBeanInfoFactory();
}
private class V0Externalizable implements Externalizable {
Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfo.java?rev=645077&r1=645076&r2=645077&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfo.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfo.java Sat Apr 5 04:13:30 2008
@@ -267,7 +267,7 @@
return constructor;
}
- public Set getOperations() {
+ public Set<GOperationInfo> getOperations() {
return operations;
}
@@ -275,7 +275,7 @@
return notifications;
}
- public Set getReferences() {
+ public Set<GReferenceInfo> getReferences() {
return references;
}
@@ -283,7 +283,7 @@
return (GReferenceInfo) referencesByName.get(name);
}
- public Set getInterfaces() {
+ public Set<String> getInterfaces() {
return interfaces;
}
Added: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfoFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfoFactory.java?rev=645077&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfoFactory.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfoFactory.java Sat Apr 5 04:13:30 2008
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.geronimo.gbean;
+
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public interface GBeanInfoFactory {
+ GBeanInfo getGBeanInfo(Class clazz) throws GBeanInfoFactoryException;
+
+ GBeanInfo getGBeanInfo(String className, ClassLoader classLoader) throws GBeanInfoFactoryException;
+}
\ No newline at end of file
Added: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfoFactoryException.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfoFactoryException.java?rev=645077&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfoFactoryException.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfoFactoryException.java Sat Apr 5 04:13:30 2008
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.geronimo.gbean;
+
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public class GBeanInfoFactoryException extends RuntimeException {
+
+ public GBeanInfoFactoryException(String message) {
+ super(message);
+ }
+
+ public GBeanInfoFactoryException(Throwable cause) {
+ super(cause);
+ }
+
+}
\ No newline at end of file
Added: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfoFactoryRegistry.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfoFactoryRegistry.java?rev=645077&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfoFactoryRegistry.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfoFactoryRegistry.java Sat Apr 5 04:13:30 2008
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.geronimo.gbean;
+
+
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public interface GBeanInfoFactoryRegistry {
+ void registerFactory(GBeanInfoFactory factory);
+
+ void unregisterFactory(GBeanInfoFactory factory);
+}
\ No newline at end of file
Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GConstructorInfo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GConstructorInfo.java?rev=645077&r1=645076&r2=645077&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GConstructorInfo.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GConstructorInfo.java Sat Apr 5 04:13:30 2008
@@ -43,7 +43,7 @@
this.attributeNames = Collections.unmodifiableList(attributeNames);
}
- public List getAttributeNames() {
+ public List<String> getAttributeNames() {
return attributeNames;
}
Added: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/MultiGBeanInfoFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/MultiGBeanInfoFactory.java?rev=645077&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/MultiGBeanInfoFactory.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/MultiGBeanInfoFactory.java Sat Apr 5 04:13:30 2008
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.geronimo.gbean;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.apache.geronimo.gbean.annotation.AnnotationGBeanInfoFactory;
+
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public class MultiGBeanInfoFactory extends AbstractGBeanInfoFactory implements GBeanInfoFactoryRegistry {
+ private final static CopyOnWriteArrayList<GBeanInfoFactory> factories = new CopyOnWriteArrayList<GBeanInfoFactory>();
+
+ static {
+ factories.add(new BasicGBeanInfoFactory());
+ factories.add(new AnnotationGBeanInfoFactory());
+ }
+
+ public void registerFactory(GBeanInfoFactory factory) {
+ factories.add(0, factory);
+ }
+
+ public void unregisterFactory(GBeanInfoFactory factory) {
+ factories.remove(factory);
+ }
+
+ public GBeanInfo getGBeanInfo(Class clazz) throws GBeanInfoFactoryException {
+ for (GBeanInfoFactory factory : factories) {
+ try {
+ return factory.getGBeanInfo(clazz);
+ } catch (GBeanInfoFactoryException e) {
+ }
+ }
+ throw new GBeanInfoFactoryException("Cannot create a GBeanInfo for [" + clazz + "]");
+ }
+
+}
\ No newline at end of file
Added: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/AnnotationGBeanInfoBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/AnnotationGBeanInfoBuilder.java?rev=645077&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/AnnotationGBeanInfoBuilder.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/AnnotationGBeanInfoBuilder.java Sat Apr 5 04:13:30 2008
@@ -0,0 +1,227 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.geronimo.gbean.annotation;
+
+import java.beans.Introspector;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.GReferenceInfo;
+
+
+
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public class AnnotationGBeanInfoBuilder {
+ private static final String DEFAULT_J2EE_TYPE = "GBean";
+
+ private final Class gbeanClass;
+
+ public AnnotationGBeanInfoBuilder(Class gbeanClass) {
+ if (null == gbeanClass) {
+ throw new IllegalArgumentException("gbeanClass is required");
+ }
+ this.gbeanClass = gbeanClass;
+ }
+
+ public GBeanInfo buildGBeanInfo() throws GBeanAnnotationException {
+ String name = getName();
+ String j2eeType = getJ2eeyType();
+ GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(name, gbeanClass, j2eeType);
+
+ setPriority(infoBuilder);
+ setConstructor(infoBuilder);
+ markPersistent(infoBuilder);
+ addReferences(infoBuilder);
+
+ return infoBuilder.getBeanInfo();
+ }
+
+ protected void setPriority(GBeanInfoBuilder infoBuilder) {
+ Priority priority = (Priority) gbeanClass.getAnnotation(Priority.class);
+ if (null == priority) {
+ return;
+ }
+
+ infoBuilder.setPriority(priority.priority());
+ }
+
+ protected void setConstructor(GBeanInfoBuilder infoBuilder) {
+ Constructor[] constructors = gbeanClass.getDeclaredConstructors();
+ for (Constructor constructor : constructors) {
+ Annotation[][] paramsAnnotations = constructor.getParameterAnnotations();
+ if (0 < paramsAnnotations.length) {
+ Annotation[] paramAnnotations = paramsAnnotations[0];
+ for (Annotation paramAnnotation : paramAnnotations) {
+ if (paramAnnotation instanceof ParamAttribute
+ || paramAnnotation instanceof ParamReference
+ || paramAnnotation instanceof ParamSpecial) {
+ setConstructor(infoBuilder, constructor);
+ return;
+ }
+ }
+ }
+ }
+
+ try {
+ gbeanClass.getConstructor();
+ } catch (Exception e) {
+ throw new GBeanAnnotationException("Missing default constructor");
+ }
+ infoBuilder.setConstructor(new String[0]);
+ }
+
+ protected void setConstructor(GBeanInfoBuilder infoBuilder, Constructor constructor) {
+ Class[] types = constructor.getParameterTypes();
+ Type[] genericTypes = constructor.getGenericParameterTypes();
+ Annotation[][] parametersAnnotations = constructor.getParameterAnnotations();
+ String[] cstrNames = new String[types.length];
+ int index = 0;
+ for (Annotation[] paramterAnnotations : parametersAnnotations) {
+ Class parameterType = types[index];
+ boolean annotationFound = false;
+ for (Annotation parameterAnnotation : paramterAnnotations) {
+ if (parameterAnnotation instanceof ParamAttribute) {
+ ParamAttribute attribute = (ParamAttribute) parameterAnnotation;
+ String name = attribute.name();
+ boolean persistent = attribute.persistent();
+ boolean manageable = attribute.manageable();
+ infoBuilder.addAttribute(name, parameterType, persistent, manageable);
+ cstrNames[index] = name;
+ annotationFound = true;
+ break;
+ } else if (parameterAnnotation instanceof ParamSpecial) {
+ ParamSpecial attribute = (ParamSpecial) parameterAnnotation;
+ String name = attribute.type().name();
+ infoBuilder.addAttribute(name, parameterType, false);
+ cstrNames[index] = name;
+ annotationFound = true;
+ break;
+ } else if (parameterAnnotation instanceof ParamReference) {
+ ParamReference reference = (ParamReference) parameterAnnotation;
+ String name = reference.name();
+ Class referenceType = getGenericActualType(genericTypes[index], parameterType);
+ String namingType = reference.namingType();
+ infoBuilder.addReference(name, referenceType, namingType);
+ cstrNames[index] = name;
+ annotationFound = true;
+ break;
+ }
+ }
+ if (!annotationFound) {
+ throw new GBeanAnnotationException("Missing constructor parameter annotation for constructor ["
+ + constructor + "] at index [" + index + "]");
+ }
+ index++;
+ }
+ infoBuilder.setConstructor(cstrNames);
+ }
+
+ protected Set<Method> filterSettersByAnnotation(Class annotationClass) {
+ Set<Method> filteredMethods = new HashSet<Method>();
+ Method[] methods = gbeanClass.getMethods();
+ for (Method method : methods) {
+ if (null == method.getAnnotation(annotationClass)) {
+ continue;
+ }
+ if (isNotSetter(method)) {
+ throw new GBeanAnnotationException("[" + method + "] is not a setter and annotated with ["
+ + annotationClass + "]");
+ }
+ filteredMethods.add(method);
+ }
+ return filteredMethods;
+ }
+
+ protected void markPersistent(GBeanInfoBuilder infoBuilder) {
+ Set<Method> methods = filterSettersByAnnotation(Persistent.class);
+ for (Method method : methods) {
+ Persistent persistent = method.getAnnotation(Persistent.class);
+ Class type = method.getParameterTypes()[0];
+ String name = getName(method);
+ name = Introspector.decapitalize(name);
+ infoBuilder.addAttribute(name, type, true, persistent.manageable());
+ }
+ }
+
+ protected void addReferences(GBeanInfoBuilder infoBuilder) {
+ Set<Method> methods = filterSettersByAnnotation(Reference.class);
+ for (Method method : methods) {
+ Reference reference = method.getAnnotation(Reference.class);
+ Class type = method.getParameterTypes()[0];
+ Class referenceType = getGenericActualType(method.getGenericParameterTypes()[0], type);
+ String name = getName(method);
+ GReferenceInfo referenceInfo = new GReferenceInfo(name,
+ referenceType.getName(),
+ type.getName(),
+ method.getName(),
+ reference.namingType());
+ infoBuilder.addReference(referenceInfo);
+ }
+ }
+
+ protected Class getGenericActualType(Type genericType, Class parameterType) {
+ if (Collection.class.isAssignableFrom(parameterType)) {
+ if (genericType instanceof ParameterizedType) {
+ ParameterizedType parameterizedType = (ParameterizedType) genericType;
+ return (Class) parameterizedType.getActualTypeArguments()[0];
+ } else {
+ throw new GBeanAnnotationException(Collection.class + " parameter must be generified");
+ }
+ }
+ return parameterType;
+ }
+
+ protected String getName() {
+ GBean bean = (GBean) gbeanClass.getAnnotation(GBean.class);
+ if (null == bean) {
+ return gbeanClass.getSimpleName();
+ }
+ return bean.name();
+ }
+
+ protected String getJ2eeyType() {
+ GBean bean = (GBean) gbeanClass.getAnnotation(GBean.class);
+ if (null == bean) {
+ return DEFAULT_J2EE_TYPE;
+ }
+ return bean.j2eeType();
+ }
+
+ protected String getName(Method method) {
+ return method.getName().substring(3);
+ }
+
+ protected boolean isNotSetter(Method method) {
+ return !(method.getName().startsWith("set") && method.getParameterTypes().length == 1);
+ }
+
+}
Added: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/AnnotationGBeanInfoFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/AnnotationGBeanInfoFactory.java?rev=645077&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/AnnotationGBeanInfoFactory.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/AnnotationGBeanInfoFactory.java Sat Apr 5 04:13:30 2008
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.geronimo.gbean.annotation;
+
+import org.apache.geronimo.gbean.AbstractGBeanInfoFactory;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoFactoryException;
+
+
+
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public class AnnotationGBeanInfoFactory extends AbstractGBeanInfoFactory {
+
+ public GBeanInfo getGBeanInfo(Class clazz) throws GBeanInfoFactoryException {
+ AnnotationGBeanInfoBuilder infoFactory = new AnnotationGBeanInfoBuilder(clazz);
+ try {
+ return infoFactory.buildGBeanInfo();
+ } catch (GBeanAnnotationException e) {
+ throw new GBeanInfoFactoryException(e);
+ }
+ }
+
+}
Added: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/GBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/GBean.java?rev=645077&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/GBean.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/GBean.java Sat Apr 5 04:13:30 2008
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.geronimo.gbean.annotation;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+@Documented
+@Retention(value = RUNTIME)
+@Target(value = {TYPE})
+public @interface GBean {
+ String name();
+
+ String j2eeType() default "GBean";
+}
Added: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/GBeanAnnotationException.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/GBeanAnnotationException.java?rev=645077&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/GBeanAnnotationException.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/GBeanAnnotationException.java Sat Apr 5 04:13:30 2008
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.geronimo.gbean.annotation;
+
+
+
+
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public class GBeanAnnotationException extends RuntimeException {
+
+ public GBeanAnnotationException(String message) {
+ super(message);
+ }
+
+}
Added: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/ParamAttribute.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/ParamAttribute.java?rev=645077&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/ParamAttribute.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/ParamAttribute.java Sat Apr 5 04:13:30 2008
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.geronimo.gbean.annotation;
+
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+@Documented
+@Retention(value = RUNTIME)
+@Target(value = {PARAMETER})
+public @interface ParamAttribute {
+ String name();
+
+ boolean persistent() default true;
+
+ boolean manageable() default true;
+}
Added: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/ParamReference.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/ParamReference.java?rev=645077&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/ParamReference.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/ParamReference.java Sat Apr 5 04:13:30 2008
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.geronimo.gbean.annotation;
+
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+@Documented
+@Retention(value = RUNTIME)
+@Target(value = {PARAMETER})
+public @interface ParamReference {
+ String name();
+
+ String namingType() default "GBean";
+}
Added: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/ParamSpecial.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/ParamSpecial.java?rev=645077&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/ParamSpecial.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/ParamSpecial.java Sat Apr 5 04:13:30 2008
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.geronimo.gbean.annotation;
+
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+@Documented
+@Retention(value = RUNTIME)
+@Target(value = {PARAMETER})
+public @interface ParamSpecial {
+ SpecialAttributeType type();
+}
Added: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/Persistent.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/Persistent.java?rev=645077&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/Persistent.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/Persistent.java Sat Apr 5 04:13:30 2008
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.geronimo.gbean.annotation;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+@Documented
+@Retention(value = RUNTIME)
+@Target(value = {METHOD})
+public @interface Persistent {
+ boolean manageable() default true;
+}
Added: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/Priority.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/Priority.java?rev=645077&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/Priority.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/Priority.java Sat Apr 5 04:13:30 2008
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.geronimo.gbean.annotation;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+@Documented
+@Retention(value = RUNTIME)
+@Target(value = {TYPE})
+public @interface Priority {
+ int priority();
+}
Added: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/Reference.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/Reference.java?rev=645077&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/Reference.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/Reference.java Sat Apr 5 04:13:30 2008
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.geronimo.gbean.annotation;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+@Documented
+@Retention(value = RUNTIME)
+@Target(value = {METHOD})
+public @interface Reference {
+ String namingType() default "GBeanInfo";
+}
Added: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/SpecialAttributeType.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/SpecialAttributeType.java?rev=645077&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/SpecialAttributeType.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/SpecialAttributeType.java Sat Apr 5 04:13:30 2008
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.geronimo.gbean.annotation;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public enum SpecialAttributeType {
+ abstractName,
+ objectName,
+ classLoader,
+ kernel
+}
Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/AbstractGBeanReference.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/AbstractGBeanReference.java?rev=645077&r1=645076&r2=645077&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/AbstractGBeanReference.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/AbstractGBeanReference.java Sat Apr 5 04:13:30 2008
@@ -189,10 +189,4 @@
"\n Proxy Type: " + referenceInfo.getProxyType();
}
- public final synchronized void inject(Object target) throws Exception {
- // set the proxy into the instance
- if (setInvoker != null && hasTargets) {
- setInvoker.invoke(target, new Object[]{getProxy()});
- }
- }
}
Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/GBeanAttribute.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/GBeanAttribute.java?rev=645077&r1=645076&r2=645077&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/GBeanAttribute.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/GBeanAttribute.java Sat Apr 5 04:13:30 2008
@@ -43,14 +43,11 @@
private final MethodInvoker setInvoker;
- private final boolean isConstructorArg;
-
private final boolean persistent;
private final boolean manageable;
private Object persistentValue;
-
/**
* Is this a special attribute like objectName, classLoader or gbeanContext?
* Special attributes are injected at startup just like persistent attrubutes, but are
@@ -70,6 +67,8 @@
private GBeanAttribute(GBeanAttribute attribute, GBeanInstance gbeanInstance, String name, Class type, Object value) {
this.special = true;
+ this.persistentValue = value;
+
this.framework = false;
this.dynamic = false;
@@ -103,16 +102,13 @@
// setter
if (attribute != null) {
this.setInvoker = attribute.setInvoker;
- this.isConstructorArg = attribute.isConstructorArg;
} else {
this.setInvoker = null;
- this.isConstructorArg = false;
}
this.writable = false;
// persistence
this.persistent = false;
- initializePersistentValue(value);
// not manageable
this.manageable = false;
@@ -152,6 +148,7 @@
this.special = false;
this.framework = true;
this.dynamic = false;
+ this.persistentValue = persistentValue;
if (gbeanInstance == null || name == null || type == null) {
throw new IllegalArgumentException("null param(s) supplied");
@@ -167,12 +164,10 @@
// setter
this.setInvoker = setInvoker;
- this.isConstructorArg = false;
this.writable = (this.setInvoker != null);
// persistence
this.persistent = persistent;
- initializePersistentValue(persistentValue);
// manageable
this.manageable = manageable;
@@ -188,22 +183,16 @@
null);
}
- public GBeanAttribute(GBeanInstance gbeanInstance, GAttributeInfo attributeInfo, boolean isConstructorArg) throws InvalidConfigurationException {
+ public GBeanAttribute(GBeanInstance gbeanInstance, GAttributeInfo attributeInfo) throws InvalidConfigurationException {
this.special = false;
this.framework = false;
if (gbeanInstance == null || attributeInfo == null) {
throw new IllegalArgumentException("null param(s) supplied");
}
- if (!attributeInfo.isReadable() && !attributeInfo.isWritable() && !attributeInfo.isPersistent() && !isConstructorArg)
- {
- throw new InvalidConfigurationException("An attribute must be readable, writable, persistent or a constructor arg: " +
- " name=" + attributeInfo.getName() + " targetClass=" + gbeanInstance.getType().getName());
- }
this.gbeanInstance = gbeanInstance;
this.attributeInfo = attributeInfo;
this.name = attributeInfo.getName();
- this.isConstructorArg = isConstructorArg;
try {
this.type = ClassLoading.loadClass(attributeInfo.getType(), gbeanInstance.getClassLoader());
} catch (ClassNotFoundException e) {
@@ -255,8 +244,7 @@
getInvoker = null;
}
- // If attribute is persistent or not tagged as unwritable, search
- // for a setter method
+ // If attribute is persistent or not tagged as unwritable, search for a setter method
if (attributeInfo.getSetterName() != null) {
try {
String setterName = attributeInfo.getSetterName();
@@ -273,33 +261,6 @@
setInvoker = null;
}
}
-
- initializePersistentValue(null);
- }
-
- private void initializePersistentValue(Object value) {
- if (persistent || special) {
- if (value == null && type.isPrimitive() && isConstructorArg) {
- if (type == Boolean.TYPE) {
- value = Boolean.FALSE;
- } else if (type == Byte.TYPE) {
- value = new Byte((byte) 0);
- } else if (type == Short.TYPE) {
- value = new Short((short) 0);
- } else if (type == Integer.TYPE) {
- value = new Integer(0);
- } else if (type == Long.TYPE) {
- value = new Long(0);
- } else if (type == Character.TYPE) {
- value = new Character((char) 0);
- } else if (type == Float.TYPE) {
- value = new Float(0);
- } else /** if (type == Double.TYPE) */ {
- value = new Double(0);
- }
- }
- persistentValue = value;
- }
}
public String getName() {
@@ -342,12 +303,6 @@
return special;
}
- public void inject(Object target) throws Exception {
- if ((persistent || special) && !isConstructorArg && writable && persistentValue != null) {
- setValue(target, persistentValue);
- }
- }
-
public Object getPersistentValue() {
if (!persistent && !special) {
throw new IllegalStateException("Attribute is not persistent " + getDescription());
@@ -444,4 +399,11 @@
return null;
}
}
+
+ public void inject(Object target) throws Exception {
+ if ((persistent || special) && writable && null != persistentValue) {
+ setValue(target, persistentValue);
+ }
+ }
+
}