Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: RemoteDBAccess

 
Ulrich Heeger
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
I have a question concerning my RMI implementation and its use at the client side. For local connection I use DBAccess interface (I will have the fat client solution) and for the networking connection I use the RemoteDBAccess interface (containing exactly the same methods like DBAccess, excepting the RemoteExceptions)
RemoteDBAccess and DBAccess don't share an interface, RemoteDBAccessImpl wraps Data.
But of course at the client side I don't want to contact my connection with different object references. The only valuable object reference would be the Object itself:
Object o = RoomConnector.getRemote(String ip);
Object o = RoomConnector.getLocal();
But that wouldn't be an elegant solution, I think. Perhaps you guys had similar problems and you know a better solution?
Thanks in advance & greetings
Ulrich
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulrich,
Have you considered making RemoteDBAccess extending DBAccess
Regards, Andrew
 
Vlad Rabkin
Ranch Hand
Posts: 555
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulrich,
I had the same problem.
I have a ClientAdapter class on the client. It implements DBAccess.
Its Constructor takes DBRemoteAccess object as a paramaterer.
ClientAdapter just wraps DBRemoteAccess.
So, my client works only with DBAccess(For remote mode it works with ClientAdapter, which implements DBAccess).
Ex:

Best,
Vlad
P.S. See you soon in Carnaval in Cologne
 
