[jboss-cvs] JBossAS SVN: r82680 - in projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer: env and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jan 7 16:34:37 EST 2009
Author: alesj
Date: 2009-01-07 16:34:37 -0500 (Wed, 07 Jan 2009)
New Revision: 82680
Added:
projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/DeployersUtils.java
Modified:
projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/env/WebBeanDiscoveryDeployer.java
projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/ext/JBossWebBeansMetaData.java
projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/metadata/PostJBossAppMetadataDeployer.java
projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/metadata/PostWebMetadataDeployer.java
projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/metadata/WBEjbInterceptorMetadataDeployer.java
projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/metadata/WebBeansFilesDeployer.java
Log:
Create new utils class.
Added: projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/DeployersUtils.java
===================================================================
--- projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/DeployersUtils.java (rev 0)
+++ projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/DeployersUtils.java 2009-01-07 21:34:37 UTC (rev 82680)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.webbeans.integration.microcontainer.deployer;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * WebBeans deployers utils.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public final class DeployersUtils
+{
+ private DeployersUtils()
+ {
+ }
+
+ public static final String WEB_BEANS_FILES = "WEB_BEANS_FILES";
+ public static final String WEB_BEANS_CLASSPATH = "WEB_BEANS_CLASSPATH";
+ public static final String WEB_BEANS_DEPLOYMENT_FLAG = "WEB_BEANS_DEPLOYMENT_FLAG";
+
+ /**
+ * Check deployment hierarchy for web-beans.xml files.
+ * It checks the 'cached' flag.
+ *
+ * @param unit the deployment unit
+ * @return true if web-beans.xml files exist, false otherwise
+ */
+ public static boolean checkForWebBeansFiles(DeploymentUnit unit)
+ {
+ DeploymentUnit top = unit.getTopLevel();
+
+ Boolean flag = top.getAttachment(WEB_BEANS_DEPLOYMENT_FLAG, Boolean.class);
+ if (flag != null)
+ return flag;
+
+ flag = searchForWebBeans(top);
+ top.addAttachment(WEB_BEANS_DEPLOYMENT_FLAG, flag, Boolean.class);
+
+ return flag;
+ }
+
+ /**
+ * Search deployment hierarchy for web-beans.xml files.
+ *
+ * @param unit the deployment unit
+ * @return true if web-beans.xml files exist, false otherwise
+ */
+ private static boolean searchForWebBeans(DeploymentUnit unit)
+ {
+ Collection files = unit.getAttachment(WEB_BEANS_FILES, Collection.class);
+ if (files != null && files.isEmpty() == false)
+ return true;
+
+ List<DeploymentUnit> children = unit.getChildren();
+ if (children != null && children.isEmpty() == false)
+ {
+ for (DeploymentUnit child : children)
+ {
+ boolean result = searchForWebBeans(child);
+ if (result)
+ return true;
+ }
+ }
+ return false;
+ }
+}
Modified: projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/env/WebBeanDiscoveryDeployer.java
===================================================================
--- projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/env/WebBeanDiscoveryDeployer.java 2009-01-07 20:11:45 UTC (rev 82679)
+++ projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/env/WebBeanDiscoveryDeployer.java 2009-01-07 21:34:37 UTC (rev 82680)
@@ -34,6 +34,7 @@
import org.jboss.deployers.vfs.spi.deployer.AbstractOptionalVFSRealDeployer;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.virtual.VirtualFile;
+import org.jboss.webbeans.integration.microcontainer.deployer.DeployersUtils;
import org.jboss.webbeans.integration.microcontainer.deployer.ext.JBossWebBeansMetaData;
/**
@@ -46,8 +47,8 @@
public WebBeanDiscoveryDeployer()
{
super(JBossWebBeansMetaData.class);
- addInput(JBossWebBeansMetaData.WEB_BEANS_FILES);
- addInput(JBossWebBeansMetaData.WEB_BEANS_CLASSPATH);
+ addInput(DeployersUtils.WEB_BEANS_FILES);
+ addInput(DeployersUtils.WEB_BEANS_CLASSPATH);
addOutput(WebBeanDiscoveryEnvironment.class);
setStage(DeploymentStages.PRE_REAL);
}
@@ -55,11 +56,11 @@
public void deploy(VFSDeploymentUnit unit, JBossWebBeansMetaData deployment) throws DeploymentException
{
@SuppressWarnings("unchecked")
- Collection<VirtualFile> wbFiles = unit.getAttachment(JBossWebBeansMetaData.WEB_BEANS_FILES, Collection.class);
+ Collection<VirtualFile> wbFiles = unit.getAttachment(DeployersUtils.WEB_BEANS_FILES, Collection.class);
boolean hasWB = (wbFiles != null && wbFiles.isEmpty() == false);
@SuppressWarnings("unchecked")
- Collection<VirtualFile> cpFiles = unit.getAttachment(JBossWebBeansMetaData.WEB_BEANS_CLASSPATH, Collection.class);
+ Collection<VirtualFile> cpFiles = unit.getAttachment(DeployersUtils.WEB_BEANS_CLASSPATH, Collection.class);
boolean hasCp = (cpFiles != null && cpFiles.isEmpty() == false);
WebBeanDiscoveryEnvironment environment = null;
Modified: projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/ext/JBossWebBeansMetaData.java
===================================================================
--- projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/ext/JBossWebBeansMetaData.java 2009-01-07 20:11:45 UTC (rev 82679)
+++ projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/ext/JBossWebBeansMetaData.java 2009-01-07 21:34:37 UTC (rev 82680)
@@ -23,11 +23,8 @@
import java.io.Serializable;
import java.net.URL;
-import java.util.Collection;
-import java.util.List;
import org.jboss.virtual.VirtualFile;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
/**
* JBoss WebBeans custom meta data
@@ -38,10 +35,6 @@
{
private static final long serialVersionUID = 1l;
- public static final String WEB_BEANS_FILES = "WEB_BEANS_FILES";
- public static final String WEB_BEANS_CLASSPATH = "WEB_BEANS_CLASSPATH";
- public static final String WEB_BEANS_DEPLOYMENT_FLAG = "WEB_BEANS_DEPLOYMENT_FLAG";
-
private VirtualFile file;
public JBossWebBeansMetaData(VirtualFile file)
@@ -55,50 +48,4 @@
{
return file.toURL();
}
-
- /**
- * Check deployment hierarchy for web-beans.xml files.
- * It check the 'cached' flag.
- *
- * @param unit the deployment unit
- * @return true if web-beans.xml files exist, false otherwise
- */
- public static boolean checkForWebBeansFiles(DeploymentUnit unit)
- {
- DeploymentUnit top = unit.getTopLevel();
-
- Boolean flag = top.getAttachment(WEB_BEANS_DEPLOYMENT_FLAG, Boolean.class);
- if (flag != null)
- return flag;
-
- flag = searchForWebBeans(top);
- top.addAttachment(WEB_BEANS_DEPLOYMENT_FLAG, flag, Boolean.class);
-
- return flag;
- }
-
- /**
- * Search deployment hierarchy for web-beans.xml files.
- *
- * @param unit the deployment unit
- * @return true if web-beans.xml files exist, false otherwise
- */
- private static boolean searchForWebBeans(DeploymentUnit unit)
- {
- Collection files = unit.getAttachment(WEB_BEANS_FILES, Collection.class);
- if (files != null && files.isEmpty() == false)
- return true;
-
- List<DeploymentUnit> children = unit.getChildren();
- if (children != null && children.isEmpty() == false)
- {
- for (DeploymentUnit child : children)
- {
- boolean result = searchForWebBeans(child);
- if (result)
- return true;
- }
- }
- return false;
- }
}
\ No newline at end of file
Modified: projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/metadata/PostJBossAppMetadataDeployer.java
===================================================================
--- projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/metadata/PostJBossAppMetadataDeployer.java 2009-01-07 20:11:45 UTC (rev 82679)
+++ projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/metadata/PostJBossAppMetadataDeployer.java 2009-01-07 21:34:37 UTC (rev 82680)
@@ -25,7 +25,7 @@
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.metadata.ear.jboss.JBossAppMetaData;
import org.jboss.virtual.VirtualFile;
-import org.jboss.webbeans.integration.microcontainer.deployer.ext.JBossWebBeansMetaData;
+import org.jboss.webbeans.integration.microcontainer.deployer.DeployersUtils;
/**
* Post jboss-app.xml webbeans deployer.
@@ -39,7 +39,7 @@
public PostJBossAppMetadataDeployer()
{
super(JBossAppMetaData.class);
- addInput(JBossWebBeansMetaData.WEB_BEANS_FILES);
+ addInput(DeployersUtils.WEB_BEANS_FILES);
setOptionalWebBeansXml(true);
}
@@ -51,7 +51,7 @@
@Override
protected boolean isIsolated(VFSDeploymentUnit unit, VirtualFile wbXml)
{
- return (super.isIsolated(unit, wbXml) && (wbXml != null || JBossWebBeansMetaData.checkForWebBeansFiles(unit)));
+ return (super.isIsolated(unit, wbXml) && (wbXml != null || DeployersUtils.checkForWebBeansFiles(unit)));
}
protected String getJMXName(JBossAppMetaData metaData, DeploymentUnit unit)
Modified: projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/metadata/PostWebMetadataDeployer.java
===================================================================
--- projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/metadata/PostWebMetadataDeployer.java 2009-01-07 20:11:45 UTC (rev 82679)
+++ projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/metadata/PostWebMetadataDeployer.java 2009-01-07 21:34:37 UTC (rev 82680)
@@ -30,7 +30,7 @@
import org.jboss.metadata.web.jboss.JBossWebMetaData;
import org.jboss.metadata.web.spec.ListenerMetaData;
import org.jboss.virtual.VirtualFile;
-import org.jboss.webbeans.integration.microcontainer.deployer.ext.JBossWebBeansMetaData;
+import org.jboss.webbeans.integration.microcontainer.deployer.DeployersUtils;
/**
* Post web.xml webbeans deployer.
@@ -44,7 +44,7 @@
public PostWebMetadataDeployer()
{
super(JBossWebMetaData.class);
- addInput(JBossWebBeansMetaData.WEB_BEANS_FILES);
+ addInput(DeployersUtils.WEB_BEANS_FILES);
addInput("merged." + JBossWebMetaData.class.getName());
setStage(DeploymentStages.POST_CLASSLOADER);
setOptionalWebBeansXml(true);
@@ -55,7 +55,7 @@
protected void internalDeploy(VFSDeploymentUnit unit, JBossWebMetaData deployment, VirtualFile wbXml) throws DeploymentException
{
- if (wbXml != null || JBossWebBeansMetaData.checkForWebBeansFiles(unit))
+ if (wbXml != null || DeployersUtils.checkForWebBeansFiles(unit))
{
List<ListenerMetaData> listeners = deployment.getListeners();
if (listeners == null)
Modified: projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/metadata/WBEjbInterceptorMetadataDeployer.java
===================================================================
--- projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/metadata/WBEjbInterceptorMetadataDeployer.java 2009-01-07 20:11:45 UTC (rev 82679)
+++ projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/metadata/WBEjbInterceptorMetadataDeployer.java 2009-01-07 21:34:37 UTC (rev 82680)
@@ -34,7 +34,7 @@
import org.jboss.metadata.ejb.spec.InterceptorClassesMetaData;
import org.jboss.metadata.ejb.spec.InterceptorMetaData;
import org.jboss.metadata.ejb.spec.InterceptorsMetaData;
-import org.jboss.webbeans.integration.microcontainer.deployer.ext.JBossWebBeansMetaData;
+import org.jboss.webbeans.integration.microcontainer.deployer.DeployersUtils;
/**
* Adds wb custom interceptor to ejb deployments.
@@ -44,21 +44,29 @@
@SuppressWarnings("deprecation")
public class WBEjbInterceptorMetadataDeployer extends AbstractVFSRealDeployer
{
-
private static final String INTERCEPTOR_CLASS_NAME = "org.jboss.webbeans.ejb.SessionBeanInterceptor";
private InterceptorMetaData SBI;
+ private InterceptorBindingMetaData IBMD;
public WBEjbInterceptorMetadataDeployer()
{
addInput(JBossMetaData.class);
addOutput(JBossMetaData.class);
- addInput(JBossWebBeansMetaData.WEB_BEANS_FILES);
+ addInput(DeployersUtils.WEB_BEANS_FILES);
addInput("merged." + JBossMetaData.class.getName());
setStage(DeploymentStages.POST_CLASSLOADER);
+
// create interceptor metadata instance
SBI = new InterceptorMetaData();
SBI.setInterceptorClass(INTERCEPTOR_CLASS_NAME);
+
+ // create interceptor binding metadata instance
+ IBMD = new InterceptorBindingMetaData();
+ InterceptorClassesMetaData interceptorClasses = new InterceptorClassesMetaData();
+ interceptorClasses.add(INTERCEPTOR_CLASS_NAME);
+ IBMD.setInterceptorClasses(interceptorClasses);
+ IBMD.setEjbName("*");
}
public void deploy(VFSDeploymentUnit unit) throws DeploymentException
@@ -78,7 +86,7 @@
}
else
{
- interceptors.add(SBI);
+ interceptors.add(SBI); // clone?
}
JBossAssemblyDescriptorMetaData assemblyDescriptor = jbmd.getAssemblyDescriptor();
@@ -87,27 +95,13 @@
assemblyDescriptor = new JBossAssemblyDescriptorMetaData();
jbmd.setAssemblyDescriptor(assemblyDescriptor);
}
- bindInterceptorToEjbs(assemblyDescriptor);
+ InterceptorBindingsMetaData interceptorBindings = assemblyDescriptor.getInterceptorBindings();
+ if (interceptorBindings == null)
+ {
+ interceptorBindings = new InterceptorBindingsMetaData();
+ assemblyDescriptor.setInterceptorBindings(interceptorBindings);
+ }
+ interceptorBindings.add(IBMD); // clone?
}
}
-
- private void bindInterceptorToEjbs(JBossAssemblyDescriptorMetaData assemblyDescriptor)
- {
- InterceptorBindingMetaData interceptorBinding = new InterceptorBindingMetaData();
- InterceptorClassesMetaData interceptorClasses = new InterceptorClassesMetaData();
- interceptorClasses.add(INTERCEPTOR_CLASS_NAME);
- interceptorBinding.setInterceptorClasses(interceptorClasses);
- interceptorBinding.setEjbName("*");
- if (assemblyDescriptor.getInterceptorBindings() == null)
- {
- InterceptorBindingsMetaData interceptorBindings = new InterceptorBindingsMetaData();
- interceptorBindings.add(interceptorBinding);
- assemblyDescriptor.setInterceptorBindings(interceptorBindings);
- }
- else
- {
- assemblyDescriptor.getInterceptorBindings().add(interceptorBinding);
- }
- }
-
}
\ No newline at end of file
Modified: projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/metadata/WebBeansFilesDeployer.java
===================================================================
--- projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/metadata/WebBeansFilesDeployer.java 2009-01-07 20:11:45 UTC (rev 82679)
+++ projects/webbeans-ri-int/trunk/microcontainer/src/main/java/org/jboss/webbeans/integration/microcontainer/deployer/metadata/WebBeansFilesDeployer.java 2009-01-07 21:34:37 UTC (rev 82680)
@@ -31,6 +31,7 @@
import org.jboss.deployers.vfs.spi.deployer.AbstractOptionalVFSRealDeployer;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.virtual.VirtualFile;
+import org.jboss.webbeans.integration.microcontainer.deployer.DeployersUtils;
import org.jboss.webbeans.integration.microcontainer.deployer.ext.JBossWebBeansMetaData;
/**
@@ -45,8 +46,8 @@
public WebBeansFilesDeployer()
{
super(JBossWebBeansMetaData.class);
- addOutput(JBossWebBeansMetaData.WEB_BEANS_FILES);
- addOutput(JBossWebBeansMetaData.WEB_BEANS_CLASSPATH);
+ addOutput(DeployersUtils.WEB_BEANS_FILES);
+ addOutput(DeployersUtils.WEB_BEANS_CLASSPATH);
setStage(DeploymentStages.POST_PARSE);
}
@@ -86,9 +87,9 @@
}
if (wbFiles.isEmpty() == false)
- unit.addAttachment(JBossWebBeansMetaData.WEB_BEANS_FILES, wbFiles, Collection.class);
+ unit.addAttachment(DeployersUtils.WEB_BEANS_FILES, wbFiles, Collection.class);
if (cpFiles.isEmpty() == false)
- unit.addAttachment(JBossWebBeansMetaData.WEB_BEANS_CLASSPATH, cpFiles, Collection.class);
+ unit.addAttachment(DeployersUtils.WEB_BEANS_CLASSPATH, cpFiles, Collection.class);
}
catch (Exception e)
{
More information about the jboss-cvs-commits
mailing list