[jboss-cvs] JBossAS SVN: r85987 - projects/mc-int/trunk/servlet/src/main/java/org/jboss/mc/servlet/vdf/api.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Mar 17 10:13:36 EDT 2009
Author: alesj
Date: 2009-03-17 10:13:36 -0400 (Tue, 17 Mar 2009)
New Revision: 85987
Added:
projects/mc-int/trunk/servlet/src/main/java/org/jboss/mc/servlet/vdf/api/AbstractBeanFactoryReflectionVDFConnector.java
projects/mc-int/trunk/servlet/src/main/java/org/jboss/mc/servlet/vdf/api/AbstractBeanFactoryTypeVDFConnector.java
Modified:
projects/mc-int/trunk/servlet/src/main/java/org/jboss/mc/servlet/vdf/api/AbstractBeanFactoryInitializerVDFConnector.java
Log:
Add generic reflection based deployment unit initializer.
Modified: projects/mc-int/trunk/servlet/src/main/java/org/jboss/mc/servlet/vdf/api/AbstractBeanFactoryInitializerVDFConnector.java
===================================================================
--- projects/mc-int/trunk/servlet/src/main/java/org/jboss/mc/servlet/vdf/api/AbstractBeanFactoryInitializerVDFConnector.java 2009-03-17 13:58:38 UTC (rev 85986)
+++ projects/mc-int/trunk/servlet/src/main/java/org/jboss/mc/servlet/vdf/api/AbstractBeanFactoryInitializerVDFConnector.java 2009-03-17 14:13:36 UTC (rev 85987)
@@ -23,7 +23,7 @@
import javax.servlet.ServletContext;
-import org.jboss.mc.servlet.vdf.spi.DeploymentUnitAware;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
/**
* AbstractBeanFactoryInitializerTypeVDFConnector.
@@ -31,7 +31,7 @@
* @param <T> exact bean type
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
-public abstract class AbstractBeanFactoryInitializerVDFConnector<T extends DeploymentUnitAware> extends AbstractBeanFactoryVDFConnector<T>
+public abstract class AbstractBeanFactoryInitializerVDFConnector<T> extends AbstractBeanFactoryVDFConnector<T>
{
protected AbstractBeanFactoryInitializerVDFConnector(ServletContext servletContext)
{
@@ -45,6 +45,14 @@
if (connector.isValid() == false)
throw new IllegalArgumentException("No deployment unit.");
- bean.setDeploymentUnit(connector.getUtility());
+ setDeploymentUnit(bean, connector.getUtility());
}
+
+ /**
+ * Set deployment unit.
+ *
+ * @param bean the bean
+ * @param unit the deployment unit
+ */
+ protected abstract void setDeploymentUnit(T bean, DeploymentUnit unit);
}
\ No newline at end of file
Copied: projects/mc-int/trunk/servlet/src/main/java/org/jboss/mc/servlet/vdf/api/AbstractBeanFactoryReflectionVDFConnector.java (from rev 85979, projects/mc-int/trunk/servlet/src/main/java/org/jboss/mc/servlet/vdf/api/AbstractBeanFactoryInitializerVDFConnector.java)
===================================================================
--- projects/mc-int/trunk/servlet/src/main/java/org/jboss/mc/servlet/vdf/api/AbstractBeanFactoryReflectionVDFConnector.java (rev 0)
+++ projects/mc-int/trunk/servlet/src/main/java/org/jboss/mc/servlet/vdf/api/AbstractBeanFactoryReflectionVDFConnector.java 2009-03-17 14:13:36 UTC (rev 85987)
@@ -0,0 +1,67 @@
+/*
+* 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.mc.servlet.vdf.api;
+
+import java.lang.reflect.Method;
+import javax.servlet.ServletContext;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * AbstractBeanFactoryReflectionVDFConnector.
+ *
+ * @param <T> exact bean type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AbstractBeanFactoryReflectionVDFConnector<T> extends AbstractBeanFactoryInitializerVDFConnector<T>
+{
+ private String setterName = "setDeploymentUnit";
+
+ protected AbstractBeanFactoryReflectionVDFConnector(ServletContext servletContext)
+ {
+ super(servletContext);
+ }
+
+ protected void setDeploymentUnit(T bean, DeploymentUnit unit)
+ {
+ try
+ {
+ Class<?> clazz = bean.getClass();
+ Method setter = clazz.getMethod(setterName, DeploymentUnit.class);
+ setter.invoke(bean, unit);
+ }
+ catch (Exception e)
+ {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ /**
+ * Set the setter name.
+ *
+ * @param setterName the setter name
+ */
+ public void setSetterName(String setterName)
+ {
+ this.setterName = setterName;
+ }
+}
\ No newline at end of file
Copied: projects/mc-int/trunk/servlet/src/main/java/org/jboss/mc/servlet/vdf/api/AbstractBeanFactoryTypeVDFConnector.java (from rev 85979, projects/mc-int/trunk/servlet/src/main/java/org/jboss/mc/servlet/vdf/api/AbstractBeanFactoryInitializerVDFConnector.java)
===================================================================
--- projects/mc-int/trunk/servlet/src/main/java/org/jboss/mc/servlet/vdf/api/AbstractBeanFactoryTypeVDFConnector.java (rev 0)
+++ projects/mc-int/trunk/servlet/src/main/java/org/jboss/mc/servlet/vdf/api/AbstractBeanFactoryTypeVDFConnector.java 2009-03-17 14:13:36 UTC (rev 85987)
@@ -0,0 +1,46 @@
+/*
+* 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.mc.servlet.vdf.api;
+
+import javax.servlet.ServletContext;
+
+import org.jboss.mc.servlet.vdf.spi.DeploymentUnitAware;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * AbstractBeanFactoryInitializerTypeVDFConnector.
+ *
+ * @param <T> exact bean type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AbstractBeanFactoryTypeVDFConnector<T extends DeploymentUnitAware> extends AbstractBeanFactoryInitializerVDFConnector<T>
+{
+ protected AbstractBeanFactoryTypeVDFConnector(ServletContext servletContext)
+ {
+ super(servletContext);
+ }
+
+ protected void setDeploymentUnit(T bean, DeploymentUnit unit)
+ {
+ bean.setDeploymentUnit(unit);
+ }
+}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list