• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to bind an object instanciated from an extended class ?

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how can I bind my RemoteDataAccess?
this one must extend the UnicastRemoteObject to be bound to the rmiregistry AND extend the Data class as described in the submission requirement...
Can anyone that have extended the Data class to implement the locking methods, explain to me how to bind ?
A bit explaination on my system:
Each Client call first a getConnection() method that create a RemoteDataAccess object and bind it to the registry.The RemoteDataAccess class implement Runnable to be sure ThreadSafe.Then, the getConnection() method send the reference of the RemoteDataAccess object.The client has just to connect to this Object to call any methods.Each client has his own rmi binded object.
Is this a good minded solution or not?
Bruno
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your RemoteDataAccess class just needs to extend Remote, you do not need to bind it into the registry at all.
Mark
 
bru pe
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mark,
my RemoteDataAccess is not an interface...
As described in the Java tutorial, the interface must extend Remote an the binded classes must extends UnicastRemoteObject and implement this interface
NB: RemoteDataAccess class is on the Server side and not on the Client.Maybe should I rename it as DataServer to be more right in the context.
If I don't bind this class to the Registry, how can the clients call any methods of the "DataServer" class
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, so your class is not the implementation of your DataAccess interface then. This is your actual Connection/Server engine that each client needs to get and calls a method on it called GetConnection.
In your server startup class you will using the RMI Naming classes to call rebind() to bind the object. Use rebind, because it will overwrite the object if it already exsits, rather than having to unbind the object then bind again to replace with the new one

Mark
 
bru pe
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mark,
All right,I've renamed my classes and now I'll explain the entire Server system:

RemoteDataAccesInterface extend Remote - interface that contain all the Data methods and the lock and unlock methods declaration.
Data - give the methods to acces the db.db file.just as given from the assignement.
DataServer extend Data(,UnicastRemoteObject) implement Runnable,RemoteDataAccessInterface - just the implementation of the lock and unlock methods. My problem is there !! I need to extend the Data class AND the UnicastRemot...
ConnectionFactoryInterface extend Remote - interface which contain the getConnection() method
ConnectionFactory extend UnicastRemoteObject implement ConnectionFactoryInterface - the getConnectin is implemented . When a client call this method : creation of a DataServer object,bind it to the registry and return the name of the object bound to the client. So the Client have to make a connection to the object created. Then each Client own his own DataServer Object in his own Thread.
LockMgr - a "static" map that contain the records number and their state (Locked - Unlocked)
to make the things more clear for me, can you answer this short questions:
1)How many object are bound in your rmiregistry?
I expect you have one ConnectionFactory object( to get a reference to the DataAcces objects) and the same number of DataAccess object than the number of client which are connected
2)Did I miss something in my Server Design?
3)How many "aspirin" have you eat since the beginning of your assignement?
Thank you so much for the advice
Bruno
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok here's the 911.
There is only ever one object bound to RMI, that is your DataServer, which should only have one method. GetConnection() It returns a DataAccessRemote object which is only a Remote object, it does not extend Unicast...
when the client calls get connection it returns a new instance of DataAccessRemote, however it will be running on the Server. Meaning there will be one DataAccessRemote per client running.
In your DataServer, you should have an instance of the Data class.
DataServer should not extend the Data Class.
When your DataServer creates an instance of DataAccessRemote, you pass a reference to the Data class reference that is in your DataServer. There for each DataAccessRemote has a reference to the one and only one Data class instance.
Hope that helps.
Mark
 
bru pe
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
wow!!! ...my rescuer...
Thank you so much!
I stay with a doubt:
in the submission ,they said:
"Part of your assignement will be to enhance th Data class.You may do this by modification or subclassing. This last word doesn't mean that I should extend the Data class?
more clear:
subclassing = inheritance or composition?
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

This last word doesn't mean that I should extend the Data class?


Maybe maybe not.
This is a tough call, because I only modified the data class, meaning I went into the data.java file and changed the stuff directly, instead of extending and overriding. But it really depends on if the "New" data class that you will creat, is it really a new class, or jsut some stuff that should have been there in the first place.
Good Luck
Mark
 
bru pe
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I got it.
Bruno Vs the FBN project : 1-0
with the good design, my cleared RMI skills and after a long working night, my server is all functional
Thank you Mark.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,


There is only ever one object bound to RMI, that is your DataServer, which should only have one method. GetConnection() It returns a DataAccessRemote object which is only a Remote object, it does not extend Unicast...


I've messed with this for several days now... How can you return a DataAccessRemote object which "does not extend Unicast..." if it wraps the Data object (which is non-serializable)???
My version works with only the DataServer bound to the registry and both the DataServer and DataAccessRemote object extending UnicastRemoteObject (or if just the DataServer extends it and the DataAccessRemote is exported with the UnicastRemoteObject.export() method).
If the DataAccessRemote object does not extend UnicastRemoteObject than I get the "non-serializable" errors, which I would expect, since it then tries to send the Data object (which is non-serializable) over the wire.
I also have to have 2 stubs - one for the DataServer and one for the DataAccessRemote class - is this right??
Thank you,
Jeff
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In order to send the RemoteDataClass across the network it either needs to extend UnicastRemoteObject, implement Remote or implement Serializable(Not really messed with this yet.). I have a base interface DataAccessInterface. I have a RemoteDataInterface which extends DataInterface and Remote. The RemoteDataInterface is merely a mixin. Now the RemoteData class, in which has all of the calls to the Data file, implements the RemoteDataInterface. The DataServer( ConnectionFactory ) can send this object through rmi to the client.
Hope that makes sense.
Travis Zimmerman
 
jefferson p
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the quick response, Travis,
I can't seem to get it to work without the export.
My RemoteData class has a reference to Data which is set in the constructor...

I can't figure it out... The data is somehow being sent across the wire and puking since it's not serializable... Aaaaghh!
Thanks,
Jeff
 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi jefferson,
I am also experiencing the SAME problem ...
I also extended UnicastRemoteObject in both cases:
1) RemoteDataAccess and 2)DataServer.
Otherwise, it gives "Serialization errors" ...
But, Mark Spritzler argues that we need to extend
UnicastRemoteObject only in the case of DataServer and not with RemoteDataAccess.
But, I could not get it work ... It's throwing
serialization errors ...
Is there someone who went through this phase and
made it work without extending UnicastRemoteobject
Please help us(Jefferson and Myself) out ...
Thanks,
Regards,
Krishna Varma Adluru
 
Travis Zimmerman
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, I must have misunderstood/misspoke. Everyone ends up using close to the same names so it gets a little confusing.
Here is how I have set mine up:
public interface DataInterface
public interface RemoteDataInterface extends Remote, DataInterface
public class DataServer extends UnicastRemoteObject implements RemoteDataInterface, Unreferenced
-- This is my class that connects to the db. It is where I validate locking/unlocking and the object that is sent to the client. This class is not bound to the registry.
class ConnectionFactory extends UnicastRemoteObject implements ConnectionFactoryInterface
-- This is the class that is bound to the registry ( and I believe what you call the DataServer ). This class creates a new DataServer object and passes it to the client. through the following function call:
public DataInterface getConnection() throws RemoteException
I hope that clears it up for you both.
Travis
 
Travis Zimmerman
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe Mark's comments are in reference to what I call RemoteDataInterface. I belive bru was using a class instead of an interface here. This interface should not extend Unicast.., it should extend Remote and RemoteDataInterface.

Travis
[ March 15, 2002: Message edited by: Travis Zimmerman ]
 
jefferson p
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks!
 
Krishna Varma Adluru
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Travis,
Thank You very much ...This is exactly what
I did and it works .... But, Mark's comments
were in regard to "DataServer" in your case.
Anyway, Thanks a lot ..
Regards,
Krishna
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The RemoteConnection object extends Remote, that is all it needs to do to download, becuase it is like RMI in that the client only uses a stub(Adapter Pattern) to make the calls to the object. The RemoteConnection object does not get downloaded to the client. This seems to be what I am hearing is happening when you get Serialization errors with the data class.
Mark
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic