JBoss Community

Re: Implementing a non-flat deployment for Weld Integration

created by Flavia Rainone in JBoss Microcontainer Development POJO Server - View the full discussion

Ales Justin wrote:

 

IMO, I would move the initialization of default domain to a static block. In this block, I would also add the lib Archives after the default domain is created:

The initialization cannot be in a static block, since the libs provider is dynamic -- injected via MC beans.

 

Indeed.

In that case, an alternative is adding the libs at the exact moment setLibArchivesProvider is invoked. We could initialize the DefaultClasspath inside that method, that would need another name now, or we could initialize it staticaly again. Either way, this matter of initializing it statically or inside create is personal. I just think that it would be nice to get rid of the synchronized block and to get rid of the "if defaultClasspath is null", given that everytime ClasspathFactory is invoked, we will end up needing DefaultClasspath anyway.

Ales Justin wrote:

 

- if the libraries are loaded after ClasspathFactory, we won't enter the loop

OK, while this might save us from this curent loop,

having Classpath that refs itself seems like asking for another loop trouble.

 

Isn't there a better/safer aka proper way of doing this?

I think that the proper way is to initialize the parent container , i.e, DefaultClasspath, prior to initializing all the rest, including its contents, i.e., Archive/ArchiveInfo structure. Isn't it done this way with default domain initialization vs class loader initializations?

 

The Archive/ArchiveInfo structure is written in a way that assumes that the container (Classpath) to which an Archive will be added is already created or, if not, will be created transparently, mirroring the ClassLoader structure. This saves whoever is the Archive client the trouble of having to worry about Classpaths. Transparently as well, the ArchiveInfo/Archive/Classpath structure reaccomodates itself to mirror BDAs created and BDAs not created.I wrote it this way because I was following the natural order of deployment, and I wanted to keep the deployers as simple as possible.

 

So, in order to create BDAs for the libs, the best way IMO is to initialize DefaultClasspath without any contents,  and rename LibraryDiscoveryService.getLibraries method to discoverServices, loadServices, or something like that. You won't need any return value for that method because, at the moment it creates ArchiveInfo, the corresponding Classpath structure is initialized, and the structure is updated when you create an Archive out of it and extract the BDAs. Meaning that DefaultClasspath will automaticaly add the created Archives to itself.

 

BTW DefaultClasspath does not ref itself, as the classpaths mirror the domain structure.

Reply to this message by going to Community

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