java - Handling Objects coming from RMI server and delegating to objects in the client -


I am using RMI using an instant chat application the server sends some objects through, I want to handle For example, the server will send a connected group operation class. In my client application, I need to identify the class and move my handler ( HandleJoinedGroupOperation ). This class will make a bunch of stuff on the client side.

My question is how can I handle classes that come from the server from a class so I do not have to make statements? I.e.

  if (join the server.getResponse (example) group operation) {handeljoint group operation handle = new handlodge group operation (); Handle.foo (); }    

Using one of the possible options in your case is the design panoron Make some abstract of potential operators (such as HandleJoinedGroupOperation ), then linking those handlers (at the start time) as an example, create an interface

  Interface OperationHandler {zero handle (Operation op); }   

Where operation is also a basic type for all possible tasks; in this type ( operation ) the type of type of operation type Can be:

  enum operation type {...}   

Then you can check this field in the solid operators (though in the If the statement is included, but those statements will be explained in each specific handler)

As a simple example, here is a handler Defense conducts a default implementation

  class SimpleHandler Opreshnhandlr {private Opreshnhandlr Next; Public Zero Handle (Operation Option) {if (op.getType () == OperationTip.SOMEYOURTYPE} {// some stuff} and {next.handle (op); }}}   

In this case your server.getResponse () method will simply return the original type of operation hierarchy

Read the article to get more information

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -