[New] Added tx.getPolicy(Class<T> clazz, ...) overrides
Old version are deprecated. This is to help the compiler know what we really want as result. This is a stop gap till we can make PolicyDef be typed, but this requires moving StrolchPolicy to model.
This commit is contained in:
parent
35bf9261e6
commit
87804809f3
|
@ -317,7 +317,7 @@ public abstract class AbstractTransaction implements StrolchTransaction {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends StrolchRootElement> void releaseLock(Locator locator) throws StrolchLockException {
|
public void releaseLock(Locator locator) throws StrolchLockException {
|
||||||
this.realm.releaseLock(locator);
|
this.realm.releaseLock(locator);
|
||||||
this.lockedElements.remove(locator);
|
this.lockedElements.remove(locator);
|
||||||
}
|
}
|
||||||
|
@ -419,15 +419,27 @@ public abstract class AbstractTransaction implements StrolchTransaction {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public <T extends StrolchPolicy> T getPolicy(PolicyDef policyDef) {
|
public <T extends StrolchPolicy> T getPolicy(PolicyDef policyDef) {
|
||||||
return getContainer().getComponent(PolicyHandler.class).getPolicy(policyDef, this);
|
return getContainer().getComponent(PolicyHandler.class).getPolicy(policyDef, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public <T extends StrolchPolicy> T getPolicy(Class<T> clazz, PolicyDef policyDef) {
|
||||||
|
return getContainer().getComponent(PolicyHandler.class).getPolicy(policyDef, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
public <T extends StrolchPolicy> T getPolicy(PolicyDef policyDef, PolicyDef defaultDef) {
|
public <T extends StrolchPolicy> T getPolicy(PolicyDef policyDef, PolicyDef defaultDef) {
|
||||||
return getContainer().getComponent(PolicyHandler.class).getPolicy(policyDef, defaultDef, this);
|
return getContainer().getComponent(PolicyHandler.class).getPolicy(policyDef, defaultDef, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends StrolchPolicy> T getPolicy(Class<T> clazz, PolicyDef policyDef, PolicyDef defaultDef) {
|
||||||
|
return getContainer().getComponent(PolicyHandler.class).getPolicy(policyDef, defaultDef, this);
|
||||||
|
}
|
||||||
|
|
||||||
private void assertQueryAllowed(StrolchQuery query) {
|
private void assertQueryAllowed(StrolchQuery query) {
|
||||||
try {
|
try {
|
||||||
getPrivilegeContext().validateAction(query);
|
getPrivilegeContext().validateAction(query);
|
||||||
|
|
|
@ -238,9 +238,26 @@ public interface StrolchTransaction extends AutoCloseable {
|
||||||
* the type of policy to return
|
* the type of policy to return
|
||||||
*
|
*
|
||||||
* @return the policy
|
* @return the policy
|
||||||
|
*
|
||||||
|
* @deprecated use {@link #getPolicy(Class, PolicyDef)} instead
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
<T extends StrolchPolicy> T getPolicy(PolicyDef policyDef);
|
<T extends StrolchPolicy> T getPolicy(PolicyDef policyDef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates the policy using the given {@link PolicyDef}
|
||||||
|
*
|
||||||
|
* @param clazz
|
||||||
|
* the type of policy to return
|
||||||
|
* @param policyDef
|
||||||
|
* the policy definition
|
||||||
|
* @param <T>
|
||||||
|
* the type of policy to return
|
||||||
|
*
|
||||||
|
* @return the policy
|
||||||
|
*/
|
||||||
|
<T extends StrolchPolicy> T getPolicy(Class<T> clazz, PolicyDef policyDef);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates the policy using the given {@link PolicyDef}, or if not available, the default policy
|
* Instantiates the policy using the given {@link PolicyDef}, or if not available, the default policy
|
||||||
*
|
*
|
||||||
|
@ -252,9 +269,28 @@ public interface StrolchTransaction extends AutoCloseable {
|
||||||
* the type of policy to return
|
* the type of policy to return
|
||||||
*
|
*
|
||||||
* @return the policy
|
* @return the policy
|
||||||
|
*
|
||||||
|
* @deprecated user {@link #getPolicy(Class, PolicyDef, PolicyDef)} instead
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
<T extends StrolchPolicy> T getPolicy(PolicyDef policyDef, PolicyDef defaultDef);
|
<T extends StrolchPolicy> T getPolicy(PolicyDef policyDef, PolicyDef defaultDef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates the policy using the given {@link PolicyDef}, or if not available, the default policy
|
||||||
|
*
|
||||||
|
* @param clazz
|
||||||
|
* the type of policy to return
|
||||||
|
* @param policyDef
|
||||||
|
* the policy definition
|
||||||
|
* @param defaultDef
|
||||||
|
* the default policy definition if the given policy definition is unavailable
|
||||||
|
* @param <T>
|
||||||
|
* the type of policy to return
|
||||||
|
*
|
||||||
|
* @return the policy
|
||||||
|
*/
|
||||||
|
<T extends StrolchPolicy> T getPolicy(Class<T> clazz, PolicyDef policyDef, PolicyDef defaultDef);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the currently set {@link TransactionCloseStrategy}
|
* Returns the currently set {@link TransactionCloseStrategy}
|
||||||
*
|
*
|
||||||
|
@ -324,6 +360,7 @@ public interface StrolchTransaction extends AutoCloseable {
|
||||||
* StrolchTransactionException} which can be thrown by the caller to stop the exception
|
* StrolchTransactionException} which can be thrown by the caller to stop the exception
|
||||||
*
|
*
|
||||||
* @param exceptionMessage
|
* @param exceptionMessage
|
||||||
|
* the message with which this TX has failed
|
||||||
*
|
*
|
||||||
* @return a {@link StrolchTransactionException} to be thrown by the caller
|
* @return a {@link StrolchTransactionException} to be thrown by the caller
|
||||||
*/
|
*/
|
||||||
|
@ -505,7 +542,7 @@ public interface StrolchTransaction extends AutoCloseable {
|
||||||
* @throws StrolchLockException
|
* @throws StrolchLockException
|
||||||
* if something goes wrong while unlocking
|
* if something goes wrong while unlocking
|
||||||
*/
|
*/
|
||||||
<T extends StrolchRootElement> void releaseLock(Locator locator) throws StrolchLockException;
|
void releaseLock(Locator locator) throws StrolchLockException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the given {@link Command} to the transaction. Using this method guarantees that a {@link Command} is
|
* Adds the given {@link Command} to the transaction. Using this method guarantees that a {@link Command} is
|
||||||
|
|
Loading…
Reference in New Issue