cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf-fediz git commit: Minor update to CXF plugin to use ResourceUtils (ResourceResolver extension) to load a config file, and using a default config file name if none is set
Date Thu, 15 Oct 2015 14:23:11 GMT
Repository: cxf-fediz
Updated Branches:
  refs/heads/1.2.x-fixes 7f2045010 -> 8acd00d2a


Minor update to CXF plugin to use ResourceUtils (ResourceResolver extension) to load a config
file, and using a default config file name if none is set


Project: http://git-wip-us.apache.org/repos/asf/cxf-fediz/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf-fediz/commit/8acd00d2
Tree: http://git-wip-us.apache.org/repos/asf/cxf-fediz/tree/8acd00d2
Diff: http://git-wip-us.apache.org/repos/asf/cxf-fediz/diff/8acd00d2

Branch: refs/heads/1.2.x-fixes
Commit: 8acd00d2a55243c3d198b1c284eb2f4a39fc7294
Parents: 7f20450
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Thu Oct 15 11:33:30 2015 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Thu Oct 15 15:21:58 2015 +0100

----------------------------------------------------------------------
 .../plugin/AbstractServiceProviderFilter.java   | 21 ++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/8acd00d2/plugins/cxf/src/main/java/org/apache/cxf/fediz/cxf/plugin/AbstractServiceProviderFilter.java
----------------------------------------------------------------------
diff --git a/plugins/cxf/src/main/java/org/apache/cxf/fediz/cxf/plugin/AbstractServiceProviderFilter.java
b/plugins/cxf/src/main/java/org/apache/cxf/fediz/cxf/plugin/AbstractServiceProviderFilter.java
index 43cd8d3..b9e89a9 100644
--- a/plugins/cxf/src/main/java/org/apache/cxf/fediz/cxf/plugin/AbstractServiceProviderFilter.java
+++ b/plugins/cxf/src/main/java/org/apache/cxf/fediz/cxf/plugin/AbstractServiceProviderFilter.java
@@ -37,7 +37,8 @@ import javax.ws.rs.core.HttpHeaders;
 import javax.xml.bind.JAXBException;
 
 import org.w3c.dom.Element;
-import org.apache.cxf.common.classloader.ClassLoaderUtils;
+
+import org.apache.cxf.BusFactory;
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.fediz.core.SecurityTokenThreadLocal;
 import org.apache.cxf.fediz.core.config.FedizConfigurator;
@@ -48,6 +49,7 @@ import org.apache.cxf.fediz.cxf.plugin.state.ResponseState;
 import org.apache.cxf.fediz.cxf.plugin.state.SPStateManager;
 import org.apache.cxf.jaxrs.impl.HttpHeadersImpl;
 import org.apache.cxf.jaxrs.impl.UriInfoImpl;
+import org.apache.cxf.jaxrs.utils.ResourceUtils;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.security.SecurityContext;
 import org.apache.cxf.staxutils.StaxUtils;
@@ -85,15 +87,19 @@ public abstract class AbstractServiceProviderFilter implements ContainerRequestF
     }
     
     @PostConstruct
-    public synchronized void configure() throws JAXBException, MalformedURLException {
+    public synchronized void configure() throws JAXBException, IOException {
         if (configurator == null) {
+            String actualConfigFile = configFile;
+            if (actualConfigFile == null) {
+                actualConfigFile = "fediz_config.xml";
+            }
             try {
-                File f = new File(configFile);
+                File f = new File(actualConfigFile);
                 if (!f.exists()) {
-                    URL url = ClassLoaderUtils.getResource(configFile, 
-                                                           AbstractServiceProviderFilter.class);
+                    URL url = ResourceUtils.getResourceURL(actualConfigFile, 
+                                                        BusFactory.getThreadDefaultBus());
                     if (url == null) {
-                        url = new URL(configFile);
+                        url = new URL(actualConfigFile);
                     }
                     if (url != null) {
                         f = new File(url.getPath());
@@ -108,6 +114,9 @@ public abstract class AbstractServiceProviderFilter implements ContainerRequestF
             } catch (MalformedURLException e) {
                 LOG.error("Error in loading configuration file", e);
                 throw e;
+            } catch (Exception e) {
+                LOG.error("Error in loading configuration file", e);
+                throw new IOException(e);
             }
         }
         


Mime
View raw message