RE: RE: Event Processing at servlet startup..

Kirk Daries <[email protected]>
Newsgroups gmane.comp.java.enhydra.barracuda.general
Message-ID <D09B591872D1D611AF2B0010B5A1AAD074E39C@WCSMAIL>
Hi Christian,

Thanx for the response. First off. I'm not familiar with the
ObjectRepositoryAssembler class.
I know it's similar to the ApplicationAssembler.. in that it uses a xml file
to load stuff.
Other than that... I'm not too sure how it's being used. 
Something to do with keeping state right?

Let me give you a little background on our environment here at the moment.
In 1 week's time we're going live with our first Barracuda application.
It's taken +- a year to get this baby going and is quite a huge system.
Property managment. Resource management. Finance. Budgeting, etc etc.
Everything running over a VPN/WAN across the western cape(South Africa).

Because of the size of the project... we've had to customize our development
environment to get the most out of Barracuda. Currently.. there are 5
developers
working on the project(includ me). Each has been delegated a subset of the
system...
which we consider to be an application in it's own right. 
So that's 1 system and 9 little applications.

Since each developer is responsible for 1 or more applications, we rely on
the functionality I added
to ApplicationAssembler which allow's multiple processing of the assembler
xml files. 
This way... developers can work in the proverbial little black room and not
have to worry about/have to wait
for other developers. Once we deploy to test/production. The latest source
is obtained from cvs and deployed
to the correct context dir. Upon servlet startup, the application assembler
processes everyone's assembler 
files.

Now.. to get to your question.
We have only one servlet for the entire system. It's generic and know's
nothing about the system.

All it's know's is to load any config files it finds and does the setting
up. 
Database pooling, and what ever it finds. 
Now. 
What I'd like to do... is to be able to set static variables based on
database information.

E.g.
<ACTUAL CODE SNIPPET HERE>
public static int STATUS_NOT_OPEN;
public static int STATUS_BUDGETING_ONLY;
public static int STATUS_BUDGETING_AND_PAYMENTS;
public static int STATUS_POSTING_ONLY;
public static int STATUS_FROZEN;
public static int STATUS_CLOSED;

public static int ACTION_INITIAL;
public static int ACTION_ADJUSTMENT;
public static int ACTION_TRANSFER;


Remember....
These variables are set based on a few database tables and their key values.
Each Application requires this sort of setup.

However, since our servlet know's nothing about any of the applications....
Up till now... I've had to hack it abit.
When the very first user log's in. I check to see if the static variables
are setup.
If not.. I load them. Each application has a Login_listener which is mapped
to the login event.

It's not Ideal as far as I'm concerned. 
That's why I'd like to have some sort of startup event fired which notifies
all applications that
they can now start processing their own initialization.
I hope that makes sense.

>Now Barracuda is capabale of handling this (ie. dispatching to
>events that don't generate a response), but you wouldn't exactly be able to
>reuse the event handlers either. In other words, you're not going to want
to
>try using these handlers to do setup stuff AND actually generate
>responses...it'd just be one or the other.
That's fine. It's just for initialization.

Thanx Christian,
KD

-----Original Message-----
From: Christian Cryder [mailto:[email protected]]
Sent: 16 June 2003 05:37
To: BarracudaMVC
Subject: [Barracuda] RE: Event Processing at servlet startup..


Hi Kirk,

Ok, so I'm just now getting around to responding to this...sorry its taken
me so long!

> Is there a mechanism to fire 'events' during my initializeLocal method
> withing my ApplicationGateway...

Right now, there's not, but we could probably create something if need be.
First, however, I want to better understand exactly what you're trying to
accomplish.

> Here's what I'd like to do.
>
> E.g.
>
> public void initializeLocal() {
>   super.initializeLocal();
>
>   //Startup configuration...
>   .
>   .
>   .
>   //Done Setting up the Servlet
>
>   //Now I'd like to notify all interested event listeners
>   //that the servlet has done starting up.
>
>   //If so.. then go and do their own mini initializations..
>   // database stuff and what not..
>
>   //Pseudo Code Follows here...
>   Have 2 Events and Listeners...specified in my ApplicationAssembler XML
>
>   ServeletStartupComplete.Event and After_StartupComplete.Event which
> extends ServeletStartupComplete.Event
>
>   Get the EventQueue...
>   Add After_StartupComplete.Event to the queue
>   Let Barracuda process the queue and all interested listeners
>   //End Pseudo Code
>
> The idea is that I'd like all interested listeners to listen for
> ServeletStartupComplete.Event.
>
> This way.. when I add the After_StartupComplete.Event..the queue should
> process all the waiting listeners..

So here's a couple of questions. First of all, most events are designed to
generate a response back to the client...you wouldn't be doing that here
(presumably). Now Barracuda is capabale of handling this (ie. dispatching to
events that don't generate a response), but you wouldn't exactly be able to
reuse the event handlers either. In other words, you're not going to want to
try using these handlers to do setup stuff AND actually generate
responses...it'd just be one or the other.

Now, the next question that I have relates to the wisdom of actually doing
this type of thing in event handlers. Typically, event handlers are short
lived, that is, instances are created when they are needed and then
discarded for gc once they're done...you don't typically have event handlers
living beyond the scope of a single req-resp cycle.

So the question arises, why would you actually need to notify them that the
servlet is up and running? I guess this relates to the thing I'm still most
unclear on here...what types of specific things do you actually want to see
configured here?

My gut feeling is that it'd be much easier to be using the
ObjectRepositoryAssembler for this task, but I don't want to jump to
conclusions either. So if you could provide some more specific details here,
I will try to follow up with a more complete response (and I promise to
address it today rather than wait another couple of weeks ;-)

Christian
----------------------------------------------
Christian Cryder
Internet Architect, ATMReports.com
Project Chair, BarracudaMVC - http://barracudamvc.org
----------------------------------------------
"Coffee? I could quit anytime, just not today"


-----Original Message-----
From: Kirk Daries [mailto:[email protected]]
Sent: Tuesday, June 10, 2003 2:29 AM
To: Christian Cryder
Subject: Event Processing at servlet startup..


Hi Christian...

Sorry to bother you..
I know your're extremly busy with your studies and work..

A while back you said you had an idea how I could solve this problem...
Could you point me in the right direction??

Thanx
KD

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Hi Guys,

Quick question.
Is there a mechanism to fire 'events' during my initializeLocal method
withing my ApplicationGateway...

I'm not sure if there is a mechanism already.. or a better way...

Here's what I'd like to do.

E.g.

public void initializeLocal() {
  super.initializeLocal();

  //Startup configuration...
  .
  .
  .
  //Done Setting up the Servlet

  //Now I'd like to notify all interested event listeners
  //that the servlet has done starting up.

  //If so.. then go and do their own mini initializations..
  // database stuff and what not..

  //Pseudo Code Follows here...
  Have 2 Events and Listeners...specified in my ApplicationAssembler XML

  ServeletStartupComplete.Event and After_StartupComplete.Event which
extends ServeletStartupComplete.Event

  Get the EventQueue...
  Add After_StartupComplete.Event to the queue
  Let Barracuda process the queue and all interested listeners
  //End Pseudo Code

The idea is that I'd like all interested listeners to listen for
ServeletStartupComplete.Event.

This way.. when I add the After_StartupComplete.Event..the queue should
process all the waiting listeners..

Regards
KD

_______________________________________________
Barracuda mailing list
[email protected]
http://barracudamvc.org/lists/listinfo/barracuda
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.