Following the exchanges in the mailing-list
users@openejb.apache.org: "loadbalancing & failover of stateless beans," I ask adding:
- a way to specify a list of URLs as an InitialContext param
- a way to specify the ConnectionFactoryStrategy via an additional InitialContext param
- one ore more conection strategies
If multicast is used a server list will be created automatically and each client on first request which gives a stateless failover where the server list automatically updates as servers come and go from the cluster.
Alternatively, you can now register a new ConnectionFactory by simply including a "META-INF/org.apache.openejb.client.ConnectionFactory/foo" file in your classpath where "foo" is the protocol prefix you wish to control and the file "foo" points to an implementation of org.apache.openejb.client.ConnectionFactory. A basic implementation might look like:
{code}
import java.io.IOException;
import java.net.URI;
import org.apache.openejb.client.ConnectionFactory;
import org.apache.openejb.client.ConnectionManager;
/**
* Handles any connection requests for URIs that start with "foo:"
*
* @version $Rev$ $Date$
*/
public class FooConnectionFactory implements ConnectionFactory {
/**
* Get a connection using the URI specified.
*
* @param uri in most cases will be the value of "java.naming.provider.url"
* as specified in the InitialContext parameters
* @return
* @throws IOException
*/
public Connection getConnection(URI uri) throws IOException {
// Get the URIs from a System property or possibly
// create some URI format that can be split or expanded
// into a list of "ejbd:" URIs
URI[] uris = null;
for (URI serverURI : uris) {
// serverURI should be an "ejbd:" or similar URI handleable
// by the built-in ConnectionFactory implementations.
return ConnectionManager.getConnection(serverURI);
}
throw new IOException("No Server URIs specified");
}
}
{code}