SPRNET-1390 - Allow for dependency injection on object returned from TIBCO EMS's JndiLookupFactoryObject

This commit is contained in:
markpollack
2010-11-16 16:41:52 +00:00
parent bf51d96ec6
commit 32aa99ff87
3 changed files with 30 additions and 12 deletions

View File

@@ -224,7 +224,7 @@
application context the class <classname>JndiFactoryObject</classname>
is used. This allows you look configure the location of the JNDI
registry and to retrieve objects by name. The objects are retrieved from
JNDI at application startup. </para>
JNDI at application startup.</para>
<para>These retrieved objetcts from JNDI in turn can be dependency
injected into other collaborating objects such as Spring's
@@ -237,11 +237,16 @@
&lt;property name="JndiProperties[LookupContext.PROVIDER_URL]" value="tibjmsnaming://localhost:7222"/&gt;
&lt;/object&gt;</programlisting>
<para>JndiLookupFactory object implements the IFactoryObject interface,
so the type that is associated with the name 'jndiConnectionFactory' is
not JndiLookupFactoryObject, but the type returned from this factory's
'GetType' method, in this case the type of what was retrieved from
JNDI.</para>
<para>JndiLookupFactory object implements the
<interfacename>IConfigurableFactoryObject</interfacename> interface, so
the type that is associated with the name 'jndiConnectionFactory' is not
JndiLookupFactoryObject, but the type returned from this factory's
'GetType' method, in this case the type of what was retrieved from JNDI.
The <interfacename>IConfigurableFactoryObject</interfacename> interface
also allows for the object that was returned to be dependency injected.
Please refer to the documentation on
<interfacename>IConfigurableFactoryObject</interfacename> for more
information.</para>
<note>
<para>The dictionary JndiProperties is set using Spring Expression
@@ -253,7 +258,7 @@
<para>The use of this object retrieved from JNDI to configure Spring's
CachingConnectionFactory set the property TargetConnectionFactory as
shown below </para>
shown below</para>
<programlisting language="myxml"> &lt;object id="cachingJndiConnectionFactory" type="Spring.Messaging.Ems.Connections.CachingConnectionFactory, Spring.Messaging.Ems"&gt;
&lt;property name="SessionCacheSize" value="10" /&gt;
@@ -329,7 +334,7 @@
<para>Spring's MessageListenerContainer's are used to process messages
asynchronously and concurrently. MessageListenerContainers are described
more in <link linkend="activemq-listener-containers">this</link>
section. </para>
section.</para>
</section>
<section>
@@ -352,7 +357,7 @@
linkend="activemq-sending-messages">section</link> aside from the use of
type destination type TIBCO.EMS.Destination instead of
Apache.NMS.IDestination and switching of the namespace from Apache.NMS
to Spring.Messaging.Ems.Common. </para>
to Spring.Messaging.Ems.Common.</para>
<para>Shown below is the code example for a SimplePublisher using
Spring's TIBCO EMS classes. This does now show the 'one-liner' send
@@ -482,7 +487,7 @@ namespace Spring.Messaging.Ems.Core
</section>
<section xml:id="ems-async">
<title>Asynchronous Reception </title>
<title>Asynchronous Reception</title>
<para>Please refer to <link linkend="???"
xml:id="activemq-async-reception">this</link> section for an

View File

@@ -21,13 +21,14 @@
using System;
using Spring.Core.TypeResolution;
using Spring.Objects.Factory;
using Spring.Objects.Factory.Config;
using Spring.Util;
using TIBCO.EMS;
using Common.Logging;
namespace Spring.Messaging.Ems.Jndi
{
public class JndiLookupFactoryObject : JndiObjectLocator, IFactoryObject
public class JndiLookupFactoryObject : JndiObjectLocator, IConfigurableFactoryObject
{
static JndiLookupFactoryObject()
{
@@ -37,6 +38,7 @@ namespace Spring.Messaging.Ems.Jndi
private object defaultObject;
private Object jndiObject;
private IObjectDefinition productTemplate;
public JndiLookupFactoryObject()
{
@@ -143,5 +145,16 @@ namespace Spring.Messaging.Ems.Jndi
throw;
}
}
/// <summary>
/// Gets the template object definition that should be used
/// to configure the instance of the object managed by this factory.
/// </summary>
/// <value></value>
public IObjectDefinition ProductTemplate
{
get { return productTemplate; }
set { productTemplate = value; }
}
}
}

View File

@@ -40,7 +40,7 @@ namespace Spring.Messaging.Ems.Jndi
/// </remarks>
/// <author>Juergen Hoeller</author>
/// <author>Mark Pollack (.NET)</author>
public abstract class JndiObjectLocator : JndiLocatorSupport, IInitializingObject
public abstract class JndiObjectLocator : JndiLocatorSupport
{
private string jndiName;