Return-Path: X-Original-To: apmail-struts-issues-archive@minotaur.apache.org Delivered-To: apmail-struts-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2A29C172D7 for ; Thu, 2 Oct 2014 14:52:35 +0000 (UTC) Received: (qmail 12663 invoked by uid 500); 2 Oct 2014 14:52:34 -0000 Delivered-To: apmail-struts-issues-archive@struts.apache.org Received: (qmail 12636 invoked by uid 500); 2 Oct 2014 14:52:34 -0000 Mailing-List: contact issues-help@struts.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@struts.apache.org Delivered-To: mailing list issues@struts.apache.org Received: (qmail 12626 invoked by uid 99); 2 Oct 2014 14:52:34 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Oct 2014 14:52:34 +0000 Date: Thu, 2 Oct 2014 14:52:34 +0000 (UTC) From: "Lorenzo Bernacchioni (JIRA)" To: issues@struts.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (WW-4410) Custom configuration providers accessing servlet-context MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/WW-4410?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Lorenzo Bernacchioni updated WW-4410: ------------------------------------- Affects Version/s: 2.3.16.3 > Custom configuration providers accessing servlet-context > -------------------------------------------------------- > > Key: WW-4410 > URL: https://issues.apache.org/jira/browse/WW-4410 > Project: Struts 2 > Issue Type: Improvement > Components: Dispatch Filter > Affects Versions: 2.3.16.3 > Reporter: Lorenzo Bernacchioni > Priority: Minor > > I'm using custom configuration providers following the suggestion of [this post|http://cppoon.wordpress.com/2013/11/11/change-apache-struts2-configuration-programmatically/comment-page-1/#comment-157]. > I figured out that my custom configuration provider needed access to the servlet-context so I patched the code in the Dispatcher class to let, in case the constructor is available, instantiate a ConfigurationProvider with the servlet-context as argument > {code} > private void init_CustomConfigurationProviders() { > String configProvs = initParams.get("configProviders"); > if (configProvs != null) { > String[] classes = configProvs.split("\\s*[,]\\s*"); > for (String cname : classes) { > try { > Class cls = ClassLoaderUtil.loadClass(cname, this.getClass()); > > ConfigurationProvider prov; > try { > Constructor constructor = cls.getConstructor(ServletContext.class); > prov = (ConfigurationProvider)constructor.newInstance(servletContext); > } catch (Exception e) { > prov = (ConfigurationProvider)cls.newInstance(); > } > configurationManager.addContainerProvider(prov); > } catch (InstantiationException e) { > throw new ConfigurationException("Unable to instantiate provider: "+cname, e); > } catch (IllegalAccessException e) { > throw new ConfigurationException("Unable to access provider: "+cname, e); > } catch (ClassNotFoundException e) { > throw new ConfigurationException("Unable to locate provider class: "+cname, e); > } > } > } > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)