JBossClientMetaData clientMetaData = unit.getAttachment(JBossClientMetaData.class);
if(ejbMetaData == null && webMetaData == null && clientMetaData == null)
return;
// Create a map of the reference endpoints if it does not exist in the top unit
DeploymentUnit top = unit.getTopLevel();
Map<String, ContainerDependencyMetaData> endpointMap = top.getAttachment(ENDPOINT_MAP_KEY, Map.class);
Map<String, String> endpointAlternateMap = top.getAttachment(ALTERNATE_MAP_KEY, Map.class);
if(endpointMap == null)
{
endpointMap = new ConcurrentHashMap<String, ContainerDependencyMetaData>();
endpointAlternateMap = new ConcurrentHashMap<String, String>();
mapEndpoints(top, endpointMap, endpointAlternateMap);
top.addAttachment(ENDPOINT_MAP_KEY, endpointMap, Map.class);
top.addAttachment(ALTERNATE_MAP_KEY, endpointAlternateMap);
DeploymentEndpointResolver resolver = new MappedDeploymentEndpointResolver(endpointMap, endpointAlternateMap, unit.getRelativePath());
top.addAttachment(DeploymentEndpointResolver.class, resolver);
}
DeploymentEndpointResolver resolver = new MappedDeploymentEndpointResolver(
endpointMap, endpointAlternateMap, unit.getRelativePath());
List<String> unresolvedPaths = new ArrayList<String>();
if(ejbMetaData != null)
{
JBossEnterpriseBeansMetaData beans = ejbMetaData.getEnterpriseBeans();
// Process ejb references
try
{
resolve(unit, endpointMap, beans, resolver, unresolvedPaths);
}
catch (Exception e)
{
throw new DeploymentException(e);
}
if(unresolvedPaths.size() > 0)
log.warn("Unresolved references exist in JBossMetaData:"+unresolvedPaths);
}
if(webMetaData != null)
{
// Process web app references
ContainerDependencyMetaData webAppCDMD = new ContainerDependencyMetaData(unit.getSimpleName(), "web-app", unit.getRelativePath());
try
{
resolve(webAppCDMD, unit, endpointMap, webMetaData.getJndiEnvironmentRefsGroup(), resolver, unresolvedPaths);
}
catch (Exception e)
{
throw new DeploymentException(e);
}
if(unresolvedPaths.size() > 0)
log.warn("Unresolved references exist in JBossWebMetaData:"+unresolvedPaths);
}
if(clientMetaData != null)
{
// Process client app references
ContainerDependencyMetaData clientCDMD = new ContainerDependencyMetaData(unit.getSimpleName(), "client", unit.getRelativePath());
try
{
resolve(clientCDMD, unit, endpointMap, clientMetaData.getJndiEnvironmentRefsGroup(), resolver, unresolvedPaths);
}
catch (Exception e)
{
throw new DeploymentException(e);
}
if(unresolvedPaths.size() > 0)
log.warn("Unresolved references exist in JBossClientMetaData: "+unresolvedPaths);
}
// Add the unique set of ContainerDependencyMetaData
Set<ContainerDependencyMetaData> depends = new HashSet<ContainerDependencyMetaData>();
for(ContainerDependencyMetaData cdmd : endpointMap.values())
{
depends.add(cdmd);
}
top.addAttachment(DEPENDS_SET_KEY, depends, Set.class);
unit.addAttachment(DeploymentEndpointResolver.class, resolver);
dump(unit);
}