• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to display the MetaData to the client?

 
Tien Fu Liu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi:
I use RMI to implement my assignment.
But from the given interface, DBMain.java, there is no method to gain the related information about field name, and data record.
And we are not suggested to add methods in DBMain.java.

My interface, signon, extends DBMain and Remote and has one method getMetadata to gain metadata.

My Data.java implements the above 2 interfaces DBMain and signon.

For the local mode, I implement those 2 interfaces in Data.java to gain the metadata. This works in local mode.

For the remote mode, I have some problems.
I read from the threads online, they said I need to create another interface, RemoteDBMain which has the same methods from DBMain and extends Remote. In interface RemoteDBMain I add the method getMetadata to get the metadata from interface signon.
Basically, I don't know if it is correct to add method getMetadata here.
I use the adapter design pattern as suggested on this forum.
Please refer the following thread about Example 3.
web page

My question is as following.

signon adapter = null;

swich (mode){
case "local": adapter = Data("db-2x3.db");
case "remote": adapter = RemoteDBMain obj = (RemoteDBMain)Naming.lookup(urlSting);
}

The remote case does not work.
1.Is there something wrong with my design?

One thing confuses me is the relationship between signon, DBMain, and RemoteDBMain in different modes seems very complex.
2.Can anyone explain this to me?

Thanks
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tien
The remote case does not work.
Marlene's design works, so a little more information on what problems you are seeing with your modification of the design might help you to get some ideas from other forum members.
One thing confuses me is the relationship between signon, DBMain, and RemoteDBMain in different modes seems very complex.
2.Can anyone explain this to me?
That was actually one of the major discusion points of the thread you pointed to - no matter how you handle it, there is going to be complexity at some point. Design 3 was intended to keep the client code reasonably simple: it got a generic connection, and handled generic exceptions.

Rather than asking "Can anyone explain this to me?", perhaps you could explain what you understand, then perhaps others here can fill in the gaps.

Regards, Andrew
 
Tien Fu Liu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andrew:
Thanks for pointing me out.

In my original question I should said that the remote mode does not work is because the client throws a cast exception. and Proxy0???
Sorry for the imcomplete!

After I worked on the interfaces design for 2 days, I know the relationship between SignOn, DBMain, RemoteDBMain.
And I now can use the getMetaData method in both modes to access the .db file.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tien,
And I now can use the getMetaData method in both modes to access the .db file.
So I take it that this is now working for you.

Regards, Andrew
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic