This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Micro Frontends in Action and have Michael Geers on-line!
See this thread for details.
Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!

Martin Habicht

+ Follow
since Nov 07, 2001
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Martin Habicht

Dear all,

nice surprise to hear a feedback after so long! I'm glad to hear the idea works and is quite simple using filters.

Just because I haven't been posting that frequently doesn't mean I'm dead! ;-)

- Martin
14 years ago
I have a web app with a property file for all language depending strings, which works great! :-)
Now I'd like to allow the super-user to update that file from the browser. As it is currently part of my WAR file, I don't want to change that on the runtime.
Where and how would you save the properties?
- in an exerrnal file (outside of application.war)
- in the DB
- ?!?

17 years ago
Peter, you've got my point!
not that I want to make a second google, but I'm working on a web app... and as we all know they are usually kind of slow. There are certainly a lot to say about optimization and this would fill its own category...
Anwyay, I thought with this idea I could speed up all pages by just adding one more step in the build script. And I see that many or our pages contain about 33% white spaces. So I was wondering, whether the additional overhead for SSL encription, maybe a few IP packages more, their SSL decription and client-side parsing would have a measurable influence on the performance of the web app.
And since google is in general faster than many other pages, I thought this might be part of it. But I'm open too all ideas!
17 years ago
Hi all,
does anyone has experience with removing unnecessary white spaces from a JSP? I thougth of running a little utility tool in my build process, that makes the JSP smaller. Looking at Google's HTML, they seem doing something similar...
Has anyone done this yet? Do you know a neat tool?

PS: for those who really like whitespaces, check out this:
white space programming language
17 years ago
after uploading the exam, a written test is required. What preparation would you recommand for this test? I've been told to take it without any preparation at all - provided one has completed the assignment himself. (which i have )
Is there any list of (dis-)advantages for RMI vs. Sockets, etc.?


How simple can a Server be, as it gives up to 53 points?
I'm asking because so far I have a very simple Server and all he does is to create an instance of a RemoteData object (which extends UnicastRemoteObject and redirects every mehtod call to a single Data instance). Then it puts it on the RMI-registry. Done! Only one command line parameter: the file name. No GUI, no extras.
Do you think such a server would be sufficient?

I agree, that for a nicer design, I would rather put a ConnectionFactory on the RMI-Registry, which would give each client it's own instance of a RemoteData (Data would still be Singleton). This would also allow tracking of Client-ID's for lock() and unlock().

Do I need to make the Server multithreaded explicitely?
Does the Server needs to have multiple threads to be able to accept a new rmi call before a previous hasn't returned because it got blocked?

After writing this, I guess it have to!
So then I could eighter have a thread for each client or better just start a new thread each time a request comes in.

any thoughts?!? thanks in advance...

if you want to program more generic and not depend on the actual column number, you can use findColumn("col name").

see javadoc for details:
to be able to remove locks of a dead client, do I use the following approach or is there something better?
my UnicastRemoteObject (of which every remote client gets its own instance, just as in solution c) implements java.rmi.server.Unreferenced.
if unreferenced() gets called by RMI RE i release all locks by this client. (it's probably not worth to build my own datastructure (like e.g. a linked list) to keep track of locks per client, is it? well, it would be more scalable though...)

- Martin

1) Peter, thanks for the clarification with the 3 possibilities of tracking client ID's. I understand all of them, but now it comes to the problem of choosing ONE.
earlier I thought of choosing simple b), but now that you mention I'd probably loose points, I rather choose c) - which seems to be the most elegant choice. Do you think I'd loose points with solution a) too?
2) do we ever use lock(-1) in our application? and if so where? lock and unlock make sense and criteriaFind is perfectly situated for the origin/destination filter. Or should my local client lock whole db? makes no sense to me...
(i read and understood the posts about a seperate lockfile for local use)
- Martin
hi Farouk and Mark
i'm just working on the architecture of the modules. so I can't provide a well-thought and tested design, but here are my thoughts... (hoping this helps more than it confuses )
In general your design looks very nice. I didn't plan on using so many classes (Design pattern: Keep it Simple ), but yours probably looks nicer.

