Search in sources :

Example 56 with ComponentInvocation

use of org.glassfish.api.invocation.ComponentInvocation in project Payara by payara.

the class UserTransactionImpl method setTransactionTimeout.

public void setTransactionTimeout(int seconds) throws SystemException {
    if (!initialized)
        init();
    if (userTx != null) {
        userTx.setTransactionTimeout(seconds);
        return;
    }
    ComponentInvocation inv = invocationManager.getCurrentInvocation();
    if (inv != null) {
        checkUserTransactionMethodAccess(inv);
    }
    transactionManager.setTransactionTimeout(seconds);
}
Also used : ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation)

Example 57 with ComponentInvocation

use of org.glassfish.api.invocation.ComponentInvocation in project Payara by payara.

the class UserTransactionImpl method commit.

public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException {
    if (!initialized)
        init();
    if (userTx != null) {
        userTx.commit();
        return;
    }
    ComponentInvocation inv = invocationManager.getCurrentInvocation();
    if (inv != null) {
        checkUserTransactionMethodAccess(inv);
    }
    try {
        // TMSUCCESS
        transactionManager.delistComponentResources(false);
        transactionManager.commit();
    } catch (RemoteException ex) {
        _logger.log(Level.SEVERE, "enterprise_distributedtx.excep_in_utx_commit", ex);
        throw new SystemException();
    } finally {
        if (inv != null)
            inv.setTransaction(null);
    }
}
Also used : ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) RemoteException(java.rmi.RemoteException)

Example 58 with ComponentInvocation

use of org.glassfish.api.invocation.ComponentInvocation in project Payara by payara.

the class WeldDeployer method createComponentInvocation.

private ComponentInvocation createComponentInvocation(ApplicationInfo applicationInfo) {
    BundleDescriptor bundleDescriptor = getCurrentBundleForContext(deployment.getCurrentDeploymentContext());
    ComponentInvocation componentInvocation = new ComponentInvocation(getComponentEnvId((JndiNameEnvironment) bundleDescriptor), SERVLET_INVOCATION, applicationInfo, applicationInfo.getName(), applicationInfo.getName());
    componentInvocation.setJNDIEnvironment(bundleDescriptor);
    return componentInvocation;
}
Also used : WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) JndiNameEnvironment(com.sun.enterprise.deployment.JndiNameEnvironment) ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation)

Example 59 with ComponentInvocation

use of org.glassfish.api.invocation.ComponentInvocation in project Payara by payara.

the class WeldFacesConfigProvider method getResources.

@Override
public Collection<URI> getResources(ServletContext context) {
    ServiceLocator defaultServices = (ServiceLocator) context.getAttribute(HABITAT_ATTRIBUTE);
    invokeMgr = defaultServices.getService(InvocationManager.class);
    ComponentInvocation inv = invokeMgr.getCurrentInvocation();
    WebModule webModule = (WebModule) inv.getContainer();
    WebBundleDescriptor wdesc = webModule.getWebBundleDescriptor();
    List<URI> list = new ArrayList<URI>(1);
    if (!wdesc.hasExtensionProperty(WeldDeployer.WELD_EXTENSION)) {
        return list;
    }
    // Don't use Util.getCurrentLoader().  This config resource should
    // be available from the same classloader that loaded this instance.
    // Doing so allows us to be more OSGi friendly.
    ClassLoader loader = this.getClass().getClassLoader();
    URL resource = loader.getResource(SERVICES_FACES_CONFIG);
    if (resource != null) {
        try {
            list.add(resource.toURI());
        } catch (URISyntaxException ex) {
            if (logger.isLoggable(Level.SEVERE)) {
                logger.log(Level.SEVERE, CDILoggerInfo.SEVERE_ERROR_CREATING_URI_FOR_FACES_CONFIG_XML, new Object[] { resource.toExternalForm(), ex });
            }
        }
    }
    return list;
}
Also used : ServiceLocator(org.glassfish.hk2.api.ServiceLocator) ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) InvocationManager(org.glassfish.api.invocation.InvocationManager) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) ArrayList(java.util.ArrayList) WebModule(com.sun.enterprise.web.WebModule) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) URL(java.net.URL)

Example 60 with ComponentInvocation

use of org.glassfish.api.invocation.ComponentInvocation in project Payara by payara.

