Win a copy of Head First Android this week in the Android forum!

Kenny Johnson

Ranch Hand
+ Follow
since Jan 01, 2007
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Kenny Johnson

A common theme I am seeing for implementing the SCJD assignment is the 3 tier approach:

Layer 1: DB interface ( provided by sun ) and then a Data class which implements these methods. Provides actual I/O to the database.

Layer 2: A business layer of sorts. An abstract class called something like DataBaseService defines read/write/update methods that delegate to the Data class. Then sub classes are created which are tailored to either a local or remote approach. So you would have say, LocalDataBaseService and RemoteDataBaseService. A Factory would be created to return the appropriate implementation in your view layer. The client ( the view code ) would never know if its using the Local or Remote version. It just knows its using a DataBaseService.

Layer 3: The GUI layer. For the SCJD it is in SWING, but could be in HTML or some other GUI technology. The view would use the Factory mentioned in the previous paragraph to instantiate an instance of DataBaseService. The "action listeners" or some other event processor would fire methods in DataBaseService to perform database operations. The DataBaseService could possibly implement Observable, so that GUI clients could implement Observer ( and add the instance of DataBaseService to its observables list ) and update the GUI when notifications are passed along.

is this design considered MVC or some other pattern? It looks like layer 1 could be the model, layer 2 the controller, and layer 3 the view.... or am I mistaken? A friend of mine says this is not MVC. He says all it is is the Adapter pattern ( layer 2 ). He said Layer 1 and 2 are not much different from each other- and are not clear model and controller layers.
I have 3 classes:

1 ( model ). DataBase - this class performs low level read/write/delete operations on some type of database ( specifics not important ). I consider this to be the model layer.

2 ( controller ). I have a Service class. This class implements Observable. It also defines read/write/delete methods which a client will use to interface with the database. It delegates the actual work of these actions to the DataBase class.

3 ( view ). I then have a GUI SWING class. It implements Observer. This class uses an instance of Service to perform database operations and get notified of events. It adds the instance of Service to its Observables collection so that when events in that class take place, the GUI can update accordingly.

I'm wondering if a deign such as this can be considered MVC. This application is just for my own use to learn design patterns.
Thank you for the detailed reply, and although the information is good and may help a new comer I am already aware of the reason for IDs and such. I am simply wondering which classes in my application I should explicitly define an ID for as to adhere to good coding standards.

In my response to Roel, I made the assumption that any GUI classes ( JFrames, JPanels, Buttons, etc etc ) will have the assertion @SuppressWarnings("serial") which 1.) remove annoying compiler warnings, and 2.) indicate to any other developers who might read your code that your most probably NOT ever serializing these classes even though they implement Serializable.

In my SCJD app, I want to provide an explicit serialID value on all the classes which might get serialized due to using RMI as my network technique. I know that my GUI classes are never being shared, so I confidently add @SuppressWarnings("serial") to them as an indication that they will never be serialized ( even though they implement serializable ).


"In every class which implements Serializable (and has the capability to be transported over a network) I explicitly declared a serialVersionUID with a self chosen value (just 1 value for all classes)"

Yes exactly what I was thinking, yet I am still confused on one aspect ( how to tell which object get transported over the network ). Going by the example I gave, would I only give an ID for the class that I bind to my RMI registry, or would any class that has any type of relationship with it ( in my case Tire and OutOfGasException ).

I use the assertion that ignores compiler warnings for serializeable in my GUI classes, since these shouldn't be transported over the network ( and quit frankly don't understand why all SWING classes implement serializable ).

In your project, what critera did you go by to decide on weither to give an explicit ID or not? I'm assuming on all your GUI code you used the assertion to ignore the warnings. Is there a way to tell exactly which items will travel over the network?
When I use RMI, are the only objects passed over the network ( and hence need to have a serialID specified ) the ones that you bind to your RMI registry, or are other classes - like exceptions throw in your binded objects also serialized and passed around?

so say I have a Car class, and I bind it to my registry so others can perform remote method invocation on it. My car class contains tires ( of class Tire ) and it also could possibly throw some custom exceptions ( like say, OutOfGasException ). Should Tire and OutOfGasException have a serialID? Are these objects serialized?

Thanks for any help given!
When I use RMI, are the only objects passed over the network ( and hence need to have a serialID specified ) the ones that you bind to your RMI registry, or are other classes - like exceptions throw in your binded objects also serialized and passed around?

