use of org.glassfish.api.invocation.ComponentInvocation in project Payara by payara.
the class Ejb2RuntimeEndpointInfo method getHandlerImplementor.
public AdapterInvocationInfo getHandlerImplementor() throws Exception {
ComponentInvocation inv = container.startInvocation();
AdapterInvocationInfo aInfo = new AdapterInvocationInfo();
aInfo.setInv(inv);
synchronized (this) {
if (tieClass == null) {
tieClass = Thread.currentThread().getContextClassLoader().loadClass(getEndpoint().getTieClassName());
}
if (tieInstance == null) {
tieInstance = (Tie) tieClass.newInstance();
tieInstance.setTarget((Remote) webServiceEndpointServant);
}
}
EJBInvocation.class.cast(inv).setWebServiceTie(tieInstance);
aInfo.setHandler((Handler) tieInstance);
return aInfo;
}
use of org.glassfish.api.invocation.ComponentInvocation 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.ComponentInvocation in project Payara by payara.
the class ConfigProviderResolverImpl method getAppInfo.
ApplicationInfo getAppInfo(ClassLoader loader) {
ApplicationInfo appInfo = null;
// fast check against current app
ComponentInvocation currentInvocation = invocationManager.getCurrentInvocation();
if (currentInvocation == null) {
// OK we are not a normal request see if we can find the app name from the
// app registry via the classloader
Set<String> allApplicationNames = applicationRegistry.getAllApplicationNames();
for (String allApplicationName : allApplicationNames) {
ApplicationInfo testInfo = applicationRegistry.get(allApplicationName);
if (loader.equals(testInfo.getAppClassLoader())) {
appInfo = testInfo;
return appInfo;
} else {
// search the modules within the app info to see if they have the classloader
for (ModuleInfo mi : testInfo.getModuleInfos()) {
if (loader.equals(mi.getModuleClassLoader())) {
return testInfo;
}
}
}
}
} else {
String appName = currentInvocation.getAppName();
appInfo = applicationRegistry.get(appName);
}
if (appInfo != null && appInfo.getAppClassLoader().equals(loader)) {
return appInfo;
}
// search the modules
if (appInfo != null) {
for (ModuleInfo mInfo : appInfo.getModuleInfos()) {
if (loader.equals(mInfo.getModuleClassLoader())) {
return appInfo;
}
}
}
// fast check fails search the app registry
for (String name : applicationRegistry.getAllApplicationNames()) {
ApplicationInfo testInfo = applicationRegistry.get(name);
if (testInfo.getClassLoaders().contains(loader)) {
return testInfo;
}
}
return appInfo;
}
use of org.glassfish.api.invocation.ComponentInvocation in project Payara by payara.
the class EntityManagerFactoryWrapper method lookupEntityManagerFactory.
/**
* Lookup physical EntityManagerFactory based on current component
* invocation.
* @param invMgr invocationmanager
* @param emfUnitName unit name of entity manager factory or null if not
* specified.
* @return EntityManagerFactory or null if no matching factory could be
* found.
*/
static EntityManagerFactory lookupEntityManagerFactory(InvocationManager invMgr, ComponentEnvManager compEnvMgr, String emfUnitName) {
ComponentInvocation inv = invMgr.getCurrentInvocation();
EntityManagerFactory emf = null;
if (inv != null) {
Object desc = compEnvMgr.getCurrentJndiNameEnvironment();
if (desc != null) {
emf = lookupEntityManagerFactory(inv.getInvocationType(), emfUnitName, desc);
}
}
return emf;
}
use of org.glassfish.api.invocation.ComponentInvocation in project Payara by payara.
the class EntityManagerWrapper method _getDelegate.
private EntityManager _getDelegate() {
if (entityManagerFactory == null) {
init();
}
EntityManager delegate;
if (contextType == PersistenceContextType.TRANSACTION) {
JavaEETransaction tx = getCurrentTransaction();
if (tx != null) {
// If there is an active extended persistence context
// for the same entity manager factory and the same tx,
// it takes precedence.
PhysicalEntityManagerWrapper propagatedPersistenceContext = getExtendedEntityManager(tx, entityManagerFactory);
if (propagatedPersistenceContext == null) {
propagatedPersistenceContext = getTxEntityManager(tx, entityManagerFactory);
if (propagatedPersistenceContext == null) {
// If there is a transaction and this is the first
// access of the wrapped entity manager, create an
// actual entity manager and associate it with the
// entity manager factory.
EntityManager em = entityManagerFactory.createEntityManager(synchronizationType, emProperties);
propagatedPersistenceContext = new PhysicalEntityManagerWrapper(em, synchronizationType);
tx.addTxEntityManagerMapping(entityManagerFactory, propagatedPersistenceContext);
} else {
// Check if sync type of current persistence context is compatible with persistence context being propagated
if (synchronizationType == SYNCHRONIZED && propagatedPersistenceContext.getSynchronizationType() == UNSYNCHRONIZED) {
throw new IllegalStateException("Detected an UNSYNCHRONIZED persistence context being propagated to SYNCHRONIZED persistence context.");
}
}
}
delegate = propagatedPersistenceContext.getEM();
} else {
// Get non transactional entity manager corresponding to this wrapper from current invocation
delegate = getNonTxEMFromCurrentInvocation();
}
} else {
if (extendedEntityManager == null) {
ComponentInvocation ci = invMgr.getCurrentInvocation();
if (ci != null) {
Object cc = ci.getContainer();
if (cc instanceof JavaEEContainer) {
extendedEntityManager = ((JavaEEContainer) cc).lookupExtendedEntityManager(entityManagerFactory);
}
}
}
delegate = extendedEntityManager;
}
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("In EntityManagerWrapper::_getDelegate(). " + "Logical entity manager = " + this);
_logger.fine("Physical entity manager = " + delegate);
}
return delegate;
}
Aggregations