[jboss-user] [Microcontainer] - Re: Use of JBoss MC Pojo from in distributed env
alesj
do-not-reply at jboss.com
Thu Aug 13 06:39:51 EDT 2009
"manik.surtani at jboss.com" wrote : One way to do this - and this would involve extending or modifying the MC - is to replace whatever backing container the MC uses to store beans it creates (probably a Map) with an Infinispan Cache.
You can easily achieve this with the bean implementing KernelRegistryPlugin.
| public interface KernelRegistryPlugin
| {
| /**
| * Get a registration
| *
| * @param name the name of the object
| * @return the registration
| * @throws IllegalArgumentException for a null name
| */
| KernelRegistryEntry getEntry(Object name);
| }
|
Every such bean becomes part of MC registry,
and as such it's always "asked" if it knows how to provide a bean per name parameter.
e.g. JNDI KRP
| public class JNDIKernelRegistryPlugin implements KernelRegistryPlugin
| {
| private Hashtable<?,?> properties;
| private Context context;
|
| public void setProperties(Hashtable<?,?> properties)
| {
| this.properties = properties;
| }
|
| public void create() throws NamingException
| {
| if (properties != null)
| context = new InitialContext(properties);
| else
| context = new InitialContext();
| }
|
| public void destroy() throws NamingException
| {
| if (context != null)
| context.close();
| context = null;
| }
|
| public KernelRegistryEntry getEntry(Object name)
| {
| try
| {
| Object target = context.lookup(name.toString());
| if (target != null)
| return new AbstractKernelRegistryEntry(name, target);
| }
| catch (NamingException e)
| {
| }
| return null;
| }
| }
|
In Infinispan's case you would simply replace context with cache.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4249373#4249373
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4249373
More information about the jboss-user
mailing list