[jboss-cvs] JBossAS SVN: r66640 - in trunk/server/src: main/org/jboss/deployment and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Nov 1 03:18:33 EDT 2007
Author: scott.stark at jboss.org
Date: 2007-11-01 03:18:33 -0400 (Thu, 01 Nov 2007)
New Revision: 66640
Modified:
trunk/server/src/etc/deployers/metadata-beans.xml
trunk/server/src/main/org/jboss/deployment/ReferenceMetaDataResolverDeployer.java
Log:
Have ejb-ref resolution working
Modified: trunk/server/src/etc/deployers/metadata-beans.xml
===================================================================
--- trunk/server/src/etc/deployers/metadata-beans.xml 2007-11-01 00:56:56 UTC (rev 66639)
+++ trunk/server/src/etc/deployers/metadata-beans.xml 2007-11-01 07:18:33 UTC (rev 66640)
@@ -6,6 +6,16 @@
-->
<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <!-- The reference metdata resolving deployer
+ -->
+ <bean name="ReferenceMetaDataResolverDeployer"
+ class="org.jboss.deployment.ReferenceMetaDataResolverDeployer">
+ </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
+ documents.
+ -->
<bean name="SchemaResolverConfig"
class="org.jboss.xb.binding.sunday.unmarshalling.SchemaResolverConfig">
Modified: trunk/server/src/main/org/jboss/deployment/ReferenceMetaDataResolverDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/ReferenceMetaDataResolverDeployer.java 2007-11-01 00:56:56 UTC (rev 66639)
+++ trunk/server/src/main/org/jboss/deployment/ReferenceMetaDataResolverDeployer.java 2007-11-01 07:18:33 UTC (rev 66640)
@@ -30,10 +30,6 @@
import java.util.StringTokenizer;
import java.util.concurrent.ConcurrentHashMap;
-import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
-import org.jboss.beans.metadata.plugins.AbstractDemandMetaData;
-import org.jboss.beans.metadata.spi.BeanMetaData;
-import org.jboss.beans.metadata.spi.SupplyMetaData;
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.DeploymentStages;
import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
@@ -42,7 +38,6 @@
import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
import org.jboss.logging.Logger;
import org.jboss.metadata.client.jboss.JBossClientMetaData;
-import org.jboss.metadata.ear.jboss.JBossAppMetaData;
import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
import org.jboss.metadata.ejb.jboss.JBossEntityBeanMetaData;
@@ -55,8 +50,6 @@
import org.jboss.metadata.javaee.spec.Environment;
import org.jboss.metadata.javaee.spec.MessageDestinationMetaData;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
-import org.jboss.system.metadata.ServiceDeployment;
-import org.jboss.system.metadata.ServiceMetaData;
import org.jboss.util.Strings;
/**
@@ -84,34 +77,49 @@
super.setInputs(inputs);
}
+ /**
+ * We want to process the parent last
+ */
+ @Override
+ public boolean isParentFirst()
+ {
+ return false;
+ }
+
+ /**
+ * Look for ejb, web or client metadata to resolve references without
+ * mapped names.
+ */
public void deploy(DeploymentUnit unit) throws DeploymentException
{
- // Could have conflicts with multiple deploy directories
- String vfsPath = unit.getRelativePath();
JBossMetaData ejbMetaData = unit.getAttachment(JBossMetaData.class);
JBossWebMetaData webMetaData = unit.getAttachment(JBossWebMetaData.class);
JBossClientMetaData clientMetaData = unit.getAttachment(JBossClientMetaData.class);
if(ejbMetaData == null && webMetaData == null && clientMetaData == null)
return;
+ dump(unit);
if(ejbMetaData != null)
{
- // First map the providers of resources
+ // Process ejb references
JBossEnterpriseBeansMetaData beans = ejbMetaData.getEnterpriseBeans();
- mapEjbs(vfsPath, beans);
- ejbMetaData.getAssemblyDescriptor();
- //
List<String> unresolvedPaths = resolve(unit, beans);
+ if(unresolvedPaths != null && unresolvedPaths.size() > 0)
+ log.warn("Unresolved references exist in JBossMetaData: "+unresolvedPaths);
}
- // Web app processed next
if(webMetaData != null)
{
+ // Process web app references
List<String> unresolvedPaths = resolve(unit, webMetaData.getJndiEnvironmentRefsGroup());
+ if(unresolvedPaths != null && unresolvedPaths.size() > 0)
+ log.warn("Unresolved references exist in JBossWebMetaData: "+unresolvedPaths);
}
- // Client app is processed last
if(clientMetaData != null)
{
+ // Process client app references
List<String> unresolvedPaths = resolve(unit, clientMetaData.getJndiEnvironmentRefsGroup());
+ if(unresolvedPaths != null && unresolvedPaths.size() > 0)
+ log.warn("Unresolved references exist in JBossClientMetaData: "+unresolvedPaths);
}
}
@@ -133,9 +141,6 @@
}
}
- protected void resolve(JBossMetaData ejb)
- {
- }
protected List<String> resolve(DeploymentUnit unit, Environment env)
{
if(env == null)
@@ -144,6 +149,9 @@
ArrayList<String> unresolvedRefs = new ArrayList<String>();
EJBLocalReferencesMetaData localRefs = env.getEjbLocalReferences();
resolveEjbLocalRefs(unit, localRefs, unresolvedRefs);
+ EJBReferencesMetaData ejbRefs = env.getEjbReferences();
+ resolveEjbRefs(unit, ejbRefs, unresolvedRefs);
+ // TODO, other references
return unresolvedRefs;
}
protected List<String> resolve(DeploymentUnit unit, JBossEnterpriseBeansMetaData beans)
@@ -154,35 +162,47 @@
for(JBossEnterpriseBeanMetaData bean : beans)
{
-
EJBLocalReferencesMetaData localRefs = bean.getEjbLocalReferences();
resolveEjbLocalRefs(unit, localRefs, unresolvedRefs);
EJBReferencesMetaData ejbRefs = bean.getEjbReferences();
- if(ejbRefs != null)
- for(EJBReferenceMetaData ref : ejbRefs)
- {
- String link = ref.getLink();
- String target = findEjbLink(null, unit, link);
- ref.setMappedName(target);
- if(target == null)
- unresolvedRefs.add(ref.getEjbRefName()+"/ejb-ref/"+link);
- }
+ resolveEjbRefs(unit, ejbRefs, unresolvedRefs);
}
return unresolvedRefs;
}
protected void resolveEjbLocalRefs(DeploymentUnit unit, EJBLocalReferencesMetaData localRefs, ArrayList<String> unresolvedRefs)
{
- if(localRefs != null)
- for(EJBLocalReferenceMetaData ref : localRefs)
+ if(localRefs == null)
+ return;
+ for(EJBLocalReferenceMetaData ref : localRefs)
+ {
+ String link = ref.getLink();
+ String target = findLocalEjbLink(unit, link);
+ if(target == null)
+ unresolvedRefs.add(ref.getEjbRefName()+"/ejb-local-ref/"+link);
+ else
+ ref.setMappedName(target);
+ }
+ }
+ protected void resolveEjbRefs(DeploymentUnit unit, EJBReferencesMetaData ejbRefs, ArrayList<String> unresolvedRefs)
+ {
+ if(ejbRefs == null)
+ return;
+ for(EJBReferenceMetaData ref : ejbRefs)
+ {
+ String mappedName = ref.getMappedName();
+ if(mappedName == null)
{
String link = ref.getLink();
- String target = findLocalEjbLink(null, unit, link);
- ref.setMappedName(target);
+ String target = null;
+ if(link != null)
+ target = findEjbLink(unit, link);
if(target == null)
- unresolvedRefs.add(ref.getEjbRefName()+"/ejb-local-ref/"+link);
+ unresolvedRefs.add(ref.getEjbRefName()+"/ejb-ref/"+link);
+ else
+ ref.setMappedName(target);
}
-
+ }
}
/**
@@ -196,9 +216,9 @@
* @return The JNDI Entry of the target bean; <code>null</code> if
* no appropriate target could be found.
*/
- public static String findEjbLink(MainDeployerStructure server, DeploymentUnit unit, String link)
+ public static String findEjbLink(DeploymentUnit unit, String link)
{
- return resolveLink(server, unit, link, false);
+ return resolveLink(unit, link, false);
}
/**
@@ -212,9 +232,9 @@
* @return The JNDI Entry of the target bean; <code>null</code> if
* no appropriate target could be found.
*/
- public static String findLocalEjbLink(MainDeployerStructure server, DeploymentUnit unit, String link)
+ public static String findLocalEjbLink(DeploymentUnit unit, String link)
{
- return resolveLink(server, unit, link, true);
+ return resolveLink(unit, link, true);
}
/**
@@ -233,7 +253,7 @@
return resolveMessageDestination(server, di, link);
}
- private static String resolveLink(MainDeployerStructure server, DeploymentUnit di, String link, boolean isLocal)
+ private static String resolveLink(DeploymentUnit di, String link, boolean isLocal)
{
if (link == null)
{
@@ -254,7 +274,7 @@
if (link.indexOf('#') != -1)
{
// <ejb-link> is specified in the form path/file.jar#Bean
- return resolveRelativeLink(server, di, link, isLocal);
+ return resolveRelativeLink(di, link, isLocal);
}
else
{
@@ -264,9 +284,8 @@
}
}
- private static String resolveRelativeLink(MainDeployerStructure server, DeploymentUnit unit, String link, boolean isLocal)
+ private static String resolveRelativeLink(DeploymentUnit unit, String link, boolean isLocal)
{
-
String path = link.substring(0, link.indexOf('#'));
String ejbName = link.substring(link.indexOf('#') + 1);
String us = unit.getName();
@@ -311,8 +330,7 @@
DeploymentUnit targetUnit = null;
try
{
- DeploymentContext ctx = server.getDeploymentContext(target.toString());
- targetUnit = ctx.getDeploymentUnit();
+ targetUnit = findTargetUnit(unit, target);
}
catch (Exception e)
{
@@ -354,6 +372,11 @@
return linkTarget;
}
+ private static DeploymentUnit findTargetUnit(DeploymentUnit unit, URL target)
+ {
+ return null;
+ }
+
private static String resolveAbsoluteLink(DeploymentUnit unit, String link, boolean isLocal)
{
if (log.isTraceEnabled())
@@ -363,11 +386,11 @@
String ejbName = null;
- // Search current DeploymentUnit
- if (unit.getAttachment(JBossMetaData.class) != null)
+ // Search all ejb DeploymentUnits
+ List<JBossMetaData> ejbMetaData = getAllAttachments(unit, JBossMetaData.class);
+ for(JBossMetaData ejbMD : ejbMetaData)
{
- JBossMetaData appMD = unit.getAttachment(JBossMetaData.class);
- JBossEnterpriseBeanMetaData beanMD = appMD.getEnterpriseBean(link);
+ JBossEnterpriseBeanMetaData beanMD = ejbMD.getEnterpriseBean(link);
if (beanMD != null)
{
ejbName = getJndiName(beanMD, isLocal);
@@ -382,29 +405,35 @@
{
// Dump the ejb module ejbNames
log.trace("No match for ejb-link: " + link + ", module names:");
- for(JBossEnterpriseBeanMetaData md : appMD.getEnterpriseBeans())
+ for(JBossEnterpriseBeanMetaData md : ejbMD.getEnterpriseBeans())
{
String beanEjbName = getJndiName(md, isLocal);
log.trace("... ejbName: " + beanEjbName);
}
}
}
- else if (unit.getAttachment("EJB_DEPLOYMENTS") != null)
- {
- log.debug("Saw EJB3 module, cannot resolve it");
- }
- // Search each subcontext
- Iterator<DeploymentUnit> it = unit.getChildren().iterator();
- while (it.hasNext() && ejbName == null)
- {
- DeploymentUnit child = it.next();
- ejbName = resolveAbsoluteLink(child, link, isLocal);
- }
-
return ejbName;
}
+ private static <T> List<T> getAllAttachments(DeploymentUnit unit, Class<T> type)
+ {
+ ArrayList<T> attachments = new ArrayList<T>();
+ DeploymentUnit top = unit.getTopLevel();
+ getAllAttachments(top, type, attachments);
+ return attachments;
+ }
+ private static <T> void getAllAttachments(DeploymentUnit unit, Class<T> type, ArrayList<T> attachments)
+ {
+ T attachment = unit.getAttachment(type);
+ if(attachment != null)
+ attachments.add(attachment);
+ List<DeploymentUnit> children = unit.getChildren();
+ if(children != null)
+ for(DeploymentUnit child : children)
+ getAllAttachments(child, type, attachments);
+ }
+
private static String getJndiName(JBossEnterpriseBeanMetaData beanMD, boolean isLocal)
{
String jndiName = null;
@@ -563,4 +592,25 @@
// Not found
return null;
}
+
+ private void dump(DeploymentUnit unit)
+ {
+ DeploymentUnit top = unit.getTopLevel();
+ StringBuffer tmp = new StringBuffer();
+ dump(top, tmp, 0);
+ log.debug("Processing unit:\n"+tmp);
+ }
+ private void dump(DeploymentUnit unit, StringBuffer tmp, int depth)
+ {
+ for(int n = 0; n < depth; n ++)
+ tmp.append('+');
+ tmp.append(unit.getRelativePath());
+ tmp.append('\n');
+ List<DeploymentUnit> children = unit.getChildren();
+ if(children != null)
+ {
+ for(DeploymentUnit child : children)
+ dump(child, tmp, depth+1);
+ }
+ }
}
More information about the jboss-cvs-commits
mailing list