|
From: Les A. H. <le...@ha...> - 2004-06-30 13:25:46
|
Hi folks,
I'm working (meddling?) with the sandbox JMS code with Mark and I have a
question about JNDI lookups.
I'm creating a JmsTemplate class that allows one to specify a ConnectionFactory
jndi name and a Destination jndi name, both of which are needed to send and
receive messages in JMS.
They are both resources that are usually requested from JNDI as two different
lookups.
Now, I am making a JmsAccessor class (following the lead of HibernateAccessor
--> HibernateTemplate pattern) that handles acquiring those two objects. I
wanted to subclass AbstractJndiLocator so I could utilize the resourceRef and
JndiTemplate support already there, but AbstractJndiLocator expects only one
object to be located.
Would it be prudent to create a superclass of AbstractJndiLocator called
AbstractJndiAccessor that provides everything except specifying a jndiName and
doing a singular lookup? Then subclasses could do as many lookups as they
require during their afterPropertiesSet() methods. AbstractJndiLocator would
still do its singular lookup, but other subclasses could do more than one...
Or maybe I'm off base architecturally? Maybe my JmsAccessor should use OO
delegation and use two concrete instances of AbstractJndiLocator to do the two
separate lookups?
I like the first approach better since the second involves extraneous code
(methods in turn call identical delegate methods for setting JndiTemplate,
resourceRef, etc). Also my OO philosophy is that more specific (limiting)
features of a class exist lower in the hierarchy. I consider a single lookup a
limiting feature than what could exist in a superclass.
At the end of the day, I would like something as simple as:
JmsTemplate jmsTemplate =
new JmsTemplate(connectionFactoryName, destinationName);
jmsTemplate.send(Object payload, Map messageProperties);
I don't know...maybe its too early to be thinking about this stuff yet? ;)
Thoughts?
Regards,
Les
|