Client\Server App

P

PurpleServerMonkey

Looking to implement a Java Client\Server application and would like
recommendations on the best way to implement it.

I'm familiar with Java sockets and networking in general, my initial
thought was to use sockets with xml-rpc but then thought there has to
be a better way since people have been doing this for ages. RMI was my
next thought and would generally fit the bill, well I think so anyway.

Basically the aim is to create a Java server to run on a Linux host
and have a "rich client" application that runs on the end users
desktop, whether it be Linux, Mac or Windows. Expecting no more than
ten clients at anyone time but those clients will be sending\receiving
a lot of information to and from the server.

The rich client will be Java based but if it could support other
languages like .Net it would be a big bonus in terms of
interoperability.

Sorry to ask such a question but I've spent a bit of time researching
this topic but I'm consistently finding information on how to do this
with a browser and things like JSP, tomcat etc. Using a browser as the
client isn't the way we want to go with this project.

Any thoughts or recommendations are welcome.
 
I

instcode

Looking to implement a Java Client\Server application and would like
recommendations on the best way to implement it.

I'm familiar with Java sockets and networking in general, my initial
thought was to use sockets with xml-rpc but then thought there has to
be a better way since people have been doing this for ages. RMI was my
next thought and would generally fit the bill, well I think so anyway.

Basically the aim is to create a Java server to run on a Linux host
and have a "rich client" application that runs on the end users
desktop, whether it be Linux, Mac or Windows. Expecting no more than
ten clients at anyone time but those clients will be sending\receiving
a lot of information to and from the server.

The rich client will be Java based but if it could support other
languages like .Net it would be a big bonus in terms of
interoperability.

Sorry to ask such a question but I've spent a bit of time researching
this topic but I'm consistently finding information on how to do this
with a browser and things like JSP, tomcat etc. Using a browser as the
client isn't the way we want to go with this project.

Any thoughts or recommendations are welcome.

You should take a look over the MINA framework - http://mina.apache.org/
Some key features:
- High performance TCP/UDP uses Java NIO library.
- Filter and Filter chain mechanism. Several filters are available and
ready to use.
- Customizable thread model (single, multi, thread pool...)
- And more...

Using MINA, you just need to focus on your protocol (which is also
supported by some of MINA's APIs), and benefit from the Java NIO. :)
 
P

PurpleServerMonkey

You should take a look over the MINA framework -http://mina.apache.org/
Some key features:
- High performance TCP/UDP uses Java NIO library.
- Filter and Filter chain mechanism. Several filters are available and
ready to use.
- Customizable thread model (single, multi, thread pool...)
- And more...

Using MINA, you just need to focus on your protocol (which is also
supported by some of MINA's APIs), and benefit from the Java NIO. :)

Thanks instcode, have added the MINA framework to my bookmarks.

Guess the question is whether xml-rpc or soap is a better alternative
than a custom protocol over sockets?
Trying to avoid reinventing the wheel and it appears that xml-rpc and
soap both implement a protocol that I'd otherwise have to create in
order to use sockets.
 
E

EricF

Thanks instcode, have added the MINA framework to my bookmarks.

Guess the question is whether xml-rpc or soap is a better alternative
than a custom protocol over sockets?
Trying to avoid reinventing the wheel and it appears that xml-rpc and
soap both implement a protocol that I'd otherwise have to create in
order to use sockets.
Soap would be a good route to go if you do want to support .Net clients.

I think you got it right when you asked if xml-rpc/Soap are better than a
custom protocol. Can you design a better custom protocol? Maybe. But do you
want to spend the time doing this - or start working on your application?

(MINA does look pretty cool.)

Eric
 
R

Richard Maher

Hi PurpleServerMonkey,
Guess the question is whether xml-rpc or soap is a better alternative
than a custom protocol over sockets?

My guess is that the real question to all of the experience-hardened IT
professionals in this NewsGroup (who are responsible for application/network
performance and security) could more succinctly be put as "Have you really
chosen a connectionless, context-devoid, poorly-performing, page transfer
protocol, such as HTTP, as your application middleware backbone?".

If you're interested in persuing this line of thought and other questions
such as "Why does Silverlight want Mugabe(esque) totalitarian control over
(you'll think it's Ajax) data access?" or "Why is Adobe trying to also claim
control of the server with Flash Data Management Services?" then just
respond to this post.

Or how 'bout Serialization eh - What's it all about? Take an Object, flatten
it out into a stream of bytes (ASCII XML perhaps), and then re-build it all
again at the other end. - Sounds idyllic (optimal at least!).

In the meantime, here is my vision of a Socket Client/Server application
that I recently used as an example when replying to a post in
comp.lang.javascript. I think you'll find that the issue is really one of
server middleware availability; HTTP-aware Web Servers (for better or worse)
are ubiquitous and, although they are complete crap for RPC-type
communication, they can be fudged (via Tomcat et al) to provide a veneer of
load-balancing/multithreading, authorization and so on.

The easiest thing to do is just keep banging that square peg into the round
hole; everyone else is :-(

*OR* you could do something like: -


Hi Marshal,
is there a similar feature in
JavaScript - or at least soem thing mroe flaxible than lines and lines
of assignments?

One possibility, and my personal preference, is to deploy a TCP/IP Socket
managed by a Java Applet. As long as you connect back to the same codebase
then no certificate signing is reqd. Server Affinity is completely under
your control, and you can receive any number of rows, or array elements, in
response. Unlike Ajax or a.n.other option, you can achieve a high degree of
parallelism with the client JavaScript enriching and adding value to rows,
and presenting them, while the server is busy filling the queue with the
rest of the result set. Realtime visual status aids such as a Record Count
or a Diminishing Scrollbar can also help the user to feel that the server
hasn't forgotten about them. (I'm also quite excited about the prospect of
dynamic/animated chart building with Flash's "Data Binding" and the
streaming of periodic sales figures down the pipe - but I haven't worked
that part out yet :) Anybody with opinions/experiences of
JavaScript+FABridge -vs- Native ActionScript Getters and Setters?)

Anyway, here is an example of what I'm talking about: -
http://manson.vistech.net/t3$examples/demo_client_web.html

Username: TIER3_DEMO
Password: QUEUE

I'll post more demo instructions at the end of this but, to see the bit you
want in action, just enter an asterix "*" for the Queue Name and then click
the green "Get Job Info" button. You'll see that the <select> list is
populated from the server, one row/element at a time. I have tested this
with up to 3000 rows and scalability doesn't seem to be an issue! The one
performance problem I experienced was the tear-down of the old/previous
option-collection before populating the results from the next query. Thanks
to RobG, the problem was solved with DOM Node Cloning and Replacing.

All of the client source code can be found at:-
http://manson.vistech.net/t3$examples/

QUEUE_LOOKUP.HTML contains the code you'd be interested in specifically the
jobLookup() and getResponse() functions, although following the selectRef
and selectClone objects through the code could be worthwhile. The driving
Applet is CornuCopiae.java and the object definition can be found in
CornuCopiae.html. (The main Socket stuff being in Tier3Socket.java) NB: All
Applet Java code is application-neutral and completely reusable. No Java
coding "need" be done for applications 2 to N.

If you'd prefer someone to have Mugabe(esque) totalitarian control over your
server interaction then I'd suggest Silverlight. (Or Flash's Data Management
Services - "All client-resident data in sync" - Yeah right. But at least
with Flash (and obviously Java) you get the choice!)

Although my code is, at present, VMS-specific you could achieve similar
results with simple INETd server processes, if you dropped the authorization
and were happy with one server process per user.

Cheers Richard Maher

PS. The code doesn't automatically check for versions, but does work on
recent versions of Mac OS X Safari (1.5 JDK), Firefox, Windows Firefox and
IE 6 and 7, Opera, Linux and Firefox. You must have JavaScript enabled,
Applets enabled and a recent JVM. You also can't be behind a firewall that
bans outgoing connections unless you open up 5255.

Here's some of the functionality-catwalk highlights from the example: -

1) Full, one-time, context-specific, VMS User Authentication. No Cookies,
Session IDs, Password Caching or generic Work-Station or Browser
credentials! When you load the demo_client_web.html page into your browser,
a Java Applet is automatically activated that prompts the user for their VMS
Username and Password via a modal dialogue box. If authorization fails, the
"Access Denied" page will be displayed and VMS Intrusion Detection (in
accordance with the policy set out by your System Manager) will be enforced,
and Login-Failures is incremented in SYSUAF. Alternatively, if authorization
is successful (and you left the "Display Logon Confirmation" box ticked)
then a Welcome dialog box will be displayed detailing last login times and
the number of unsuccessful login attempts (if any). Login-Failures is now
set to zero and last non-interactive login time is set to the current time.

If you refresh this page, or move to a different page, then the server
connection is broken and you must be re-authorised before continuing to
access the Demo Queue Manager application.

2) A Hot-Abort button! After you have pressed the "Get Job Info" button
you'll notice that the "Abort Request" button becomes active and turns red.
(Actually you probably won't notice 'cos this query completes too quickly
:) You can edit the DEMO_UARS.COB code and change the value of the
DEBUG_DELAY field if you want to see your 3GL Interrupt routine in action.)
In this case the cancel-flag I've set in the AST routine is picked up in the
mainline code, resulting in the graceful termination of the loop that
controls "next queue" (or "next row") retrieval.

Also, if you look at the getResponse() function in query_lookup.html, you
will see how the chan.setTimeout() method has been deployed to provide an
erstwhile "blocking" socket Read with the ability to surrender the
event-thread for things like processing the Abort button and ticking over
the clock. (all of this, and much more, "infrastructure-code" is already
there and doesn't have to be re-invented)

3) Predictive text on the Queue Name field so that all matching VMS queues
are retrieved on-demand as the user types. As is now common-place with many
websites, a drop down select list of matching options is automatically
retrieved from the server and made available for the user to select from.

4) Result-set drill-down. Many database queries return a result-set of rows
for the user to scan through and possibly drill-down into for more detail.
I've provided a reasonably generic example of this, where all matching Job
Entries have been populated into a dynamic HTML select list. Once again the
user was able to see the select-list grow, the scroll-bar diminish, and
"Jobs Found" field tick over in real-time, whilst continually being
empowered (by the Abort button) to curtail the results at any time!

If you click on an entry in the Select List then the <frame> changes and the
entry_details.html page appears. See the parent.entry_details.getReady()
call in queue_lookup.html to see how the handover to the new frame takes
place. (Also see goBack() in entry_details.html to see how simply that
operation is reversed.)

The user is now free to move forward, back, first, last, refresh, and delete
queue entries, or return to the previous frame. (Thanks to the deployment of
the VMS Persona functionality, the user is only permitted to see those queue
entries that the Username they signed in under is permitted to see. They can
also *only* delete those entries that this username is allowed to delete.)

5) Floating <div>s. You'll see that any queue names are highlighted in bold
and italics; if you mouseover any of these fields when they are not blank
then the current status information for that queue will be retrieved from
the server and displayed in a quasi-popup DIV.

6) Local Result-Set Sort. If you click on the "header" or "first" row in the
Select List of queues, you will get a popup prompting you for a sort key. If
you select one, the contents of the Select List are sorted in the chosen
order. (Try enter "*" for the Queue Name and then clicking "Get Job Info" to
get some data worth sorting)

Marshal Anderson said:
I'm working on an application that requires a lot of internal data -
short texts, numbers, switches etc. At the moment the only way I have
of loading these is long lines of Array[1,2,3 etc]=The Data. In the VB
version I read data in from text files - is there a similar feature in
JavaScript - or at least soem thing mroe flaxible than lines and lines
of assignments?

Marshal

Cheers Richard Maher
 
P

PurpleServerMonkey

Hi PurpleServerMonkey,
Guess the question is whether xml-rpc or soap is a better alternative
than a custom protocol over sockets?

My guess is that the real question to all of the experience-hardened IT
professionals in this NewsGroup (who are responsible for application/network
performance and security) could more succinctly be put as "Have you really
chosen a connectionless, context-devoid, poorly-performing, page transfer
protocol, such as HTTP, as your application middleware backbone?".

