I'm trying to provide a [code]java.sql.DataSource[/code] with an
[code]@Provides[/code] method and a [code]BindingAnnotation[/code]. How do I
tell Guice to scan a package or a class for these annotations? Do I have to
setup my own Guice (servlet-) module or is that taken care of by Magnolia? So
far I have a provider method:
[code]
@Provides
@MembershipDS
public DataSource createDataSource() {
if (this.membershipDS == null) {
String jndiName = MySQLConnector.MEMBERSHIP_DB_JNDI_NAME;
try {
Context ctx = new InitialContext();
synchronized (this.membershipDS) {
if (this.membershipDS == null) {
this.membershipDS = (DataSource) ctx.lookup(jndiName);
}
}
} catch (NamingException e) {
e.printStackTrace();
}
}
return this.membershipDS;
}
[/code]
But when I inject it somewhere, it is null:
[code]
@Inject
@MembershipDS
private DataSource membershipDS;
[/code]
--
Context is everything:
http://forum.magnolia-cms.com/forum/thread.html?threadId=1365c94f-fb89-4d7a-a3a7-61cd4c78e5fc
----------------------------------------------------------------
For list details, see http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------