File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Need help on design!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Need help on design!!" Watch "Need help on design!!" New topic

Need help on design!!

Muhammad Asif
Ranch Hand

Joined: Jul 13, 2001
Posts: 202
Hi All,
My Name is Muhammad Asif and working on an java solution. I want to discuss the design that i have developed for the Managerial portion of my module.
Basically, on the Manager side i am giving a Java Swing Interface.
Now with every interface i have attached a Mediator/Helper that does some helping work for it and also
communicates with the application handler.
For every screen i have a screen identity.
Then For each action i have an event.
When a certain event occurs, the mediator calls the ApplicationHandler on the client side.
The Application Handler with the help of service locator locates the Controller EJB.
All the data that i am sending to the server side is in hash map.
I have key value pairs.
(This is the first thing that i want to ask. Is this ok ?? because I will also need to store videos in the server side database. Will it be possible to send Videos encapsulated in a HashMap).

The controller EJB has one method that will handle all request from all modules.
The signature is
public DataPacket handleEvent(Event event,Identity identity,DataPacket dataPacket)
Where dataPacket is actually extending HashMap.
Now against this event and identity i make a call to teh database and look for the Action that needs to be generated. Action will basically be a class. For each event their is a corresponding Action Class.
The action class is instantiated and the perform() method is called for the appropriate action class.
in the perform method i am passing DataPacket and the result is also a DataPacket.

Then from the Action Class i call the DAOFactory to give me the Set of DAOs. If i need to use
Oracle Database i'll instantiate OracleDAOFactory else some other for the appropraiate database/
If some one who knows good enough about design tell me weather this design is correct. Or should i make any changes to it.
I am in particular interested in the fact that I am sending a complete DataPacket to the server side.
Which means for Videos i'll need to generate a byte array and send them on to the server side.

( I am not currently Using EJBs extensively and I donot want to use them either {at the moment that is} )
[ October 28, 2002: Message edited by: Muhammad Asif ]

Muhammad Asif
Ranch Hand

Joined: Jul 13, 2001
Posts: 202
Ne Body Home !!!
Kyle Brown
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
Well, yes, everything you send to the server must be serializable... Is that your question? Or is it more a question of layering? Personally, I abhor putting UI controller logic on the EJB side like you've done. It's OK to put domain-style commands on the EJB side, but you've tightly coupled your UI events to your domain commands, which limits the utility of your controller EJB.
Instead, why don't you investigate the Session Facade pattern from the Core J2EE patterns book and see if you couldn't apply that...

Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at for other WebSphere information.
Muhammad Asif
Ranch Hand

Joined: Jul 13, 2001
Posts: 202
Well yes the question was about coupling and the distribution of layers.
As regards coupling i think that the controller will be usable in other applications 2 where the same kind of design is applied.
The reason is that the controller has
merely 7-8 lines of code. All it does it that extracts the actions to perform from the database,
Which afterwards can be transferred to XML documents.
Regarding Session Facade, yes that will be some what useful. I thought of implementing it in the first place but then I thought what will be the function of controller. It will recieve the events and identities from the session bean and just perform the appropriate action. This is very very small responsiblity and i will have to make one extra call (Although it might be within the same container/server) but still one additional call for every action the user is performing ???
Hope u get my point ?
And yes thanx for responding

Still waiting for positive critisim
[ October 28, 2002: Message edited by: Muhammad Asif ]
I agree. Here's the link:
subject: Need help on design!!
It's not a secret anymore!