cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1041183 - /cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
Date Wed, 01 Dec 2010 21:48:26 GMT
Author: sergeyb
Date: Wed Dec  1 21:48:26 2010
New Revision: 1041183

URL: http://svn.apache.org/viewvc?rev=1041183&view=rev
Log:
[CXF-3159] Catching late provider initialization exceptions

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java?rev=1041183&r1=1041182&r2=1041183&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
Wed Dec  1 21:48:26 2010
@@ -59,9 +59,9 @@ public final class ProviderFactory {
     private static final ProviderFactory SHARED_FACTORY = new ProviderFactory();
     
     static {
-        SHARED_FACTORY.setProviders(createProvider("org.apache.cxf.jaxrs.provider.JAXBElementProvider"),
-                                    createProvider("org.apache.cxf.jaxrs.provider.JSONProvider"),
-                                    new BinaryDataProvider(),
+        setDefaultProvider(SHARED_FACTORY, "org.apache.cxf.jaxrs.provider.JAXBElementProvider");
+        setDefaultProvider(SHARED_FACTORY, "org.apache.cxf.jaxrs.provider.JSONProvider");
       
+        SHARED_FACTORY.setProviders(new BinaryDataProvider(),
                                     new SourceProvider(),
                                     new FormEncodingProvider(),
                                     new PrimitiveTextProvider(),
@@ -91,11 +91,14 @@ public final class ProviderFactory {
     private ProviderFactory() {
     }
     
-    private static Object createProvider(String className) {
+    
+    private static void setDefaultProvider(ProviderFactory factory, String className) {
+        
         try {
-            return ClassLoaderUtils.loadClass(className, ProviderFactory.class).newInstance();
+            Object provider = ClassLoaderUtils.loadClass(className, ProviderFactory.class).newInstance();
+            factory.setProviders(provider);
         } catch (Throwable ex) {
-            String message = "Problem with instantiating the default provider " + className;
+            String message = "Problem with setting the default provider " + className;
             if (ex.getMessage() != null) {
                 message += ex.getMessage();
             } else {
@@ -103,7 +106,6 @@ public final class ProviderFactory {
             }
             LOG.info(message);
         }
-        return  null;
     }
     
     public static ProviderFactory getInstance() {



Mime
View raw message