Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 019C653A1 for ; Tue, 10 May 2011 10:53:49 +0000 (UTC) Received: (qmail 17137 invoked by uid 500); 10 May 2011 10:53:48 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 17069 invoked by uid 500); 10 May 2011 10:53:48 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 17062 invoked by uid 99); 10 May 2011 10:53:48 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 May 2011 10:53:48 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 May 2011 10:53:45 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 0CF6C23889C5; Tue, 10 May 2011 10:53:24 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1101399 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/ systests/jaxrs/src/test/resources/jaxrs_non_spring/WEB-INF/ Date: Tue, 10 May 2011 10:53:23 -0000 To: commits@cxf.apache.org From: sergeyb@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110510105324.0CF6C23889C5@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: sergeyb Date: Tue May 10 10:53:23 2011 New Revision: 1101399 URL: http://svn.apache.org/viewvc?rev=1101399&view=rev Log: [CXF-3507] Support for Application constructor injection Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookApplication.java cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_non_spring/WEB-INF/web.xml Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java?rev=1101399&r1=1101398&r2=1101399&view=diff ============================================================================== --- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java (original) +++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java Tue May 10 10:53:23 2011 @@ -257,18 +257,7 @@ public class CXFNonSpringJaxrsServlet ex protected void createServerFromApplication(String cName, ServletConfig servletConfig) throws ServletException { Class appClass = loadClass(cName, "Application"); - Application app = null; - try { - app = (Application)appClass.newInstance(); - } catch (InstantiationException ex) { - ex.printStackTrace(); - throw new ServletException("Application class " + cName - + " can not be instantiated"); - } catch (IllegalAccessException ex) { - ex.printStackTrace(); - throw new ServletException("Application class " + cName - + " can not be instantiated due to IllegalAccessException"); - } + Application app = (Application)createSingletonInstance(appClass, servletConfig); String ignoreParam = servletConfig.getInitParameter(IGNORE_APP_PATH_PARAM); JAXRSServerFactoryBean bean = ResourceUtils.createApplication(app, MessageUtils.isTrue(ignoreParam)); Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookApplication.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookApplication.java?rev=1101399&r1=1101398&r2=1101399&view=diff ============================================================================== --- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookApplication.java (original) +++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookApplication.java Tue May 10 10:53:23 2011 @@ -21,12 +21,23 @@ package org.apache.cxf.systest.jaxrs; import java.util.HashSet; import java.util.Set; +import javax.servlet.ServletContext; import javax.ws.rs.ApplicationPath; import javax.ws.rs.core.Application; +import javax.ws.rs.core.Context; @ApplicationPath("/thebooks") public class BookApplication extends Application { + public BookApplication(@Context ServletContext sc) { + if (sc == null) { + throw new IllegalArgumentException("ServletContext is null"); + } + if (!"contextParamValue".equals(sc.getInitParameter("contextParam"))) { + throw new IllegalStateException("ServletContext is not initialized"); + } + } + @Override public Set> getClasses() { Set> classes = new HashSet>(); Modified: cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_non_spring/WEB-INF/web.xml URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_non_spring/WEB-INF/web.xml?rev=1101399&r1=1101398&r2=1101399&view=diff ============================================================================== --- cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_non_spring/WEB-INF/web.xml (original) +++ cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_non_spring/WEB-INF/web.xml Tue May 10 10:53:23 2011 @@ -24,6 +24,10 @@ --> + + contextParam + contextParamValue + CXFServlet CXF Servlet