Repository: struts
Updated Branches:
  refs/heads/master 5d9865092 -> 4ea8883ff

WW-4410 Adds dedicated interface to allow inject ServletContext


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/4ea8883f
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/4ea8883f
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/4ea8883f

Branch: refs/heads/master
Commit: 4ea8883ff9d81ab93a5360e17a37fc57453f56c4
Parents: 5d98650
Author: Lukasz Lenart <lukaszlen...@apache.org>
Authored: Thu Feb 25 21:29:25 2016 +0100
Committer: Lukasz Lenart <lukaszlen...@apache.org>
Committed: Thu Feb 25 21:30:19 2016 +0100

----------------------------------------------------------------------
 ...ervletContextAwareConfigurationProvider.java | 32 ++++++++++++++++++++
 .../apache/struts2/dispatcher/Dispatcher.java   |  3 ++
 2 files changed, 35 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/4ea8883f/core/src/main/java/com/opensymphony/xwork2/config/ServletContextAwareConfigurationProvider.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/com/opensymphony/xwork2/config/ServletContextAwareConfigurationProvider.java
 
b/core/src/main/java/com/opensymphony/xwork2/config/ServletContextAwareConfigurationProvider.java
new file mode 100644
index 0000000..506d906
--- /dev/null
+++ 
b/core/src/main/java/com/opensymphony/xwork2/config/ServletContextAwareConfigurationProvider.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2002-2006,2009 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.
+ */
+package com.opensymphony.xwork2.config;
+
+import javax.servlet.ServletContext;
+
+/**
+ * Dedicated interface to allow inject {@link ServletContext} and perform 
initialisation based in it
+ */
+public interface ServletContextAwareConfigurationProvider extends 
ConfigurationProvider {
+
+    /**
+     * This is a lazy constructor, called just after class was initiated
+     *
+     * @param servletContext current instance of {@link ServletContext}
+     */
+    void initWithContext(ServletContext servletContext);
+
+}

http://git-wip-us.apache.org/repos/asf/struts/blob/4ea8883f/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java 
b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
index 93d38a4..86c0f6c 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
@@ -393,6 +393,9 @@ public class Dispatcher {
                 try {
                     Class cls = ClassLoaderUtil.loadClass(cname, 
this.getClass());
                     ConfigurationProvider prov = 
(ConfigurationProvider)cls.newInstance();
+                    if (prov instanceof 
ServletContextAwareConfigurationProvider) {
+                        
((ServletContextAwareConfigurationProvider)prov).initWithContext(servletContext);
+                    }
                     configurationManager.addContainerProvider(prov);
                 } catch (InstantiationException e) {
                     throw new ConfigurationException("Unable to instantiate 
provider: "+cname, e);

Reply via email to