the class J2EEInstanceListener method handleBeforeEvent.

private void handleBeforeEvent(InstanceEvent event, InstanceEvent.EventType eventType) {
    Context context = (Context) event.getWrapper().getParent();
    if (!(context instanceof WebModule)) {
        return;
    }
    WebModule wm = (WebModule) context;
    Object instance;
    if (eventType == InstanceEvent.EventType.BEFORE_FILTER_EVENT) {
        instance = event.getFilter();
    } else {
        instance = event.getServlet();
    }
    // set security context
    // BEGIN IAfSRI 4688449
    // try {
    Realm ra = context.getRealm();
    // START OF IASRI 4713234
    if (ra != null) {
        ServletRequest request = event.getRequest();
        if (request != null && request instanceof HttpServletRequest) {
            HttpServletRequest hreq = (HttpServletRequest) request;
            HttpServletRequest base = hreq;
            Principal prin = hreq.getUserPrincipal();
            Principal basePrincipal = prin;
            boolean wrapped = false;
            while (prin != null) {
                if (base instanceof ServletRequestWrapper) {
                    // unwarp any wrappers to find the base object
                    ServletRequest sr = ((ServletRequestWrapper) base).getRequest();
                    if (sr instanceof HttpServletRequest) {
                        base = (HttpServletRequest) sr;
                        wrapped = true;
                        continue;
                    }
                }
                if (wrapped) {
                    basePrincipal = base.getUserPrincipal();
                } else if (base instanceof RequestFacade) {
                    // when we can identify see we have the texact class.
                    if (base.getClass() != RequestFacade.class) {
                        basePrincipal = ((RequestFacade) base).getUnwrappedCoyoteRequest().getUserPrincipal();
                    }
                } else {
                    basePrincipal = base.getUserPrincipal();
                }
                break;
            }
            if (prin != null && prin == basePrincipal && prin.getClass().getName().equals(SecurityConstants.WEB_PRINCIPAL_CLASS)) {
                securityContext.setSecurityContextWithPrincipal(prin);
            } else if (prin != basePrincipal) {
                // the wrapper has overridden getUserPrincipal
                // reject the request if the wrapper does not have
                // the necessary permission.
                checkObjectForDoAsPermission(hreq);
                securityContext.setSecurityContextWithPrincipal(prin);
            }
        }
    }
    // END OF IASRI 4713234
    // END IASRI 4688449
    ComponentInvocation inv;
    if (eventType == InstanceEvent.EventType.BEFORE_INIT_EVENT) {
        // The servletName is not avaiable from servlet instance before servlet init.
        // We have to pass the servletName to ComponentInvocation so it can be retrieved
        // in RealmAdapter.getServletName().
        inv = new WebComponentInvocation(wm, instance, event.getWrapper().getName());
    } else {
        inv = new WebComponentInvocation(wm, instance);
    }
    try {
        im.preInvoke(inv);
        if (eventType == InstanceEvent.EventType.BEFORE_SERVICE_EVENT) {
            // Emit monitoring probe event
            wm.beforeServiceEvent(event.getWrapper().getName());
            // enlist resources with TM for service method
            if (tm != null) {
                tm.enlistComponentResources();
            }
        }
    } catch (Exception ex) {
        // See CR 6920895
        im.postInvoke(inv);
        String msg = _rb.getString(LogFacade.EXCEPTION_DURING_HANDLE_EVENT);
        msg = MessageFormat.format(msg, new Object[] { eventType, wm });
        throw new RuntimeException(msg, ex);
    }
}
Also used : AppServSecurityContext(com.sun.enterprise.security.integration.AppServSecurityContext) ServerContext(org.glassfish.internal.api.ServerContext) HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletRequest(javax.servlet.ServletRequest) ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) WebComponentInvocation(com.sun.enterprise.web.WebComponentInvocation) ServletRequestWrapper(javax.servlet.ServletRequestWrapper) WebModule(com.sun.enterprise.web.WebModule) String(java.lang.String) RequestFacade(org.apache.catalina.connector.RequestFacade) InjectionException(com.sun.enterprise.container.common.spi.util.InjectionException) HttpServletRequest(javax.servlet.http.HttpServletRequest) WebComponentInvocation(com.sun.enterprise.web.WebComponentInvocation)

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