David Lloyd [
http://community.jboss.org/people/dmlloyd] created the discussion
"Re: META-INF/services for module extensions - question/issue"
To view the discussion, visit:
http://community.jboss.org/message/625587#625587
--------------------------------------------------------------
Dan Sirbu wrote:
The issue to me is that if the ModuleExtension needs a service from another package that
was never intended to be an extention, thus a Module only, then when I want to access a
service from that Module I should NOT need to use the jboss-module ServiceLoader API !
I should be able to use the java.util.ServiceLoader as does any WAR/RAR or other type of
app deployed as long as the dependency is set properly!
I just want to make it clear
that you do NOT need to use the jboss modules service loader API. This has never been
required, nor will it ever be required. This API exists as a convenience only.
As Brian said, you should always be using the two-argument form of
java.util.ServiceLoader#load() and provide your own class loader with it (I don't know
what you're trying to accomplish with the getParent() but it's a safe bet that
it's not the right thing to do). Usually this is just
"getClass().getClassLoader()", though you'll have to use a class literal in
the static method case. Relying on the thread context class loader is never a good idea
under any circumstances. If you rely on TCCL by using the one-argument form, you're
setting yourself up for failure at +some+ point, either here and now or in the future. If
you use the two-argument form, your program will +always+ work as long as your class
loader has the proper dependencies.
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/625587#625587]
Start a new discussion in JBoss AS7 Development at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]