Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

instruction - writing Data Client. "WAITING FOR RESPONSE"

 
Bhuvan mehra
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all!
I�m new in the forum and has lot of questions (confusions) in my mind.
In my instructions I have

Writing Data Client
To connect with your server, you should create a client program. This implementation should include a class that implements the same public methods as the suncertify.db.Data class, although it will need different constructors to allow it to support the network configuration.

I am not getting this instruction. Pls. give me your views about the instruction.
Regards,
Bhu.
[ April 01, 2002: Message edited by: Bhuvan ]
[ April 01, 2002: Message edited by: Bhuvan ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First welcome to Javaranch. The best place to get all your answers from. Post all you want, well answer more.
Second, Javaranch does have a policy for all users to be registered by the full first and last names. Your "Handle" bhu does not follow this standard. Please change it to your actual name. Thanks.
Now to your question.
Basically it states that your client will not have direct access to the Data class. It needs to have a "Proxy" or "Adapter" class in between to pass the calls from the client to the server or data.
Hope that starts you down the right path.
Mark
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well the first book of Desiong Patterns is the Gang of Four book called Design Patterns from Addison/Wesley publishing.
If you do a search on Design Patterns in this forum, you might find other links. But there is also great links on design patterns in the Architect forum. They have a links page that is posted in a thread that has it all.
As far as the Adapter pattern, RMI really handles that for you. However you need to create an interface that has all the public methods of the Data class, and in the implementation objects you need to pass the calls to the Data classes.
I'd read a bit more on this topic before going further. It looks like you might not have much experience in this arena, and you don't need to rush though your assignment. It is better for you to learn a lot out of this experience.
Mark
 
Bhuvan mehra
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Need response for �Adapter pattern� implementation.
db
===
DataInterface <i> ���������������...have all public methods of Data
Data ��������������������...implements lock(),unlock(),CF(S s)
Server
=====
SDataInterface<i> ���������������extends DataInterface, Remote
Sdata ��������������������..implements lock(),unlock(),CF(S s)
Sbind ��������������������Bind Sdata
Client
====
Client ��������������������GUI
DataFactory ������������������return DataInterface
ClientAdapter �����������������implements DataInterface
=============================================================
Mark Spritzler
However you need to create an interface that has all the public methods of the Data class, and in the implementation objects you need to pass the calls to the Data classes.
=============================================================
ClientAdapter implements DataInterface
{
        DataInterface di;
        ClientAdapter(DataInterface di)
        {
                this.di = di;
        }
        DataInfo getRecord(int rn)
        {
                return di.getRecord(rn);
        }
        public int getRecordCount()
        {
                return di.getRecordCount();
        }
        public void add(String [] record)
        {
                di.add(record);
        }
.............
.............
        public void lock(int rn)
        {
                di.lock(rn);
        }
        public void unlock(int rn)
        {
                di.unlock(rn);
        }
        DataInfo [] criteriaFind(String cri)
        {
                return di.citeriaFind(cri)
        }
.
.
.
.
.
.
.
.
        void reserveSeats(in rn)
        {
                lock(rn);
                unlock(rn);
        }
}
Client
{
...............
        ClientAdapter ca = �..;
...............
        buttonReservation.addActionListener(�.)
        {
                ca.reserveSeats(rn);
        }
...............
...............
}
is it correct implementation of Adapter pattern at client side?
thaks and regards,
Bhuvan.
[ April 01, 2002: Message edited by: Bhuvan ]
 
Bhuvan mehra
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi All!
need your response urgently. Please help me to solve above problem.
thanks and regards,
Bhuvan.
[ March 31, 2002: Message edited by: Bhuvan ]
 
dhana sekar
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
According to my knowledge Adapter pattent in RMI is as follows:
Attempt to invoke a local Object from a remote Client.
for exmaple :
+--------+
Client ----------->|RMI Server|
+--------+
|
|
|
|
+--------+
|ServerImpl|
+--------+
|
|(server instatiating the local class and make use of its method)
|
|
+----------+
|Local Class |
+----------+

Hope this helps u.

regards,
dhana
 
dhana sekar
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Iam sorry the above one which i send doesnt sounds good.
Here i repeat the same.
Client-------->RMIServer
|
|
|
|
ServerImpl
|
|
|
|
LocalClass
Here in the above diagram ServerImpl instantiate
the local class and servers both remote and also this can serve the local client. This is how we can use Adapter pattern in case of RMI.
Hope this helps u.
regards,
-dhana
 
Bhuvan mehra
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"
sun's instructions says,
Writing Data Client
To connect with your server, you should create a client program. This implementation should include a
1. "class that implements the same public methods" as the suncertify.db.Data class, although it will need different constructors to allow it to support the network configuration.
"
=======================================
Mark Spritzler
Basically it states that your client will not have direct access to the Data class. It needs to have a "Proxy" or "Adapter" class in between to pass the calls from the client to the server or data.
you need to create an interface that has all the public methods of the Data class,
2. and in the implementation objects you need to pass the calls to the Data classes.
=========================================
hi Mark!
i tried to overcome 1. & 2. in above message. desperately need you opinion.
thanks and Regards,
Bhuvan.
 
Bhuvan mehra
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Dhana!
thanks! at least you gave me the response. sorry, i didn't get the message. give a chance to understand and ans. again to the same problem.
thanks and regards,
Bhuvan.
 
Terry Wang
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
per your request, here's what i did, not exactly like yours.
i have a DataInterface which has all the same public methods in Data class. I put this interface in my client package. then i have another 2 classes in client package, RemoteDataClient and LocalDataClient, both implement DataInterface.
LocalDataClient uses Data as data source, while RemoteDataClient uses DataServerImpl class as its data source. DataServerImpl is in the server package and implements the DataServer interface. Internally, it uses Data as its data source.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your adapter looks good. It routes the calls from the adapter to the actual class. It is actually a cross between adapter and proxy. a proxy is usually a lot simpler and used mainly to check that the calls being made are valid, then it passes it through.
OK, and then your client looks OK with that actionlistener. We will probably talk about that later, when you move to the GUI side with the Model-View-Controller pattern.
Mark
 
Bhuvan mehra
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks! thanks a lot.
Bhuvan.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic