FileDocCategorySizeDatePackage
HttpProxyFactoryHA.javaAPI DocJBoss 4.2.16888Fri Jul 13 20:52:40 BST 2007org.jboss.invocation.http.server

HttpProxyFactoryHA

public class HttpProxyFactoryHA extends HttpProxyFactory implements HttpProxyFactoryHAMBean
An extension of HttpProxyFactory that supports clustering of invoker proxies. It does this by creating a HATarget that monitors the replication of the invoker url and creates a HAInvokerWrapper that handles wrapping the underlying invocation result with changes to the HATarget replication view.
author
Scott Stark
version
$Revision: 57188 $

Fields Summary
private ObjectName
realJmxInvokerName
private ObjectName
wrappedJmxInvokerName
private String
partitionName
private Class
policyClass
private HAInvokerWrapper
invokerWrapper
private org.jboss.ha.framework.server.HATarget
invokerTarget
Constructors Summary
Methods Summary
protected org.jboss.invocation.InvokercreateInvoker()
Override the HttpProxyFactory method to create a HttpInvokerProxyHA.

return
throws
Exception

      InitialContext iniCtx = new InitialContext();
      HAPartition partition = (HAPartition) iniCtx.lookup("/HAPartition/" + partitionName);

      /* Create a HATarget for the local invoker mbean stub. The name passed
      to the HATarget must be the wrappedJmxInvokerName so that different
      more than one HttpProxyFactoryHA may be configured for the same
      realJmxInvokerName.
      */
      checkInvokerURL();
      Serializable invokerStub = super.getInvokerURL();
      invokerTarget = new HATarget(partition, wrappedJmxInvokerName.toString(),
         invokerStub, HATarget.MAKE_INVOCATIONS_WAIT);
      log.debug("Created invoker: "+invokerTarget);
      // Create and register the invoker wrapper
      MBeanServer mbeanServer = super.getServer();
      invokerWrapper = new HAInvokerWrapper(mbeanServer, realJmxInvokerName, invokerTarget);
      mbeanServer.registerMBean(invokerWrapper, wrappedJmxInvokerName);

      // Create the LoadBalancePolicy instance
      LoadBalancePolicy policy = (LoadBalancePolicy) policyClass.newInstance();

      // Finally, create the invoker proxy, a HttpInvokerProxyHA
      String clusterFamilyName = partitionName + "/" + wrappedJmxInvokerName.toString();
      Invoker delegateInvoker = new HttpInvokerProxyHA(invokerTarget.getReplicants(), invokerTarget.getCurrentViewId (),
                                                       policy, clusterFamilyName);
      return delegateInvoker;
   
protected java.util.ArrayListdefineInterceptors()

      ArrayList interceptorClasses = new ArrayList();
      interceptorClasses.add(ClientMethodInterceptorHA.class);
      interceptorClasses.add(InvokerInterceptor.class);
      return interceptorClasses;
   
public voiddestroy()
Destroys the HATarget

      super.destroy();
      try
      {
         invokerTarget.destroy();
      }
      catch(Exception ignore)
      {
      }
   
public java.lang.ClassgetLoadBalancePolicy()
Get the server side mbean that exposes the invoke operation for the exported interface


                     
     
   
      return this.policyClass;
   
public java.lang.StringgetPartitionName()
Get the name of the cluster partition the invoker is deployed in

      return this.partitionName;
   
public javax.management.ObjectNamegetRealJmxInvokerName()

return
the ObjectName the HAInvokerWrapper delegates to

      return realJmxInvokerName;
   
public voidsetInvokerName(javax.management.ObjectName jmxInvokerName)
Override the superclass method to create a wrapped ObjectName for the HAInvokerWrapper mbean. This will be the name of the invoker as known by the proxy. The HAInvokerWrapper is the HttpProxyFactoryHA name + wrapperType=httpHA

param
jmxInvokerName

      realJmxInvokerName = jmxInvokerName;
      ObjectName factoryName = getServiceName();
      Hashtable props = factoryName.getKeyPropertyList();
      props.put("wrapperType", "httpHA");
      try
      {
         wrappedJmxInvokerName = new ObjectName(factoryName.getDomain(), props);
         super.setInvokerName(wrappedJmxInvokerName);
      }
      catch(MalformedObjectNameException e)
      {
         throw new IllegalStateException("Was not able to create wrapped ObjectName");
      }
   
public voidsetLoadBalancePolicy(java.lang.Class policyClass)
Set the server side mbean that exposes the invoke operation for the exported interface

      this.policyClass = policyClass;
   
public voidsetPartitionName(java.lang.String name)
Set the name of the cluster partition the invoker is deployed in

      this.partitionName = name;
   
protected voidstopService()
Override the HttpProxyFactory stop to unregister the HAInvokerWrapper mbean

throws
Exception

      try
      {
         MBeanServer mbeanServer = super.getServer();
         mbeanServer.unregisterMBean(wrappedJmxInvokerName);
      }
      catch(Exception e)
      {
         log.debug("Failed to unregister HAInvokerWrapper: "+wrappedJmxInvokerName, e);
      }
      super.stopService();