Ulrich Heeger
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andrew, hi Vlad,
thank you very much for your rapide response.
Andrew, I can't extend DBAccess because its methods don't throw IOExceptions, but the methods of RemoteDBAccess of course throw RemoteException.
Hi Vlad, this is an elegant solution, I think I will go this way
Let us really celebrate together Carneval, Andrew you have also to come to Cologne, so we can drink K�lsch, Cascades and (what's you favorite beer, Vlad?) together and hopefully celebrate our succeed exam
Greetings
Ulrich
 
Vlad Rabkin
Ranch Hand
Posts: 555
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulrich,
The idea of Andrew is actually more elegant. I didn't want my methods to throw IOException, because it is a low level exception.
Anyway, both solutions are good and elegant.
...hopefully celebrate our succeed exam

I hope so too ...
It will be not easy for Andrew to join us: He needs about 20 hours flight to get to Cologne, but will I drink some beers for him
I like dark strong beer. I forget always the name of it (it is a beer for X-mas in Germany). I like also beer from Belgium and Latvia (that's where I come from).
Cheers,
Vlad
[ November 04, 2003: Message edited by: Vlad Rabkin ]
 
Ulrich Heeger
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vlad,
thanks for your answer.
It will be not easy for Andrew to join us: He needs about 20 hours flight to get to Cologne, but will I drink some beers for him

Oh, that's true, so we two will have to drink for him...
I like also beer from Belgium and Latvia (that's where I come from).

I will hold my thumbs for Latvia to get through the qualifications for Euro 2004
But back to our beloved assignement , I still have a little question concerning my further actions. What have you done after the programmation of the networking layer: Have you started the programmation of the GUI Client or the implementation of the handling with the suncertify.properties-files? Because I haven't occupied myself with these themes, so I don't know where to start...
Greetings
Ulrich
 
Vlad Rabkin
Ranch Hand
Posts: 555
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulrich,
I will hold my thumbs for Latvia to get through the qualifications for Euro 2004

Tx!
Ok. Honestly saying suncertify.properties was the first thing I have done in the assignment .
I have three classes: one abstract, which wrapps java.util.Properties and
provides default properties. One class for client and one for the server.
It looks like a JavaBean (getter/setters). I have done it first not to refactor my server and client code later.
So my suggestion is start with properties and then with GUI.
There were a lot of discussion whether we should lock property file. It is a nice idea. However, I don't see any hint in the assignement to do it. So I use standard Properties class to load/save properties and I DIDN'T lock the property file.
Best,
Vlad
 
Ulrich Heeger
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vlad,
thanks for your advice, so I will start with the property-files.
Greetings
Ulrich
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vlad & Ulrich,
Originally posted by Ulrich Heeger:
Let us really celebrate together Carneval, Andrew you have also to come to Cologne, so we can drink K�lsch, Cascades and (what's you favorite beer, Vlad?) together and hopefully celebrate our succeed exam
Originally posted by Vlad Rabkin:
It will be not easy for Andrew to join us: He needs about 20 hours flight to get to Cologne, but will I drink some beers for him
I like dark strong beer. I forget always the name of it (it is a beer for X-mas in Germany). I like also beer from Belgium and Latvia (that's where I come from).

Very difficult for me - especially since my girlfriend has no interest in going to Europe again for a while, and even less interest in making a trip for beers
Vlad - are you thinking of Bok beers? Winter-bok / Herfst-Bok? Very dark, very tasty. I love the Grolsch Bok Beer. But I thought that they were a Belgian / Dutch beer: I even had a friend from Munich who would drive up to Utrecht each Novemeber and fill his car up with Bok beers to last him the comming year.
Carneval is not until about March or April though (isn't it?) - so the winter beers wont be available then
Regards, Andrew
 
Vlad Rabkin
Ranch Hand
Posts: 555
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andrew,
Vlad - are you thinking of Bok beers

Yes! There is a very old bar in Frankfurt . It is one of two bars in Germany, which offers the the Bok beer during all the long. My wife doesn't like this kind of beer. So, when I have guests, I use always a chance to go there.
... my girlfriend has no interest in going to Europe again for a while, and even less interest in making a trip for beers

Well, as we agreed with Ulrich, we will drink for you. I plan also to go to Brussels to do it also with Phil.
BTW, What is the "national drink" in Australia?
Best,
Vlad
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vlad,
Originally posted by Vlad Rabkin:
BTW, What is the "national drink" in Australia?

Hmmm - we had better watch out in case a bartender tells us off for being so far off topic
Australia'a national drink is beer of course
Opinion is divided on which beer though. Not so long ago, each state was very loyal to the beer from that state. We are not so parochial these days though. VB (Victoria Bitter) seems to be the most common beer throughout Australia, with the Tasmanian beers (especially Cascade) coming in a close second (other beers, while good, are not as available in the other states). Most pubs also keep Fosters around for the tourists.
Regards, Andrew
 
Ulrich Heeger
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Andrew & Vlad,
we have also Bock-Beers in Germany, but more in the nothern part..
I've tried also to get some Cascades here in Cologne, but no way
Perhaps we should change our job and engage us in the apparently profitable business of beer smuggling (clandestine Connection Cologne - Riga - Sydney)
Anyway, Vlad, I would like to join you and Phil in Brussel to get some beers after SCJD, because my brother and my sister are living there, I'm often there
I'm sorry to come back to our SCJD after this discussion of tasty beer
Shame on me...
Soon, I will start a new thread concerning suncertify.properties but I want just to profit of the occasion and to ask a few question concerning your approach, Vlad:
I have three classes: one abstract, which wrapps java.util.Properties and
provides default properties. One class for client and one for the server.

Because I haven't any experience concerning property-files, my questions may appear simple-minded, I'm sorry once more
1. What do you mean with default properties? Do you mean default properties for the location of the database, the servername, for example "localhost" etc?
2. We will have two different property-files, one for the client and one for the server?
3. Each time, we start the server, do we have to create newly the suncertify.properties-file and to delete it, when the server shuts down?
the same for the clients' suncertify.prop.-file?
4.
It looks like a JavaBean (getter/setters)

Do you integrate the setProperty/getProperty-methods of java.util.Properties within this new methods? for example:

Is that the way you mean?
Thanks a lot in advance,
Ulrich
[ November 05, 2003: Message edited by: Ulrich Heeger ]
 
Vlad Rabkin
Ranch Hand
Posts: 555
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulrich,
I'm sorry to come back to our SCJD after this discussion of tasty beer. Shame on me...

It's ok, don't worry
1. What do you mean with default properties? Do you mean default properties for the location of the database, the servername, for example "localhost" etc?

Yeap.
2. We will have two different property-files, one for the client and one for the server?

Nope. I have one property file. it has such properties like: server.dbfile,
client.dbfile and so on.
3. Each time, we start the server, do we have to create newly the suncertify.properties-file and to delete it, when the server shuts down?
the same for the clients' suncertify.prop.-file?

Nope. First, I have only one propertiy file. Second, I don't recreate the file:#
java.util.Properties has two methods, which you can be interested in:
Properties.load() and Properties.store().
Do you integrate the setProperty/getProperty-methods of java.util.Properties within this new methods?

Yeap.
Best,
Vlad
 
Ulrich Heeger
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vlad,
thanks a lot for your answer.
Just one more question, afterwards, I promise I will post my questions in a new thread.
I wrote some code and I would like to know what you think about it

public abstract class AbstractProperties{
String propertyName = "test.properties";
public abstract String getTestName() throws IOException;
public abstract void setTestName(String testName)
throws IOException;
}
public class TestProperties extends AbstractProperties{
private Properties P;
private FileInputStream in;
private FileOutputStream fos;
public TestProperties() throws FileNotFoundException{
P=new Properties();
in=new FileInputStream(propertyName);
fos = new FileOutputStream(propertyName);
}

public String getTestName() throws IOException{
P.load(in);
return P.getProperty("testname", "defaultname");
}

public void setTestName(String testName) throws IOException{
if(testName==null){
testName="defaultname"
}
P.setProperty("testname", testName);
P.store(fos,"Test Properties");
}

protected void finalize() throws IOException{
in.close();
fos.close();
}
}


I hope Andrew, I haven�t posted too much of code.
I just want to know, if my way of opening and closing the I/O-Streams and my setting of default-values are ok?
Thanks in advance & greetings
Ulrich
[ November 05, 2003: Message edited by: Ulrich Heeger ]
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulrich,
Ulrich:
Let us really celebrate together Carneval, Andrew you have also to come to Cologne, so we can drink K�lsch, Cascades and (what's you favorite beer, Vlad?) together and hopefully celebrate our succeed exam.

And what about Phil then ?!
Best,
Phil.
[ November 07, 2003: Message edited by: Philippe Maquet ]
 
Ulrich Heeger
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Phil,
And what about Phil then ?!

Of course, I hope you will join us in viva Colonia. But you surely know, that little belgians and little swiss have to wear the most ridiculous disguisement at Carneval
Vlad:
I plan also to go to Brussels to do it also with Phil.
--------------------------------------------------------------------------------
Finally !
Ulrich:
Anyway, Vlad, I would like to join you and Phil in Brussel to get some beers after SCJD

Oh, then you will take your revenge, n'est-ce pas?
Greetings
Ulrich
 
Vlad Rabkin
Ranch Hand
Posts: 555
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
I will reply about about the beer later. The internet works only partially today in the company I work for. So I want to use a chance to answer Ulrich, before it crashes again.
Ulrich, your load and store method shouldn't be in get/set.
Let me give a sample for the main abstract class and you will anderstand what its subclasses should do:

Best,
Vlad
[ November 05, 2003: Message edited by: Vlad Rabkin ]
 
Ulrich Heeger
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vlad,
thank you for your answer, now I understand.

protected AbstractConfig() throws IOException {
...
//load properties
props.load(fis);
fis.close();
}
public void store() throws IOException {
...
// store properties
props.store(fos, null);
}

So you create and close fis/fos within the constructor/store()-method of AC? Where do you make a call to store(), I suppose not within the set methods but perhaps within the finalize() of the SC?
Regards
Ulrich
 
Vlad Rabkin
Ranch Hand
Posts: 555
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulrich,
I call store(), when I start Client/Server.
I have connection dialog on the client. When a user press "Connect" button
I set all values in CC (ClientConfig) with values from appropriate text fields and call CC.store() before starting the client. The same on the server.
Best,
Vlad
[ November 06, 2003: Message edited by: Vlad Rabkin ]
 
Ulrich Heeger
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vlad,
thanks a lot for your help.
Cheers
Ulrich
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic