Overview | Package | Class | Use | Tree | Deprecated | Index | Help
|  | BEA Systems, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

WebLogic Server 5.1.0sp9 API Reference

## weblogic.rmi.extensions
Interface CallRouter

public interface CallRouter
extends java.io.Serializable

A class implementing this interface must be provided to rmic to enable parameter-based routing. In order to enable parameter-based routing for a RMI service you must run rmic on the service implelentation using these options:

     $ java weblogic.rmic -clusterable -callRouter <callRouterClass> <remoteObjectClass>

The call router is called by the clusterable stub each time a remote method is invoked. The router is responsbile for returning the name of the server to which the call should be routed.

Each server in the cluster is uniquely identified by its name, which is set by starting the WebLogic Server with the `weblogic.system.name` property. These are the names that the method router must use for identifying servers.

Example: Consider the `ExampleImpl` class which implements a remote interface `Example`, with one method `foo`:

     public class ExampleImpl implements Example {
       public void foo(String arg) { return arg; }
     }

This `CallRouter` implementation `ExampleRouter` ensures that all `foo` calls with 'arg' < "n" go to server1 (or server3 if server1 is unreachable) and that all calls with 'arg' >= "n" go to server2 (or server3 if server2 is unreachable):

     public class ExampleRouter implements CallRouter {
       private static final String[] aToM = { "server1", "server3" };
       private static final String[] nToZ = { "server2", "server3" };

       public String[] getServerList(Method m, Object[] params) {
         if (m.GetName().equals("foo")) {
           if (((String)params[0]).charAt(0) < 'n') {
             return aToM;
           } else {
             return nToZ;
           }
         } else {
           return null;
         }
       }
     }

This rmic call associates the `ExampleRouter` with `ExampleImpl` to enable parameter-based routing:

     $ java weblogic.rmic -clusterable -callRouter ExampleRouter ExampleImpl

Author:
  Copyright (c) 1999 by BEA Systems, Inc. All Rights Reserved.
  Copyright © 2001 BEA Systems, Inc. All Rights Reserved.

Method Summary
`java.lang.String[]` | `getServerList(java.lang.reflect.Method method, java.lang.Object[] params)` Returns an ordered list of servers to which this method can be routed.

Method Detail

### getServerList

    public java.lang.String[] getServerList(java.lang.reflect.Method method,
                                            java.lang.Object[] params)

  Returns an ordered list of servers to which this method can be routed. The framework will attempt to send the message to the first server in the list. If the server is not reachable or there is no replica on that server, it will then try the second, and so on. This method may return null to disable call routing for the current call, in which case the current loadAlgorithm is used to choose a server.

  Each server is identified by its name, which is set on server startup with the weblogic.system.name property. The name list should only name servers on which replicas for this service are deployed.

  Parameters:
    `method` - Method to be routed
    `params` - Array of parameters for method
  Returns:
    List of servers to which this method can be routed, or null

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Documentation is available at http://www.weblogic.com/docs51
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD