This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes MVC - Current Service instance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "MVC - Current Service instance" Watch "MVC - Current Service instance" New topic

MVC - Current Service instance

Peter G Walker

Joined: Apr 10, 2005
Posts: 2

I'm wondering if anyone can help me out with my design.

I've implemented an MVC architecture for the client side gui. I'm using RMI to get an instance of a local or remote Services interface that holds the methods book & search.

The controller is registered as a listener of the view and so when a user clicks the book button the controller needs to determine the currently selected row by querying the view and then needs to call the Service book method with the record number as a parameter.

Now i'm just wondering where I should be putting the Services instance so that it can be called by the controller? Should it be:-

1) A static member of some class (MainClass)or
2) Passed into the controller with the model and view or
2) Should the service register with the controller and the controller should fire an event sending the recNum as a parameter in the event?

Any help is much appreciated.
Peter G Walker

Joined: Apr 10, 2005
Posts: 2
Should the model contain the reference to the services instance? I.e should I pass the service to the model constructor?

Most of these will work i'm just wondering if anyone has a better design? since I think SUN is mostly interested in a well designed system.
I agree. Here's the link:
subject: MVC - Current Service instance
It's not a secret anymore!