Examples of PlexusContainer


Examples of org.codehaus.plexus.PlexusContainer

     */
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        loaded = true;

        try {
            PlexusContainer pc = new DefaultPlexusContainer();
            PlexusUtils.configure(pc, "plexus-application.xml");
            ServletContext ctx = servletContextEvent.getServletContext();
            ctx.setAttribute(KEY, pc);

            pc.initialize();
            pc.start();
        } catch (Exception e) {
            LOG.error("Error initializing plexus container (scope: application)", e);
        }
    }
View Full Code Here

Examples of org.codehaus.plexus.PlexusContainer

     * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
     */
    public void contextDestroyed(ServletContextEvent servletContextEvent) {
        try {
            ServletContext ctx = servletContextEvent.getServletContext();
            PlexusContainer pc = (PlexusContainer) ctx.getAttribute(KEY);
            pc.dispose();
        } catch (Exception e) {
            LOG.error("Error disposing plexus container (scope: application)", e);
        }
    }
View Full Code Here

Examples of org.codehaus.plexus.PlexusContainer

     */
    public void sessionCreated(HttpSessionEvent httpSessionEvent) {
        try {
            HttpSession session = httpSessionEvent.getSession();
            ServletContext ctx = session.getServletContext();
            PlexusContainer parent = (PlexusContainer) ctx.getAttribute(KEY);
            PlexusContainer child = parent.createChildContainer("session", Collections.EMPTY_LIST, Collections.EMPTY_MAP);
            session.setAttribute(KEY, child);
            PlexusUtils.configure(child, "plexus-session.xml");
            child.initialize();
            child.start();
        } catch (Exception e) {
            LOG.error("Error initializing plexus container (scope: session)", e);
        }
    }
View Full Code Here

Examples of org.codehaus.plexus.PlexusContainer

     * @see javax.servlet.http.HttpSessionListener#sessionDestroyed(javax.servlet.http.HttpSessionEvent)
     */
    public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
        try {
            HttpSession session = httpSessionEvent.getSession();
            PlexusContainer child = (PlexusContainer) session.getAttribute(KEY);
            child.dispose();
        } catch (Exception e) {
            LOG.error("Error initializing plexus container (scope: session)", e);
        }
    }
View Full Code Here

Examples of org.codehaus.plexus.PlexusContainer

    /* (non-Javadoc)
     * @see com.opensymphony.xwork2.ObjectFactory#getClassInstance(java.lang.String)
     */
    public Class getClassInstance(String className)
            throws ClassNotFoundException {
        PlexusContainer pc = PlexusThreadLocal.getPlexusContainer();

        if (pc == null) {
            pc = base;
        }

        try {
            return pc.lookup(className).getClass();
        }
        catch (Exception e1) {
            try {
                return pc.lookup(Action.class.getName(), className).getClass();
            }
            catch (Exception e2) {
                try {
                    return pc.lookup(Interceptor.class.getName(), className).getClass();
                }
                catch (Exception e3) {
                    try {
                        return pc.lookup(Validator.class.getName(), className).getClass();
                    }
                    catch (Exception e4) {
                        try {
                            return pc.lookup(Result.class.getName(), className).getClass();
                        }
                        catch (Exception e5) {
                            return super.getClassInstance(className);
                        }
                    }
View Full Code Here

Examples of org.codehaus.plexus.PlexusContainer

     * @return The object
     * @throws Exception If the lookup fails
     */
    private Object lookup(String role, String roleHint, Map extraContext)
            throws Exception {
        PlexusContainer pc = PlexusThreadLocal.getPlexusContainer();

        if (pc == null) {
            pc = base;
        }

        try {
            return pc.lookup(role, roleHint);
        }
        catch (Exception e) {
            if (LOG.isDebugEnabled()) {
          LOG.debug("Can't load component (" + role + "/" + roleHint + ") with plexus, try now with struts.", e);
            }
            Object o = super.buildBean(super.getClassInstance(role), extraContext);
            pc.autowire(o);
            return o;
        }
    }
View Full Code Here

Examples of org.codehaus.plexus.PlexusContainer

    /* (non-Javadoc)
     * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
     */
    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
        PlexusContainer child = null;
        try {
            try {
                HttpServletRequest request = (HttpServletRequest) req;
                HttpSession session = request.getSession(false);
                PlexusContainer parent;
                if (session != null) {
                    parent = (PlexusContainer) session.getAttribute(PlexusLifecycleListener.KEY);
                } else {
                    parent = (PlexusContainer) ctx.getAttribute(PlexusLifecycleListener.KEY);
                }

                if (parent.hasChildContainer(CHILD_CONTAINER_NAME)) {
                    if (LOG.isWarnEnabled()) {
                  LOG.warn("Plexus container (scope: request) alredy exist.");
                    }
                    child = parent.getChildContainer(CHILD_CONTAINER_NAME);
                } else {
                    child = parent.createChildContainer(CHILD_CONTAINER_NAME, Collections.EMPTY_LIST, Collections.EMPTY_MAP);
                    PlexusUtils.configure(child, "plexus-request.xml");
                    child.initialize();
                    child.start();
                }
                PlexusThreadLocal.setPlexusContainer(child);
View Full Code Here

Examples of org.codehaus.plexus.PlexusContainer

{
    public void execute( Object object, ComponentManager manager )
    {
        if ( object instanceof Serviceable )
        {
            PlexusContainer container = manager.getContainer();

            ( (Serviceable) object ).service( new PlexusContainerLocator(container) );
        }
    }
View Full Code Here

Examples of org.codehaus.plexus.PlexusContainer

    public void execute( Object object, ComponentManager manager )
        throws PhaseExecutionException
    {
        // We only need to assemble a component if it specifies requirements.

        PlexusContainer container = manager.getContainer();

        ComponentDescriptor descriptor = manager.getComponentDescriptor();

        try
        {
            container.composeComponent( object, descriptor );
        }
        catch ( CompositionException e )
        {
            throw new PhaseExecutionException( "Error composing component", e );
        }
View Full Code Here

Examples of org.codehaus.plexus.PlexusContainer

    }

    public void contextualize( final Context context )
        throws ContextException
    {
        PlexusContainer container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
        this.realm = container.getContainerRealm();
        try
        {
            configurator = (ComponentConfigurator) container.lookup( ComponentConfigurator.ROLE );
        }
        catch ( ComponentLookupException e )
        {
            throw new ContextException( "Failed to lookup component configurator: " + e.getMessage(), e );
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.