Richard Yip

Greenhorn
+ Follow
since Nov 24, 2002
Merit badge: grant badges
For More
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 Richard Yip

Mike,
Thanks! It works! What a killer. I was stuck with this for the last three days. And it turn out to be something so simple.
Now I can concentrate on finishing up. Need to do some more testing before cleaning up the code and writing design docs for the upload by next week.
Intend to take the exams end of next week.
Richard
Hello Ranchers,
I got problems in running my client jar file and hence the title.
Although I looked through all the previous threads regarding the stub and the client jar file, I am still unable to solve it.
Here's my output when run my client jar.

C:\scjd\dist\client>java -jar client.jar localhost 1099 db.db
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: suncertify.server.RemoteDataServer_Stu
b (no security manager: RMI class loader disabled)
Exception in thread "main" java.lang.NullPointerException
at suncertify.client.DataAccess.readData(DataAccess.java:139)
at suncertify.client.DataAccess.<init>(DataAccess.java:82)
at suncertify.client.Client.<init>(Client.java:32)
at suncertify.client.Client.main(Client.java:62)

I did not apply any security manager or codebase.
I have added the main class in the manifest file of the client jar.
Manifest-Version: 1.0
Created-By: Apache Ant 1.5.1
Built-By: richard yip
Main-Class: suncertify.client.Client
I have three packages.
suncertify.db
suncertift.client
suncertify.server
I generate the stubs and skeletons within the server package and copied the stub to the client package.
For the cient jar, I pack the client and db together. For server jar, I pack the server and db together.
I put the common interface files in db since both server and client package access it.
Just confirm that it didn't even work when I unjared it.
This is my code which I used to access the registry.
private RemoteDataService remoteData;
Registry remoteRegistry = LocateRegistry.getRegistry(host, portNumber);
remoteData = (RemoteDataService)remoteRegistry.lookup(RemoteDataService.SERVICENAME);
RemoteDataService is the remote interface.
I have tested both the client and server together in my coding environment before jarring the packages.
Need help in solving this. Any ideas?
Richard
Hello Victor,
I have the same problem. Been reading through the old threads and hacking through my server code.
Here's how I did.
public class RemoteDataService extends UnicastRemoteObject implements RemoteData {
private Data data;
private LockedRecords lockedRecords = new LockedRecords();

/**
* Constructor for the RemoteDataService object
*
* @param dbName Description of the Parameter
* @exception RemoteException Description of the Exception
*/
public RemoteDataService(String dbName) throws RemoteException {
try {
data = new Data(getFile(dbName).toString());
}
catch (IOException e) {
System.out.println(e);
}
}

/**
* Gets the file attribute of the RemoteDataService object
*
* @param filename Description of the Parameter
* @return The file value
* @exception IOException Description of the Exception
*/
private File getFile(String filename) throws IOException {
//create the fullpathname of the database file
String userDir = System.getProperty("user.dir");
String fileSeperator = System.getProperty("file.separator");
String dbName = userDir + fileSeperator + filename;
File file = new File(dbName);
return file;
}
I didn't use the getResource method. Instead, I try to get the full pathname of the file and create a File object to access the database file.
The only restriction is that both my server.jar and db.db has to be in the same directory when I run the server.
maybe if I set my classpath before starting the server....

Richard
Hello Guys,
I agree with most of the statements above. However I like to point out what FlightTableModel extends AbstractTableModel actually does.
The FlightTableModel provides information(data) for the views; i.e. JTable for display. The data is this case is dataInfo like this.
public FlightTableModel(ArrayList newDataInfoList) {
This works fine if you don't need any edits/updates.
You can provide ways to edit/update by adding/removing listeners directly the model itself or through some actionListener on the JTable.
I use the second approach. I have created popupmenu that shows a list of task that I can do when clicking on the JTable.
I have a method for any client program to update flight data within the model. It is something like this.
protected void flightChanged(DataInfo dataInfo, int numberOfSeats)
By using this approach, I was able to reuse the model.
Richard
Hello,
I am using JEdit now. It's quick and simple to use, just like emacs. It is quite easy to configure the JEdit environment.
I am taking my SCJD certification now and using JEdit. I have configure the ANT plugin and run my test all the time. The other good time is the XML plugin/editor which is quite good for editing; i.e. build.xml for example.
Richard
Hello Bern,
Got it working! Thanks. Here's my rmic stuff.
<target name="rmic" depends="compile"
description="Generate stubs and skeletons for the server">
<rmic base="${build.classes.dir}"
classpath="test.complie.classpath"
classname="suncertify.server.RemoteData">
</rmic>
</target>

Richard
Hello Bernhard,
I got some problems in configuring my build file for rmic to generate the stubs and skeletons from my server class.
I got the packages suncertify/db, suncertify/server and suncertify/client.
Here's what I did in my build.xml.
<target name="rmic" depends="compile"
description="Generate stubs and skeletons for the server">
<rmic classname="RemoteData" base="${build.class.dir}/suncertify/server/ /">
<classpath refid="test.compile.classpath"/>
</rmic>
</target>
The build.class.dir refers to my build dir which is from
<property name="build.dir" location="${basedir}/build" />
<property name="build.classes.dir" location="${build.dir}/classes" />
and my test.compile.classpath refers to
<path id="test.compile.classpath">
<!--path to testing libraries needed-->
<pathelement location="${junit.jar}" />
<pathelement location="${ant.optional.jar}" />
<!--path of complied source code needed-->
<pathelement location="${build.classes.dir}" />
</path>
and RemoteData is
public class RemoteData extends UnicastRemoteObject implements RemoteDataInterface {
and RemoteDataInterface is from the interface DataInterface that has all the common public methods of Data.
public interface RemoteDataInterface extends DataInterface {

Need your help in cracking this build.xml.
Thanks.

Richard
Hello,
I have made some changes in my algorithm, code and tested the criteria find. It is working fine. Here's my updated algorithm for criteriaFind.
Duplicated fields and its value in the criteria string will be ignored during parsing of the criteria string.
Invalid fields and its value will be ignored during parsing of the criteria string.

Parse Algorithm
0. Set boolean isKey to false. Create key and value Strings. Create searchCriteria using a HashMap.
1. Create a tokenizer st1 using the criteria string and strip all quotations; i.e.both double and single and commas.
2. Iterate the tokenizer st1.
3. Create a tokenizer st2 using each token of tokenizer st1 and strip all "=".
4. Iterate the tokenizer st2.
5. If token is a valid Field, assign token to key and set isKey to true.
6. If token is not a valid Field, do task 7 to 9
7. If isKey is true, assign token to value.
8. If searchCriteria does not contain key, put the key/value pair into searchCriteria.
9. Set isKey to false;
10. End Iterator for the tokenizer st2.
11. End Iterator for the tokenizer st1.

Search Algorithm
0. Create a dataInfoList using an ArrayList, Get the searchCriteria.
1. Iterate the list of records.
2. Skip deleted records.
3. Get the number count of criteria that the record must fullfilled before it is considered a match from searchCriteria.
4. Iterate the record's fields.
5. If searchCriteria.containsKey(record's field), do task 6 to 8.
6. Get the matching field's value from the searchCriteria.
7. If the two value matches, decrement number count; i.e. one criteria is fullfilled.
8. If number count is zero, add record to dataInfoLIst; i.e. all criteria fullfilled, record found.
9. End Iterator for the record's fields.
10. End Iterator for the list of records.

Thanks Peter for the great help in streamlining my algos.

Richard
Peter,
Thanks for the quick reply. Your analysis on the algos has broaden my understanding of the find tasks. It is definately much more simple and elegant than my existing algos.
I will take into consideration of your recommendations when I rehash my algos.
Thanks Peter.

Richard
Hello,
I have just started working on the criteriaFind task and this thread helps me understand the task better.
From all the ideas gathered, I have decided break the functionality of criteriaFind into two task.
The first task is the parsing algorithm which breaksdown the criteria string into a search critera object.
The second task is the searching algorithm. This uses the search criteria object in searching the records.
Here the details of the two algorithm.
My assumption for the criteraString is that it has no duplicate field.

Parse Algorithm
1. Iterate the criteria string character by character.
2. At each field token, iterate the fieldInfo schema.
3. If match, create a map with the field token as the key and break the fieldInfo iteration.
4. Get the next token (i.e. value token).
5. put value token into the map.
6. put the map into a vector.
Search Algorithm
1. Iterate the list of records.
2. At each record, create a copy of the parsed vector. Each record will make changes to this copy.
3. Iterate the list of record fields.
4. At each record field,
5. Iterate the parsed vector.
6. Compare the record field with parsed vector field.
7. If the field matches, compare the values.
8. If the values matches, delete the matching field/value pair in the copy of the parsed vector. This will indicate that one search criteria is successful.
9. Check if parse vector is empty. If empty (i.e. all search criteria is successful, positive record found), add record to record list.
10. Break out of record.

This is a genric find that is capable of searching any field/value combination of records.
I will be implementing the two algo soon. Any comments from you guys?

Richard
Hello,
I have just started the assignment about a month ago. I have learnt quite a lot from the previous threads posted.
I have setup my ant/junit environment and have created some tests for my lock/unlock tasks.
I have followed some of the previous threads idea of creating a bookFlight(int recordNumber, int numberOfSeats) method within a DataServer class that handles all the clients' requests for Data services.
Although each single bookFlight transaction works, my unittest that contains multiple concurrent clients calling the DataServer still have some problems. Any suggestions?
Meanwhile, I have started looking into the criteriaFind task.
I have a source tree that contains my source code and build tree which hold my compiled classes. My test code are in the same package as my source code.
I have a TestCase class that reads the db.db file for me to run my tests.
Just want to say that the ant/junit really speeds up coding/testing although it is a pain to setup initially. Took me a week as I am a ant greenhorn.
Richard