[jboss-user] [Remoting] - Re: Remoting using Http over a singel port

dreyk do-not-reply at jboss.com
Wed Jul 26 04:31:06 EDT 2006


While jboss server deploy ejb3 module,it properly find default ClientBindUrl
from ejb3.deployer/META-INF/jboss-service.xml see Ejb3JmxDeployment.java :
public String getDefaultClientBinding()
  |    {
  | 	  
  |       try
  |       {
  |          ObjectName on = new ObjectName("jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3");
  |          ConnectorMBean connector = (ConnectorMBean) MBeanProxyExt.create(ConnectorMBean.class, on, deploymentInfo.getServer());
  |          String uri = connector.getInvokerLocator();
  |          return connector.getInvokerLocator();
  |       }
  |       catch (Exception e)
  |       {
  |          throw new RuntimeException(e);
  |       }
  |    }

This method always invoking during deployment, and aftter that deployer set property defaultClientBinding in class ProxyDeployer to correct value.
But after that server invoke method initializeRemoteBindingMetadata() in ProxyDeployer class, and if it can't find RemoteBinding anntation it will be use defaultClientBinding from jboss-service.xml and default jndi binding, but if it find this annatation in deployed ejb it will be use RemoteBinding from whith ejb,where default value is socket://0.0.0.0:XXXX, that is why you can change this code for use defaultClientBinding from jboss-service.xml. But preffer is define in RemoteBinding annatotion default value for clientBindUrl to "" and in method initializeRemoteBindingMetadata() chek that this property not set to some value diferent from default and set it to property defaultClientBinding.
see Original code:
public void initializeRemoteBindingMetadata()
  |    {
  | 	   
  |       remoteBindings = (RemoteBindings) advisor.resolveAnnotation(RemoteBindings.class);
  |       if (remoteBindings == null)
  |       {
  |          RemoteBinding binding = (RemoteBinding) advisor.resolveAnnotation(RemoteBinding.class);
  |          if (binding == null)
  |          {
  |             log.debug("no declared remote bindings for : " + container.getEjbName());
  |             if (ProxyFactoryHelper.getRemoteInterfaces(container) != null)
  |             {
  |                log.debug("there is remote interfaces for " + container.getEjbName());
  |                String jndiName = ProxyFactoryHelper.getDefaultRemoteJndiName(container);
  |                log.debug("default remote binding has jndiName of " + jndiName);
  |                // todo we need to have a way to define default configuration
  |                String uri = defaultClientBinding;
  |                Class factory = null;
  |                factory = getDefaultRemoteProxyFactory();
  |                RemoteBinding[] list = {new RemoteBindingImpl(jndiName, "", uri, factory)};
  |                remoteBindings = new RemoteBindingsImpl(list);
  |                advisor.getAnnotations().addClassAnnotation(RemoteBindings.class, remoteBindings);
  |             }
  |          }
  |          else
  |          {
  |         	
  |         	RemoteBinding[] list = {binding};
  |         	remoteBindings = new RemoteBindingsImpl(list);
  |             advisor.getAnnotations().addClassAnnotation(RemoteBindings.class, remoteBindings);
  |          }
  |       }
  |    }

and changed code:
  public void initializeRemoteBindingMetadata()
  |    {
  | 	   
  |       remoteBindings = (RemoteBindings) advisor.resolveAnnotation(RemoteBindings.class);
  |       if (remoteBindings == null)
  |       {
  |          RemoteBinding binding = (RemoteBinding) advisor.resolveAnnotation(RemoteBinding.class);
  |          if (binding == null)
  |          {
  |             log.debug("no declared remote bindings for : " + container.getEjbName());
  |             if (ProxyFactoryHelper.getRemoteInterfaces(container) != null)
  |             {
  |                log.debug("there is remote interfaces for " + container.getEjbName());
  |                String jndiName = ProxyFactoryHelper.getDefaultRemoteJndiName(container);
  |                log.debug("default remote binding has jndiName of " + jndiName);
  |                // todo we need to have a way to define default configuration
  |                String uri = defaultClientBinding;
  |                Class factory = null;
  |                factory = getDefaultRemoteProxyFactory();
  |                RemoteBinding[] list = {new RemoteBindingImpl(jndiName, "", uri, factory)};
  |                remoteBindings = new RemoteBindingsImpl(list);
  |                advisor.getAnnotations().addClassAnnotation(RemoteBindings.class, remoteBindings);
  |             }
  |          }
  |          else
  |          {
  |         	 //if user define clientBindUrl than use binding.clientBindUrl()
  |         	if(binding.clientBindUrl().equals("")){
  |         		RemoteBinding[] list = {new RemoteBindingImpl(binding.jndiBinding(),binding.interceptorStack(),defaultClientBinding,binding.factory())};
  |         		remoteBindings = new RemoteBindingsImpl(list);
  |         	}
  |         	else{
  |         		RemoteBinding[] list = {binding};
  |             	remoteBindings = new RemoteBindingsImpl(list);
  |         	}
  |             advisor.getAnnotations().addClassAnnotation(RemoteBindings.class, remoteBindings);
  |          }
  |       }
  |    }

String clientBindUrl() default ""; in org.jboss.annotation.ejb.RemoteBinding

But I think preffer solution for this problem it's define new annatation for clientBindUrl and in this method check only existinse this annataton.



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3960897#3960897

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3960897



More information about the jboss-user mailing list