[jboss-dev] Dependencies to JBoss as core libs

Adrian abrock at redhat.com
Wed Jun 27 10:03:22 EDT 2007


By the way, I'm not suggesting you should really implement it the
way I described below. It is too simplistic.

e.g. Problems:
1) You can't subclass the bridge for other reasons
2) You can't mix jndi sources with non jndi destinations

i.e. it lacks "aspectization", really it is a problem
of abstraction.

Better would be to make a class in jboss-integration say

public interface JMSConfiguration
{
   ConnectionFactory getConnectionFactory();
   XAConnectionFactory getXAConnectionFactory();
   Destination getDestination();
}

that can be implemented in all sorts of different ways
(including using the JNDIProvider) then inject
that into the bridge

public class Bridge
{
   setSource(JMSConfiguration source);
   setTarget(JMSConfiguration target);
}

On Wed, 2007-06-27 at 15:51 +0200, Adrian wrote:
> On Wed, 2007-06-27 at 14:01 +0100, Tim Fox wrote:
> > The JBoss Messaging Bridge MBean has dependencies on JMSProviderLoader 
> > since it uses these to connect to its source and target destinations.
> > 
> > Are you suggesting we move the Bridge MBean into the AS project?
> 
> No, I'm suggesting you think about providing a clean api
> which can be used by the AS to integrate with its configuration
> mechanisms.
> 
> Trying to do integration in your project just leads
> to JBAS-1796 style problems and bad api!
> 
> IOC 101
> 
> Why doesn't the bridge just take connection factories
> and destinations as injections (javabean setters)?
> That is a trivial "no dependency required"
> configuration api.
> 
> public SimpleBridge
> {
>    setSourceConnectionFactory(XAConnectionFactory cf) {};
>    setTargetConnectionFactory(XAConnectionFactory cf) {};
>    setSourceDestination(Destination destination) {};
>    setTargetDestination(Destination destination) {};
> 
>    ...
> }
> 
> ANY FORM OF INTEGRATION IS NOW EASY
> 
> For standalone ease of use, you could subclass the simple bridge
> with a version that does something like (psuedo code):
> 
> public JNDIBridge extends SimpleBridge
> {
> 
>    public void setTargetDestinationJndiName(String targetJNDI) {}
> 
>    public void setJNDITargetProperties(Properties targetProperties) { }
> 
>    // Create lifecycle that does base setters from jndi configuration
>    public void create() throws Exception
>    {
>       if (targetJNDI == null)
>          throw new IllegalStateException("Target jndi name not set!");
> 
>       InitialContext context;
>       if (targetProperties == null)
>          context = new InitialContext();
>       else
>          context = new InitialContext(targetProperties);
>       try
>       {
>           Destination d = (Destination) context.lookup(targetJNDI);
>           setTargetDestination(d);
> 
>           etc....
>       }
>       finally
>       {
>          context.close();
>       }
> 
>    }
> }
> 
> Which is basically what the JMSProvider really does anyway!
> 
> JBOSS INTEGRATION IS ALSO TRIVIAL
> 
> In the appserver we could have a JNDIProvider based version
> to integrate with the current way of configuring jms servers
> in one place.
> 
> public JNDIProviderBridge extends SimpleBridge
> {
>    public void setSourceJNDIProviderName(String jndiName) {}
>    public void setTargetJNDIProviderName(String jndiName) {}
>    public void setSourceDestination(String jndiName) {}
>    public void setTargetDestination(String jndiName) {}
> 
>    etc....
> }
> 
-- 
xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Adrian Brock
Chief Scientist
JBoss, a division of Red Hat
xxxxxxxxxxxxxxxxxxxxxxxxxxxx




More information about the jboss-development mailing list