[jboss-dev-forums] [Design of POJO Server] - Re: ENC Deployment

adrian@jboss.org do-not-reply at jboss.com
Mon Sep 18 06:21:46 EDT 2006


Which leaves the final piece of the puzzle.

When the ENCFactory is constructed it could have dependencies like:


  | <bean name="ENCFactory.MyEJB">
  |    <property name="beans">
  |       <map>
  |           <key>jdbc/DataSource</key>
  |           <value><inject bean="SomeDataSource"/></value>
  | etc.
  | 

The SomeDataSource will come from the annotations.

But what if it is just a jndi binding?


  | <bean name="ENCFactory.MyEJB">
  |    <property name="bindngs">
  |       <map>
  |           <key>jdbc/DataSource</key>
  |           <value>java:/MyDataSource</value>
  | 

The way to solve this is to remove the jndi binding from the services
themselves, so we can create a "registry" of bindings.
(This also means services don't need to know the jndi population
mechanism as well).

Using a use case configuration:

  | <bean name="SomeDataSource">
  |    <property name="JNDIBinding">
  |        <jndibinding xmlns="urn:jboss:naming:1.0" binding="java:/MyDataSource" bean="SomeDataSoure"/>        
  | etc.
  | 

The jndibinding creates a bean that has a contract like:

  | public interface JNDIBinding
  | {
  |    public void setObject(Object object);
  | }
  | 

When setObject is invoked with a value, the binding
is added to jndi when it is null it is removed.

It also gives a bean to depend upon for the "bindings" above.
e.g. the use case config would really be something like:

  | <bean name="java:/MyDataSource" whenRequired="constructed">
  |    <factory><inject bean="JNDIBindingFactory"/></factory>
  |    <depends>SomeDataSource</depends>
  | </bean>
  | 

i.e. The binding is injected into once it is constructed,
but it doesn't "start" (bind into jndi) until the bean itself is installed.
What it binds is determined by the setObject().

Obviously there are additional complications/configuration options
for when:
1) The object is not serializable/referencable
2) The "bindings" above reference an external jndi and so
cannot form a real dependency
etc.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3972244#3972244

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3972244



More information about the jboss-dev-forums mailing list