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

Re: [xmlblaster] Subscriber getting first message only - big clue!



On Tue, 8 Apr 2003, Michael Atighetchi wrote:

> I like the factory pattern you described. The factory would then be a
> singelton, right ?
+1 for the GlobalFactory

Heinrich

>
> Michael
>
>
> On Tue, Apr 08, 2003 at 09:09:34AM -0500, David Hooker wrote:
> > Global is confusing because it acts like a singleton... but isn't.  I'd
> > suggest that it be made into a factory - make the constructors private
> > and provide static methods to create each connection-specific global.
> > In order to avoid having to pass in the args everytime, have one of the
> > static factory methods take the config parameters and store them as
> > static members.  Have another no-arg factory method which creates a
> > global using those stored values.  I think this is much cleaner.
> >
> > From: Marcel Ruff [mailto:mr at marcelruff.info]
> > Sent: Tuesday, April 08, 2003 2:43 AM
> > To: xmlblaster at server.xmlblaster.org
> > Subject: Re: [xmlblaster] Subscriber getting first message only - big
> > clue!
> >
> >
> > Hi,
> >
> > HelloWorld5.java uses two connections, here
> > the second connection clones a global:
> >
> >    ...
> >    Global globReceiver = glob.getClone(null);
> >    receiver = globReceiver.getXmlBlasterAccess();
> >
> >    ConnectQos qos = new ConnectQos(receiver.getGlobal());
> >    ConnectReturnQos conRetQos = receiver.connect(qos, new I_Callback() {
> >    ...
> >
> > The getClone(String[]) is probably the way to go.
> >
> > The Global is a 'local stack' of execution, the
> > local settings of a client connection (and as well
> > the local settings of an embedded xmlBlaster server).
> > With this approach you can have many independent
> > client connections and embedded servers in the same
> > JVM.
> >
> > We don't use ANY singletons in xmlBlaster (apart from
> > finals) as they are only causing problems.
> > Global can be seen as a connection specific singleton.
> >
> > Since this is now the second time that somebody
> > gets confused about using different global instances
> > for different connections we need to think about
> > the design or a better naming ... any ideas?
> >
> >
> > David Hooker wrote:
> > > Well, if I call "new Global()" more than once, it prints a warning
> > > message to the screen.  So the best thing I see is to do something
> > like
> > > this:
> > >
> > > 	global = new Global(Global.instance());
> >
> > I have set this to deprecated, please use getClone() instead.
> >
> > thanks
> >
> > Marcel
> > >
> > > I hope that's the preferred way to create multiple Globals.  The 3-arg
> > > constructor is very cumbersome.
> >
>
> --
> matighet at bbn.com   BBN Technologies