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

Re: [xmlblaster-devel] LOCAL not working?



Meetings all day yesterday, but now I have something that works; but as
far as I understand it not designed exactly the way your stuff seems to
be heading.

Here's the deal:

You must use a Global which contains the serverside engine global in its
ObjectEntry "ServerNodeScope". The cloning process for each
XmlBlasterAccess instance must therefore include ServerNodeScope.

The LocalConnections is simple: look up the engine.Global, get the stuff
you need from it and just delegate.

LocalCallbackImpl must also have access to the engine.Global. There it
simply adds itself as an ObjectEntry with its raw adress as key. It
implements a new interface ServerNodeScope wich the serverside callback
expect to find in the ObjectEntry.

Here are some snippets from LocalCallbackImpl:

   public synchronized final void initialize(Global glob, String
loginName,
                            CallbackAddress callbackAddress,
I_CallbackExtended cbClient) throws XmlBlasterException {
      this.glob = (glob == null) ? Global.instance() : glob;
      this.log = this.glob.getLog("local");
      this.ME = "LocalCallbackImpl-" + loginName;
      this.callbackId = "LOCAL:"+this.hashCode();
      this.cbClient = cbClient;
      
      // Set this object an the engine.Global so that the server cb
handler
      // can find it.
      engineGlob =
(org.xmlBlaster.engine.Global)glob.getObjectEntry("ServerNodeScope");
      if (engineGlob == null)
         throw new XmlBlasterException(this.glob,
ErrorCode.INTERNAL_UNKNOWN, ME + ".init", "could not retreive the
ServerNodeScope. Am I really on the server side ?");
      
      // Ad the driver to the "naming" store.
      engineGlob.addObjectEntry(callbackId,this);

   }

   public String getCbAddress() throws XmlBlasterException {
      return callbackId;
   }

   public String[] update(String cbSessionId, MsgUnitRaw[] msgUnitArr)
throws XmlBlasterException
   {
      if (msgUnitArr == null) throw new XmlBlasterException(ME,
"Received update of null message");
      if (log.CALL) log.call(ME, "Entering update(" + cbSessionId + ")
of " + msgUnitArr.length + " messages");
      
      return cbClient.update(cbSessionId, msgUnitArr);
   }

The serverside part is CallbackLocalDriver. Its job is to lookup the
client part in the ObjectEntry and just delegate to it.

   public final void init(Global glob, CallbackAddress callbackAddress)
throws XmlBlasterException {
      this.glob = glob;
      this.log = glob.getLog("local");
      this.callbackAddress = callbackAddress;
      String callbackId = callbackAddress.getRawAddress();
      try {
         localCallback  = ( I_LocalCallback
)glob.getObjectEntry(callbackId);

         if ( localCallback == null) {
            throw new XmlBlasterException(this.glob,
ErrorCode.INTERNAL_UNKNOWN, ME + ".init", "could not retreive the
LocalCallbackImpl, was there really one started");
         } // end of if ()
         
      }
      catch (Throwable e) {
         log.error(ME, "The given callback id ='" + callbackId + "' is
invalid: " + e.toString());
         throw new XmlBlasterException(glob,
ErrorCode.RESOURCE_CONFIGURATION_ADDRESS, "Local-CallbackHandleInvalid",
"The given callback Id is invalid: " + e.toString());
      }
   }

   public final String[] sendUpdate(MsgUnitRaw[] msgArr) throws
XmlBlasterException
   {
      if (msgArr == null || msgArr.length < 1)
         throw new XmlBlasterException(glob,
ErrorCode.INTERNAL_ILLEGALARGUMENT, ME, "Illegal sendUpdate()
argument");
      if (log.TRACE) log.trace(ME, "xmlBlaster.update() to " +
callbackAddress.getSecretSessionId());
      
      try {
         return
localCallback.update(callbackAddress.getSecretSessionId(), msgArr);
      } catch (XmlBlasterException xmlBlasterException) {
         
         // WE ONLY ACCEPT ErrorCode.USER... FROM CLIENTS !
         if (xmlBlasterException.isUser())
            throw xmlBlasterException;
         
         throw new XmlBlasterException(glob,
ErrorCode.USER_UPDATE_ERROR, ME,
                   "Local Callback of " + msgArr.length +
                                       " messages to client [" +
callbackAddress.getSecretSessionId() + "] failed.",
xmlBlasterException);
      }
   }

What do you say about this?

//Peter

On Mon, 2003-09-15 at 23:58, Marcel Ruff wrote:
> Michele Laghi wrote:
> > Hi Peter,
> > you'r right. The implementation of the native access has not been 
> > completed yet.
> 
> I have started on it but hadn't time to finish it.
> There are probably one/two days open
> for finishing implementation, adding testsuite and docu and a little demo client.
> If you do it its fine, otherwise one day i will complete it.
> The native access is to be seen in conjunction with the
> runlevel manager to load the native client, see
> http://www.xmlBlaster.org/xmlBlaster/doc/requirements/engine.runlevel.howto.html
> 
> regards
> 
> Marcel
> 
> PS: The Euro wasn't introduced in Sweden, so my
> Kroner lying around somewhere won't be valueless :-)
> > 
> > Michele
> > 
> > 
> > Peter Antman wrote:
> > 
> >> Hi,
> >> am I right if I have found that client.protocol.local is not working, or
> >> should it be able to get it to work (yes, I do have access to
> >> engine.Global), but I am getting exceptions on the server callback part
> >> (and looking into the code I get the impression that something is
> >> missing).
> >>
> >> //Peter
> > 
> > 
> > 
> 
> 
> -- 
> http://www.xmlBlaster.org
-- 
------------------------------------------------------------
Peter Antman	Chief Technology Officer, Development
Technology in Media, Box 34105 100 26 Stockholm
WWW: http://www.tim.se	WWW: http://www.backsource.org
Email: pra at tim.se	 
Phone: +46-(0)8-506 381 11 Mobile: +46-(0)704 20 58 11
------------------------------------------------------------