BEA Systems, Inc.

WebLogic Server 5.1.0 API Reference

Interface CallRouter

public interface CallRouter

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 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

Copyright (c) 1999 by BEA Systems, Inc. All Rights Reserved.
Copyright © 2000 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


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 property. The name list should only name servers on which replicas for this service are deployed.

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

Documentation is available at