If you're interested in persuing this line of thought and other questions
such as "Why does Silverlight want Mugabe(esque) totalitarian control over
(you'll think it's Ajax) data access?" or "Why is Adobe trying to also claim
control of the server with Flash Data Management Services?" then just
respond to this post.

Or how 'bout Serialization eh - What's it all about? Take an Object, flatten
it out into a stream of bytes (ASCII XML perhaps), and then re-build it all
again at the other end. - Sounds idyllic (optimal at least!).

In the meantime, here is my vision of a Socket Client/Server application
that I recently used as an example when replying to a post in
comp.lang.javascript. I think you'll find that the issue is really one of
server middleware availability; HTTP-aware Web Servers (for better or worse)
are ubiquitous and, although they are complete crap for RPC-type
communication, they can be fudged (via Tomcat et al) to provide a veneer of
load-balancing/multithreading, authorization and so on.

The easiest thing to do is just keep banging that square peg into the round
hole; everyone else is :-(

*OR* you could do something like: -



Hi Marshal,
is there a similar feature in
JavaScript - or at least soem thing mroe flaxible than lines and lines
of assignments?

One possibility, and my personal preference, is to deploy a TCP/IP Socket
managed by a Java Applet. As long as you connect back to the same codebase
then no certificate signing is reqd. Server Affinity is completely under
your control, and you can receive any number of rows, or array elements, in
response. Unlike Ajax or a.n.other option, you can achieve a high degree of
parallelism with the client JavaScript enriching and adding value to rows,
and presenting them, while the server is busy filling the queue with the
rest of the result set. Realtime visual status aids such as a Record Count
or a Diminishing Scrollbar can also help the user to feel that the server
hasn't forgotten about them. (I'm also quite excited about the prospect of
dynamic/animated chart building with Flash's "Data Binding" and the
streaming of periodic sales figures down the pipe - but I haven't worked
that part out yet :) Anybody with opinions/experiences of
JavaScript+FABridge -vs- Native ActionScript Getters and Setters?)

Anyway, here is an example of what I'm talking about: -http://manson.vistech.net/t3$examples/demo_client_web.html

Username: TIER3_DEMO
Password: QUEUE

I'll post more demo instructions at the end of this but, to see the bit you
want in action, just enter an asterix "*" for the Queue Name and then click
the green "Get Job Info" button. You'll see that the <select> list is
populated from the server, one row/element at a time. I have tested this
with up to 3000 rows and scalability doesn't seem to be an issue! The one
performance problem I experienced was the tear-down of the old/previous
option-collection before populating the results from the next query. Thanks
to RobG, the problem was solved with DOM Node Cloning and Replacing.

All of the client source code can be found at:-http://manson.vistech.net/t3$examples/

QUEUE_LOOKUP.HTML contains the code you'd be interested in specifically the
jobLookup() and getResponse() functions, although following the selectRef
and selectClone objects through the code could be worthwhile. The driving
Applet is CornuCopiae.java and the object definition can be found in
CornuCopiae.html. (The main Socket stuff being in Tier3Socket.java) NB: All
Applet Java code is application-neutral and completely reusable. No Java
coding "need" be done for applications 2 to N.

If you'd prefer someone to have Mugabe(esque) totalitarian control over your
server interaction then I'd suggest Silverlight. (Or Flash's Data Management
Services - "All client-resident data in sync" - Yeah right. But at least
with Flash (and obviously Java) you get the choice!)

Although my code is, at present, VMS-specific you could achieve similar
results with simple INETd server processes, if you dropped the authorization
and were happy with one server process per user.

Cheers Richard Maher

PS. The code doesn't automatically check for versions, but does work on
recent versions of Mac OS X Safari (1.5 JDK), Firefox, Windows Firefox and
IE 6 and 7, Opera, Linux and Firefox. You must have JavaScript enabled,
Applets enabled and a recent JVM. You also can't be behind a firewall that
bans outgoing connections unless you open up 5255.

Here's some of the functionality-catwalk highlights from the example: -

