Call a method based on string value received - Suggestions?

K

Karthik D

Hello All,
I am working on a small project (of my own to learn Java N/W
programming)which is to implement a FTP server.I am newbie in
designing Java programs.
What I am trying to achieve is when a ftp client sends a message
like USER,PASS or some message I wanted to invoke the appropriate
method which does the processing of client's request and sends the
response back to the client?
I read the client's request from the socket through BufferedReader
Stream.
For e.g when I receive a string called PASS I would call PASS()
method which sends the request for password to the client asking the
user to enter the password to login.
I read in the newsgroups(comp.lang.java.*)that to invoke a method
dynamically one can use reflection APIs to achieve it.Some of them
told reflection APIs have some problems/overhead.
Is there any other way I can invoke methods based on a particular
string value?
One more question.I have read little about design patterns.But I
used to get confused where to use which patterns while designing the
programs.I would like to understand design patterns well and apply
them even in my small Java projects.Any suggestions for designing
better java programs?

Thanks & Regards,
Karthik
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top