[ http://issues.apache.org/jira/browse/JAMES-494?page=comments#action_12411927 ]
Stefano Bagnara commented on JAMES-494: --------------------------------------- I really don't like (never heard of projects using that) JNDI for fine grained service/component wiring/configuration. I think that using JNDI will give much more power to the services itself and remove power from the container: noone is moving in this direction today. If we move to commons-configuration or obix configuration framework then we can store configurations in JNDI/LDAP, but I don't think that the JNDI wiring is good at all. As you are a "supporter of the OSGi cause", can you point me some example of how OSGi and JNDI should be used together and link to any project succesfully using the 2 technologies? Btw once we'll have SDI objects noone block us from creating an extension of those objects to lookup services in JNDI and call the setters, isn't it true? > Refactor the service methods to inject services via setters > ----------------------------------------------------------- > > Key: JAMES-494 > URL: http://issues.apache.org/jira/browse/JAMES-494 > Project: James > Type: Sub-task > Versions: 2.4.0 > Reporter: Stefano Bagnara > Fix For: 2.4.0 > > Nothing worth more than an example: > Here is the current service method of the SMTPServer: > public void service( final ServiceManager manager ) throws ServiceException { > super.service( manager ); > serviceManager = manager; > mailetcontext = (MailetContext) > manager.lookup("org.apache.mailet.MailetContext"); > mailServer = (MailServer) manager.lookup(MailServer.ROLE); > users = (UsersRepository) manager.lookup(UsersRepository.ROLE); > dnsServer = (DNSServer) manager.lookup(DNSServer.ROLE); > } > We could change it to > public void service( final ServiceManager manager ) throws ServiceException { > super.service( manager ); > serviceManager = manager; > setMailetContext((MailetContext) > manager.lookup("org.apache.mailet.MailetContext")); > setMailServer((MailServer) manager.lookup(MailServer.ROLE)); > setUsersRepository((UsersRepository) > manager.lookup(UsersRepository.ROLE)); > setDNSServer((DNSServer) manager.lookup(DNSServer.ROLE)); > } > and add the above setters. > This way we can fill dependencies of SMTPServer without using the Serviceable > interface and the ServiceManager component. > Later we'll move the whole service method and Serviceable interface to the > specific Avalon extension of the "container-agnostic" SMTPServer. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