1) Full, one-time, context-specific, VMS User Authentication. No Cookies,
Session IDs, Password Caching or generic Work-Station or Browser
credentials! When you load the demo_client_web.html page into your browser,
a Java Applet is automatically activated that prompts the user for their VMS
Username and Password via a modal dialogue box. If authorization fails, the
"Access Denied" page will be displayed and VMS Intrusion Detection (in
accordance with the policy set out by your System Manager) will be enforced,
and Login-Failures is incremented in SYSUAF. Alternatively, if authorization
is successful (and you left the "Display Logon Confirmation" box ticked)
then a Welcome dialog box will be displayed detailing last login times and
the number of unsuccessful login attempts (if any). Login-Failures is now
set to zero and last non-interactive login time is set to the current time.

If you refresh this page, or move to a different page, then the server
connection is broken and you must be re-authorised before continuing to
access the Demo Queue Manager application.

2) A Hot-Abort button! After you have pressed the "Get Job Info" button
you'll notice that the "Abort Request" button becomes active and turns red.
(Actually you probably won't notice 'cos this query completes too quickly
:) You can edit the DEMO_UARS.COB code and change the value of the
DEBUG_DELAY field if you want to see your 3GL Interrupt routine in action..)
In this case the cancel-flag I've set in the AST routine is picked up in the
mainline code, resulting in the graceful termination of the loop that
controls "next queue" (or "next row") retrieval.

Also, if you look at the getResponse() function in query_lookup.html, you
will see how the chan.setTimeout() method has been deployed to provide an
erstwhile "blocking" socket Read with the ability to surrender the
event-thread for things like processing the Abort button and ticking over
the clock. (all of this, and much more, "infrastructure-code" is already
there and doesn't have to be re-invented)

3) Predictive text on the Queue Name field so that all matching VMS queues
are retrieved on-demand as the user types. As is now common-place with many
websites, a drop down select list of matching options is automatically
retrieved from the server and made available for the user to select from.

4) Result-set drill-down. Many database queries return a result-set of rows
for the user to scan through and possibly drill-down into for more detail.
I've provided a reasonably generic example of this, where all matching Job
Entries have been populated into a dynamic HTML select list. Once again the
user was able to see the select-list grow, the scroll-bar diminish, and
"Jobs Found" field tick over in real-time, whilst continually being
empowered (by the Abort button) to curtail the results at any time!

If you click on an entry in the Select List then the <frame> changes and the
entry_details.html page appears. See the parent.entry_details.getReady()
call in queue_lookup.html to see how the handover to the new frame takes
place. (Also see goBack() in entry_details.html to see how simply that
operation is reversed.)

The user is now free to move forward, back, first, last, refresh, and delete
queue entries, or return to the previous frame. (Thanks to the deployment of
the VMS Persona functionality, the user is only permitted to see those queue
entries that the Username they signed in under is permitted to see. They can
also *only* delete those entries that this username is allowed to delete.)

5) Floating <div>s. You'll see that any queue names are highlighted in bold
and italics; if you mouseover any of these fields when they are not blank
then the current status information for that queue will be retrieved from
the server and displayed in a quasi-popup DIV.

6) Local Result-Set Sort. If you click on the "header" or "first" row in the
Select List of queues, you will get a popup prompting you for a sort key. If
you select one, the contents of the Select List are sorted in the chosen
order. (Try enter "*" for the Queue Name and then clicking "Get Job Info" to
get some data worth sorting)

I'm working on an application that requires a lot of internal data -
short texts, numbers, switches etc. At the moment the only way I have
of loading these is long lines of Array[1,2,3 etc]=The Data. In the VB
version I read data in from text files - is there a similar feature in
JavaScript - or at least soem thing mroe flaxible than lines and lines
of assignments?

Cheers Richard Maher





...

read more »

Richard,

Thanks for your comments they have certainly struck a chord with me.

Having looked a lot deeper into the xml-rpc and soap frameworks I can
that they have advantages but are not appropriate for what I want to
do. As you say, a square peg in a round hole.

Currently looking into using IIOP or RMI as they appear to suit the
client\service requirements for my project.
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top