[jboss-cvs] JBossAS SVN: r67635 - in trunk/server/src: main/org/jboss/deployment and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Nov 29 18:59:16 EST 2007
Author: scott.stark at jboss.org
Date: 2007-11-29 18:59:16 -0500 (Thu, 29 Nov 2007)
New Revision: 67635
Added:
trunk/server/src/main/org/jboss/ejb/deployers/MergedJBossMetaDataDeployer.java
trunk/server/src/main/org/jboss/ejb/deployers/StandardJBossMetaDataDeployer.java
Modified:
trunk/server/src/etc/deployers/ejb-deployer-beans.xml
trunk/server/src/etc/deployers/metadata-beans.xml
trunk/server/src/main/org/jboss/deployment/AnnotationMetaDataDeployer.java
trunk/server/src/main/org/jboss/deployment/JBossEjbParsingDeployer.java
Log:
Split up JBossMetaData creation across deployers
Modified: trunk/server/src/etc/deployers/ejb-deployer-beans.xml
===================================================================
--- trunk/server/src/etc/deployers/ejb-deployer-beans.xml 2007-11-29 23:47:57 UTC (rev 67634)
+++ trunk/server/src/etc/deployers/ejb-deployer-beans.xml 2007-11-29 23:59:16 UTC (rev 67635)
@@ -47,4 +47,9 @@
<depends>SecurityDeployer</depends>
</bean>
+
+ <bean name="MergedJBossMetaDataDeployer" class="org.jboss.ejb.deployers.MergedJBossMetaDataDeployer">
+ </bean>
+ <bean name="StandardJBossMetaDataDeployer" class="org.jboss.ejb.deployers.StandardJBossMetaDataDeployer">
+ </bean>
</deployment>
Modified: trunk/server/src/etc/deployers/metadata-beans.xml
===================================================================
--- trunk/server/src/etc/deployers/metadata-beans.xml 2007-11-29 23:47:57 UTC (rev 67634)
+++ trunk/server/src/etc/deployers/metadata-beans.xml 2007-11-29 23:59:16 UTC (rev 67635)
@@ -9,8 +9,11 @@
<!-- The reference metdata resolving deployer
-->
<bean name="ReferenceMetaDataResolverDeployer"
- class="org.jboss.deployment.ReferenceMetaDataResolverDeployer">
+ class="org.jboss.deployment.ReferenceMetaDataResolverDeployer">
</bean>
+ <bean name="AnnotationMetaDataDeployer"
+ class="org.jboss.deployment.AnnotationMetaDataDeployer">
+ </bean>
<!-- The schema location to JBossXB binding class mappings. We specify the dtd/xsd name
of the schema as the location to work with legacy dtd as well as namespace based
Modified: trunk/server/src/main/org/jboss/deployment/AnnotationMetaDataDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/AnnotationMetaDataDeployer.java 2007-11-29 23:47:57 UTC (rev 67634)
+++ trunk/server/src/main/org/jboss/deployment/AnnotationMetaDataDeployer.java 2007-11-29 23:59:16 UTC (rev 67635)
@@ -36,12 +36,12 @@
import org.jboss.metadata.annotation.finder.AnnotationFinder;
import org.jboss.metadata.annotation.finder.DefaultAnnotationFinder;
import org.jboss.metadata.client.jboss.JBossClientMetaData;
+import org.jboss.metadata.client.spec.ApplicationClientMetaData;
import org.jboss.metadata.ejb.jboss.JBossMetaData;
-import org.jboss.metadata.ejb.jboss.JBossMetaDataWrapper;
-import org.jboss.metadata.ejb.spec.AnnotationMergedView;
import org.jboss.metadata.ejb.spec.EjbJar30MetaData;
import org.jboss.metadata.ejb.spec.EjbJarMetaData;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.metadata.web.spec.WebMetaData;
import org.jboss.virtual.VirtualFile;
/**
@@ -53,10 +53,16 @@
*/
public class AnnotationMetaDataDeployer extends AbstractDeployer
{
+ public static final String EJB_ANNOTATED_ATTACHMENT_NAME = "annotated."+EjbJarMetaData.class.getName();
+ public static final String CLIENT_ANNOTATED_ATTACHMENT_NAME = "annotated."+ApplicationClientMetaData.class.getName();
+ public static final String WEB_ANNOTATED_ATTACHMENT_NAME = "annotated."+WebMetaData.class.getName();
public AnnotationMetaDataDeployer()
{
setStage(DeploymentStages.POST_CLASSLOADER);
+ addOutput(EJB_ANNOTATED_ATTACHMENT_NAME);
+ addOutput(CLIENT_ANNOTATED_ATTACHMENT_NAME);
+ addOutput(WEB_ANNOTATED_ATTACHMENT_NAME);
}
public void deploy(DeploymentUnit unit) throws DeploymentException
@@ -166,25 +172,7 @@
// Create the metadata model from the annotations
EjbJar30Creator creator = new EjbJar30Creator(finder);
EjbJar30MetaData annotationMetaData = creator.create(classes.values());
- EjbJarMetaData specMetaData = unit.getAttachment(EjbJarMetaData.class);
- EjbJarMetaData specMerged = specMetaData;
- if(specMetaData != null)
- {
- specMerged = new EjbJar30MetaData();
- AnnotationMergedView.merge(specMerged, specMetaData, annotationMetaData);
- }
-
- // Get the standardjboss.xml metadata
- JBossMetaData stdMetaData = unit.getAttachment("standardjboss.xml", JBossMetaData.class);
- // Get the raw parsed metadata
- JBossMetaData rawMetaData = unit.getAttachment("raw."+JBossMetaData.class.getName(), JBossMetaData.class);
- // Merge the xml and annotated view
- JBossMetaData mergedMetaData = new JBossMetaData();
- mergedMetaData.merge(rawMetaData, specMerged);
- unit.addAttachment("annotated."+JBossMetaData.class.getName(), mergedMetaData);
- // Wrap the merged view with the standard jboss metadata
- JBossMetaDataWrapper wrapper = new JBossMetaDataWrapper(mergedMetaData, stdMetaData);
- unit.getTransientManagedObjects().addAttachment(JBossMetaData.class, wrapper);
+ unit.addAttachment(EJB_ANNOTATED_ATTACHMENT_NAME, annotationMetaData, EjbJarMetaData.class);
}
protected void processJBossWebMetaData(VFSDeploymentUnit unit,
AnnotationFinder<AnnotatedElement> finder, Map<VirtualFile, Class<?>> classes)
Modified: trunk/server/src/main/org/jboss/deployment/JBossEjbParsingDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/JBossEjbParsingDeployer.java 2007-11-29 23:47:57 UTC (rev 67634)
+++ trunk/server/src/main/org/jboss/deployment/JBossEjbParsingDeployer.java 2007-11-29 23:59:16 UTC (rev 67635)
@@ -36,7 +36,6 @@
import org.jboss.metadata.common.jboss.LoaderRepositoryMetaData;
import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
import org.jboss.metadata.ejb.jboss.JBossMetaData;
-import org.jboss.metadata.ejb.jboss.JBossMetaDataWrapper;
import org.jboss.metadata.ejb.spec.EjbJarMetaData;
import org.jboss.mx.loading.LoaderRepositoryFactory.LoaderRepositoryConfig;
import org.jboss.mx.server.ServerConstants;
@@ -46,7 +45,7 @@
/**
* An ObjectModelFactoryDeployer for translating jboss.xml descriptors into
- * ApplicationMetaData instances.
+ * JBossMetaData instances.
*
* @author Scott.Stark at jboss.org
* @author adrian at jboss.org
@@ -62,11 +61,18 @@
*/
public JBossEjbParsingDeployer()
{
+ // Output the jboss.xml metadata
super(JBossMetaData.class);
- super.getOutputs().add(ApplicationMetaData.class.getName());
- // Optional overridden meta data
- addInput(EjbJarMetaData.class);
setName("jboss.xml");
+
+ // Optional ejb-jar.xml metadata
+ addInput(EjbJarMetaData.class);
+ // Output the legacy jboss ejb metadata
+ addOutput(ApplicationMetaData.class.getName());
+ // Output the standardjboss.xml metadata
+ addOutput("standardjboss.xml");
+ // Output the LoaderRepositoryConfig
+ addOutput(LoaderRepositoryConfig.class);
}
@Override
@@ -76,43 +82,21 @@
// For legacy
ApplicationMetaData amd = new ApplicationMetaData(metaData);
unit.addAttachment(ApplicationMetaData.class, amd);
- }
- @Override
- protected JBossMetaData parse(VFSDeploymentUnit unit, VirtualFile file, JBossMetaData root) throws Exception
- {
- JBossMetaData metaData = super.parse(unit, file, root);
- return metaData;
- }
+ // Wrap in the standardjboss.xml
+ JBossMetaData stdMetaData = getStandardMetaData(unit);
+ // Save this as a transient(non-managed) attachment
+ unit.addAttachment("standardjboss.xml", stdMetaData);
- private JBossMetaData getStandardMetaData(VFSDeploymentUnit unit) throws DeploymentException
- {
- if (standardMetaData == null)
- {
- try
- {
- String configPath = System.getProperty(ServerConfig.SERVER_CONFIG_URL);
- URL configUrl = new URL(configPath);
- VirtualFile stdJBoss = VFS.getVirtualFile(configUrl, "standardjboss.xml");
- if (stdJBoss == null)
- {
- throw new DeploymentException("standardjboss.xml not found in config dir: " + configPath);
- }
- standardMetaData = super.parse(unit, stdJBoss, null);
- }
- catch (Exception ex)
- {
- DeploymentException.rethrowAsDeploymentException(ex.getMessage(), ex);
- }
- }
- return standardMetaData;
+ // Add the loader repository config
+ LoaderRepositoryConfig loaderRepositoryConfig = createLoaderRepositoryConfig(metaData);
+ if (loaderRepositoryConfig != null)
+ unit.addAttachment(LoaderRepositoryConfig.class.getName(), loaderRepositoryConfig);
}
/**
- * Override to wrap the jboss.xml metadata with a wrapper that delegates to
- * the standardjboss.xml metadata, and to include any EjbJarMetaData
- * override. We also make sure we always have a JBossMetaData object attached, even
- * if there is no jboss.xml in the deployment, if there is an EjbJarMetaData.
+ * Override to ensure we always have a JBossMetaData object attached, even
+ * if there is no jboss.xml in the deployment, provided there is an EjbJarMetaData.
*/
@Override
protected void createMetaData(DeploymentUnit unit, String name, String suffix, String key) throws DeploymentException
@@ -123,7 +107,6 @@
if((specMetaData == null && metaData == null) || (unit instanceof VFSDeploymentUnit) == false)
return;
- VFSDeploymentUnit vfsunit = (VFSDeploymentUnit) unit;
// If there no JBossMetaData was created from a jboss.xml, create one
if (metaData == null)
{
@@ -131,25 +114,8 @@
JBossEnterpriseBeansMetaData jbBeans = new JBossEnterpriseBeansMetaData();
metaData.setEnterpriseBeans(jbBeans);
}
- // Create a merged view
- JBossMetaData mergedMetaData = new JBossMetaData();
- mergedMetaData.merge(metaData, specMetaData);
- // Wrap in the standardjboss.xml
- JBossMetaData stdMetaData = getStandardMetaData(vfsunit);
- // Save this as a transient(non-managed) attachment
- unit.addAttachment("standardjboss.xml", stdMetaData);
- JBossMetaDataWrapper wrapper = new JBossMetaDataWrapper(mergedMetaData, stdMetaData);
- // Set the wrapper as the output
- unit.getTransientManagedObjects().addAttachment(JBossMetaData.class, wrapper);
- // Keep the raw parsed metadata as well
- unit.addAttachment("raw."+JBossMetaData.class.getName(), metaData, JBossMetaData.class);
-
- // Add the loader repository config
- LoaderRepositoryConfig loaderRepositoryConfig = createLoaderRepositoryConfig(metaData);
- if (loaderRepositoryConfig != null)
- unit.addAttachment(LoaderRepositoryConfig.class.getName(), loaderRepositoryConfig);
}
-
+
/**
* Create the loader repository config
*
@@ -205,4 +171,27 @@
repositoryConfig.repositoryConfig = configData.toString().trim();
return repositoryConfig;
}
+
+ private JBossMetaData getStandardMetaData(VFSDeploymentUnit unit) throws DeploymentException
+ {
+ if (standardMetaData == null)
+ {
+ try
+ {
+ String configPath = System.getProperty(ServerConfig.SERVER_CONFIG_URL);
+ URL configUrl = new URL(configPath);
+ VirtualFile stdJBoss = VFS.getVirtualFile(configUrl, "standardjboss.xml");
+ if (stdJBoss == null)
+ {
+ throw new DeploymentException("standardjboss.xml not found in config dir: " + configPath);
+ }
+ standardMetaData = super.parse(unit, stdJBoss, null);
+ }
+ catch (Exception ex)
+ {
+ DeploymentException.rethrowAsDeploymentException(ex.getMessage(), ex);
+ }
+ }
+ return standardMetaData;
+ }
}
Added: trunk/server/src/main/org/jboss/ejb/deployers/MergedJBossMetaDataDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/deployers/MergedJBossMetaDataDeployer.java (rev 0)
+++ trunk/server/src/main/org/jboss/ejb/deployers/MergedJBossMetaDataDeployer.java 2007-11-29 23:59:16 UTC (rev 67635)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.ejb.deployers;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployment.AnnotationMetaDataDeployer;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.spec.AnnotationMergedView;
+import org.jboss.metadata.ejb.spec.EjbJar30MetaData;
+import org.jboss.metadata.ejb.spec.EjbJarMetaData;
+
+/**
+ * A deployer that
+ *
+ * @author Scott.Stark at jboss.org
+ * @author adrian at jboss.org
+ * @version $Revision$
+ */
+public class MergedJBossMetaDataDeployer extends AbstractDeployer
+{
+ public static final String EJB_MERGED_ATTACHMENT_NAME = "merged."+JBossMetaData.class.getName();
+
+ /**
+ * Create a new JBossEjbParsingDeployer.
+ */
+ public MergedJBossMetaDataDeployer()
+ {
+ setStage(DeploymentStages.POST_CLASSLOADER);
+ // ejb-jar.xml metadata
+ addInput(EjbJarMetaData.class);
+ // jboss.xml metadata
+ addInput(JBossMetaData.class);
+ // annotated metadata view
+ addInput(AnnotationMetaDataDeployer.EJB_ANNOTATED_ATTACHMENT_NAME);
+ // Output is the merge JBossMetaData view
+ setOutput(JBossMetaData.class);
+ //
+ addOutput(EJB_MERGED_ATTACHMENT_NAME);
+ }
+
+ public void deploy(DeploymentUnit unit) throws DeploymentException
+ {
+ EjbJarMetaData specMetaData = unit.getAttachment(EjbJarMetaData.class);
+ JBossMetaData metaData = unit.getAttachment(JBossMetaData.class);
+ if(specMetaData == null && metaData == null)
+ return;
+
+ // Check for an annotated view
+ String key = AnnotationMetaDataDeployer.EJB_ANNOTATED_ATTACHMENT_NAME;
+ EjbJarMetaData annotatedMetaData = unit.getAttachment(key, EjbJarMetaData.class);
+ if(annotatedMetaData != null)
+ {
+ EjbJarMetaData specMerged = new EjbJar30MetaData();
+ AnnotationMergedView.merge(specMerged, specMetaData, annotatedMetaData);
+ specMetaData = specMerged;
+ }
+
+ // Create a merged view
+ JBossMetaData mergedMetaData = new JBossMetaData();
+ mergedMetaData.merge(metaData, specMetaData);
+ unit.addAttachment(JBossMetaData.class, mergedMetaData);
+ }
+
+}
Property changes on: trunk/server/src/main/org/jboss/ejb/deployers/MergedJBossMetaDataDeployer.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: trunk/server/src/main/org/jboss/ejb/deployers/StandardJBossMetaDataDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/deployers/StandardJBossMetaDataDeployer.java (rev 0)
+++ trunk/server/src/main/org/jboss/ejb/deployers/StandardJBossMetaDataDeployer.java 2007-11-29 23:59:16 UTC (rev 67635)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.ejb.deployers;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaDataWrapper;
+
+/**
+ * Wrap the jboss.xml and standardjboss.xml JBossMetaData attachments
+ * to create the combined JBossMetaData view
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class StandardJBossMetaDataDeployer extends AbstractDeployer
+{
+ public static final String RAW_ATTACHMENT_NAME = "raw."+JBossMetaData.class.getName();
+ /**
+ * Create a new StandardJBossMetaDataDeployer.
+ */
+ public StandardJBossMetaDataDeployer()
+ {
+ setStage(DeploymentStages.POST_CLASSLOADER);
+ // jboss.xml meta data
+ addInput(JBossMetaData.class);
+ // The standardjboss.xml meta data
+ addInput("standardjboss.xml");
+ // Wrapper should come after any merged view
+ addInput(MergedJBossMetaDataDeployer.EJB_MERGED_ATTACHMENT_NAME);
+ //
+ setOutput(JBossMetaData.class);
+ addOutput(RAW_ATTACHMENT_NAME);
+ }
+
+ /**
+ * Override to wrap the jboss.xml metadata with a wrapper that delegates to
+ * the standardjboss.xml metadata.
+ */
+ public void deploy(DeploymentUnit unit)
+ throws DeploymentException
+ {
+ // Get the jboss.xml attachment
+ JBossMetaData metaData = unit.getAttachment(JBossMetaData.class);
+ // Get the standardjboss.xml attachment
+ JBossMetaData stdMetaData = unit.getAttachment("standardjboss.xml", JBossMetaData.class);
+ if(metaData == null || stdMetaData == null)
+ return;
+
+ JBossMetaDataWrapper wrapper = new JBossMetaDataWrapper(metaData, stdMetaData);
+ // Set the wrapper as the output
+ unit.getTransientManagedObjects().addAttachment(JBossMetaData.class, wrapper);
+ // Keep the raw parsed metadata as well
+ unit.addAttachment(RAW_ATTACHMENT_NAME, metaData, JBossMetaData.class);
+ }
+}
Property changes on: trunk/server/src/main/org/jboss/ejb/deployers/StandardJBossMetaDataDeployer.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
More information about the jboss-cvs-commits
mailing list