a) DataBeans: are they really needed? I thought of just useing a FlightTableModel, which holds all record. Not sure yet whether I want to apply a filter (for user selection of origin and dest), so a selection doesen't drops records out of the model or rather implement a simpler aproach of reloading the model from the db evertime a selection is made (using criteriaFind(...)).

b)DataInterface: which Exceptions do you throw? DatabaseException and RemoteException? I also have a DataInterface for local and remote use: it is implemented by Data and RemoteData, which redirects all calls to a Data instance. So it looks pretty much the same as yours.

c) LockManager?!? can't I just implement lock() and unlock() in Data? I guess therefore only one instance needs to be guaranteed - how? Using a Singleton pattern might not work across multiple VM's?

d) Server: you made a GUI-Server? Wow! I used a simple Server class, that basically creates a RemoteData (which holds the Data instance) and put in on the RMI registry. Istn't this enough?

e) .jar files: I also plan two jars (client.jar and server.jar), but use only 3 packages (db is shared).

f) I like the Factory for creating a Connection, but wouldn't it be possible to simply implement 2 methods somewhere on the client side like:
DataInterface getLocalConnection(String db-file-path);
DataInterface getRemoteConnection(String host [,port?] [,path?]);

ok, that's enough for now
- Martin

PS: Farouk, I hope your nice design didn't get screwed with those brut force aproaches...
hi, I've got a question about requirements too:
a) what would you expect to see if criteriaFind("") is called with an empty String? All records, just as an empty SQL WHERE clause?
b) the specs said field names must be matched (<field name>=<value to mach>) and an example is provided ("Carrier='SpeedyAir',Origin='SFO'" ). But the field names contain spaces, like "Origin airport", not just "Origin".
So what do you think would be most appropriate? using the original field name including spaces? only the first part? use my own name for each field? or ???

first of all, thanks for your detailed and knowledgeable replays.
i now understand, that modify() needs to be synchronized. just like all the other data reading/writing methods.

but im my design I use a single instance of Data, which is shared by all clients. (remote and local - there are interfaces and wrapper classes in between, but in the end the single instance of Data will handle all requests). Or just say Data is a Singleton. So in this situation, only one thread can perform an operation (which are now all sync) at a time. All other threads need to wait until they get the monitor on the Data instance.
a) do I need to call wait() and notifyAll() in a loop or doesen't it already works in a way, that thread_2 waits automatically until he can get the monitor?
b) what for do I need locks in this situation? (apart from the sun requirement)


PS: did you specialists knew that synchronize(this){method body} and syncronized method() and has the same effect, but gets compiled to different bytecode? But that's a different issue...
ok, i understand what you mean, but...

if the user calls lock(), modify(), unlock() why does modify() needs to by sync? To make sure local variables won't get screwed?

And if modify(), add() and delete() are synchronized, why do we need locks? We don't have transactions, just atomic operations. So one user enters the synchronized modify() and until the method returns, nobody can call a method of this instance of Data. Or do I miss something?!?

hi all,
let's say I have lock() and unlock() mehtods synchronized (Peter and Mark I completely agree that this is needed). From where do I call them? From modify(), delete() and add()? As of now they are all synchronized themself (acutally on the Data instance, of which I have only one). So if I call lock() and unlock() within the methodbody of modify(), delete() and add(), those 3 don't need to be synchronized and probably shouldn't be. Is this correct?
There are two underlying private methods (readRecord() and writeRecord()), which are also synchronized, but I better keep them sync - for safety?
Well, I usually use locks in DB to isolate transactions, but as far as I see, we only use atomic operations, no transactions, so locks are just a nice thing to make the db extenable for future purpose, right?!?

I appreciate your comment and have a nice weekend :-)
just worked on this yesterday. according to javadoc of the old methods, it uses ASCII encoding. So I just continued using ASCII encoding with the non-deprecated methods. You also need to be aware that UTF-8 uses variable length encoding.
Good luck...