geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefan Arentz" <stefan.are...@gmail.com>
Subject Re: Adding new deployable module types
Date Sat, 10 Jun 2006 22:39:27 GMT
On 6/11/06, David Jencks <david_jencks@yahoo.com> wrote:
>
> On Jun 10, 2006, at 2:45 PM, Stefan Arentz wrote:
>
> > On 6/10/06, David Jencks <david_jencks@yahoo.com> wrote:
> > ...
> >> > You can also package the resource and application as plugins, so
> >> they
> >> > could be separate but anyone who installed the application plugin
> >> > would automatically get the realm and pool and so on.
> >>
> >> I think the missing piece is making the stuff deployed this way
> >> accessible through spring.  I think the way to to is is with spring
> >> beans that look up the gbeans: then you can use spring injection to
> >> get the e.g. datasource into your spring bean.
> >
> > What would be the advantage of talking to GBeans instead of doing a
> > simple JNDI lookup?
>
> Well,
> - right now jndi is only available in j2ee apps.  Global jndi is
> expected in 1.2, but I think it's a terrible idea :-).  If you really
> want jndi, I'd work on something like the j2ee description of how to
> put stuff in java:comp
> - Why would you consider using jndi when you have a dependency
> injection system available from spring?
>
> Maybe I'm misunderstanding your question, so I'll explain how looking
> up a datasource in jndi works now:
> - we bind a reference into jndi.  It contains the kernel name and
> gbean name for a ManagedConnectionFactoryWrapper gbean
> - when you look up the reference, to resolve what it points to, it
> finds the gbean in the kernel and calls a method, $getResource, which
> returns (a proxy to) the connection factory.  We return the
> connection factory as the lookup result.
>
> IIUC Spring has a way of injecting the result of calling a method on
> a spring bean as a constructor or setter parameter.  I'm thinking
> that we should have in this case a spring bean that has a method that
> delegates to the $getResource method, so you can use spring to inject
> the datasource that is set up in geronimo.

You are right of course. For Spring it doesn't matter where it gets
the connection factory.

It would simply look something like this:

<bean id="simple" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="jdbc/MyDataSource"/>
</bean>

vs

<bean id="simple" class="org.springframework.geronimo.GBeanObjectFactoryBean">
    <property name="gbeanName"
value="geronimo.server:J2EEApplication=null,J2EEServer=geronimo,JCAResource=org/apache/geronimo/SystemDatabase,j2eeType=JCAManagedConnectionFactory,name=SystemDatasource"/>
</bean>

(I googled for 'geronimo jdbc gbean name' ... not sure how that would
really look, hopefully not that long :-)

Another option would be to create a GeronimoApplicationContext that
can lookup a bean in both the spring context and Geronimo's GBean
'registry' (not sure what to call it).

Then you can simply reference the GBean directly and  do something like this:

<bean id="someBean" class="foo.SomeBean">
  <property name="dataSource"
ref="geronimo.server:J2EEApplication=null,J2EEServer=geronimo,JCAResource=org/apache/geronimo/SystemDatabase,j2eeType=JCAManagedConnectionFactory,name=SystemDatasource"/>
</bean>

 S.

Mime
View raw message