{
throw new NullPointerException("locator cannot be null");
}
synchronized(clientLock)
{
ClientInvoker invoker = getRegisteredClientInvoker(locator, configuration);
if(invoker != null)
{
if(trace) { log.trace("Found and returning cached client invoker (" + invoker + ")"); }
return invoker;
}
boolean isForceRemote = false;
boolean isPassByValue = false;
Map parameters = locator.getParameters();
if(parameters != null)
{
String value = (String) parameters.get(InvokerLocator.BYVALUE);
if(value != null && Boolean.valueOf(value).booleanValue())
{
isPassByValue = true;
}
value = (String) parameters.get(InvokerLocator.FORCE_REMOTE);
if(value != null && Boolean.valueOf(value).booleanValue())
{
isForceRemote = true;
}
}
// configuration map will override locator params
if(configuration != null)
{
String value = (String) configuration.get(InvokerLocator.BYVALUE);
if(value != null && Boolean.valueOf(value).booleanValue())
{
isPassByValue = true;
}
value = (String) configuration.get(InvokerLocator.FORCE_REMOTE);
if(value != null && Boolean.valueOf(value).booleanValue())
{
isForceRemote = true;
}
}
// Check to see if server invoker is local
// If in server locators map, then created locally by this class
ServerInvoker svrInvoker = (ServerInvoker) serverLocators.get(locator);
if(svrInvoker != null && !isForceRemote)
{
LocalClientInvoker localInvoker = new LocalClientInvoker(locator, configuration, isPassByValue);
// have to set reference to local server invoker so client in invoke directly
localInvoker.setServerInvoker(svrInvoker);
invoker = localInvoker;
InvokerLocator l = invoker.getLocator();
addRegisteredClientInvoker(invoker, l, configuration);
}
else //not local
{
String protocol = locator.getProtocol();
if(protocol == null)
{
throw new NullPointerException("protocol cannot be null for the locator");
}
invoker = loadClientInvoker(protocol, locator, configuration);
InvokerLocator l = invoker.getLocator();
addRegisteredClientInvoker(invoker, l, configuration);
}
return invoker;
}