Package com.sun.enterprise.web

Examples of com.sun.enterprise.web.WebModule


        Wrapper wrapper = event.getWrapper();
        Context context = (Context) wrapper.getParent();
        if (!(context instanceof WebModule)) {
            return;
        }
        WebModule wm = (WebModule)context;

        Object instance;
        if (eventType == InstanceEvent.EventType.AFTER_FILTER_EVENT) {
            instance = event.getFilter();
        } else {
            instance = event.getServlet();
        }
        if (instance == null) {
            return;
        }

        // Emit monitoring probe event
        if (instance instanceof Servlet) {
            if (eventType == InstanceEvent.EventType.AFTER_INIT_EVENT) {
                wm.servletInitializedEvent(wrapper.getName());
            } else if (eventType == InstanceEvent.EventType.AFTER_DESTROY_EVENT) {
                wm.servletDestroyedEvent(wrapper.getName());
            }
        }

        // Must call InjectionManager#destroyManagedObject WITHIN
        // EE invocation context
        try {
            if (eventType == InstanceEvent.EventType.AFTER_DESTROY_EVENT &&
                    !DefaultServlet.class.equals(instance.getClass()) &&
                    !JspServlet.class.equals(instance.getClass())) {
                injectionMgr.destroyManagedObject(instance, false);
            }
        } catch (InjectionException ie) {
            String msg = _rb.getString(EXCEPTION_DURING_HANDLE_EVENT);
            msg = MessageFormat.format(msg, new Object[] { eventType, wm });
            _logger.log(Level.SEVERE, msg, ie);
        }

        ComponentInvocation inv = new WebComponentInvocation(wm, instance);
        try {
            im.postInvoke(inv);
        } catch (Exception ex) {
            String msg = _rb.getString(EXCEPTION_DURING_HANDLE_EVENT);
            msg = MessageFormat.format(msg, new Object[] { eventType, wm });
            throw new RuntimeException(msg, ex);
        } finally {
            if (eventType == InstanceEvent.EventType.AFTER_DESTROY_EVENT) {
                if (tm != null) {
                    tm.componentDestroyed(instance, inv);
                }
            } else if (eventType == InstanceEvent.EventType.AFTER_FILTER_EVENT ||
                    eventType == InstanceEvent.EventType.AFTER_SERVICE_EVENT) {
                // Emit monitoring probe event
                if (eventType == InstanceEvent.EventType.AFTER_SERVICE_EVENT) {
                    ServletResponse response = event.getResponse();
                    int status = -1;
                    if (response != null &&
                            response instanceof HttpServletResponse) {
                        status = ((HttpServletResponse) response).getStatus();
                    }
                    wm.afterServiceEvent(wrapper.getName(), status);
                }

                // check it's top level invocation
                // BEGIN IASRI# 4646060
                if (im.getCurrentInvocation() == null) {
View Full Code Here


      WebContainer webContainer = glassfish.getService(WebContainer.class);
      for(String deploymentName : webArchiveNames)
      {
         for(VirtualServer server : webContainer.getVirtualServers())
         {
            WebModule webModule = null;
           
            for(Context serverContext : server.getContexts())
            {
               if(serverContext instanceof WebModule)
               {
                  if(((WebModule)serverContext).getID().startsWith(deploymentName))
                  {
                     webModule = (WebModule)serverContext;
                  }
               }
            }
            if(webModule == null)
            {
               if(server instanceof com.sun.enterprise.web.VirtualServer)
               {
                  Container child = ((com.sun.enterprise.web.VirtualServer)server).findChild("/" + deploymentName);
                  if(child instanceof WebModule)
                  {
                     webModule = (WebModule)child;
                  }
               }
            }
            if(webModule != null)
            {
               for(Map.Entry<String, ? extends ServletRegistration> servletRegistration : webModule.getServletRegistrations().entrySet())
               {
                  httpContext.add(new Servlet(servletRegistration.getKey(), webModule.getContextPath()));
               }
            }
         }
      }
   }
View Full Code Here

    public void instanceEvent(InstanceEvent event) {
        Context context = (Context) event.getWrapper().getParent();
        if (!(context instanceof WebModule)) {
            return;
        }
        WebModule wm = (WebModule)context;
        init(wm);

        InstanceEvent.EventType eventType = event.getType();
        if(_logger.isLoggable(Level.FINEST)) {
            _logger.log(Level.FINEST, INSTANCE_EVENT, eventType);
View Full Code Here

    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();
        /** IASRI 4713234
        if (ra != null) {
            HttpServletRequest request =
                (HttpServletRequest) event.getRequest();
            if (request != null && request.getUserPrincipal() != null) {
                WebPrincipal prin =
                    (WebPrincipal) request.getUserPrincipal();
                // ra.authenticate(prin);

                // It is inefficient to call authenticate just to set
                // sec.ctx.  Instead, WebPrincipal modified to keep the
                // previously created secctx, and set it here directly.

                SecurityContext.setCurrent(prin.getSecurityContext());
            }
        }
        **/
        // 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) {
      // try to avoid the getUnWrappedCoyoteRequest call
      // 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 = 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();
                }
            }
View Full Code Here

        Wrapper wrapper = event.getWrapper();
        Context context = (Context) wrapper.getParent();
        if (!(context instanceof WebModule)) {
            return;
        }
        WebModule wm = (WebModule)context;

        Object instance;
        if (eventType == InstanceEvent.EventType.AFTER_FILTER_EVENT) {
            instance = event.getFilter();
        } else {
            instance = event.getServlet();
        }
        if (instance == null) {
            return;
        }

        // Emit monitoring probe event
        if (instance instanceof Servlet) {
            if (eventType == InstanceEvent.EventType.AFTER_INIT_EVENT) {
                wm.servletInitializedEvent(wrapper.getName());
            } else if (eventType == InstanceEvent.EventType.AFTER_DESTROY_EVENT) {
                wm.servletDestroyedEvent(wrapper.getName());
            }
        }

        // Must call InjectionManager#destroyManagedObject WITHIN
        // EE invocation context
        try {
            if (eventType == InstanceEvent.EventType.AFTER_DESTROY_EVENT &&
                    !DefaultServlet.class.equals(instance.getClass()) &&
                    !JspServlet.class.equals(instance.getClass())) {
                injectionMgr.destroyManagedObject(instance, false);
            }
        } catch (InjectionException ie) {
            String msg = _rb.getString(EXCEPTION_DURING_HANDLE_EVENT);
            msg = MessageFormat.format(msg, new Object[] { eventType, wm });
            _logger.log(Level.SEVERE, msg, ie);
        }

        ComponentInvocation inv = new WebComponentInvocation(wm, instance);
        try {
            im.postInvoke(inv);
        } catch (Exception ex) {
            String msg = _rb.getString(EXCEPTION_DURING_HANDLE_EVENT);
            msg = MessageFormat.format(msg, new Object[] { eventType, wm });
            throw new RuntimeException(msg, ex);
        } finally {
            if (eventType == InstanceEvent.EventType.AFTER_DESTROY_EVENT) {
                if (tm != null) {
                    tm.componentDestroyed(instance, inv);
                }
            } else if (eventType == InstanceEvent.EventType.AFTER_FILTER_EVENT ||
                    eventType == InstanceEvent.EventType.AFTER_SERVICE_EVENT) {
                // Emit monitoring probe event
                if (eventType == InstanceEvent.EventType.AFTER_SERVICE_EVENT) {
                    ServletResponse response = event.getResponse();
                    int status = -1;
                    if (response != null &&
                            response instanceof HttpServletResponse) {
                        status = ((HttpServletResponse) response).getStatus();
                    }
                    wm.afterServiceEvent(wrapper.getName(), status);
                }

                // check it's top level invocation
                // BEGIN IASRI# 4646060
                if (im.getCurrentInvocation() == null) {
View Full Code Here

      WebContainer webContainer = glassfish.getService(WebContainer.class);
      for(String deploymentName : webArchiveNames)
      {
         for(VirtualServer server : webContainer.getVirtualServers())
         {
            WebModule webModule = null;
           
            for(Context serverContext : server.getContexts())
            {
               if(serverContext instanceof WebModule)
               {
                  if(((WebModule)serverContext).getID().startsWith(deploymentName))
                  {
                     webModule = (WebModule)serverContext;
                  }
               }
            }
            if(webModule == null)
            {
               if(server instanceof com.sun.enterprise.web.VirtualServer)
               {
                  Container child = ((com.sun.enterprise.web.VirtualServer)server).findChild("/" + deploymentName);
                  if(child instanceof WebModule)
                  {
                     webModule = (WebModule)child;
                  }
               }
            }
            if(webModule != null)
            {
               for(Map.Entry<String, ? extends ServletRegistration> servletRegistration : webModule.getServletRegistrations().entrySet())
               {
                  httpContext.add(new Servlet(servletRegistration.getKey(), webModule.getContextPath()));
               }
            }
         }
      }
   }
View Full Code Here

    public void instanceEvent(InstanceEvent event) {
        Context context = (Context) event.getWrapper().getParent();
        if (!(context instanceof WebModule)) {
            return;
        }
        WebModule wm = (WebModule)context;
        init(wm);

        InstanceEvent.EventType eventType = event.getType();
        if(_logger.isLoggable(Level.FINEST)) {
            _logger.log(Level.FINEST,"*** InstanceEvent: " + eventType);
View Full Code Here

    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();
        /** IASRI 4713234
        if (ra != null) {
            HttpServletRequest request =
                (HttpServletRequest) event.getRequest();
            if (request != null && request.getUserPrincipal() != null) {
                WebPrincipal prin =
                    (WebPrincipal) request.getUserPrincipal();
                // ra.authenticate(prin);

                // It is inefficient to call authenticate just to set
                // sec.ctx.  Instead, WebPrincipal modified to keep the
                // previously created secctx, and set it here directly.

                SecurityContext.setCurrent(prin.getSecurityContext());
            }
        }
        **/
        // 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) {
      // try to avoid the getUnWrappedCoyoteRequest call
      // 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 = 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
                Transaction tran;
                if ((tran = tm.getTransaction()) != null) {
                    inv.setTransaction(tran);
                }
View Full Code Here

        Wrapper wrapper = event.getWrapper();
        Context context = (Context) wrapper.getParent();
        if (!(context instanceof WebModule)) {
            return;
        }
        WebModule wm = (WebModule)context;

        Object instance;
        if (eventType == InstanceEvent.EventType.AFTER_FILTER_EVENT) {
            instance = event.getFilter();
        } else {
            instance = event.getServlet();
        }
        if (instance == null) {
            return;
        }

        // Emit monitoring probe event
        if (instance instanceof Servlet) {
            if (eventType == InstanceEvent.EventType.AFTER_INIT_EVENT) {
                wm.servletInitializedEvent(wrapper.getName());
            } else if (eventType == InstanceEvent.EventType.AFTER_DESTROY_EVENT) {
                wm.servletDestroyedEvent(wrapper.getName());
            }
        }

        // Must call InjectionManager#destroyManagedObject WITHIN
        // EE invocation context
        try {
            if (eventType == InstanceEvent.EventType.AFTER_DESTROY_EVENT &&
                    !DefaultServlet.class.equals(instance.getClass()) &&
                    !JspServlet.class.equals(instance.getClass())) {
                injectionMgr.destroyManagedObject(instance, false);
            }
        } catch (InjectionException ie) {
            String msg = _rb.getString(
                "containerListener.exceptionDuringHandleEvent");
            msg = MessageFormat.format(msg, new Object[] { eventType, wm });
            _logger.log(Level.SEVERE, msg, ie);
        }

        ComponentInvocation inv = new WebComponentInvocation(wm, instance);
        try {
            im.postInvoke(inv);
        } catch (Exception ex) {
            String msg = _rb.getString(
                "containerListener.exceptionDuringHandleEvent");
            msg = MessageFormat.format(msg, new Object[] { eventType, wm });
            throw new RuntimeException(msg, ex);
        } finally {
            if (eventType == InstanceEvent.EventType.AFTER_DESTROY_EVENT) {
                tm.componentDestroyed(instance, inv);               
            } else if (eventType == InstanceEvent.EventType.AFTER_FILTER_EVENT ||
                    eventType == InstanceEvent.EventType.AFTER_SERVICE_EVENT) {
                // Emit monitoring probe event
                if (eventType == InstanceEvent.EventType.AFTER_SERVICE_EVENT) {
                    ServletResponse response = event.getResponse();
                    int status = -1;
                    if (response != null &&
                            response instanceof HttpServletResponse) {
                        status = ((HttpServletResponse) response).getStatus();
                    }
                    wm.afterServiceEvent(wrapper.getName(), status);
                }

                // check it's top level invocation
                // BEGIN IASRI# 4646060
                if (im.getCurrentInvocation() == null) {
View Full Code Here

        }

        String type = event.getType();

        try {
            WebModule wm = (WebModule) event.getContainer();
            if (beforeEvents.contains(type)) {
                preInvoke(wm);
            } else if (afterEvents.contains(type)) {
                if (type.equals(ContainerEvent.AFTER_FILTER_DESTROYED) ||
                        type.equals(ContainerEvent.AFTER_CONTEXT_DESTROYED)) {
View Full Code Here

TOP

Related Classes of com.sun.enterprise.web.WebModule

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.