JBoss Community

Implementing a non-flat deployment for Weld Integration

reply from Flavia Rainone in JBoss Microcontainer Development POJO Server - View the full discussion

This is about the TODO comment that Ales added to DeploymentImpl:

 

 

public BeanDeploymentArchive loadBeanDeploymentArchive(Class<?> beanClass)
   {
      // collection to mark the archives we have already searched
      Collection<Archive> searchedArchives = new HashSet<Archive>();
      // collection to mark the classpaths we have already searched
      Collection<Classpath> searchedClasspaths = new HashSet<Classpath>();
      // TODO -- why the search? beanClass' ClassLoader should be mapped to Archive?
      // need to throw an IllegalArgumentException if the Archive is not reachable from
      // the archives contained in the archives of this deployment
      Archive archive = findArchive(beanClass, archives, searchedArchives, searchedClasspaths);
      if (archive == null)

 

I put a temporary answer right below the TODO as you can see. It is undeniable that Ales' suggested approach is much simpler and faster than searching for the Archive in the graph.

 

The problem is that we need to throw the IllegalArgumentException whenever the Archive is not reachable. I'm wondering if that exception is really necessary, as IMHO the gains of following Ales suggestion outweight the fact that we are not checking for Archive visibility.

 

So, in order for this exception to happen, we would need to assume that Weld is asking for a bean loaded by a ClassLoader that is not visible to the ClassLoader that loaded the current deployment. Would this scenario ever happen?

Reply to this message by going to Community

Start a new discussion in JBoss Microcontainer Development POJO Server at Community