use of org.jboss.stm.internal.proxy.LockManagerProxy in project narayana by jbosstm.
the class Container method getContainer.
/**
* Given the proxy return the container that is managing it.
*
* @param proxy the instance within the container we're looking for.
* @return the container or null. Shouldn't really be possible to get null!
*/
public static final Container<?> getContainer(Object proxy) {
/*
* Rather than maintain a list of Container instances and iterate through them
* we create a clone of the Container using the real container within the
* proxy itself. Container is essentially a (almost) stateless wrapper class
* anyway so hopefully this is a lightweight and faster way of achieving this.
* Can revisit later if this creates too many instances.
*/
Container<?> toReturn = null;
if (proxy instanceof OptimisticLockManagerProxy<?>) {
RecoverableContainer<?> cont = ((OptimisticLockManagerProxy<?>) proxy).getContainer();
toReturn = new Container(cont);
} else {
if (proxy instanceof LockManagerProxy<?>) {
RecoverableContainer<?> cont = ((LockManagerProxy<?>) proxy).getContainer();
toReturn = new Container(cont);
} else
throw new IllegalArgumentException("Not a proxy object!");
}
return toReturn;
}
Aggregations