|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.sapia.ubik.rmi.naming.ServiceLocator
public class ServiceLocator
This class implements the Service Locator pattern. It acts as a universal
lookup "helper", in conjunction with pluggable ServiceHandler
instances. The ServiceLocator encapsulates one to many service handlers;
for a given lookup, the locator retrieves the appropriate locator and then
delegates the lookup to the latter, returning the result to the caller.
Service handlers are plugged into the locator in one of the following ways:
ubik.rmi.naming.service.handler.uri_scheme (where 'uri_scheme'
is the scheme that is used to retreive a given object.
registerHandler(...) method.
For example, given the following service handler: com.acme.MyServiceHandler,
the configuration could be created has follows:
System.setProperty("ubik.rmi.naming.service.handler.acme", "com.acme.MyServiceHandler");
Then, latter on, a lookup can be performed using this class:
Object remote = ServiceLocator.lookup("acme://localhost:7070");
As shown above, the "acme" uri that was used to register the handler is
then used in the lookup. Using the scheme of the passed in URI, the
lookup(...) method delegates the operation to the proper
handler.
IMPORTANT: If service handlers are configured through system properties, it is important to do so before invoking the ServiceLocator class in any way: the latter retrieves the configured handlers in a static initializer, which would prevent the handlers from being discovered if configured after the ServiceLocator class' initialization.
| Field Summary | |
|---|---|
static java.lang.String |
HANDLER_PATTERN
Corresponds to the prefix of properties specifying service handlers. |
static java.lang.String |
UBIK_SCHEME
The URI scheme for the default service handler: ubik. |
static int |
UNDEFINED_PORT
This constant identifies an unidentified port. |
| Constructor Summary | |
|---|---|
ServiceLocator()
|
|
| Method Summary | |
|---|---|
static java.lang.Object |
lookup(java.lang.String url)
Performs the lookup for the given path. |
static void |
registerHandler(java.lang.String scheme,
ServiceHandler handler)
Registers the given handler with the passed in scheme. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int UNDEFINED_PORT
public static final java.lang.String HANDLER_PATTERN
public static final java.lang.String UBIK_SCHEME
JNDIHandler,
Constant Field Values| Constructor Detail |
|---|
public ServiceLocator()
| Method Detail |
|---|
public static java.lang.Object lookup(java.lang.String url)
throws javax.naming.NameNotFoundException,
javax.naming.NamingException
url - the url of the object to look up.
Object
javax.naming.NameNotFoundException - if no object could be found for the
given url.
javax.naming.NamingException - if an error occurs while performing the lookup.
public static void registerHandler(java.lang.String scheme,
ServiceHandler handler)
throws java.lang.IllegalStateException
scheme - a URI scheme.handler - a ServiceHandler.
java.lang.IllegalStateException - if a handler is already registered with the given scheme.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||