D
- T
- public abstract class AbstractInvocationHandler<D,T> extends java.lang.Object implements java.lang.reflect.InvocationHandler, SQLProxy<D,T>
Modifier and Type | Class and Description |
---|---|
protected class |
AbstractInvocationHandler.SimpleInvoker |
Modifier and Type | Field and Description |
---|---|
protected DatabaseCluster<D> |
cluster |
protected Logger |
logger |
Modifier | Constructor and Description |
---|---|
protected |
AbstractInvocationHandler(DatabaseCluster<D> cluster,
java.lang.Class<T> proxyClass,
java.util.Map<Database<D>,T> objectMap) |
Modifier and Type | Method and Description |
---|---|
void |
addChild(SQLProxy<D,?> child) |
protected abstract void |
close(Database<D> database,
T object) |
protected abstract T |
createObject(Database<D> database) |
protected void |
detectClusterPanic(java.util.Map<java.lang.Boolean,java.util.List<Database<D>>> aliveMap)
Detect cluster panic if all conditions are met:
We're in distributable mode
We're the only group member
All alive databases are local
All dead databases are remote
|
java.util.Set<java.util.Map.Entry<Database<D>,T>> |
entries() |
java.util.Map.Entry<Database<D>,T> |
entry() |
DatabaseCluster<D> |
getDatabaseCluster() |
protected InvocationStrategy<D,T,?> |
getInvocationStrategy(T object,
java.lang.reflect.Method method,
java.lang.Object[] parameters)
Returns the appropriate
InvocationStrategy for the specified method. |
protected Invoker<D,T,?> |
getInvoker(T object,
java.lang.reflect.Method method,
java.lang.Object[] parameters)
Return the appropriate invoker for the specified method.
|
T |
getObject(Database<D> database)
Returns the underlying SQL object for the specified database.
|
void |
handleFailure(Database<D> database,
java.lang.Exception exception) |
void |
handleFailures(java.util.SortedMap<Database<D>,java.lang.Exception> exceptionMap) |
<R> java.util.SortedMap<Database<D>,R> |
handlePartialFailure(java.util.SortedMap<Database<D>,R> resultMap,
java.util.SortedMap<Database<D>,java.lang.Exception> exceptionMap) |
java.lang.Object |
invoke(java.lang.Object object,
java.lang.reflect.Method method,
java.lang.Object[] parameters) |
protected boolean |
isRecordable(java.lang.reflect.Method method) |
protected boolean |
isSQLMethod(java.lang.reflect.Method method)
Indicates whether or not the specified method accepts a SQL string as its first parameter.
|
protected void |
postInvoke(T proxy,
java.lang.reflect.Method method,
java.lang.Object[] parameters)
Called after method is invoked.
|
protected void |
record(Invoker<D,T,?> invoker,
java.lang.reflect.Method method,
java.lang.Object[] parameters) |
void |
removeChild(SQLProxy<D,?> child) |
void |
removeChildren() |
protected void |
replay(Database<D> database,
T object) |
void |
retain(java.util.Set<Database<D>> databaseSet) |
protected Logger logger
protected DatabaseCluster<D> cluster
protected AbstractInvocationHandler(DatabaseCluster<D> cluster, java.lang.Class<T> proxyClass, java.util.Map<Database<D>,T> objectMap)
cluster
- the database clusterproxyClass
- the interface being proxiedobjectMap
- a map of database to sql object.public final java.lang.Object invoke(java.lang.Object object, java.lang.reflect.Method method, java.lang.Object[] parameters) throws java.lang.Exception
invoke
in interface java.lang.reflect.InvocationHandler
java.lang.Exception
InvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
protected InvocationStrategy<D,T,?> getInvocationStrategy(T object, java.lang.reflect.Method method, java.lang.Object[] parameters) throws java.lang.Exception
InvocationStrategy
for the specified method.
This implementation detects Wrapper
methods; and Object.equals(java.lang.Object)
, Object.hashCode()
, and Object.toString()
.
Default invocation strategy is DatabaseWriteInvocationStrategy
.object
- the proxied objectmethod
- the method to invokeparameters
- the method invocation parametersjava.lang.Exception
protected Invoker<D,T,?> getInvoker(T object, java.lang.reflect.Method method, java.lang.Object[] parameters) throws java.lang.Exception
object
- method
- parameters
- java.lang.Exception
protected boolean isSQLMethod(java.lang.reflect.Method method)
method
- a methodprotected void postInvoke(T proxy, java.lang.reflect.Method method, java.lang.Object[] parameters)
proxy
- the proxied objectmethod
- the method that was just invokedparameters
- the parameters of the method that was just invokedpublic java.util.Map.Entry<Database<D>,T> entry()
entry
in interface SQLProxy<D,T>
SQLProxy.entry()
public java.util.Set<java.util.Map.Entry<Database<D>,T>> entries()
entries
in interface SQLProxy<D,T>
SQLProxy.entries()
public final void addChild(SQLProxy<D,?> child)
addChild
in interface SQLProxy<D,T>
SQLProxy.addChild(net.sf.hajdbc.sql.SQLProxy)
public final void removeChildren()
removeChildren
in interface SQLProxy<D,T>
SQLProxy.removeChildren()
public final void removeChild(SQLProxy<D,?> child)
removeChild
in interface SQLProxy<D,T>
SQLProxy.removeChild(net.sf.hajdbc.sql.SQLProxy)
public T getObject(Database<D> database)
protected abstract T createObject(Database<D> database) throws java.lang.Exception
java.lang.Exception
protected void record(Invoker<D,T,?> invoker, java.lang.reflect.Method method, java.lang.Object[] parameters)
protected boolean isRecordable(java.lang.reflect.Method method)
protected void replay(Database<D> database, T object) throws java.lang.Exception
java.lang.Exception
public final void retain(java.util.Set<Database<D>> databaseSet)
retain
in interface SQLProxy<D,T>
SQLProxy.retain(java.util.Set)
public final DatabaseCluster<D> getDatabaseCluster()
getDatabaseCluster
in interface SQLProxy<D,T>
SQLProxy.getDatabaseCluster()
public void handleFailure(Database<D> database, java.lang.Exception exception) throws java.lang.Exception
handleFailure
in interface SQLProxy<D,T>
java.lang.Exception
SQLProxy.handleFailure(net.sf.hajdbc.Database, java.lang.Exception)
public void handleFailures(java.util.SortedMap<Database<D>,java.lang.Exception> exceptionMap) throws java.lang.Exception
handleFailures
in interface SQLProxy<D,T>
java.lang.Exception
SQLProxy.handleFailures(java.util.SortedMap)
public <R> java.util.SortedMap<Database<D>,R> handlePartialFailure(java.util.SortedMap<Database<D>,R> resultMap, java.util.SortedMap<Database<D>,java.lang.Exception> exceptionMap) throws java.lang.Exception
handlePartialFailure
in interface SQLProxy<D,T>
java.lang.Exception
SQLProxy.handlePartialFailure(java.util.SortedMap, java.util.SortedMap)
protected void detectClusterPanic(java.util.Map<java.lang.Boolean,java.util.List<Database<D>>> aliveMap) throws java.lang.Exception
aliveMap
- java.lang.Exception