use of org.glassfish.api.invocation.InvocationException in project Payara by payara.
the class ResourceManagerImpl method unregisterResource.
/**
* Unregister the <code>ResourceHandle</code> from the transaction
*
* @param resource <code>ResourceHandle</code> object
* @param xaresFlag flag indicating transaction success. This can
* be XAResource.TMSUCCESS or XAResource.TMFAIL
* @exception <code>PoolingException</code>
*/
public void unregisterResource(ResourceHandle resource, int xaresFlag) {
JavaEETransactionManager tm = ConnectorRuntime.getRuntime().getTransactionManager();
Transaction tran = null;
try {
// delist with TMSUCCESS if necessary
if (resource.isTransactional()) {
InvocationManager invmgr = ConnectorRuntime.getRuntime().getInvocationManager();
ComponentInvocation inv = invmgr.getCurrentInvocation();
if (inv == null) {
// in that, you return the transaction from the TxManager
try {
tran = tm.getTransaction();
} catch (Exception e) {
tran = null;
_logger.log(Level.INFO, e.getMessage());
}
} else {
tran = (Transaction) inv.getTransaction();
tm.unregisterComponentResource(resource);
}
if (tran != null && resource.isEnlisted()) {
tm.delistResource(tran, resource, xaresFlag);
}
}
} catch (SystemException ex) {
_logger.log(Level.WARNING, "poolmgr.system_exception", ex);
} catch (IllegalStateException ex) {
// transaction aborted. Do nothing
} catch (InvocationException ex) {
// unregisterResource is called outside of component context
// likely to be container-forced destroy. Do nothing
}
}
use of org.glassfish.api.invocation.InvocationException in project Payara by payara.
the class JavaEETransactionManagerSimplified method delistComponentResources.
private void delistComponentResources(ComponentInvocation inv, boolean suspend) throws InvocationException {
try {
Transaction tran = (Transaction) inv.getTransaction();
if (isTransactionActive(tran)) {
List l = getExistingResourceList(inv.getInstance(), inv);
if (l == null || l.size() == 0)
return;
int flag = (suspend) ? XAResource.TMSUSPEND : XAResource.TMSUCCESS;
Iterator it = l.iterator();
while (it.hasNext()) {
TransactionalResource h = (TransactionalResource) it.next();
try {
if (h.isEnlisted()) {
delistResource(tran, h, flag);
}
} catch (IllegalStateException ex) {
if (_logger.isLoggable(Level.FINE))
_logger.log(Level.FINE, "TM: Exception in delistResource", ex);
// ignore error due to tx time out
} catch (Exception ex) {
if (_logger.isLoggable(Level.FINE))
_logger.log(Level.FINE, "TM: Exception in delistResource", ex);
it.remove();
handleResourceError(h, ex, tran);
}
}
// END OF IASRI 4658504
}
} catch (Exception ex) {
_logger.log(Level.SEVERE, "enterprise_distributedtx.excep_in_delist", ex);
}
}
use of org.glassfish.api.invocation.InvocationException in project Payara by payara.
the class JavaEETransactionManagerSimplified method enlistComponentResources.
public void enlistComponentResources() throws RemoteException {
if (_logger.isLoggable(Level.FINE))
_logger.log(Level.FINE, "TM: enlistComponentResources");
ComponentInvocation inv = invMgr.getCurrentInvocation();
if (inv == null)
return;
try {
Transaction tran = getTransaction();
inv.setTransaction((JavaEETransaction) tran);
enlistComponentResources(inv);
} catch (InvocationException ex) {
_logger.log(Level.SEVERE, "enterprise_distributedtx.excep_in_enlist", ex);
throw new RemoteException(ex.getMessage(), ex.getNestedException());
} catch (Exception ex) {
_logger.log(Level.SEVERE, "enterprise_distributedtx.excep_in_enlist", ex);
throw new RemoteException(ex.getMessage(), ex);
}
}
use of org.glassfish.api.invocation.InvocationException 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.InvocationException in project Payara by payara.
the class PoolManagerImpl method handleLazilyAssociatedConnectionPools.
/**
* If the connections associated with the component are lazily-associatable, dissociate them.
* @param comp Component that acquired connections
* @param invToUse component invocation
*/
private void handleLazilyAssociatedConnectionPools(Object comp, ComponentInvocation invToUse) {
JavaEETransactionManager tm = getConnectorRuntime().getTransactionManager();
List list = tm.getExistingResourceList(comp, invToUse);
if (list == null) {
// have any resources and hence the existingResourcesList is null
return;
}
if (list.isEmpty())
return;
ResourceHandle[] handles = new ResourceHandle[list.size()];
handles = (ResourceHandle[]) list.toArray(handles);
for (ResourceHandle h : handles) {
if (h == null) {
_logger.log(Level.WARNING, "lazy_association.lazy_association_resource_handle");
continue;
}
ResourceSpec spec = h.getResourceSpec();
if (spec == null) {
_logger.log(Level.WARNING, "lazy_association.lazy_association_resource_spec");
continue;
}
if (spec.isLazyAssociatable()) {
// of type DissociatableManagedConnection
if (h.getResource() != null) {
javax.resource.spi.DissociatableManagedConnection mc = (javax.resource.spi.DissociatableManagedConnection) h.getResource();
if (h.isEnlisted()) {
getResourceManager(spec).delistResource(h, XAResource.TMSUCCESS);
}
try {
mc.dissociateConnections();
} catch (ResourceException re) {
InvocationException ie = new InvocationException(re.getMessage());
ie.initCause(re);
throw ie;
} finally {
if (h.getResourceState().isBusy()) {
putbackDirectToPool(h, spec.getPoolInfo());
}
}
} else {
_logger.log(Level.WARNING, "lazy_association.lazy_association_resource");
}
}
}
}
Aggregations