Handle @RemoteBinding.clientBindUrl defaults when unspecified
-------------------------------------------------------------
Key: EJBTHREE-1419
URL:
http://jira.jboss.com/jira/browse/EJBTHREE-1419
Project: EJB 3.0
Issue Type: Task
Components: proxy
Reporter: Andrew Lee Rubinger
Assigned To: Andrew Lee Rubinger
Fix For: AS 5.0.0.CR2
Current implementation has logic that must be reworked into the Proxy component to provide
intelligent defaults for the clientBindUrl in the case that it's unspecified by the
developer (most cases):
public static String getClientBindUrl(RemoteBinding binding) throws Exception
{
String clientBindUrl = binding.clientBindUrl();
if (clientBindUrl.trim().length() == 0)
{
if (binding.invokerName()!=null && binding.invokerName().trim().length()
!= 0)
{
try
{
ObjectName connectionON = new ObjectName(binding.invokerName());
KernelAbstraction kernelAbstraction =
KernelAbstractionFactory.getInstance();
clientBindUrl = (String)kernelAbstraction.getAttribute(connectionON,
"InvokerLocator");
}
catch (Exception e)
{
log.warn("Unable to find InvokerLocator " + binding.invokerName()
+ ". Using default. " + e);
clientBindUrl = RemoteProxyFactory.DEFAULT_CLIENT_BINDING;
}
}
else
{
try
{
ObjectName connectionON = new
ObjectName("jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3");
KernelAbstraction kernelAbstraction =
KernelAbstractionFactory.getInstance();
clientBindUrl = (String)kernelAbstraction.getAttribute(connectionON,
"InvokerLocator");
}
catch (Exception e)
{
log.warn("Unable to find default InvokerLocator. Using default. "
+ e);
clientBindUrl = RemoteProxyFactory.DEFAULT_CLIENT_BINDING;
}
}
}
else if (clientBindUrl.indexOf("0.0.0.0") != -1)
{
KernelAbstraction kernelAbstraction = KernelAbstractionFactory.getInstance();
ObjectName query = new
ObjectName("jboss.remoting:type=Connector,handler=ejb3,*");
Set mbeanSet = kernelAbstraction.getMBeans(query);
URI targetUri = new URI(clientBindUrl);
Iterator mbeans = mbeanSet.iterator();
while (mbeans.hasNext())
{
ObjectInstance invokerInstance = (ObjectInstance)mbeans.next();
ObjectName invokerName = invokerInstance.getObjectName();
String invokerLocator = (String)kernelAbstraction.getAttribute(invokerName,
"InvokerLocator");
URI uri = new URI(invokerLocator);
if (uri.getScheme().equals(targetUri.getScheme()) && uri.getPort() ==
targetUri.getPort())
{
return invokerLocator;
}
}
}
if (clientBindUrl == null)
clientBindUrl = RemoteProxyFactory.DEFAULT_CLIENT_BINDING;
return clientBindUrl;
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira