[jboss-cvs] JBossAS SVN: r60354 - in projects/microcontainer/trunk/container/src/main/org/jboss: beans/info/spi and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Feb 6 18:30:34 EST 2007


Author: alesj
Date: 2007-02-06 18:30:34 -0500 (Tue, 06 Feb 2007)
New Revision: 60354

Modified:
   projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractBeanInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/spi/BeanInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/javabean/plugins/xml/Common.java
   projects/microcontainer/trunk/container/src/main/org/jboss/joinpoint/plugins/Config.java
Log:
Support static method invocation on BeanInfo.

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractBeanInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractBeanInfo.java	2007-02-06 22:50:40 UTC (rev 60353)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractBeanInfo.java	2007-02-06 23:30:34 UTC (rev 60354)
@@ -55,31 +55,31 @@
 {
    /** The class name */
    protected String name;
-   
+
    /** The class adapter */
    protected ClassAdapter classAdapter;
-   
+
    /** The properties */
    protected Set<PropertyInfo> properties;
 
    /** The properties by name */
    private transient Map<String, PropertyInfo> propertiesByName = Collections.emptyMap();
-   
+
    /** The constructors */
    protected Set<ConstructorInfo> constructors;
-   
+
    /** The methods */
    protected Set<MethodInfo> methods;
-   
+
    /** The events */
    protected Set<EventInfo> events;
-   
+
    /** The BeanInfoFactory */
    protected BeanInfoFactory beanInfoFactory;
 
    /**
     * Create a new bean info
-    * 
+    *
     * @param beanInfoFactory the bean info factory
     * @param classAdapter the class adapter
     * @param properties the properties
@@ -103,12 +103,12 @@
    {
       return name;
    }
-   
+
    public Set<PropertyInfo> getProperties()
    {
       return properties;
    }
-   
+
    public void setProperties(Set<PropertyInfo> properties)
    {
       this.properties = properties;
@@ -144,7 +144,7 @@
 
    /**
     * Get a property
-    * 
+    *
     * @param name the property name
     * @return the property
     * @throws IllegalArgumentException if there is no such property
@@ -153,13 +153,13 @@
    {
       if (name == null)
          throw new IllegalArgumentException("Null name");
-      
+
       PropertyInfo property = propertiesByName.get(name);
       if (property == null)
          throw new IllegalArgumentException("No such property " + name + " for bean " + getName() + " available " + propertiesByName.keySet());
       return property;
    }
-   
+
    public ClassInfo getClassInfo()
    {
       return classAdapter.getClassInfo();
@@ -179,7 +179,7 @@
    {
       this.constructors = constructors;
    }
-   
+
    public Set<EventInfo> getEvents()
    {
       return events;
@@ -189,7 +189,7 @@
    {
       this.events = events;
    }
-   
+
    public Set<MethodInfo> getMethods()
    {
       return methods;
@@ -199,7 +199,7 @@
    {
       this.methods = methods;
    }
-   
+
    public BeanInfoFactory getBeanInfoFactory()
    {
       return beanInfoFactory;
@@ -230,7 +230,7 @@
    {
       return newInstance(typeInfosToStrings(paramTypes), params);
    }
-   
+
    public Object getProperty(Object bean, String name) throws Throwable
    {
       PropertyInfo property = getProperty(name);
@@ -250,7 +250,7 @@
 
    public Object invoke(Object bean, String name, String[] paramTypes, Object[] params) throws Throwable
    {
-      MethodJoinpoint joinpoint = Config.getMethodJoinpoint(bean, getJoinpointFactory(), name, paramTypes, params, false);
+      MethodJoinpoint joinpoint = Config.getMethodJoinpoint(bean, getJoinpointFactory(), name, paramTypes, params);
       return joinpoint.dispatch();
    }
 
@@ -264,6 +264,27 @@
       return invoke(bean, name, typeInfosToStrings(paramTypes), params);
    }
 
+   public Object invokeStatic(String name) throws Throwable
+   {
+      return invokeStatic(name, (String[]) null, null);
+   }
+
+   public Object invokeStatic(String name, String[] paramTypes, Object[] params) throws Throwable
+   {
+      MethodJoinpoint joinpoint = Config.getStaticMethodJoinpoint(getJoinpointFactory(), name, paramTypes, params);
+      return joinpoint.dispatch();
+   }
+
+   public Object invokeStatic(String name, Class[] paramTypes, Object[] params) throws Throwable
+   {
+      return invokeStatic(name, classesToStrings(paramTypes), params);
+   }
+
+   public Object invokeStatic(String name, TypeInfo[] paramTypes, Object[] params) throws Throwable
+   {
+      return invokeStatic(name, typeInfosToStrings(paramTypes), params);
+   }
+
    public boolean equals(Object object)
    {
       if (object == null || object instanceof AbstractBeanInfo == false)

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/spi/BeanInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/spi/BeanInfo.java	2007-02-06 22:50:40 UTC (rev 60353)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/spi/BeanInfo.java	2007-02-06 23:30:34 UTC (rev 60354)
@@ -245,4 +245,46 @@
     * @throws Throwable for any error
     */
    Object invoke(Object bean, String name, TypeInfo[] paramTypes, Object[] params) throws Throwable;
+
+   /**
+    * Invoke a static method with no parameters
+    *
+    * @param name the method name
+    * @return the result
+    * @throws Throwable for any error
+    */
+   Object invokeStatic(String name) throws Throwable;
+
+   /**
+    * Invoke a static method
+    *
+    * @param name the method name
+    * @param paramTypes the parameter types
+    * @param params the parameters
+    * @return the result
+    * @throws Throwable for any error
+    */
+   Object invokeStatic(String name, String[] paramTypes, Object[] params) throws Throwable;
+
+   /**
+    * Invoke a static method
+    *
+    * @param name the method name
+    * @param paramTypes the parameter types
+    * @param params the parameters
+    * @return the result
+    * @throws Throwable for any error
+    */
+   Object invokeStatic(String name, Class[] paramTypes, Object[] params) throws Throwable;
+
+   /**
+    * Invoke a static method
+    *
+    * @param name the method name
+    * @param paramTypes the parameter types
+    * @param params the parameters
+    * @return the result
+    * @throws Throwable for any error
+    */
+   Object invokeStatic(String name, TypeInfo[] paramTypes, Object[] params) throws Throwable;
 }

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/javabean/plugins/xml/Common.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/javabean/plugins/xml/Common.java	2007-02-06 22:50:40 UTC (rev 60353)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/javabean/plugins/xml/Common.java	2007-02-06 23:30:34 UTC (rev 60354)
@@ -113,7 +113,7 @@
          if (factoryMethod != null)
          {
             BeanInfo beanInfo = ConfigurationUtil.getBeanInfo(constructor.getFactoryClass());
-            return beanInfo.invoke(null, factoryMethod, getParamTypes(), getArgs());
+            return beanInfo.invokeStatic(factoryMethod, getParamTypes(), getArgs());
          }
          return ConfigurationUtil.newInstance(getClassName(), getParamTypes(), getArgs());
       }

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/joinpoint/plugins/Config.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/joinpoint/plugins/Config.java	2007-02-06 22:50:40 UTC (rev 60353)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/joinpoint/plugins/Config.java	2007-02-06 23:30:34 UTC (rev 60354)
@@ -210,35 +210,45 @@
     */
    public static MethodJoinpoint getMethodJoinpoint(Object object, JoinpointFactory jpf, String name, String[] paramTypes, Object[] params) throws Throwable
    {
-      return getMethodJoinpoint(object, jpf, name, paramTypes, params, true);
+      boolean trace = log.isTraceEnabled();
+      if (trace)
+      {
+         if (paramTypes != null)
+            log.trace("Get method Joinpoint jpf=" + jpf + " target=" + object + " name=" + name + " paramTypes=" + Arrays.asList(paramTypes));
+         else
+            log.trace("Get method Joinpoint jpf=" + jpf + " target=" + object + " name=" + name + " paramTypes=()");
+      }
+
+      MethodInfo methodInfo = findMethodInfo(jpf.getClassInfo(), name, paramTypes);
+      MethodJoinpoint joinpoint = jpf.getMethodJoinpoint(methodInfo);
+      joinpoint.setTarget(object);
+      joinpoint.setArguments(params);
+      return joinpoint;
    }
 
    /**
-    * Get a method joinpoint
+    * Get a static method joinpoint
     *
-    * @param object the object to invoke
     * @param jpf the join point factory
     * @param name the name of the method
     * @param paramTypes the parameter types
     * @param params the parameters
-    * @param strict is strict about method modifiers
     * @return the join point
     * @throws Throwable for any error
     */
-   public static MethodJoinpoint getMethodJoinpoint(Object object, JoinpointFactory jpf, String name, String[] paramTypes, Object[] params, boolean strict) throws Throwable
+   public static MethodJoinpoint getStaticMethodJoinpoint(JoinpointFactory jpf, String name, String[] paramTypes, Object[] params) throws Throwable
    {
       boolean trace = log.isTraceEnabled();
       if (trace)
       {
          if (paramTypes != null)
-            log.trace("Get method Joinpoint jpf=" + jpf + " target=" + object + " name=" + name + " paramTypes=" + Arrays.asList(paramTypes));
+            log.trace("Get method Joinpoint jpf=" + jpf + " name=" + name + " paramTypes=" + Arrays.asList(paramTypes));
          else
-            log.trace("Get method Joinpoint jpf=" + jpf + " target=" + object + " name=" + name + " paramTypes=()");
+            log.trace("Get method Joinpoint jpf=" + jpf + " name=" + name + " paramTypes=()");
       }
 
-      MethodInfo methodInfo = findMethodInfo(jpf.getClassInfo(), name, paramTypes, strict);
+      MethodInfo methodInfo = findMethodInfo(jpf.getClassInfo(), name, paramTypes, true, true);
       MethodJoinpoint joinpoint = jpf.getMethodJoinpoint(methodInfo);
-      joinpoint.setTarget(object);
       joinpoint.setArguments(params);
       return joinpoint;
    }




More information about the jboss-cvs-commits mailing list