use of org.glassfish.api.invocation.InvocationManager in project Payara by payara.
the class ImplementorCacheDelegateImpl method getImplementorFor.
public Implementor getImplementorFor(RuntimeEndpointInfo targetEndpoint) {
Implementor implementor = null;
try {
synchronized (targetEndpoint) {
implementor = (Implementor) implementorCache_.get(targetEndpoint);
if (implementor == null) {
implementor = createImplementor(targetEndpoint);
implementorCache_.put(targetEndpoint, implementor);
}
}
WebServiceContractImpl wscImpl = WebServiceContractImpl.getInstance();
InvocationManager invManager = wscImpl.getInvocationManager();
ComponentInvocation inv = invManager.getCurrentInvocation();
if (inv instanceof EJBInvocation)
((EJBInvocation) inv).setWebServiceTie(implementor.getTie());
} catch (Throwable t) {
RuntimeException re = new RuntimeException();
re.initCause(t);
throw re;
}
return implementor;
}
use of org.glassfish.api.invocation.InvocationManager in project Payara by payara.
the class ResourceManagerImpl method rollBackTransaction.
/**
* Get's the component's transaction and marks it for rolling back.
*/
public void rollBackTransaction() {
InvocationManager invmgr = ConnectorRuntime.getRuntime().getInvocationManager();
JavaEETransactionManager tm = ConnectorRuntime.getRuntime().getTransactionManager();
Transaction tran = null;
try {
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();
}
if (tran != null) {
tran.setRollbackOnly();
}
} catch (SystemException ex) {
_logger.log(Level.WARNING, "poolmgr.system_exception", ex);
} catch (IllegalStateException ex) {
// ignore
}
}
use of org.glassfish.api.invocation.InvocationManager in project Payara by payara.
the class ResourceManagerImpl method registerResource.
/**
* Register the <code>ResourceHandle</code> in the transaction
*
* @param handle <code>ResourceHandle</code> object
* @exception <code>PoolingException</code>
*/
public void registerResource(ResourceHandle handle) throws PoolingException {
try {
Transaction tran = null;
JavaEETransactionManager tm = ConnectorRuntime.getRuntime().getTransactionManager();
// enlist if necessary
if (handle.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.registerComponentResource(handle);
}
if (tran != null) {
try {
tm.enlistResource(tran, handle);
} catch (Exception ex) {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Exception whle trying to enlist resource " + ex.getMessage());
}
// to enlist the resource
if (inv != null) {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Attempting to unregister component resource");
}
tm.unregisterComponentResource(handle);
}
throw ex;
}
}
}
} catch (Exception ex) {
_logger.log(Level.SEVERE, "poolmgr.component_register_exception", ex);
throw new PoolingException(ex.toString(), ex);
}
}
use of org.glassfish.api.invocation.InvocationManager in project Payara by payara.
the class ResourceManagerImpl method getComponent.
/**
* Returns the component invoking resource request.
*
* @return Handle to the component.
*/
public Object getComponent() {
InvocationManager invmgr = ConnectorRuntime.getRuntime().getInvocationManager();
ComponentInvocation inv = invmgr.getCurrentInvocation();
if (inv == null) {
return null;
}
return inv.getInstance();
}
use of org.glassfish.api.invocation.InvocationManager in project Payara by payara.
the class GlassfishNamingManagerImpl method getComponentId.
/**
* Get the component id from the Invocation Manager.
*
* @return the component id as a string.
*/
private String getComponentId() throws NamingException {
String id;
ComponentInvocation ci;
if (invMgr == null) {
ci = habitat.<InvocationManager>getService(InvocationManager.class).getCurrentInvocation();
} else {
ci = invMgr.getCurrentInvocation();
}
if (ci == null) {
throw new NamingException("Invocation exception: Got null ComponentInvocation ");
}
try {
id = ci.getComponentId();
if (id == null) {
throw new NamingException("Invocation exception: ComponentId is null");
}
} catch (Throwable th) {
NamingException ine = new NamingException("Invocation exception: " + th);
ine.initCause(th);
throw ine;
}
return id;
}
Aggregations