org.jboss.proxy.ejb
Class RetryInterceptor

java.lang.Object
  extended by org.jboss.proxy.Interceptor
      extended by org.jboss.proxy.ejb.RetryInterceptor
All Implemented Interfaces:
Externalizable, Serializable
Direct Known Subclasses:
SingleRetryInterceptor

public class RetryInterceptor
extends Interceptor

An interceptor that will retry failed invocations by restoring the InvocationContext invoker. This is triggered by a ServiceUnavailableException which causes the interceptor to fall into a while loop that retries the lookup of the transport invoker using the jndi name obtained from the invocation context under the key InvocationKey.JNDI_NAME, with the additional extension of "-RemoteInvoker" if the invocation type is InvocationType.REMOTE and "-HomeInvoker" if the invocation type is InvocationType.HOME. The JNDI environment used for the lookup can be set via the setRetryEnv. Typically this is an HA-JNDI configuration with one or more bootstrap urls. If not set, an attempt will be made to use NamingContextFactory.getInitialContext(Hashtable) to find the JNDI environment. This will only be useful if java.naming.factory.initial was set to org.jboss.naming.NamingContextFactory. If neither of the above steps yield a set of naming environment properties, a default InitialContext will be used.

Version:
$Revision: 57209 $
Author:
Scott.Stark@jboss.org, brian.stansberry@jboss.org
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jboss.proxy.Interceptor
nextInterceptor
 
Constructor Summary
  RetryInterceptor()
          No-argument constructor for externalization.
protected RetryInterceptor(int maxRetries, long sleepTime)
          Create a new RetryInterceptor that will retry the specified number of times.
 
Method Summary
 int getMaxRetries()
          Gets the maximum number of retries that will be attempted.
 boolean getRetry()
           
 long getSleepTime()
          Gets the number of ms of sleep between each retry attempt.
 Object invoke(Invocation invocation)
          InvocationHandler implementation.
 void readExternal(ObjectInput in)
          Reads the next interceptor.
 void setMaxRetries(int maxRetries)
          Sets the maximum number of retries that will be attempted.
 void setRetry(boolean flag)
           
static void setRetryEnv(Properties env)
          Set the HA-JNDI InitialContext env used to lookup the invoker proxy
 void setSleepTime(long sleepTime)
          Sets the number of ms of sleep between each retry attempt.
 void writeExternal(ObjectOutput out)
          Writes the next interceptor.
 
Methods inherited from class org.jboss.proxy.Interceptor
getNext, setNext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RetryInterceptor

public RetryInterceptor()
No-argument constructor for externalization.


RetryInterceptor

protected RetryInterceptor(int maxRetries,
                           long sleepTime)
Create a new RetryInterceptor that will retry the specified number of times.

Parameters:
maxRetries - the maximum number of retries to attempt. -1 (the default) means retry until successful.
sleepTime - number of ms to pause between each retry attempt
Method Detail

setRetryEnv

public static void setRetryEnv(Properties env)
Set the HA-JNDI InitialContext env used to lookup the invoker proxy

Parameters:
env - the InitialContext env used to lookup the invoker proxy

setRetry

public void setRetry(boolean flag)

getRetry

public boolean getRetry()

getMaxRetries

public int getMaxRetries()
Gets the maximum number of retries that will be attempted.


setMaxRetries

public void setMaxRetries(int maxRetries)
Sets the maximum number of retries that will be attempted.

Parameters:
maxRetries - the maximum number of retries to attempt. -1 (the default) means retry until successful.

getSleepTime

public long getSleepTime()
Gets the number of ms of sleep between each retry attempt.


setSleepTime

public void setSleepTime(long sleepTime)
Sets the number of ms of sleep between each retry attempt.


invoke

public Object invoke(Invocation invocation)
              throws Throwable
InvocationHandler implementation.

Specified by:
invoke in class Interceptor
Throws:
Throwable - Any exception or error thrown while processing.

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Writes the next interceptor.

Specified by:
writeExternal in interface Externalizable
Overrides:
writeExternal in class Interceptor
Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Reads the next interceptor.

Specified by:
readExternal in interface Externalizable
Overrides:
readExternal in class Interceptor
Throws:
IOException
ClassNotFoundException


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.