use of org.glassfish.api.invocation.ComponentInvocation in project Payara by payara.
the class UserTransactionImpl method setRollbackOnly.
public void setRollbackOnly() throws IllegalStateException, SystemException {
if (!initialized)
init();
if (userTx != null) {
userTx.setRollbackOnly();
return;
}
ComponentInvocation inv = invocationManager.getCurrentInvocation();
if (inv != null) {
checkUserTransactionMethodAccess(inv);
}
transactionManager.setRollbackOnly();
}
use of org.glassfish.api.invocation.ComponentInvocation in project Payara by payara.
the class EJBSecurityManager method postInvoke.
/**
* This method is used by Message Driven Bean Container to remove
* the run-as identity information that was set up using the
* preSetRunAsIdentity method
*/
public void postInvoke(ComponentInvocation inv) {
if (runAs != null && inv.isPreInvokeDone()) {
final ComponentInvocation finv = inv;
AppservAccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
SecurityContext.setCurrent((SecurityContext) finv.getOldSecurityContext());
return null;
}
});
}
}
use of org.glassfish.api.invocation.ComponentInvocation in project Payara by payara.
the class EJBSecurityManager method getCallerPrincipal.
/**
* This method returns the Client Principal who initiated the current
* Invocation.
*
* @return A Principal object of the client who made this invocation.
* or null if the SecurityContext has not been established by the client.
*/
public Principal getCallerPrincipal() {
SecurityContext sc = null;
if (runAs != null) {
// Run As
// return the principal associated with the old security context
ComponentInvocation ci = invMgr.getCurrentInvocation();
if (ci == null) {
// 4646060
throw new InvocationException();
}
sc = (SecurityContext) ci.getOldSecurityContext();
} else {
// lets optimize a little. no need to look up oldsecctx
// its the same as the new one
sc = SecurityContext.getCurrent();
}
Principal prin;
if (sc != null) {
prin = sc.getCallerPrincipal();
} else {
prin = SecurityContext.getDefaultCallerPrincipal();
}
return prin;
}
use of org.glassfish.api.invocation.ComponentInvocation in project Payara by payara.
the class MessageBeanContainer method cleanupResources.
private void cleanupResources() {
ComponentInvocation componentInvocation = createComponentInvocation();
ASyncClientShutdownTask task = new ASyncClientShutdownTask(appEJBName_, messageBeanClient_, loader, messageBeanPool_, componentInvocation);
long timeout = 0;
try {
timeout = ejbContainerUtilImpl.getServices().getService(ConnectorRuntime.class).getShutdownTimeout();
} catch (Throwable th) {
_logger.log(Level.WARNING, "[MDBContainer] Got exception while trying " + " to get shutdown timeout", th);
}
try {
boolean addedAsyncTask = false;
if (timeout > 0) {
try {
ejbContainerUtilImpl.addWork(task);
addedAsyncTask = true;
} catch (Throwable th) {
// Since we got an exception while trying to add the async
// task
// we will have to do the cleanup in the current thread
// itself.
addedAsyncTask = false;
_logger.log(WARNING, "[MDBContainer] Got exception while trying " + "to add task to ContainerWorkPool. Will execute " + "cleanupResources on current thread", th);
}
}
if (addedAsyncTask) {
synchronized (task) {
if (!task.isDone()) {
_logger.log(Level.FINE, "[MDBContainer] " + "Going to wait for a maximum of " + timeout + " mili-seconds.");
long maxWaitTime = System.currentTimeMillis() + timeout;
// wait in loop to guard against spurious wake-up
do {
long timeTillTimeout = maxWaitTime - System.currentTimeMillis();
if (timeTillTimeout <= 0)
break;
task.wait(timeTillTimeout);
} while (!task.isDone());
}
if (!task.isDone()) {
_logger.log(Level.WARNING, "[MDBContainer] ASync task has not finished. " + "Giving up after " + timeout + " mili-seconds.");
} else {
_logger.log(Level.FINE, "[MDBContainer] ASync task has completed");
}
}
} else {
// Execute in the same thread
_logger.log(Level.FINE, "[MDBContainer] Attempting to do cleanup()in current thread...");
task.run();
_logger.log(Level.FINE, "[MDBContainer] Current thread done cleanup()... ");
}
} catch (InterruptedException inEx) {
_logger.log(Level.SEVERE, "containers.mdb.cleanup_exception", new Object[] { appEJBName_, inEx.toString() });
} catch (Exception ex) {
_logger.log(Level.SEVERE, "containers.mdb.cleanup_exception", new Object[] { appEJBName_, ex.toString() });
}
}
use of org.glassfish.api.invocation.ComponentInvocation in project Payara by payara.
the class TransactionalInterceptorBase method setTransactionalTransactionOperationsManger.
void setTransactionalTransactionOperationsManger(boolean userTransactionMethodsAllowed) {
if (testTransactionManager != null) {
// test
return;
}
ComponentInvocation currentInvocation = getCurrentInvocation();
if (currentInvocation == null) {
_logger.log(WARNING, CDI_JTA_NOCOMPONENT);
return;
}
preexistingTransactionOperationsManager = (TransactionOperationsManager) currentInvocation.getTransactionOperationsManager();
currentInvocation.setTransactionOperationsManager(userTransactionMethodsAllowed ? transactionalTransactionOperationsManagerTransactionMethodsAllowed : transactionalTransactionOperationsManagerTransactionMethodsNotAllowed);
}
Aggregations