[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [xmlblaster-devel] LOCAL not working?



Peter Antman wrote:
Hi again,
I have also done some changes to the JXM/Embedded/JBoss service, which
makes it possible for clients running in the same JBoss/JMX server to
get access to the serverside engine global, and as an effect of that is
able to use the LOCAL in vm protocol.

Yep.


This is done through JNDI.

The embedded service creates a utility class (GlobalUtil) which holds
the engine global:

      if ( jndiName != null) {
         bind( blaster.getMain().getGlobal() );
      } // end of if ()

private void bind(org.xmlBlaster.engine.Global engineGlobal) throws
Exception{
if ( jndiName == null) {
return;
} // end of if ()
// Do we have JNDI at all?
Context ctx = null;
try {
ctx = new InitialContext();
} catch (NamingException e) {
throw new IllegalStateException("No NamingContext available,
trying to run with a jndiName in a server withouth jndi is not valid:
"+e);
} // end of try-catch
GlobalUtil gu = new GlobalUtil(engineGlobal);
bind(ctx,jndiName,gu);


   }

The GlobalUtil holds the engine.Global as a transient variable, which
means that if its not serialized (looked up in the same VM) it will be
accessable by the client doing the lookup. The client then uses the
GlobalUtil to hanlde its global creation and cloning, so that
engine.Global will be put in its objectEntry:

   public Global newGlobal(String propertyFileName, Properties args)
throws IllegalStateException {
      Global glob = new Global(new String[]{},false,false);
      Global clone = getClone(glob);
      addEngineProperties(clone);
      addServerProperties(clone);
      loadPropertyFile(clone,propertyFileName);
      addArguments(clone,args);
      return clone;
   }

public Global getClone(Global global) {
Global g = global.getClone(null);
Object engine = global.getObjectEntry("ServerNodeScope");
Object eg = engine != null ? engine : engineGlobal;
if ( eg != null) {
g.addObjectEntry("ServerNodeScope", eg);
} // end of if ()
// Should we perhaps also clone POA???


      return g;
   }

Here's how for example the JCA adapter uses this:

      globalUtil = new GlobalUtil();
      if ( jndiName != null) {
         try {
            globalUtil = (GlobalUtil)new
InitialContext().lookup(jndiName);
         } catch (NamingException e) {
            throw new IllegalStateException("Could not lookup GlobalUtil
with JNDI " + jndiName + ": "+e);
         } // end of try-catch
      } // end of if ()

      glob = globalUtil.newGlobal( propFile,
glob.getProperty().getProperties() );

This means that if a JNDI name is specified and the lookup is done in
the same VM as the process that bound the GlobalUtil into jndi, the
global the JCA adapter uses will be able to use a LOCAL protocol to
access the server.

Any complaints about this design?

Cool! Exactly what we need. Is there a way to implement an automatic testsuite to check all this? This way all developers are forced to look at issues if this framework fails in future xmlBlaster versions. I think its the only way to keep this framework alive over all versions in future.

regards

Marcel

//Peter



--
http://www.xmlBlaster.org