Discussions

EJB design: EJB Observer Pattern

  1. EJB Observer Pattern (1 messages)

    Hi, I've a problem. I've read the article about EJB Observer Pattern http://www.theserverside.com/tt/articles/article.tss?l=ObserverPattern but unfortunately I didn't understand this piece of code... (Tester.class) f.addObserver (obs); f.setSomething (args[0]); f.notifyObservers (args[1]); What are the 2 args that I must give at statup? Thanks in advance. Franco.

    Threaded Messages (1)

  2. the two args[ Go to top ]

    the first one could be a String Object, public void setSomething (String s) { mSomething = s; setChanged (true); /* We could call notifyObservers right here, but this may or may not be a good thing to do. Each call to notifyObservers will result in a remote method call for every registered observer. If there is more than one attribute to 'set' then it might be better for the caller to set them all and then call notifyObservers explicitly. */ } the secode one an arbitrary Object. public void update (EJBObservable observable, Object arg) { System.out.println ("Hey! I've been updated! " + "observable = " + observable.toString() + " arg = " + arg.toString()); }