[jboss-cvs] JBossAS SVN: r64427 - projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Aug 2 08:54:35 EDT 2007


Author: alesj
Date: 2007-08-02 08:54:35 -0400 (Thu, 02 Aug 2007)
New Revision: 64427

Added:
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/JavaBeanValueAnnotationPlugin.java
Log:
Missing @JavaBeanValue handler.

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/JavaBeanValueAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/JavaBeanValueAnnotationPlugin.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/JavaBeanValueAnnotationPlugin.java	2007-08-02 12:54:35 UTC (rev 64427)
@@ -0,0 +1,76 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.annotations;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import org.jboss.beans.metadata.plugins.AbstractValueMetaData;
+import org.jboss.beans.metadata.plugins.annotations.JavaBeanValue;
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.config.plugins.property.PropertyConfiguration;
+import org.jboss.config.spi.Configuration;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class JavaBeanValueAnnotationPlugin extends PropertyAnnotationPlugin<JavaBeanValue>
+{
+   static JavaBeanValueAnnotationPlugin INSTANCE = new JavaBeanValueAnnotationPlugin();
+
+   /** The configuration */
+   private static Configuration configuration;
+
+   static
+   {
+      configuration = AccessController.doPrivileged(new PrivilegedAction<Configuration>()
+      {
+         public Configuration run()
+         {
+            return new PropertyConfiguration();
+         }
+      });
+   }
+
+   public JavaBeanValueAnnotationPlugin()
+   {
+      super(JavaBeanValue.class);
+   }
+
+   public ValueMetaData createValueMetaData(JavaBeanValue annotation)
+   {
+      String className = annotation.value();
+      if (isAttributePresent(className) == false)
+         throw new IllegalArgumentException("Javabean class must be set: " + annotation);
+      
+      try
+      {
+         BeanInfo beanInfo = configuration.getBeanInfo(className, null);
+         return new AbstractValueMetaData(beanInfo.newInstance());
+      }
+      catch (Throwable t)
+      {
+         throw new IllegalArgumentException("Exception while creating javabean: " + t);
+      }
+   }
+}




More information about the jboss-cvs-commits mailing list