06-15-2010 07:57 AM
public class MyJOB extends QuartzJobBean {
private ActionService actionService;
private AuthenticationComponent authenticationComponent;
private TransactionService transactionService;
protected void executeInternal(JobExecutionContext jobContext) {
Authentication currentAuthentication = getAuthenticationComponent().getCurrentAuthentication();
// authenticate as system user
getAuthenticationComponent().setSystemUserAsCurrentUser();
UserTransaction tx = null;
try {
tx = getTransactionService().getUserTransaction();
tx.begin();
Action myJobEx= getActionService().createAction(MyJOBExecuter.NAME);
getActionService().executeAction(myJobEx, null);
} catch (Throwable err) {
err.printStackTrace();
try {
if (tx != null) {
tx.rollback();
}
} catch (Exception tex) {
}
} finally {
// restore user security context
getAuthenticationComponent().setCurrentAuthentication(currentAuthentication);
}
}
public void setAuthenticationComponent(AuthenticationComponent authenticationComponent) {
this.authenticationComponent = authenticationComponent;
}
public AuthenticationComponent getAuthenticationComponent() {
return authenticationComponent;
}
public void setActionService(ActionService actionService) {
this.actionService = actionService;
}
public ActionService getActionService() {
return actionService;
}
public void setTransactionService(TransactionService transactionService) {
this.transactionService = transactionService;
}
public TransactionService getTransactionService() {
return transactionService;
}
06-15-2010 08:31 AM
12-22-2011 11:30 AM
finally {
// restore user security context
authenticationComponent
.setCurrentAuthentication(currentAuthentication);
try {
if (tx != null) {
tx.rollback();
}
} catch (Exception tex) {
}
}
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.