Author: dain Date: Wed Dec 1 00:01:37 2004 New Revision: 109314 URL: http://svn.apache.org/viewcvs?view=rev&rev=109314 Log: Changed the GBeanInfo classes to require full specification and move the "figure things out" code from the GBeanInstance to the GBeanInfoBuilder.
Removed: geronimo/trunk/modules/core/src/test/org/apache/geronimo/management/NotificationTypeTest.java geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/Util.java Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/AbstractConnectionManager.java geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/GenericConnectionManager.java geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/mejb/MEJB.java geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JAASJettyRealm.java geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/connector/JettyConnector.java geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/DynamicGAttributeInfo.java geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GAttributeInfo.java geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanInfo.java geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanInfoBuilder.java geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GConstructorInfo.java geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GReferenceInfo.java geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanJMXUtil.java geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/AbstractGBeanReference.java geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanAttribute.java geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanCollectionReference.java geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanOperation.java geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanReference.java geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanSingleReference.java geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/LifecycleMonitor.java geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/management/NotificationType.java geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/GBeanInfoFactoryTest.java geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/GBeanInfoTest.java geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/runtime/GBeanAttributeTest.java geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/MockDynamicGBean.java geronimo/trunk/modules/network/project.xml geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/bridge/AbstractPrincipalMappingUserPasswordRealmBridge.java geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jaas/GeronimoLoginConfiguration.java geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/bridge/MappingUserPasswordBridgeTest.java geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCWorkerPersistence.java Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/AbstractConnectionManager.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/AbstractConnectionManager.java?view=diff&rev=109314&p1=geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/AbstractConnectionManager.java&r1=109313&p2=geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/AbstractConnectionManager.java&r2=109314 ============================================================================== --- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/AbstractConnectionManager.java (original) +++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/AbstractConnectionManager.java Wed Dec 1 00:01:37 2004 @@ -32,9 +32,12 @@ * @version $Rev$ $Date$ */ public abstract class AbstractConnectionManager implements ConnectionManagerFactory, ConnectionManager, LazyAssociatableConnectionManager, PoolingAttributes { - protected final Interceptors interceptors; + //default constructor for use as endpoint + public AbstractConnectionManager() { + interceptors = null; + } public AbstractConnectionManager(Interceptors interceptors) { this.interceptors = interceptors; Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/GenericConnectionManager.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/GenericConnectionManager.java?view=diff&rev=109314&p1=geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/GenericConnectionManager.java&r1=109313&p2=geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/GenericConnectionManager.java&r2=109314 ============================================================================== --- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/GenericConnectionManager.java (original) +++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/GenericConnectionManager.java Wed Dec 1 00:01:37 2004 @@ -36,7 +36,7 @@ //default constructor for use as endpoint public GenericConnectionManager() { - super(null); + super(); } public GenericConnectionManager(TransactionSupport transactionSupport, Deleted: /geronimo/trunk/modules/core/src/test/org/apache/geronimo/management/NotificationTypeTest.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/core/src/test/org/apache/geronimo/management/NotificationTypeTest.java?view=auto&rev=109313 ============================================================================== Modified: geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/mejb/MEJB.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/mejb/MEJB.java?view=diff&rev=109314&p1=geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/mejb/MEJB.java&r1=109313&p2=geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/mejb/MEJB.java&r2=109314 ============================================================================== --- geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/mejb/MEJB.java (original) +++ geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/mejb/MEJB.java Wed Dec 1 00:01:37 2004 @@ -44,7 +44,7 @@ import org.apache.geronimo.kernel.KernelMBean; import org.apache.geronimo.kernel.NoSuchAttributeException; import org.apache.geronimo.kernel.NoSuchOperationException; - + /** * GBean implementing Management interface and supplying proxies to act as the MEJB container. * @@ -253,7 +253,7 @@ public static final GBeanInfo GBEAN_INFO; static { - GBeanInfoBuilder infoBuilder = new GBeanInfoBuilder(MEJB.class.getName()); + GBeanInfoBuilder infoBuilder = new GBeanInfoBuilder(MEJB.class); infoBuilder.addAttribute("kernel", KernelMBean.class, false); infoBuilder.addInterface(Management.class); Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JAASJettyRealm.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JAASJettyRealm.java?view=diff&rev=109314&p1=geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JAASJettyRealm.java&r1=109313&p2=geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JAASJettyRealm.java&r2=109314 ============================================================================== --- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JAASJettyRealm.java (original) +++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JAASJettyRealm.java Wed Dec 1 00:01:37 2004 @@ -172,7 +172,7 @@ public static final GBeanInfo GBEAN_INFO; static { - GBeanInfoBuilder infoFactory = new GBeanInfoBuilder("Jetty Realm", JAASJettyRealm.class.getName()); + GBeanInfoBuilder infoFactory = new GBeanInfoBuilder("Jetty Realm", JAASJettyRealm.class); infoFactory.setConstructor(new String[]{"JettyContainer"}); infoFactory.addReference("JettyContainer", JettyContainer.class); infoFactory.addAttribute("name", String.class, true); Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/connector/JettyConnector.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/connector/JettyConnector.java?view=diff&rev=109314&p1=geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/connector/JettyConnector.java&r1=109313&p2=geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/connector/JettyConnector.java&r2=109314 ============================================================================== --- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/connector/JettyConnector.java (original) +++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/connector/JettyConnector.java Wed Dec 1 00:01:37 2004 @@ -32,6 +32,11 @@ private final JettyContainer container; protected final HttpListener listener; + public JettyConnector(JettyContainer container) { + this.container = container; + this.listener = null; + } + public JettyConnector(JettyContainer container, HttpListener listener) { this.container = container; this.listener = listener; @@ -81,6 +86,7 @@ GBeanInfoBuilder infoFactory = new GBeanInfoBuilder("Jetty HTTP Connector", JettyConnector.class); infoFactory.addAttribute("port", int.class, true); infoFactory.addReference("JettyContainer", JettyContainer.class); + infoFactory.setConstructor(new String[] {"JettyContainer"}); GBEAN_INFO = infoFactory.getBeanInfo(); } } Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/DynamicGAttributeInfo.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/DynamicGAttributeInfo.java?view=diff&rev=109314&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/DynamicGAttributeInfo.java&r1=109313&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/DynamicGAttributeInfo.java&r2=109314 ============================================================================== --- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/DynamicGAttributeInfo.java (original) +++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/DynamicGAttributeInfo.java Wed Dec 1 00:01:37 2004 @@ -23,20 +23,8 @@ * @version $Rev$ $Date$ */ public class DynamicGAttributeInfo extends GAttributeInfo { - public DynamicGAttributeInfo(String name) { - this(name, false, true, true); - } - - public DynamicGAttributeInfo(String name, boolean persistent) { - this(name, persistent, true, true); - } - - public DynamicGAttributeInfo(String name, boolean persistent, boolean readable, boolean writable) { - super(name, Object.class.getName(), persistent, Boolean.valueOf(readable), Boolean.valueOf(writable), null, null); - } - public DynamicGAttributeInfo(String name, String type, boolean persistent, boolean readable, boolean writable) { - super(name, type, persistent, Boolean.valueOf(readable), Boolean.valueOf(writable), null, null); + super(name, type, persistent, readable, writable, null, null); } } Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GAttributeInfo.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GAttributeInfo.java?view=diff&rev=109314&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GAttributeInfo.java&r1=109313&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GAttributeInfo.java&r2=109314 ============================================================================== --- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GAttributeInfo.java (original) +++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GAttributeInfo.java Wed Dec 1 00:01:37 2004 @@ -43,12 +43,12 @@ /** * Is this attribute readable? */ - private final Boolean readable; + private final boolean readable; /** * Is this attribute writiable? */ - private final Boolean writable; + private final boolean writable; /** * Name of the getter method. @@ -62,15 +62,11 @@ */ private final String setterName; - public GAttributeInfo(String name, String type, boolean persistent) { - this(name, type, persistent, null, null, null, null); - } - public GAttributeInfo(String name, String type, boolean persistent, String getterName, String setterName) { - this(name, type, persistent, Boolean.valueOf(getterName != null), Boolean.valueOf(setterName != null), getterName, setterName); + this(name, type, persistent, getterName != null, setterName != null, getterName, setterName); } - public GAttributeInfo(String name, String type, boolean persistent, Boolean readable, Boolean writable, String getterName, String setterName) { + public GAttributeInfo(String name, String type, boolean persistent, boolean readable, boolean writable, String getterName, String setterName) { this.name = name; this.type = type; this.persistent = persistent; @@ -92,11 +88,11 @@ return persistent; } - public Boolean isReadable() { + public boolean isReadable() { return readable; } - public Boolean isWritable() { + public boolean isWritable() { return writable; } Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanInfo.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanInfo.java?view=diff&rev=109314&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanInfo.java&r1=109313&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanInfo.java&r2=109314 ============================================================================== --- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanInfo.java (original) +++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanInfo.java Wed Dec 1 00:01:37 2004 @@ -28,6 +28,9 @@ import java.util.Set; import java.util.Map; import java.util.HashMap; +import java.util.Arrays; + +import org.apache.geronimo.kernel.management.NotificationType; /** * Describes a GBean. @@ -35,6 +38,8 @@ * @version $Rev$ $Date$ */ public final class GBeanInfo implements Serializable { + private static final Set DEFAULT_NOTIFICATIONS = Collections.unmodifiableSet(new HashSet(Arrays.asList(NotificationType.TYPES))); + /** * Static helper to try to get the GBeanInfo from the class supplied. * @@ -72,10 +77,24 @@ private final Set notifications; private final Set references; + public GBeanInfo(String className, Collection attributes, GConstructorInfo constructor, Collection operations, Set references) { + this(className, className, attributes, constructor, operations, references, DEFAULT_NOTIFICATIONS); + } + + public GBeanInfo(String name, String className, Collection attributes, GConstructorInfo constructor, Collection operations, Set references) { + this(name, className, attributes, constructor, operations, references, DEFAULT_NOTIFICATIONS); + } + + /** + * @deprecated + */ public GBeanInfo(String className, Collection attributes, GConstructorInfo constructor, Collection operations, Set references, Set notifications) { this(className, className, attributes, constructor, operations, references, notifications); } + /** + * @deprecated + */ public GBeanInfo(String name, String className, Collection attributes, GConstructorInfo constructor, Collection operations, Set references, Set notifications) { this.name = name; this.className = className; Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanInfoBuilder.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanInfoBuilder.java?view=diff&rev=109314&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanInfoBuilder.java&r1=109313&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanInfoBuilder.java&r2=109314 ============================================================================== --- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanInfoBuilder.java (original) +++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanInfoBuilder.java Wed Dec 1 00:01:37 2004 @@ -17,9 +17,10 @@ package org.apache.geronimo.gbean; import java.beans.Introspector; +import java.lang.reflect.Constructor; import java.lang.reflect.Method; -import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -35,104 +36,57 @@ private final String name; - private final String className; + private final Class gbeanType; private final Map attributes = new HashMap(); - private GConstructorInfo constructor; + private GConstructorInfo constructor = new GConstructorInfo(); private final Map operations = new HashMap(); - private final Set references = new HashSet(); + private final Map references = new HashMap(); - private final Set notifications = new HashSet(); - - public GBeanInfoBuilder(String name) { - this(name, name, null); - } - - public GBeanInfoBuilder(Class clazz) { - this(checkNotNull(clazz).getName(), clazz.getName(), null); - } - - public GBeanInfoBuilder(String name, String className) { - this(name, className, null); - } - - public GBeanInfoBuilder(String name, Class clazz) { - this(name, checkNotNull(clazz).getName(), null); - } - - public GBeanInfoBuilder(Class clazz, GBeanInfo source) { - this(checkNotNull(clazz).getName(), clazz.getName(), source); + public GBeanInfoBuilder(Class gbeanType) { + this(checkNotNull(gbeanType).getName(), gbeanType, null); } - public GBeanInfoBuilder(String name, GBeanInfo source) { - this(checkNotNull(name), name, source); + public GBeanInfoBuilder(String name, Class gbeanType) { + this(name, checkNotNull(gbeanType), null); } - public GBeanInfoBuilder(String name, ClassLoader cl) { - this(checkNotNull(name), name, GBeanInfo.getGBeanInfo(name, cl)); + public GBeanInfoBuilder(Class gbeanType, GBeanInfo source) { + this(checkNotNull(gbeanType).getName(), gbeanType, source); } - public GBeanInfoBuilder(String name, Class clazz, GBeanInfo source) { - this(name, checkNotNull(clazz).getName(), source); + public GBeanInfoBuilder(String name, ClassLoader classLoader) { + this(checkNotNull(name), loadClass(classLoader, name), GBeanInfo.getGBeanInfo(name, classLoader)); } - public GBeanInfoBuilder(String name, String className, GBeanInfo source) { + public GBeanInfoBuilder(String name, Class gbeanType, GBeanInfo source) { checkNotNull(name); - checkNotNull(className); + checkNotNull(gbeanType); this.name = name; - this.className = className; + this.gbeanType = gbeanType; if (source != null) { - Set sourceAttributes = source.getAttributes(); - if (sourceAttributes != null && !sourceAttributes.isEmpty()) { - for (Iterator it = sourceAttributes.iterator(); it.hasNext();) { - GAttributeInfo attributeInfo = (GAttributeInfo) it.next(); - attributes.put(attributeInfo.getName(), attributeInfo); - } + for (Iterator i = source.getAttributes().iterator(); i.hasNext();) { + GAttributeInfo attributeInfo = (GAttributeInfo) i.next(); + attributes.put(attributeInfo.getName(), attributeInfo); } - Set sourceOperations = source.getOperations(); - if (sourceOperations != null && !sourceOperations.isEmpty()) { - for (Iterator it = sourceOperations.iterator(); it.hasNext();) { - GOperationInfo operationInfo = (GOperationInfo) it.next(); - operations.put(new GOperationSignature(operationInfo.getName(), - operationInfo.getParameterList()), operationInfo); - } + + for (Iterator i = source.getOperations().iterator(); i.hasNext();) { + GOperationInfo operationInfo = (GOperationInfo) i.next(); + operations.put(new GOperationSignature(operationInfo.getName(), + operationInfo.getParameterList()), operationInfo); } - references.addAll(source.getReferences()); - notifications.addAll(source.getNotifications()); - //in case subclass constructor has same parameters as superclass. - constructor = source.getConstructor(); - } - } - /** - * Checks whether or not the input argument is null; otherwise it throws - * [EMAIL PROTECTED] IllegalArgumentException}. - * - * @param clazz the input argument to validate - * @throws IllegalArgumentException if input is null - */ - private static Class checkNotNull(final Class clazz) { - if (clazz == null) { - throw new IllegalArgumentException("null argument supplied"); - } - return clazz; - } + for (Iterator iterator = source.getReferences().iterator(); iterator.hasNext();) { + GReferenceInfo referenceInfo = (GReferenceInfo) iterator.next(); + references.put(referenceInfo.getName(), referenceInfo.getReferenceType()); + } - /** - * Checks whether or not the input argument is null; otherwise it throws - * [EMAIL PROTECTED] IllegalArgumentException}. - * - * @param string the input argument to validate - * @throws IllegalArgumentException if input is null - */ - private static String checkNotNull(final String string) { - if (string == null) { - throw new IllegalArgumentException("null argument supplied"); + //in case subclass constructor has same parameters as superclass. + constructor = source.getConstructor(); } - return string; } public void addInterface(Class intf) { @@ -142,55 +96,68 @@ //do not use beaninfo Introspector to list the properties. This method is primarily for interfaces, //and it does not process superinterfaces. It seems to really only work well for classes. public void addInterface(Class intf, String[] persistentAttributes) { - Set persistentName = new HashSet(Arrays.asList(persistentAttributes)); + Set persistentNames = new HashSet(Arrays.asList(persistentAttributes)); Method[] methods = intf.getMethods(); for (int i = 0; i < methods.length; i++) { Method method = methods[i]; - String name = method.getName(); - Class[] parameterTypes = method.getParameterTypes(); - if ((name.startsWith("get") || name.startsWith("is")) && parameterTypes.length == 0) { - String attributeName = (name.startsWith("get")) ? name.substring(3) : name.substring(2); - attributeName = Introspector.decapitalize(attributeName); + if (isGetter(method)) { + String attributeName = getAttributeName(method); GAttributeInfo attribute = (GAttributeInfo) attributes.get(attributeName); - String type = method.getReturnType().getName(); + String attributeType = method.getReturnType().getName(); if (attribute == null) { - attributes.put(attributeName, new GAttributeInfo(attributeName, type, persistentName.contains(attributeName), name, null)); + attributes.put(attributeName, + new GAttributeInfo(attributeName, + attributeType, + persistentNames.contains(attributeName), + method.getName(), + null)); } else { - if (!type.equals(attribute.getType())) { + if (!attributeType.equals(attribute.getType())) { throw new IllegalArgumentException("Getter and setter type do not match: " + attributeName); } - attributes.put(attributeName, new GAttributeInfo(attributeName, type, attribute.isPersistent(), name, attribute.getSetterName())); + attributes.put(attributeName, + new GAttributeInfo(attributeName, + attributeType, + attribute.isPersistent(), + method.getName(), + attribute.getSetterName())); } - } else if (name.startsWith("set") && parameterTypes.length == 1) { - String attributeName = name.substring(3); - attributeName = Introspector.decapitalize(attributeName); + } else if (isSetter(method)) { + String attributeName = getAttributeName(method); + String attributeType = method.getParameterTypes()[0].getName(); GAttributeInfo attribute = (GAttributeInfo) attributes.get(attributeName); - String type = method.getParameterTypes()[0].getName(); if (attribute == null) { - attributes.put(attributeName, new GAttributeInfo(attributeName, type, persistentName.contains(attributeName), null, name)); + attributes.put(attributeName, + new GAttributeInfo(attributeName, + attributeType, + persistentNames.contains(attributeName), + null, + method.getName())); } else { - if (!type.equals(attribute.getType())) { + if (!attributeType.equals(attribute.getType())) { throw new IllegalArgumentException("Getter and setter type do not match: " + attributeName); } - attributes.put(attributeName, new GAttributeInfo(attributeName, type, attribute.isPersistent(), attribute.getGetterName(), name)); + attributes.put(attributeName, + new GAttributeInfo(attributeName, + attributeType, + attribute.isPersistent(), + attribute.getGetterName(), + method.getName())); } } else { - List parameters = new ArrayList(parameterTypes.length); - for (int j = 0; j < parameterTypes.length; j++) { - parameters.add(parameterTypes[j].getName()); - } - addOperation(new GOperationInfo(name, name, parameters)); + addOperation(new GOperationInfo(method.getName(), method.getParameterTypes())); } } } - public void addAttribute(String name, Class type, boolean persistent) { - addAttribute(new GAttributeInfo(name, type.getName(), persistent)); + addAttribute(name, type.getName(), persistent); } public void addAttribute(String name, String type, boolean persistent) { - addAttribute(new GAttributeInfo(name, type, persistent)); + String getter = searchForGetter(name, type, gbeanType); + String setter = searchForSetter(name, type, gbeanType); + addAttribute(new GAttributeInfo(name, type, persistent, getter, setter)); } public void addAttribute(GAttributeInfo info) { @@ -198,6 +165,7 @@ } public void setConstructor(GConstructorInfo constructor) { + assert constructor != null; this.constructor = constructor; } @@ -218,18 +186,233 @@ } public void addReference(GReferenceInfo info) { - references.add(info); + references.put(info.getName(), info.getReferenceType()); } public void addReference(String name, Class type) { - addReference(new GReferenceInfo(name, type)); + references.put(name, type.getName()); } - public void addNotification(GNotificationInfo info) { - notifications.add(info); + public GBeanInfo getBeanInfo() { + // get the types of the constructor args + // this also verifies that we have a valid constructor + Map constructorTypes = getConstructorTypes(); + + // build the reference infos now that we know the constructor types + Set referenceInfos = new HashSet(); + for (Iterator iterator = references.entrySet().iterator(); iterator.hasNext();) { + Map.Entry entry = (Map.Entry) iterator.next(); + String referenceName = (String) entry.getKey(); + String referenceType = (String) entry.getValue(); + + String proxyType = (String) constructorTypes.get(referenceName); + String setterName = null; + if (proxyType == null) { + Method setter = searchForSetterMethod(referenceName, referenceType, gbeanType); + if (setter == null) { + setter = searchForSetterMethod(referenceName, Collection.class.getName(), gbeanType); + if (setter == null) { + throw new InvalidConfigurationException("Reference must be a constructor argument or have a setter: name=" + referenceName); + } + } + proxyType = setter.getParameterTypes()[0].getName(); + + setterName = setter.getName(); + } + + if (!proxyType.equals(Collection.class.getName()) && !proxyType.equals(referenceType)) { + throw new InvalidConfigurationException("Reference proxy type must be Collection or " + referenceType + ": name=" + referenceName); + } + + referenceInfos.add(new GReferenceInfo(referenceName, referenceType, proxyType, setterName)); + } + + + return new GBeanInfo(name, gbeanType.getName(), attributes.values(), constructor, operations.values(), referenceInfos); } - public GBeanInfo getBeanInfo() { - return new GBeanInfo(name, className, attributes.values(), constructor, operations.values(), references, notifications); + private Map getConstructorTypes() throws InvalidConfigurationException { + List arguments = constructor.getAttributeNames(); + String[] argumentTypes = new String[arguments.size()]; + boolean[] isReference = new boolean[arguments.size()]; + for (int i = 0; i < argumentTypes.length; i++) { + String argumentName = (String) arguments.get(i); + if (attributes.containsKey(argumentName)) { + GAttributeInfo attribute = (GAttributeInfo) attributes.get(argumentName); + argumentTypes[i] = attribute.getType(); + isReference[i] = false; + } else if (references.containsKey(argumentName)) { + argumentTypes[i] = (String) references.get(argumentName); + isReference[i] = true; + } + } + + Constructor[] constructors = gbeanType.getConstructors(); + Set validConstructors = new HashSet(); + for (int i = 0; i < constructors.length; i++) { + Constructor constructor = constructors[i]; + if (isValidConstructor(constructor, argumentTypes, isReference)) { + validConstructors.add(constructor); + } + } + + if (validConstructors.isEmpty()) { + throw new InvalidConfigurationException("Could not find a valid constructor for GBean: " + name); + } + if (validConstructors.size() > 1) { + throw new InvalidConfigurationException("More then one valid constructors found for GBean: " + name); + } + + Map constructorTypes = new HashMap(); + Constructor constructor = (Constructor) validConstructors.iterator().next(); + Class[] parameterTypes = constructor.getParameterTypes(); + Iterator argumentIterator = arguments.iterator(); + for (int i = 0; i < parameterTypes.length; i++) { + String parameterType = parameterTypes[i].getName(); + String argumentName = (String) argumentIterator.next(); + constructorTypes.put(argumentName, parameterType); + } + return constructorTypes; + } + + private static String searchForGetter(String name, String type, Class gbeanType) throws InvalidConfigurationException { + Method getterMethod = null; + + // no explicit name give so we must search for a name + String getterName = "get" + name; + String isName = "is" + name; + Method[] methods = gbeanType.getMethods(); + for (int i = 0; i < methods.length; i++) { + if (methods[i].getParameterTypes().length == 0 && methods[i].getReturnType() != Void.TYPE + && (getterName.equalsIgnoreCase(methods[i].getName()) || isName.equalsIgnoreCase(methods[i].getName()))) { + + // found it + getterMethod = methods[i]; + break; + } + } + + // if the return type of the getter doesn't match, throw an exception + if (getterMethod != null && !type.equals(getterMethod.getReturnType().getName())) { + throw new InvalidConfigurationException("Incorrect return type for getter method:" + + " name=" + name + + ", targetClass=" + gbeanType.getName() + + ", getter type=" + getterMethod.getReturnType() + + ", expected type=" + type); + } + + if (getterMethod == null) { + return null; + } + return getterMethod.getName(); + } + + private static String searchForSetter(String name, String type, Class gbeanType) throws InvalidConfigurationException { + Method method = searchForSetterMethod(name, type, gbeanType); + if (method == null) { + return null; + } + return method.getName(); + } + + private static Method searchForSetterMethod(String name, String type, Class gbeanType) throws InvalidConfigurationException { + // no explicit name give so we must search for a name + String setterName = "set" + name; + Method[] methods = gbeanType.getMethods(); + for (int i = 0; i < methods.length; i++) { + Method method = methods[i]; + if (method.getParameterTypes().length == 1 && + method.getParameterTypes()[0].getName().equals(type) && + method.getReturnType() == Void.TYPE && + setterName.equalsIgnoreCase(method.getName())) { + + return method; + } + } + + // a setter is not necessary for this attribute + return null; + } + + private static boolean isValidConstructor(Constructor constructor, String[] argumentTypes, boolean[] isReference) { + Class[] parameterTypes = constructor.getParameterTypes(); + + // same number of parameters? + if (parameterTypes.length != argumentTypes.length) { + return false; + } + + // is each parameter the correct type? + for (int i = 0; i < parameterTypes.length; i++) { + String parameterType = parameterTypes[i].getName(); + if (isReference[i]) { + // reference: does type match + // OR is it a java.util.Collection + // OR is it a java.util.Set? + if (!parameterType.equals(argumentTypes[i]) && + !parameterType.equals(Collection.class.getName()) && + !parameterType.equals(Set.class.getName())) { + return false; + } + } else { + // attribute: does type match? + if (!parameterType.equals(argumentTypes[i])) { + return false; + } + } + } + return true; + } + + private String getAttributeName(Method method) { + String name = method.getName(); + String attributeName = (name.startsWith("get") || name.startsWith("set")) ? name.substring(3) : name.substring(2); + attributeName = Introspector.decapitalize(attributeName); + return attributeName; + } + + private boolean isSetter(Method method) { + return method.getName().startsWith("set") && method.getParameterTypes().length == 1; + } + + private static boolean isGetter(Method method) { + String name = method.getName(); + return (name.startsWith("get") || name.startsWith("is")) && method.getParameterTypes().length == 0; + } + + /** + * Checks whether or not the input argument is null; otherwise it throws + * [EMAIL PROTECTED] IllegalArgumentException}. + * + * @param clazz the input argument to validate + * @throws IllegalArgumentException if input is null + */ + private static Class checkNotNull(final Class clazz) { + if (clazz == null) { + throw new IllegalArgumentException("null argument supplied"); + } + return clazz; + } + + /** + * Checks whether or not the input argument is null; otherwise it throws + * [EMAIL PROTECTED] IllegalArgumentException}. + * + * @param string the input argument to validate + * @throws IllegalArgumentException if input is null + */ + private static String checkNotNull(final String string) { + if (string == null) { + throw new IllegalArgumentException("null argument supplied"); + } + return string; + } + + private static Class loadClass(ClassLoader classLoader, String name) { + try { + return classLoader.loadClass(name); + } catch (ClassNotFoundException e) { + throw new InvalidConfigurationException("Could not load class " + name, e); + } } } Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GConstructorInfo.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GConstructorInfo.java?view=diff&rev=109314&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GConstructorInfo.java&r1=109313&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GConstructorInfo.java&r2=109314 ============================================================================== --- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GConstructorInfo.java (original) +++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GConstructorInfo.java Wed Dec 1 00:01:37 2004 @@ -28,6 +28,10 @@ public class GConstructorInfo implements Serializable { private final List attributeNames; + public GConstructorInfo() { + this.attributeNames = Collections.EMPTY_LIST; + } + public GConstructorInfo(String[] attributeNames) { this(Arrays.asList(attributeNames)); } Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GReferenceInfo.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GReferenceInfo.java?view=diff&rev=109314&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GReferenceInfo.java&r1=109313&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GReferenceInfo.java&r2=109314 ============================================================================== --- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GReferenceInfo.java (original) +++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/GReferenceInfo.java Wed Dec 1 00:01:37 2004 @@ -32,38 +32,35 @@ /** * Type of this reference. */ - private final String type; + private final String referenceType; + + /** + * Type of the proxy injected into the bean. + */ + private final String proxyType; /** * Name of the setter method. - * The default is "set" + name. In the case of a default value we do a caseless search for the name. */ private final String setterName; - public GReferenceInfo() { - this(null, null, null); - } - - public GReferenceInfo(String name, String type) { - this(name, type, null); - } - - public GReferenceInfo(String name, Class type) { - this(name, type.getName(), null); - } - - public GReferenceInfo(String name, String type, String setterName) { + public GReferenceInfo(String name, String referenceType, String proxyType, String setterName) { this.name = name; - this.type = type; + this.referenceType = referenceType; this.setterName = setterName; + this.proxyType = proxyType; } public String getName() { return name; } - public String getType() { - return type; + public String getReferenceType() { + return referenceType; + } + + public String getProxyType() { + return proxyType; } public String getSetterName() { @@ -72,7 +69,8 @@ public String toString() { return "[GReferenceInfo: name=" + name + - " type=" + type + + " referenceType=" + referenceType + + " proxyType=" + proxyType + " setterName=" + setterName + "]"; } Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanJMXUtil.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanJMXUtil.java?view=diff&rev=109314&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanJMXUtil.java&r1=109313&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanJMXUtil.java&r2=109314 ============================================================================== --- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanJMXUtil.java (original) +++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanJMXUtil.java Wed Dec 1 00:01:37 2004 @@ -48,7 +48,7 @@ int a = 0; for (Iterator iterator = gbeanAttributes.iterator(); iterator.hasNext();) { GAttributeInfo gAttributeInfo = (GAttributeInfo) iterator.next(); - attributes[a] = new MBeanAttributeInfo(gAttributeInfo.getName(), gAttributeInfo.getType(), "no description available", gAttributeInfo.isReadable().booleanValue(), gAttributeInfo.isWritable().booleanValue(), isIs(gAttributeInfo)); + attributes[a] = new MBeanAttributeInfo(gAttributeInfo.getName(), gAttributeInfo.getType(), "no description available", gAttributeInfo.isReadable(), gAttributeInfo.isWritable(), isIs(gAttributeInfo)); a++; } Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/AbstractGBeanReference.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/AbstractGBeanReference.java?view=diff&rev=109314&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/AbstractGBeanReference.java&r1=109313&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/AbstractGBeanReference.java&r2=109314 ============================================================================== --- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/AbstractGBeanReference.java (original) +++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/AbstractGBeanReference.java Wed Dec 1 00:01:37 2004 @@ -46,7 +46,12 @@ /** * Interface this GBeanInstance uses to refer to the other. */ - private final Class type; + private final Class referenceType; + + /** + * Proxy type which is injected into the GBeanInstance. + */ + private final Class proxyType; /** * The GBeanInstance to which this reference belongs. @@ -74,6 +79,8 @@ */ private final Set targets = new HashSet(); + private final GReferenceInfo referenceInfo; + /** * The kernel to which the reference is bound. */ @@ -84,25 +91,34 @@ */ private Object proxy; - public AbstractGBeanReference(GBeanInstance gbeanInstance, GReferenceInfo referenceInfo, Class constructorType) throws InvalidConfigurationException { + public AbstractGBeanReference(GBeanInstance gbeanInstance, GReferenceInfo referenceInfo) throws InvalidConfigurationException { this.gbeanInstance = gbeanInstance; + this.referenceInfo = referenceInfo; this.name = referenceInfo.getName(); try { - this.type = ClassLoading.loadClass(referenceInfo.getType(), gbeanInstance.getClassLoader()); + this.referenceType = ClassLoading.loadClass(referenceInfo.getReferenceType(), gbeanInstance.getClassLoader()); } catch (ClassNotFoundException e) { - throw new InvalidConfigurationException("Could not load reference proxy interface class:" + - " name=" + name + - " class=" + referenceInfo.getType()); + throw new InvalidConfigurationException("Could not load reference proxy interface class:" + getDescription()); } - if (Modifier.isFinal(type.getModifiers())) { - throw new IllegalArgumentException("Proxy interface cannot be a final class: " + type.getName()); + if (Modifier.isFinal(referenceType.getModifiers())) { + throw new IllegalArgumentException("Proxy interface cannot be a final class: " + referenceType.getName()); + } + try { + this.proxyType = ClassLoading.loadClass(referenceInfo.getProxyType(), gbeanInstance.getClassLoader()); + } catch (ClassNotFoundException e) { + throw new InvalidConfigurationException("Could not load proxy class:" + getDescription()); } - if (constructorType != null) { - setInvoker = null; + if (referenceInfo.getSetterName() != null) { + try { + String setterName = referenceInfo.getSetterName(); + Method setterMethod = gbeanInstance.getType().getMethod(setterName, new Class[] {proxyType}); + setInvoker = new FastMethodInvoker(setterMethod); + } catch (NoSuchMethodException e) { + throw new InvalidConfigurationException("Setter method not found " + getDescription()); + } } else { - Method setterMethod = searchForSetter(gbeanInstance, referenceInfo); - setInvoker = new FastMethodInvoker(setterMethod); + setInvoker = null; } listener = new LifecycleAdapter() { @@ -150,8 +166,16 @@ return name; } - public final Class getType() { - return type; + public final GReferenceInfo getReferenceInfo() { + return referenceInfo; + } + + public final Class getReferenceType() { + return referenceType; + } + + public final Class getProxyType() { + return proxyType; } public Object getProxy() { @@ -251,37 +275,10 @@ } } - protected static Method searchForSetter(GBeanInstance gbeanInstance, GReferenceInfo referenceInfo) throws InvalidConfigurationException { - if (referenceInfo.getSetterName() == null) { - // no explicit name give so we must search for a name - String setterName = "set" + referenceInfo.getName(); - Method[] methods = gbeanInstance.getType().getMethods(); - for (int i = 0; i < methods.length; i++) { - Method method = methods[i]; - if (method.getParameterTypes().length == 1 && - method.getReturnType() == Void.TYPE && - setterName.equalsIgnoreCase(method.getName())) { - - return method; - } - } - } else { - // even though we have an exact name we need to search the methods because - // we don't know the parameter type - Method[] methods = gbeanInstance.getType().getMethods(); - String setterName = referenceInfo.getSetterName(); - for (int i = 0; i < methods.length; i++) { - Method method = methods[i]; - if (method.getParameterTypes().length == 1 && - method.getReturnType() == Void.TYPE && - setterName.equals(method.getName())) { - - return method; - } - } - } - throw new InvalidConfigurationException("Target does not have specified method:" + - " name=" + referenceInfo.getName() + - " targetClass=" + gbeanInstance.getType().getName()); + protected final String getDescription() { + return "Reference Name: " + getName() + + ", Reference Type: " + getReferenceType() + + ", Proxy Type: " + getProxy() + + ", GBeanInstance: " + gbeanInstance.getName(); } } Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanAttribute.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanAttribute.java?view=diff&rev=109314&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanAttribute.java&r1=109313&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanAttribute.java&r2=109314 ============================================================================== --- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanAttribute.java (original) +++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanAttribute.java Wed Dec 1 00:01:37 2004 @@ -60,6 +60,8 @@ private final boolean dynamic; + private final GAttributeInfo attributeInfo; + static GBeanAttribute createSpecialAttribute(GBeanAttribute attribute, GBeanInstance gbeanInstance, String name, Class type, Object value) { return new GBeanAttribute(attribute, gbeanInstance, name, type, value); } @@ -109,6 +111,26 @@ // persistence this.persistent = false; initializePersistentValue(value); + + // create an attribute info for this gbean + if (attribute != null) { + GAttributeInfo attributeInfo = attribute.getAttributeInfo(); + this.attributeInfo = new GAttributeInfo(this.name, + this.type.getName(), + this.persistent, + this.readable, + this.writable, + attributeInfo.getGetterName(), + attributeInfo.getSetterName()); + } else { + this.attributeInfo = new GAttributeInfo(this.name, + this.type.getName(), + this.persistent, + this.readable, + this.writable, + null, + null); + } } static GBeanAttribute createFrameworkAttribute(GBeanInstance gbeanInstance, String name, Class type, MethodInvoker getInvoker) { @@ -144,6 +166,15 @@ // persistence this.persistent = persistent; initializePersistentValue(persistentValue); + + // create an attribute info for this gbean + attributeInfo = new GAttributeInfo(this.name, + this.type.getName(), + this.persistent, + this.readable, + this.writable, + null, + null); } public GBeanAttribute(GBeanInstance gbeanInstance, GAttributeInfo attributeInfo, boolean isConstructorArg) throws InvalidConfigurationException { @@ -153,11 +184,12 @@ if (gbeanInstance == null || attributeInfo == null) { throw new IllegalArgumentException("null param(s) supplied"); } - if (attributeInfo.isReadable() == Boolean.FALSE && attributeInfo.isWritable() == Boolean.FALSE && !attributeInfo.isPersistent()) { - throw new InvalidConfigurationException("An attribute must be readable, writable, or persistent: +" - + " name=" + attributeInfo.getName() + " targetClass=" + gbeanInstance.getType().getName()); + 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 { @@ -167,17 +199,18 @@ } this.persistent = attributeInfo.isPersistent(); + readable = attributeInfo.isReadable(); + writable = attributeInfo.isWritable(); + // If attribute is persistent or not tagged as unreadable, search for a // getter method if (attributeInfo instanceof DynamicGAttributeInfo) { this.dynamic = true; - readable = attributeInfo.isReadable().booleanValue(); if (readable) { getInvoker = new DynamicGetterMethodInvoker(name); } else { getInvoker = null; } - writable = attributeInfo.isWritable().booleanValue(); if (writable) { setInvoker = new DynamicSetterMethodInvoker(name); } else { @@ -185,36 +218,34 @@ } } else { this.dynamic = false; - Method getterMethod = null; - if (attributeInfo.isPersistent() || attributeInfo.isReadable() != Boolean.FALSE) { - getterMethod = searchForGetter(gbeanInstance, attributeInfo, type); - } - if (getterMethod != null) { - getInvoker = new FastMethodInvoker(getterMethod); - - // this attribute is readable as long as it was not explicitly - // tagged as unreadable - readable = attributeInfo.isReadable() != Boolean.FALSE; + if (attributeInfo.getGetterName() != null) { + try { + String getterName = attributeInfo.getGetterName(); + Method getterMethod = gbeanInstance.getType().getMethod(getterName, null); + + if (!getterMethod.getReturnType().equals(type)) { + throw new InvalidConfigurationException("Getter method not found " +getDescription()); + } + getInvoker = new FastMethodInvoker(getterMethod); + } catch (NoSuchMethodException e) { + throw new InvalidConfigurationException("Getter method not found " +getDescription()); + } } else { getInvoker = null; - readable = false; } // If attribute is persistent or not tagged as unwritable, search // for a setter method - Method setterMethod = null; - if (attributeInfo.isPersistent() || attributeInfo.isWritable() != Boolean.FALSE) { - setterMethod = searchForSetter(gbeanInstance, attributeInfo, type); - } - if (setterMethod != null) { - setInvoker = new FastMethodInvoker(setterMethod); - - // this attribute is writable as long as it was not explicitly - // tagged as unwritable - writable = attributeInfo.isWritable() != Boolean.FALSE; + if (attributeInfo.getSetterName() != null) { + try { + String setterName = attributeInfo.getSetterName(); + Method setterMethod = gbeanInstance.getType().getMethod(setterName, new Class[] {type}); + setInvoker = new FastMethodInvoker(setterMethod); + } catch (NoSuchMethodException e) { + throw new InvalidConfigurationException("Setter method not found " + getDescription()); + } } else { setInvoker = null; - writable = false; } } @@ -250,6 +281,10 @@ return name; } + public GAttributeInfo getAttributeInfo() { + return attributeInfo; + } + public boolean isReadable() { return readable; } @@ -316,7 +351,7 @@ if (special) { return persistentValue; } - + // get the target to invoke Object target = gbeanInstance.getTarget(); if (target == null && !framework) { @@ -356,103 +391,6 @@ public String getDescription() { return "Attribute Name: " + getName() + ", Type: " + getType() + ", GBeanInstance: " + gbeanInstance.getName(); - } - - private static Method searchForGetter(GBeanInstance gbeanInstance, GAttributeInfo attributeInfo, Class type) throws InvalidConfigurationException { - Method getterMethod = null; - if (attributeInfo.getGetterName() == null) { - // no explicit name give so we must search for a name - String getterName = "get" + attributeInfo.getName(); - String isName = "is" + attributeInfo.getName(); - Method[] methods = gbeanInstance.getType().getMethods(); - for (int i = 0; i < methods.length; i++) { - if (methods[i].getParameterTypes().length == 0 && methods[i].getReturnType() != Void.TYPE - && (getterName.equalsIgnoreCase(methods[i].getName()) || isName.equalsIgnoreCase(methods[i].getName()))) { - - // found it - getterMethod = methods[i]; - break; - } - } - } else { - // we have an explicit name, so no searching is necessary - try { - getterMethod = gbeanInstance.getType().getMethod(attributeInfo.getGetterName(), null); - if (getterMethod.getReturnType() == Void.TYPE) { - throw new InvalidConfigurationException("Getter method return VOID:" + - " name=" + attributeInfo.getName() + - ", type=" + type.getName() + - ", targetClass=" + gbeanInstance.getType().getName()); - } - } catch (Exception e) { - // we will throw the formatted exception below - } - } - - // if the return type of the getter doesn't match, throw an exception - if (getterMethod != null && !type.equals(getterMethod.getReturnType())) { - throw new InvalidConfigurationException("Incorrect return type for getter method:" + - " name=" + attributeInfo.getName() + - ", targetClass=" + gbeanInstance.getType().getName() + - ", getter type=" + getterMethod.getReturnType() + - ", expected type=" + type.getName()); - } - - // if this attribute was explicity tagged as being readable but there is not getter - if (getterMethod == null && attributeInfo.isReadable() == Boolean.TRUE) { - throw new InvalidConfigurationException("Getter method not found on target:" + - " name=" + attributeInfo.getName() + - ", type=" + type.getName() + - ", targetClass=" + gbeanInstance.getType().getName()); - } - - return getterMethod; - } - - private static Method searchForSetter(GBeanInstance gbeanInstance, GAttributeInfo attributeInfo, Class type) throws InvalidConfigurationException { - if (attributeInfo.getSetterName() == null) { - // no explicit name give so we must search for a name - String setterName = "set" + attributeInfo.getName(); - Method[] methods = gbeanInstance.getType().getMethods(); - for (int i = 0; i < methods.length; i++) { - Method method = methods[i]; - if (method.getParameterTypes().length == 1 && - method.getParameterTypes()[0].equals(type) && - method.getReturnType() == Void.TYPE && - setterName.equalsIgnoreCase(method.getName())) { - - return method; - } - } - } else { - // we have an explicit name, so no searching is necessary - try { - Method method = gbeanInstance.getType().getMethod(attributeInfo.getSetterName(), new Class[]{type}); - if (method.getReturnType() != Void.TYPE) { - throw new InvalidConfigurationException("Setter method must return VOID:" + - " name=" + attributeInfo.getName() + - ", type=" + type.getName() + - ", targetClass=" + gbeanInstance.getType().getName()); - } - return method; - } catch (Exception e) { - // we will throw the formatted exception below - } - } - - // An attribute must have a setter if it was explicitly tagged as - // writable or if it is persistent and it is not a constructor arg - // (if it is persistent we must have a way to set the data into the - // instance) - if (attributeInfo.isWritable() == Boolean.TRUE) { - throw new InvalidConfigurationException("Setter method not found on target:" + - " name=" + attributeInfo.getName() + - ", type=" + type.getName() + - ", targetClass=" + gbeanInstance.getType().getName()); - } - - // a setter is not necessary for this attribute - return null; } private static final class DynamicGetterMethodInvoker implements MethodInvoker { Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanCollectionReference.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanCollectionReference.java?view=diff&rev=109314&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanCollectionReference.java&r1=109313&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanCollectionReference.java&r2=109314 ============================================================================== --- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanCollectionReference.java (original) +++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanCollectionReference.java Wed Dec 1 00:01:37 2004 @@ -26,8 +26,8 @@ * @version $Rev: 71492 $ $Date: 2004-11-14 21:31:50 -0800 (Sun, 14 Nov 2004) $ */ public class GBeanCollectionReference extends AbstractGBeanReference { - public GBeanCollectionReference(GBeanInstance gbeanInstance, GReferenceInfo referenceInfo, Class constructorType) throws InvalidConfigurationException { - super(gbeanInstance, referenceInfo, constructorType); + public GBeanCollectionReference(GBeanInstance gbeanInstance, GReferenceInfo referenceInfo) throws InvalidConfigurationException { + super(gbeanInstance, referenceInfo); } public synchronized void start() throws Exception { @@ -42,7 +42,7 @@ } // add a dependency on our target and create the proxy - setProxy(new ProxyCollection(getName(), getType(), getKernel().getProxyManager(), getTargets())); + setProxy(new ProxyCollection(getName(), getReferenceType(), getKernel().getProxyManager(), getTargets())); } public synchronized void stop() { Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java?view=diff&rev=109314&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java&r1=109313&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java&r2=109314 ============================================================================== --- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java (original) +++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java Wed Dec 1 00:01:37 2004 @@ -19,7 +19,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -42,7 +42,6 @@ import org.apache.geronimo.gbean.GReferenceInfo; import org.apache.geronimo.gbean.InvalidConfigurationException; import org.apache.geronimo.gbean.WaitingException; -import org.apache.geronimo.gbean.DynamicGAttributeInfo; import org.apache.geronimo.kernel.Kernel; import org.apache.geronimo.kernel.LifecycleListener; import org.apache.geronimo.kernel.NoSuchAttributeException; @@ -209,23 +208,14 @@ name = gbeanInfo.getName(); - // get the constructor - constructor = Util.searchForConstructor(gbeanInfo, type); - - // build a map from constructor argument names to type - Class[] constructorParameterTypes = constructor.getParameterTypes(); - Map constructorTypes = new HashMap(constructorParameterTypes.length); - List constructorAttributeNames = gbeanInfo.getConstructor().getAttributeNames(); - for (int i = 0; i < constructorParameterTypes.length; i++) { - Class type = constructorParameterTypes[i]; - constructorTypes.put(constructorAttributeNames.get(i), type); - } + // + Set constructorArgs = new HashSet(gbeanInfo.getConstructor().getAttributeNames()); // attributes Map attributesMap = new HashMap(); for (Iterator iterator = gbeanInfo.getAttributes().iterator(); iterator.hasNext();) { GAttributeInfo attributeInfo = (GAttributeInfo) iterator.next(); - attributesMap.put(attributeInfo.getName(), new GBeanAttribute(this, attributeInfo, constructorTypes.containsKey(attributeInfo.getName()))); + attributesMap.put(attributeInfo.getName(), new GBeanAttribute(this, attributeInfo, constructorArgs.contains(attributeInfo.getName()))); } addManagedObjectAttributes(attributesMap); attributes = (GBeanAttribute[]) attributesMap.values().toArray(new GBeanAttribute[attributesMap.size()]); @@ -237,11 +227,10 @@ Set referencesSet = new HashSet(); for (Iterator iterator = gbeanInfo.getReferences().iterator(); iterator.hasNext();) { GReferenceInfo referenceInfo = (GReferenceInfo) iterator.next(); - Class constructorType = (Class) constructorTypes.get(referenceInfo.getName()); - if (Util.isCollectionValuedReference(this, referenceInfo, constructorType)) { - referencesSet.add(new GBeanCollectionReference(this, referenceInfo, constructorType)); + if (referenceInfo.getProxyType().equals(Collection.class.getName())) { + referencesSet.add(new GBeanCollectionReference(this, referenceInfo)); } else { - referencesSet.add(new GBeanSingleReference(this, referenceInfo, constructorType)); + referencesSet.add(new GBeanSingleReference(this, referenceInfo)); } } references = (GBeanReference[]) referencesSet.toArray(new GBeanReference[gbeanInfo.getReferences().size()]); @@ -270,8 +259,33 @@ opCounter++; } + // get the constructor + List arguments = gbeanInfo.getConstructor().getAttributeNames(); + Class[] parameterTypes = new Class[arguments.size()]; + for (int i = 0; i < parameterTypes.length; i++) { + String argumentName = (String) arguments.get(i); + if (attributeIndex.containsKey(argumentName)) { + Integer index = (Integer) attributeIndex.get(argumentName); + GBeanAttribute attribute = attributes[index.intValue()]; + parameterTypes[i] = attribute.getType(); + } else if (referenceIndex.containsKey(argumentName)) { + Integer index = (Integer) referenceIndex.get(argumentName); + GBeanReference reference = references[index.intValue()]; + parameterTypes[i] = reference.getProxyType(); + } + } + try { + constructor = type.getConstructor(parameterTypes); + } catch (NoSuchMethodException e) { + throw new InvalidConfigurationException("Could not find a valid constructor for GBean: " + gbeanInfo.getName()); + } + + // rebuild the gbean info based on the current attributes, operations, and references because + // the above code add new attributes and operations + this.gbeanInfo = rebuildGBeanInfo(gbeanInfo.getConstructor()); + + // create the raw invokers rawInvoker = new RawInvoker(this); - this.gbeanInfo = rebuildGBeanInfo(gbeanInfo); // set the initial attribute values try { @@ -757,10 +771,6 @@ } else { throw new InvalidConfigurationException("Unknown attribute or reference name in constructor: name=" + name); } - assert parameters[i] == null || parameterTypes[i].isPrimitive() || parameterTypes[i].isAssignableFrom(parameters[i].getClass()): - "Attempting to construct " + objectName + " of type " + gbeanInfo.getClassName() - + ". Constructor parameter " + i + " should be " + parameterTypes[i].getName() - + " but is " + parameters[i].getClass().getName(); } // create instance @@ -990,54 +1000,34 @@ })); } - public String toString() { - if (objectName == null) { - return super.toString(); - } - return objectName.toString(); - } - - // todo this is a lame hack to get around the gbean info not being accurate when the gbean instance is creted - private GBeanInfo rebuildGBeanInfo(GBeanInfo source) { + private GBeanInfo rebuildGBeanInfo(GConstructorInfo constructor) { Set attributeInfos = new HashSet(); for (int i = 0; i < attributes.length; i++) { GBeanAttribute attribute = attributes[i]; - if (attribute.isDynamic()) { - attributeInfos.add(new DynamicGAttributeInfo(attribute.getName(), - attribute.getType().getName(), - attribute.isPersistent(), - attribute.isReadable(), - attribute.isWritable() - )); - } else { - attributeInfos.add(new GAttributeInfo(attribute.getName(), - attribute.getType().getName(), - attribute.isPersistent(), - Boolean.valueOf(attribute.isReadable()), - Boolean.valueOf(attribute.isWritable()), - null, - null - )); - } + attributeInfos.add(attribute.getAttributeInfo()); } Set operationInfos = new HashSet(); for (int i = 0; i < operations.length; i++) { - GBeanOperation operation = operations[i]; - operationInfos.add(new GOperationInfo(operation.getName(), operation.getParameterTypes())); + operationInfos.add(operations[i].getOperationInfo()); } Set referenceInfos = new HashSet(); for (int i = 0; i < references.length; i++) { - GBeanReference reference = references[i]; - referenceInfos.add(new GReferenceInfo(reference.getName(), reference.getType())); + referenceInfos.add(references[i].getReferenceInfo()); } - return Util.perfect(new GBeanInfo(source.getName(), - source.getClassName(), + return new GBeanInfo(name, + type.getName(), attributeInfos, - source.getConstructor(), + constructor, operationInfos, - referenceInfos, - new HashSet(Arrays.asList(NotificationType.TYPES))), classLoader); + referenceInfos); + } + + public String toString() { + if (objectName == null) { + return super.toString(); + } + return objectName.toString(); } } Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanOperation.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanOperation.java?view=diff&rev=109314&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanOperation.java&r1=109313&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanOperation.java&r2=109314 ============================================================================== --- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanOperation.java (original) +++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanOperation.java Wed Dec 1 00:01:37 2004 @@ -38,6 +38,7 @@ private final List parameterTypes; private final MethodInvoker methodInvoker; private final boolean framework; + private final GOperationInfo operationInfo; static GBeanOperation createFrameworkOperation(GBeanInstance gbeanInstance, String name, List parameterTypes, MethodInvoker methodInvoker) { return new GBeanOperation(gbeanInstance, name, parameterTypes, methodInvoker); @@ -49,12 +50,14 @@ this.name = name; this.parameterTypes = Collections.unmodifiableList(new ArrayList(parameterTypes)); this.methodInvoker = methodInvoker; + this.operationInfo = new GOperationInfo(this.name, this.parameterTypes); } public GBeanOperation(GBeanInstance gbeanInstance, GOperationInfo operationInfo) throws InvalidConfigurationException { framework = false; this.gbeanInstance = gbeanInstance; this.name = operationInfo.getName(); + this.operationInfo = operationInfo; // get an array of the parameter classes this.parameterTypes = Collections.unmodifiableList(new ArrayList(operationInfo.getParameterList())); @@ -101,6 +104,10 @@ public List getParameterTypes() { return parameterTypes; + } + + public GOperationInfo getOperationInfo() { + return operationInfo; } public boolean isFramework() { Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanReference.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanReference.java?view=diff&rev=109314&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanReference.java&r1=109313&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanReference.java&r2=109314 ============================================================================== --- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanReference.java (original) +++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanReference.java Wed Dec 1 00:01:37 2004 @@ -19,6 +19,7 @@ import java.util.Set; import org.apache.geronimo.kernel.Kernel; +import org.apache.geronimo.gbean.GReferenceInfo; /** * @version $Rev$ $Date$ @@ -26,7 +27,11 @@ public interface GBeanReference { String getName(); - Class getType(); + GReferenceInfo getReferenceInfo(); + + Class getReferenceType(); + + Class getProxyType(); Set getPatterns(); Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanSingleReference.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanSingleReference.java?view=diff&rev=109314&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanSingleReference.java&r1=109313&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanSingleReference.java&r2=109314 ============================================================================== --- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanSingleReference.java (original) +++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanSingleReference.java Wed Dec 1 00:01:37 2004 @@ -44,8 +44,8 @@ */ private ObjectName proxyTarget; - public GBeanSingleReference(GBeanInstance gbeanInstance, GReferenceInfo referenceInfo, Class constructorType) throws InvalidConfigurationException { - super(gbeanInstance, referenceInfo, constructorType); + public GBeanSingleReference(GBeanInstance gbeanInstance, GReferenceInfo referenceInfo) throws InvalidConfigurationException { + super(gbeanInstance, referenceInfo); } public synchronized void start() throws Exception { @@ -79,7 +79,7 @@ // add a dependency on our target and create the proxy ObjectName target = (ObjectName) targets.iterator().next(); - setProxy(kernel.getProxyManager().createProxy(target, getType())); + setProxy(kernel.getProxyManager().createProxy(target, getReferenceType())); proxyTarget = target; kernel.getDependencyManager().addDependency(objectName, target); } Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/Util.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/Util.java?view=auto&rev=109313 ============================================================================== Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java?view=diff&rev=109314&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java&r1=109313&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java&r2=109314 ============================================================================== --- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java (original) +++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java Wed Dec 1 00:01:37 2004 @@ -572,6 +572,7 @@ configurationManagerInstance = new GBeanInstance(this, configurationData, lifecycleBroadcaster, getClass().getClassLoader()); configurationManagerInstance.start(); configurationManager = (ConfigurationManager) configurationManagerInstance.getTarget(); + assert configurationManager != null: "ConfigurationManager failed to start"; // wrap it in an mbean and register it GBeanMBean configurationManagerGBean = new GBeanMBean(this, configurationManagerInstance, lifecycleBroadcaster); Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/LifecycleMonitor.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/LifecycleMonitor.java?view=diff&rev=109314&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/LifecycleMonitor.java&r1=109313&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/LifecycleMonitor.java&r2=109314 ============================================================================== --- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/LifecycleMonitor.java (original) +++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/LifecycleMonitor.java Wed Dec 1 00:01:37 2004 @@ -31,6 +31,7 @@ import javax.management.NotificationListener; import javax.management.ObjectName; import javax.management.NotificationBroadcaster; +import javax.management.NotificationFilter; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -76,7 +77,7 @@ ObjectName source = (ObjectName) iterator.next(); try { if (server.isInstanceOf(source, NotificationBroadcaster.class.getName())) { - server.addNotificationListener(source, this, NotificationType.STATE_CHANGE_FILTER, null); + server.addNotificationListener(source, this, STATE_CHANGE_FILTER, null); } } catch (InstanceNotFoundException e) { // the instance died before we could get going... not a big deal @@ -98,7 +99,7 @@ for (Iterator iterator = boundListeners.keySet().iterator(); iterator.hasNext();) { ObjectName target = (ObjectName) iterator.next(); try { - server.removeNotificationListener(target, this, NotificationType.STATE_CHANGE_FILTER, null); + server.removeNotificationListener(target, this, STATE_CHANGE_FILTER, null); } catch (Exception ignore) { // don't care... we tried } @@ -264,7 +265,7 @@ if (!boundListeners.containsKey(source)) { // register for state change notifications try { - server.addNotificationListener(source, this, NotificationType.STATE_CHANGE_FILTER, null); + server.addNotificationListener(source, this, STATE_CHANGE_FILTER, null); } catch (InstanceNotFoundException e) { // the instance died before we could get going... not a big deal return; @@ -290,6 +291,27 @@ } else if (NotificationType.STATE_FAILED.equals(type)) { fireFailedEvent(source); } + } + } + + /** + * A notification filter which only lets all J2EE state change notifications pass. + * Specifically this is STATE_STARTING, STATE_RUNNING, STATE_STOPPING, STATE_STOPPED + * and STATE_FAILED. + */ + private static final NotificationFilter STATE_CHANGE_FILTER = new J2EEStateChangeFilter(); + + private static final class J2EEStateChangeFilter implements NotificationFilter { + private J2EEStateChangeFilter() { + } + + public boolean isNotificationEnabled(Notification notification) { + String type = notification.getType(); + return NotificationType.STATE_STARTING.equals(type) || + NotificationType.STATE_RUNNING.equals(type) || + NotificationType.STATE_STOPPING.equals(type) || + NotificationType.STATE_STOPPED.equals(type) || + NotificationType.STATE_FAILED.equals(type); } } } Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/management/NotificationType.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/management/NotificationType.java?view=diff&rev=109314&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/management/NotificationType.java&r1=109313&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/management/NotificationType.java&r2=109314 ============================================================================== --- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/management/NotificationType.java (original) +++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/management/NotificationType.java Wed Dec 1 00:01:37 2004 @@ -17,8 +17,6 @@ package org.apache.geronimo.kernel.management; -import javax.management.Notification; -import javax.management.NotificationFilter; /** * Static constants class which contains all of the J2EE notification types from the @@ -78,45 +76,4 @@ STATE_STARTING, STATE_RUNNING, STATE_STOPPING, STATE_STOPPED, STATE_FAILED, ATTRIBUTE_CHANGED }; - - /** - * A notification filter which lets all J2EE notifications pass - */ - public static final NotificationFilter NOTIFICATION_FILTER = new J2EENotificationFilter(); - - private static final class J2EENotificationFilter implements NotificationFilter { - private J2EENotificationFilter() { - } - - public boolean isNotificationEnabled(Notification notification) { - String type = notification.getType(); - for (int i = 0; i < TYPES.length; i++) { - if (TYPES[i].equals(type)) { - return true; - } - } - return false; - } - } - - /** - * A notification filter which only lets all J2EE state change notifications pass. - * Specifically this is STATE_STARTING, STATE_RUNNING, STATE_STOPPING, STATE_STOPPED - * and STATE_FAILED. - */ - public static final NotificationFilter STATE_CHANGE_FILTER = new J2EEStateChangeFilter(); - - private static final class J2EEStateChangeFilter implements NotificationFilter { - private J2EEStateChangeFilter() { - } - - public boolean isNotificationEnabled(Notification notification) { - String type = notification.getType(); - return STATE_STARTING.equals(type) || - STATE_RUNNING.equals(type) || - STATE_STOPPING.equals(type) || - STATE_STOPPED.equals(type) || - STATE_FAILED.equals(type); - } - } } Modified: geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/GBeanInfoFactoryTest.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/GBeanInfoFactoryTest.java?view=diff&rev=109314&p1=geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/GBeanInfoFactoryTest.java&r1=109313&p2=geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/GBeanInfoFactoryTest.java&r2=109314 ============================================================================== --- geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/GBeanInfoFactoryTest.java (original) +++ geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/GBeanInfoFactoryTest.java Wed Dec 1 00:01:37 2004 @@ -27,31 +27,13 @@ * @version $Rev$ $Date$ */ public class GBeanInfoFactoryTest extends TestCase { - - /* - * void GBeanInfoBuilder(String) - */ - public void testGBeanInfoFactoryString() { - assertNotNull(new GBeanInfoBuilder("")); - try { - new GBeanInfoBuilder((String) null); - fail("IllegalArgumentException expected"); - } catch (IllegalArgumentException expected) { - } - - final String gbeanName = "gbeanName"; - GBeanInfoBuilder gbeanInfoFactory = new GBeanInfoBuilder(gbeanName); - assertEquals(gbeanName, gbeanInfoFactory.getBeanInfo().getName()); - assertEquals(gbeanName, gbeanInfoFactory.getBeanInfo().getClassName()); - } - /* * void GBeanInfoBuilder(Class) */ public void testGBeanInfoFactoryClass() { assertNotNull(new GBeanInfoBuilder(String.class)); try { - new GBeanInfoBuilder((Class) null); + new GBeanInfoBuilder(null); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException expected) { } @@ -83,12 +65,11 @@ } catch (IllegalArgumentException expected) { } - final Class className = String.class; - GBeanInfoBuilder gbeanInfoFactory = new GBeanInfoBuilder(className, MockGBean.getGBeanInfo()); - assertEquals(className.getName(), gbeanInfoFactory.getBeanInfo().getName()); - assertEquals(className.getName(), gbeanInfoFactory.getBeanInfo().getClassName()); - assertTrue(gbeanInfoFactory.getBeanInfo().getAttributes().isEmpty()); - assertTrue(gbeanInfoFactory.getBeanInfo().getOperations().isEmpty()); + GBeanInfoBuilder gbeanInfoFactory = new GBeanInfoBuilder(MockGBean.class, MockGBean.getGBeanInfo()); + assertEquals(MockGBean.class.getName(), gbeanInfoFactory.getBeanInfo().getName()); + assertEquals(MockGBean.class.getName(), gbeanInfoFactory.getBeanInfo().getClassName()); + assertEquals(2, gbeanInfoFactory.getBeanInfo().getAttributes().size()); + assertEquals(0, gbeanInfoFactory.getBeanInfo().getOperations().size()); } /* @@ -97,18 +78,18 @@ public void testAddInterfaceClass() { GBeanInfoBuilder gbeanInfoFactory; - gbeanInfoFactory = new GBeanInfoBuilder(""); + gbeanInfoFactory = new GBeanInfoBuilder(MockGBean.class); gbeanInfoFactory.addInterface(Serializable.class); assertTrue(gbeanInfoFactory.getBeanInfo().getAttributes().size() == 0); assertTrue(gbeanInfoFactory.getBeanInfo().getOperations().size() == 0); - gbeanInfoFactory = new GBeanInfoBuilder(""); + gbeanInfoFactory = new GBeanInfoBuilder(MockGBean.class); gbeanInfoFactory.addInterface(GBeanLifecycle.class); GBeanInfo gbeanInfo = gbeanInfoFactory.getBeanInfo(); assertTrue(gbeanInfo.getAttributes().size() == 0); assertTrue(gbeanInfo.getOperations().size() == 3); - gbeanInfoFactory = new GBeanInfoBuilder(""); + gbeanInfoFactory = new GBeanInfoBuilder(MockGBean.class); gbeanInfoFactory.addInterface(SetterOnlyInterface.class); gbeanInfo = gbeanInfoFactory.getBeanInfo(); assertEquals(1, gbeanInfo.getAttributes().size()); @@ -116,7 +97,7 @@ assertEquals("int", gattrInfo.getName()); assertEquals("setInt", gattrInfo.getSetterName()); assertNull(gattrInfo.getGetterName()); - + Set opsSet = gbeanInfo.getOperations(); assertEquals(0, opsSet.size()); @@ -129,37 +110,59 @@ assertEquals("setInt", gattrInfo.getSetterName()); opsSet = gbeanInfo.getOperations(); assertEquals(0, opsSet.size()); - + } private static interface SetterOnlyInterface { - public void setInt(int i); } private static interface GetterOnlyInterface { - public int getInt(); } final static GNotificationInfo notificationInfo = new GNotificationInfo("notification", Collections.singleton(null)); - final static GReferenceInfo refInfo = new GReferenceInfo("reference", String.class); - - public static final class MockGBean { + public static final class MockGBean implements GBeanLifecycle, SetterOnlyInterface, GetterOnlyInterface { public static final GBeanInfo GBEAN_INFO; static { GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(MockGBean.class); infoFactory.setConstructor(new String[]{"foo", "bar"}); - infoFactory.addNotification(notificationInfo); - infoFactory.addReference(refInfo); + infoFactory.addAttribute("foo", String.class, false); + infoFactory.addAttribute("bar", String.class, false); + infoFactory.addReference("reference", String.class); GBEAN_INFO = infoFactory.getBeanInfo(); } public static GBeanInfo getGBeanInfo() { return GBEAN_INFO; + } + + public MockGBean() { + } + + public MockGBean(String foo, String bar) { + } + + public void setReference(String reference) { + } + + public void setInt(int i) { + } + + public int getInt() { + return 0; + } + + public void doStart() { + } + + public void doStop() { + } + + public void doFail() { } } Modified: geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/GBeanInfoTest.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/GBeanInfoTest.java?view=diff&rev=109314&p1=geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/GBeanInfoTest.java&r1=109313&p2=geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/GBeanInfoTest.java&r2=109314 ============================================================================== --- geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/GBeanInfoTest.java (original) +++ geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/GBeanInfoTest.java Wed Dec 1 00:01:37 2004 @@ -17,7 +17,6 @@ package org.apache.geronimo.gbean; -import java.util.Collections; import java.util.List; import java.util.Set; @@ -27,8 +26,8 @@ * @version $Rev$ $Date$ */ public class GBeanInfoTest extends TestCase { - private static final String CONSTRUCTOR_ARG_0 = "ConstructorArg-0"; - private static final String CONSTRUCTOR_ARG_1 = "ConstructorArg-1"; + private static final String CONSTRUCTOR_ARG_0 = "ConstructorArg_0"; + private static final String CONSTRUCTOR_ARG_1 = "ConstructorArg_1"; public void testGetGBeanInfo() { // 1. Test GBean that exists @@ -51,22 +50,6 @@ } } - /* - * void GBeanInfo(String, Set, GConstructorInfo, Set, Set, Set) - */ - public void testGBeanInfoStringSetGConstructorInfoSetSetSet() { - GBeanInfo gbeanInfo = new GBeanInfo(null, null, null, null, null, null); - assertNotNull(gbeanInfo); - } - - /* - * void GBeanInfo(String, String, Set, GConstructorInfo, Set, Set, Set) - */ - public void testGBeanInfoStringStringSetGConstructorInfoSetSetSet() { - GBeanInfo gbeanInfo = new GBeanInfo(null, null, null, null, null, null, null); - assertNotNull(gbeanInfo); - } - public void testGetName() { assertEquals(MockGBean.class.getName(), gbeanInfo.getName()); } @@ -77,15 +60,14 @@ public void testGetAttributeSet() { Set attrSet = gbeanInfo.getAttributes(); - assertEquals(2, attrSet.size()); + assertEquals(4, attrSet.size()); assertTrue(attrSet.contains(persistentAttrInfo)); assertTrue(attrSet.contains(nonPersistentAttrInfo)); } public void testGetPersistentAttributes() { List attrList = gbeanInfo.getPersistentAttributes(); - assertEquals(1, attrList.size()); - assertEquals(persistentAttrInfo, attrList.get(0)); + assertEquals(3, attrList.size()); } public void testGetConstructor() { @@ -102,16 +84,11 @@ assertTrue(gbeanOpSet.contains(opInfo)); } - public void testGetNotificationsSet() { - Set gbeanNotificationSet = gbeanInfo.getNotifications(); - assertEquals(1, gbeanNotificationSet.size()); - assertTrue(gbeanNotificationSet.contains(notificationInfo)); - } - public void testGetReferencesSet() { Set gbeanRefSet = gbeanInfo.getReferences(); assertEquals(1, gbeanRefSet.size()); - assertTrue(gbeanRefSet.contains(refInfo)); + GReferenceInfo newRefInfo = (GReferenceInfo) gbeanRefSet.iterator().next(); + assertEquals(refInfo.getName(), newRefInfo.getName()); } public void testToString() { @@ -123,17 +100,15 @@ final static String nonPersistentAttrName = "nonPersistentAttribute"; - final static GAttributeInfo nonPersistentAttrInfo = new GAttributeInfo(nonPersistentAttrName, String.class.getName(), false); + final static GAttributeInfo nonPersistentAttrInfo = new GAttributeInfo(nonPersistentAttrName, String.class.getName(), false, "getFoo", "setFoo"); final static String persistentAttrName = "persistentAttribute"; - final static GAttributeInfo persistentAttrInfo = new GAttributeInfo(persistentAttrName, String.class.getName(), true); + final static GAttributeInfo persistentAttrInfo = new GAttributeInfo(persistentAttrName, String.class.getName(), true, "getFoo", "setFoo"); final static GOperationInfo opInfo = new GOperationInfo("operation"); - final static GNotificationInfo notificationInfo = new GNotificationInfo("notification", Collections.singleton(null)); - - final static GReferenceInfo refInfo = new GReferenceInfo("reference", String.class); + final static GReferenceInfo refInfo = new GReferenceInfo("reference", String.class.getName(), String.class.getName(), "setReference"); public void setUp() { gbeanInfo = MockGBean.getGBeanInfo(); @@ -154,17 +129,24 @@ infoFactory.addOperation(opInfo); - infoFactory.addNotification(notificationInfo); - infoFactory.addReference(refInfo); + infoFactory.addAttribute(CONSTRUCTOR_ARG_0, String.class, true); + infoFactory.addAttribute(CONSTRUCTOR_ARG_1, String.class, true); infoFactory.setConstructor(new String[]{CONSTRUCTOR_ARG_0, CONSTRUCTOR_ARG_1}); + GBEAN_INFO = infoFactory.getBeanInfo(); } public static GBeanInfo getGBeanInfo() { return GBEAN_INFO; + } + + public MockGBean(String ConstructorArg_0, String ConstructorArg_1) { + } + + public void setReference(String reference) { } } } Modified: geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/runtime/GBeanAttributeTest.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/runtime/GBeanAttributeTest.java?view=diff&rev=109314&p1=geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/runtime/GBeanAttributeTest.java&r1=109313&p2=geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/runtime/GBeanAttributeTest.java&r2=109314 ============================================================================== --- geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/runtime/GBeanAttributeTest.java (original) +++ geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/runtime/GBeanAttributeTest.java Wed Dec 1 00:01:37 2004 @@ -19,7 +19,6 @@ import javax.management.ObjectName; import junit.framework.TestCase; -import org.apache.geronimo.gbean.DynamicGAttributeInfo; import org.apache.geronimo.gbean.GAttributeInfo; import org.apache.geronimo.gbean.GBeanData; import org.apache.geronimo.gbean.InvalidConfigurationException; @@ -114,27 +113,28 @@ } { - final GAttributeInfo attributeInfo = new GAttributeInfo(attributeName, String.class.getName(), false, Boolean.TRUE, Boolean.FALSE, null, null); + final GAttributeInfo attributeInfo = new GAttributeInfo(attributeName, String.class.getName(), false, true, false, null, null); GBeanAttribute attribute = new GBeanAttribute(gbeanInstance, attributeInfo, false); assertTrue(attribute.isReadable()); assertFalse(attribute.isWritable()); } { - final GAttributeInfo attributeInfo = new GAttributeInfo(persistentPrimitiveAttributeName, int.class.getName(), false, Boolean.FALSE, Boolean.TRUE, null, null); + final GAttributeInfo attributeInfo = new GAttributeInfo(persistentPrimitiveAttributeName, int.class.getName(), false, false, true, null, null); GBeanAttribute attribute = new GBeanAttribute(gbeanInstance, attributeInfo, false); assertFalse(attribute.isReadable()); assertTrue(attribute.isWritable()); } - { - final GAttributeInfo attributeInfo = new GAttributeInfo("AnotherFinalInt", int.class.getName(), false, Boolean.TRUE, Boolean.TRUE, null, null); - try { - new GBeanAttribute(gbeanInstance, attributeInfo, false); - fail("Getter and setter methods do not have the same types; InvalidConfigurationException expected"); - } catch (InvalidConfigurationException expected) { - } - } +// // todo recreate this in the info builder tests since the compariason now happens there +// { +// final GAttributeInfo attributeInfo = new GAttributeInfo("AnotherFinalInt", int.class.getName(), false, true, true, null, null); +// try { +// new GBeanAttribute(gbeanInstance, attributeInfo, false); +// fail("Getter and setter methods do not have the same types; InvalidConfigurationException expected"); +// } catch (InvalidConfigurationException expected) { +// } +// } { // the attribute name and getter name are different, yet both @@ -225,139 +225,8 @@ } catch (InvalidConfigurationException expected) { } } - - { - final DynamicGAttributeInfo dynamicAttributeInfo = new DynamicGAttributeInfo(attributeName); - GBeanAttribute attribute = new GBeanAttribute(gbeanInstance, dynamicAttributeInfo, false); - assertFalse(attribute.isPersistent()); - assertEquals(dynamicAttributeInfo.isPersistent(), attribute.isPersistent()); - assertTrue(attribute.isReadable()); - assertEquals(dynamicAttributeInfo.isReadable().booleanValue(), attribute.isReadable()); - assertTrue(attribute.isWritable()); - assertEquals(dynamicAttributeInfo.isWritable().booleanValue(), attribute.isWritable()); - assertEquals(dynamicAttributeInfo.getName(), attribute.getName()); - } - - { - final DynamicGAttributeInfo dynamicAttributeInfo = new DynamicGAttributeInfo(attributeName, true); - GBeanAttribute attribute = new GBeanAttribute(gbeanInstance, dynamicAttributeInfo, false); - assertTrue(attribute.isPersistent()); - assertEquals(dynamicAttributeInfo.isPersistent(), attribute.isPersistent()); - assertTrue(attribute.isReadable()); - assertEquals(dynamicAttributeInfo.isReadable().booleanValue(), attribute.isReadable()); - assertTrue(attribute.isWritable()); - assertEquals(dynamicAttributeInfo.isWritable().booleanValue(), attribute.isWritable()); - assertEquals(dynamicAttributeInfo.getName(), attribute.getName()); - } - - { - final DynamicGAttributeInfo dynamicAttributeInfo = new DynamicGAttributeInfo(attributeName, true, false, - true); - GBeanAttribute attribute = new GBeanAttribute(gbeanInstance, dynamicAttributeInfo, false); - assertTrue(attribute.isPersistent()); - assertEquals(dynamicAttributeInfo.isPersistent(), attribute.isPersistent()); - assertFalse(attribute.isReadable()); - assertEquals(dynamicAttributeInfo.isReadable().booleanValue(), attribute.isReadable()); - assertTrue(attribute.isWritable()); - assertEquals(dynamicAttributeInfo.isWritable().booleanValue(), attribute.isWritable()); - assertEquals(dynamicAttributeInfo.getName(), attribute.getName()); - } - - { - final DynamicGAttributeInfo dynamicAttributeInfo = new DynamicGAttributeInfo(attributeName, true, false, - false); - GBeanAttribute attribute = new GBeanAttribute(gbeanInstance, dynamicAttributeInfo, false); - assertTrue(attribute.isPersistent()); - assertEquals(dynamicAttributeInfo.isPersistent(), attribute.isPersistent()); - assertFalse(attribute.isReadable()); - assertEquals(dynamicAttributeInfo.isReadable().booleanValue(), attribute.isReadable()); - assertFalse(attribute.isWritable()); - assertEquals(dynamicAttributeInfo.isWritable().booleanValue(), attribute.isWritable()); - assertEquals(dynamicAttributeInfo.getName(), attribute.getName()); - } } -// public final void testOnline() throws Exception { -// -// // 1. setValue throws Exception -// { -// final Integer valueThatCausesException = new Integer(-1); -// -// final GBeanAttribute attribute = new GBeanAttribute(gbeanInstance, throwingExceptionAttributeInfo); -// attribute.setValue(valueThatCausesException); -// -// final Kernel kernel = new Kernel("test.kernel"); -// try { -// kernel.boot(); -// kernel.loadGBean(name, gbeanInstance); -// attribute.start(); -// fail("Setter upon call with " + valueThatCausesException + " should have thrown exception"); -// } catch (/* IllegalArgument */Exception expected) { -// } finally { -// // @todo possible BUG: gbeanInstance holds information on being online -// // although kernel is shutdown -// // explicit unloading GBean -// kernel.unloadGBean(name); -// kernel.shutdown(); -// } -// } -// -// // 2. setValue throws Error -// { -// final Integer valueThatCausesError = new Integer(-2); -// -// final GBeanAttribute attribute = new GBeanAttribute(gbeanInstance, throwingExceptionAttributeInfo); -// attribute.setValue(valueThatCausesError); -// -// final Kernel kernel = new Kernel("test.kernel"); -// try { -// kernel.boot(); -// kernel.loadGBean(name, gbeanInstance); -// attribute.start(); -// fail("Setter upon call with " + valueThatCausesError + " should have thrown error"); -// } catch (Error expected) { -// } finally { -// // @todo possible BUG: see the above finally block -// kernel.unloadGBean(name); -// kernel.shutdown(); -// } -// } -// -// // 3. setValue throws Throwable -// { -// final Integer valueThatCausesThrowable = new Integer(-3); -// -// final GBeanAttribute attribute = new GBeanAttribute(gbeanInstance, throwingExceptionAttributeInfo); -// attribute.setValue(valueThatCausesThrowable); -// -// final Kernel kernel = new Kernel("test.kernel"); -// try { -// kernel.boot(); -// kernel.loadGBean(name, gbeanInstance); -// attribute.start(); -// fail("Setter upon call with " + valueThatCausesThrowable + " should have thrown throwable"); -// } catch (Throwable expected) { -// } finally { -// kernel.shutdown(); -// } -// } -// -// { -// try { -// GBeanMBean gmbean2 = new GBeanMBean(MockGBean.getGBeanInfo()); -// GBeanAttribute attribute2 = new GBeanAttribute(gmbean2, throwingExceptionAttributeInfo); -// attribute2.start(); -// fail("AssertionError or NullPointerException expected"); -// } catch (Exception expected) { -// } catch (AssertionError expected) { -// } -// } -// } -// -// public final void testOffline() { -// //TODO Implement offline(). -// } -// public final void testGetValue() throws Exception { { // attribute that isn't readable and persistent @@ -382,25 +251,6 @@ gbeanInstance.stop(); } } - - { - final DynamicGAttributeInfo dynamicAttributeInfo = new DynamicGAttributeInfo(MockDynamicGBean.MUTABLE_INT_ATTRIBUTE_NAME, true, true, true); - GBeanAttribute attribute = new GBeanAttribute(dynamicGBeanInstance, dynamicAttributeInfo, false); - - try { - dynamicGBeanInstance.start(); - - final Integer zero = new Integer(0); - assertEquals(zero, attribute.getValue()); - - final Integer one = new Integer(1); - attribute.setValue(one); - assertEquals(one, attribute.getValue()); - } finally { - dynamicGBeanInstance.stop(); - } - - } } public final void testSetValue() throws Exception { @@ -519,9 +369,8 @@ throw new UnsupportedOperationException("Throws exception to rise test coverage"); } }; - attributeInfo = new GAttributeInfo(attributeName, String.class.getName(), false); -// throwingExceptionAttributeInfo = new GAttributeInfo("ExceptionMutableInt", int.class.getName(), true); - persistentPrimitiveAttributeInfo = new GAttributeInfo(persistentPrimitiveAttributeName, int.class.getName(), true); + attributeInfo = new GAttributeInfo(attributeName, String.class.getName(), false, "getName", "setName"); + persistentPrimitiveAttributeInfo = new GAttributeInfo(persistentPrimitiveAttributeName, int.class.getName(), true, "getMutableInt", "setMutableInt"); } protected void tearDown() throws Exception { Modified: geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/MockDynamicGBean.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/MockDynamicGBean.java?view=diff&rev=109314&p1=geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/MockDynamicGBean.java&r1=109313&p2=geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/MockDynamicGBean.java&r2=109314 ============================================================================== --- geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/MockDynamicGBean.java (original) +++ geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/MockDynamicGBean.java Wed Dec 1 00:01:37 2004 @@ -19,6 +19,7 @@ import org.apache.geronimo.gbean.DynamicGBean; import org.apache.geronimo.gbean.GBeanInfo; import org.apache.geronimo.gbean.GBeanInfoBuilder; +import org.apache.geronimo.gbean.DynamicGAttributeInfo; /** * @version $Rev$ $Date$ @@ -59,7 +60,7 @@ static { GBeanInfoBuilder infoFactory = new GBeanInfoBuilder("MockDynamicGBean", MockDynamicGBean.class); - infoFactory.addAttribute("mutableInt", Integer.class, false); + infoFactory.addAttribute(new DynamicGAttributeInfo("mutableInt", Integer.class.getName(), false, true, true)); GBEAN_INFO = infoFactory.getBeanInfo(); } } Modified: geronimo/trunk/modules/network/project.xml Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/network/project.xml?view=diff&rev=109314&p1=geronimo/trunk/modules/network/project.xml&r1=109313&p2=geronimo/trunk/modules/network/project.xml&r2=109314 ============================================================================== --- geronimo/trunk/modules/network/project.xml (original) +++ geronimo/trunk/modules/network/project.xml Wed Dec 1 00:01:37 2004 @@ -99,7 +99,6 @@ <version>&log4j-version;</version> <url>http://jakarta.apache.org/log4j</url> </dependency> - </dependencies> <build> Modified: geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/bridge/AbstractPrincipalMappingUserPasswordRealmBridge.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/bridge/AbstractPrincipalMappingUserPasswordRealmBridge.java?view=diff&rev=109314&p1=geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/bridge/AbstractPrincipalMappingUserPasswordRealmBridge.java&r1=109313&p2=geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/bridge/AbstractPrincipalMappingUserPasswordRealmBridge.java&r2=109314 ============================================================================== --- geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/bridge/AbstractPrincipalMappingUserPasswordRealmBridge.java (original) +++ geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/bridge/AbstractPrincipalMappingUserPasswordRealmBridge.java Wed Dec 1 00:01:37 2004 @@ -163,11 +163,6 @@ infoFactory.addAttribute("userNameTargetCallbackName", String.class, true); infoFactory.addAttribute("passwordSourceType", Class.class, true); - infoFactory.setConstructor(new String[]{ - "userNameSourceType", - "userNameTargetCallbackName", - "passwordSourceType"}); - GBEAN_INFO = infoFactory.getBeanInfo(); } Modified: geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jaas/GeronimoLoginConfiguration.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jaas/GeronimoLoginConfiguration.java?view=diff&rev=109314&p1=geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jaas/GeronimoLoginConfiguration.java&r1=109313&p2=geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jaas/GeronimoLoginConfiguration.java&r2=109314 ============================================================================== --- geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jaas/GeronimoLoginConfiguration.java (original) +++ geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jaas/GeronimoLoginConfiguration.java Wed Dec 1 00:01:37 2004 @@ -17,17 +17,16 @@ package org.apache.geronimo.security.jaas; -import javax.security.auth.login.AppConfigurationEntry; -import javax.security.auth.login.Configuration; import java.util.Collection; import java.util.Collections; import java.util.Hashtable; import java.util.Iterator; import java.util.Map; +import javax.security.auth.login.AppConfigurationEntry; +import javax.security.auth.login.Configuration; -import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.Log; - +import org.apache.commons.logging.LogFactory; import org.apache.geronimo.gbean.GBeanInfo; import org.apache.geronimo.gbean.GBeanInfoBuilder; import org.apache.geronimo.gbean.GBeanLifecycle; @@ -146,7 +145,7 @@ private static final GBeanInfo GBEAN_INFO; static { - GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(GeronimoLoginConfiguration.class.getName()); + GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(GeronimoLoginConfiguration.class); infoFactory.addReference("Configurations", ConfigurationEntryFactory.class); GBEAN_INFO = infoFactory.getBeanInfo(); Modified: geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/bridge/MappingUserPasswordBridgeTest.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/bridge/MappingUserPasswordBridgeTest.java?view=diff&rev=109314&p1=geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/bridge/MappingUserPasswordBridgeTest.java&r1=109313&p2=geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/bridge/MappingUserPasswordBridgeTest.java&r2=109314 ============================================================================== --- geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/bridge/MappingUserPasswordBridgeTest.java (original) +++ geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/bridge/MappingUserPasswordBridgeTest.java Wed Dec 1 00:01:37 2004 @@ -17,14 +17,14 @@ package org.apache.geronimo.security.bridge; -import org.apache.geronimo.security.IdentificationPrincipal; -import org.apache.geronimo.security.ContextManager; - import java.security.Principal; import java.util.HashMap; import java.util.Map; import java.util.Set; import javax.security.auth.Subject; + +import org.apache.geronimo.security.ContextManager; +import org.apache.geronimo.security.IdentificationPrincipal; /** Modified: geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCWorkerPersistence.java Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCWorkerPersistence.java?view=diff&rev=109314&p1=geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCWorkerPersistence.java&r1=109313&p2=geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCWorkerPersistence.java&r2=109314 ============================================================================== --- geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCWorkerPersistence.java (original) +++ geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCWorkerPersistence.java Wed Dec 1 00:01:37 2004 @@ -320,11 +320,11 @@ static { GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(JDBCWorkerPersistence.class); - infoFactory.addAttribute("sequenceSQL", String.class, true); - infoFactory.addAttribute("insertSQL", String.class, true); - infoFactory.addAttribute("deleteSQL", String.class, true); - infoFactory.addAttribute("fixedRateUpdateSQL", String.class, true); - infoFactory.addAttribute("selectSQL", String.class, true); +// infoFactory.addAttribute("sequenceSQL", String.class, true); +// infoFactory.addAttribute("insertSQL", String.class, true); +// infoFactory.addAttribute("deleteSQL", String.class, true); +// infoFactory.addAttribute("fixedRateUpdateSQL", String.class, true); +// infoFactory.addAttribute("selectSQL", String.class, true); infoFactory.addAttribute("createSequenceSQL", String.class, true); infoFactory.addAttribute("createTableSQL", String.class, true); @@ -333,7 +333,8 @@ infoFactory.addReference("managedConnectionFactoryWrapper", ManagedConnectionFactoryWrapper.class); - infoFactory.setConstructor(new String[]{"kernel", "managedConnectionFactoryWrapper", "sequenceSQL", "insertSQL", "deleteSQL", "fixedRateUpdateSQL", "selectSQL"}); +// infoFactory.setConstructor(new String[]{"kernel", "managedConnectionFactoryWrapper", "sequenceSQL", "insertSQL", "deleteSQL", "fixedRateUpdateSQL", "selectSQL"}); + infoFactory.setConstructor(new String[]{"kernel", "managedConnectionFactoryWrapper"}); GBEAN_INFO = infoFactory.getBeanInfo(); }