Search in sources :

Example 31 with ComponentInvocation

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;
}
Also used : ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) EJBInvocation(org.glassfish.ejb.api.EJBInvocation)

Example 32 with ComponentInvocation

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;
}
Also used : Implementor(com.sun.xml.rpc.spi.runtime.Implementor) ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) InvocationManager(org.glassfish.api.invocation.InvocationManager) EJBInvocation(org.glassfish.ejb.api.EJBInvocation)

Example 33 with ComponentInvocation

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;
}
Also used : ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) ModuleInfo(org.glassfish.internal.data.ModuleInfo) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo)

Example 34 with ComponentInvocation

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;
}
Also used : ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) EntityManagerFactory(javax.persistence.EntityManagerFactory)

Example 35 with ComponentInvocation

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;
}
Also used : JavaEEContainer(com.sun.enterprise.container.common.spi.JavaEEContainer) JavaEETransaction(com.sun.enterprise.transaction.api.JavaEETransaction) ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation)

Aggregations

ComponentInvocation (org.glassfish.api.invocation.ComponentInvocation)67 InvocationManager (org.glassfish.api.invocation.InvocationManager)13 JndiNameEnvironment (com.sun.enterprise.deployment.JndiNameEnvironment)8 EjbInvocation (com.sun.ejb.EjbInvocation)7 InvocationException (org.glassfish.api.invocation.InvocationException)7 SecurityContext (com.sun.enterprise.security.SecurityContext)6 WebModule (com.sun.enterprise.web.WebModule)6 PoolingException (com.sun.appserv.connectors.internal.api.PoolingException)5 InjectionException (com.sun.enterprise.container.common.spi.util.InjectionException)5 WebComponentInvocation (com.sun.enterprise.web.WebComponentInvocation)5 BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)4 EjbDescriptor (com.sun.enterprise.deployment.EjbDescriptor)4 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)4 JavaEETransactionManager (com.sun.enterprise.transaction.api.JavaEETransactionManager)4 RemoteException (java.rmi.RemoteException)4 EJBInvocation (org.glassfish.ejb.api.EJBInvocation)4 ArrayList (java.util.ArrayList)3 NamingException (javax.naming.NamingException)3 WeldBootstrap (org.jboss.weld.bootstrap.WeldBootstrap)3 BeanDeploymentArchive (org.jboss.weld.bootstrap.spi.BeanDeploymentArchive)3