so say I have a Car class, and I bind it to my registry so others can perform remote method invocation on it. My car class contains tires ( of class Tire ) and it also could possibly throw some custom exceptions ( like say, OutOfGasException ). Should Tire and OutOfGasException have a serialID? Are these objects serialized?

Thanks for any help given!
10 years ago
what do you mean they asked a question about the JTable? That sounds kind of odd, since the instructions state you MUST use a JTable. I don't see any alternative.
For the SCJD project, do you need to JavaDoc private fields and methods? It would seem using regular comments makes more sense, since these are private hence they are not to be exposed or known about to clients of the class. A javadoc is supposed to be an API reference so clients can use your code .. or am I getting this all wrong?
So then why do they have you implement these functions in the interface, if they are never used - and how are you to test them if they are never meant to be used. off the top of my head - delete and add are usless.
My instructions state that the GUI only has to do these few things:

------------------------

* It must be composed exclusively with components from the Java Foundation Classes (Swing components).

* It must allow the user to search the data for all records, or for records where the name and/or location fields exactly match values specified by the user.

* It must present search results in a JTable.

* It must allow the user to book a selected record, updating the database file accordingly.

*Your user interface should be designed with the expectation of future functionality enhancements, and it should establish a framework that will support this with minimal disruption to the users when this occurs.

------------------------


The DB interface that I am to implement has update, delete, and add methods - but according to instructions all you have to do is show the records, filter/search threw them, and book a room.

I'm confused, if you have to implement every method in the provided interface, why don't you have to provide these actions in the GUI ( like delete a record, edit a record, change what customer is booked, add a brand new record ). I already have these in my app - will I fail since the instructions said only allow them to search or book a room?
what kind of questions are on the written exam?
Thanks!! This seems to be working so far. I was stumped for the longest time.

NOTE: I had to use the format of file:///

<attribute name="URLs">
deploy/, file:///C:/myfolder/thing.war
</attribute>
10 years ago
Thanks for the reply Peter, but I don't think that will help me 100%. I cannot WAR the contents of the external dir ( it is several GB worth of files which customers download depending on choices and the context of their request. ). My main enterprise app ( deployed as an EAR in server/default/deploy ) contains the web front end and backend logic - the external directory contains all of the stuff customers will want to download ( think of it as a warehouse ).

I kept these separate since I am constantly adding new files or deleting files from the "warehouse" and do not want to redeploy my EAR every time ( would be several times a week if the warehouse was part of the EAR ).

I merely did the experiment where I took /stuff and placed it in a WAR to see if JBOSS would recognize it, and to pinpoint my problem. Is there a way to have JBOSS treat my external directory as a WAR ( like an exploded WAR )? Let me know if you need any more detailed info.
10 years ago
I'm using JBoss 4.2.3 GA

In my server.xml ( located @ jboss-web.deployer ) I added a Context element to my Host so that I can serve files from an external directory structure. It looks like this

<Host name="localhost" etc etc>
<Context docBase="C:\myfolder\stuff" path="\warehouse" />
</Host>


Inside of C:\myfolder\stuff I added a WEB-INF directory, since JBoss now reconizes this as a web deployment of sorts. In WEB-INF I added a web.xml which defines security constraints and roles. I then added a jboss-web.xml inside of WEB-INF, and in this file I define the security-domain.

When I start the server and navigate to this resource, my secuirty policy ( as defined in login-config ) does not execuite. It turns out that JBoss is not reading in my jboss-web.xml file , it only reads the web.xml file.



Now, as an experiment I took the conents of C:\myfolder\stuff and turned it into a WAR. Then I deployed this WAR file into ${JBOSS_DIR}\default\deploy. Low and behold the jboss-web.xml was read, the security domain applied, and the policy defined in my login-config was used.


How do I get my context/external directory to be treated like something in the deploy dir... so that the jboss-web.xml is read and such??? Are there attributes I have to add? I am stumped.
10 years ago
I just purchased the OCMJD ( Oracle SCJD ) and after giving my payment information - was sent to a "test survey" web app which displayed the instruction sheet. It aslo contained a link to download the database file.

Is this all you are supposed to start off with ( the instruction sheet and database file )? I thought it came with a skeleton project or a collection of Interfaces that you need to implement. Any help would be greatly appreciated. Thanks!!!