From continuum-commits-return-1754-apmail-maven-continuum-commits-archive=maven.apache.org@maven.apache.org Tue Jul 04 16:10:28 2006 Return-Path: Delivered-To: apmail-maven-continuum-commits-archive@www.apache.org Received: (qmail 77440 invoked from network); 4 Jul 2006 16:10:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 4 Jul 2006 16:10:28 -0000 Received: (qmail 63828 invoked by uid 500); 4 Jul 2006 16:10:28 -0000 Delivered-To: apmail-maven-continuum-commits-archive@maven.apache.org Received: (qmail 63803 invoked by uid 500); 4 Jul 2006 16:10:27 -0000 Mailing-List: contact continuum-commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: continuum-dev@maven.apache.org Delivered-To: mailing list continuum-commits@maven.apache.org Received: (qmail 63780 invoked by uid 99); 4 Jul 2006 16:10:27 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Jul 2006 09:10:27 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Jul 2006 09:10:26 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 5CA051A983A; Tue, 4 Jul 2006 09:10:06 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r419044 - in /maven/continuum/branches/continuum-acegi/continuum-webapp/src/main/java/org/apache/maven/continuum/web/filter: ./ FilterToComponentProxy.java Date: Tue, 04 Jul 2006 16:10:05 -0000 To: continuum-commits@maven.apache.org From: evenisse@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060704161006.5CA051A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: evenisse Date: Tue Jul 4 09:10:04 2006 New Revision: 419044 URL: http://svn.apache.org/viewvc?rev=419044&view=rev Log: Add a basic filter that load a plexus component Added: maven/continuum/branches/continuum-acegi/continuum-webapp/src/main/java/org/apache/maven/continuum/web/filter/ maven/continuum/branches/continuum-acegi/continuum-webapp/src/main/java/org/apache/maven/continuum/web/filter/FilterToComponentProxy.java (with props) Added: maven/continuum/branches/continuum-acegi/continuum-webapp/src/main/java/org/apache/maven/continuum/web/filter/FilterToComponentProxy.java URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-webapp/src/main/java/org/apache/maven/continuum/web/filter/FilterToComponentProxy.java?rev=419044&view=auto ============================================================================== --- maven/continuum/branches/continuum-acegi/continuum-webapp/src/main/java/org/apache/maven/continuum/web/filter/FilterToComponentProxy.java (added) +++ maven/continuum/branches/continuum-acegi/continuum-webapp/src/main/java/org/apache/maven/continuum/web/filter/FilterToComponentProxy.java Tue Jul 4 09:10:04 2006 @@ -0,0 +1,85 @@ +package org.apache.maven.continuum.web.filter; + +/* + * Copyright 2004-2006 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.codehaus.plexus.PlexusContainer; +import org.codehaus.plexus.xwork.PlexusLifecycleListener; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import java.io.IOException; + +/** + * @author Emmanuel Venisse (evenisse at apache dot org) + */ +public class FilterToComponentProxy + implements Filter +{ + private static final Log log = LogFactory.getLog( FilterToComponentProxy.class ); + + private ServletContext ctx; + + private String componentName; + + public void init( FilterConfig filterConfig ) + throws ServletException + { + ctx = filterConfig.getServletContext(); + + if (filterConfig != null) + { + String param = filterConfig.getInitParameter( "component" ); + + if ( param != null) + { + componentName = param; + } + else + { + throw new ServletException( this.getClass().getName() + " require a \"component\" init-param." ); + } + } + } + + public void doFilter( ServletRequest req, ServletResponse res, FilterChain chain ) + throws IOException, ServletException + { + PlexusContainer container = (PlexusContainer) ctx.getAttribute( PlexusLifecycleListener.KEY ); + + try + { + Object component = container.lookup( componentName ); + } + catch ( Exception e ) + { + //DO SOMETHING + } + + chain.doFilter( req, res ); + } + + public void destroy() + { + } +} Propchange: maven/continuum/branches/continuum-acegi/continuum-webapp/src/main/java/org/apache/maven/continuum/web/filter/FilterToComponentProxy.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/continuum/branches/continuum-acegi/continuum-webapp/src/main/java/org/apache/maven/continuum/web/filter/FilterToComponentProxy.java ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision"