cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [1/6] cxf git commit: Do not initialize if no swagger-jaxrs classes are found
Date Wed, 02 Dec 2015 14:59:15 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes bcbf6534f -> ec399a6a7
  refs/heads/3.1.x-fixes 4685f0687 -> e4c456743
  refs/heads/master afe7a56f1 -> e915cfd79


Do not initialize if no swagger-jaxrs classes are found


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

Branch: refs/heads/3.1.x-fixes
Commit: 8c02d3c817c730851ebe748043daaec10190b125
Parents: 4685f06
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
Authored: Wed Dec 2 15:37:20 2015 +0100
Committer: Francesco Chicchiriccò <ilgrosso@apache.org>
Committed: Wed Dec 2 15:37:20 2015 +0100

----------------------------------------------------------------------
 .../jaxrs/swagger/AbstractSwaggerFeature.java   | 28 ++++++++++++++++----
 1 file changed, 23 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/8c02d3c8/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/swagger/AbstractSwaggerFeature.java
----------------------------------------------------------------------
diff --git a/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/swagger/AbstractSwaggerFeature.java
b/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/swagger/AbstractSwaggerFeature.java
index 87dfdfe..08d2e16 100644
--- a/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/swagger/AbstractSwaggerFeature.java
+++ b/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/swagger/AbstractSwaggerFeature.java
@@ -25,6 +25,13 @@ import org.apache.cxf.jaxrs.JAXRSServiceFactoryBean;
 import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
 
 public abstract class AbstractSwaggerFeature extends AbstractFeature {
+
+    private static final boolean SWAGGER_JAXRS_AVAILABLE;
+
+    static {
+        SWAGGER_JAXRS_AVAILABLE = isSwaggerJaxRsAvailable();
+    }
+
     protected boolean scan = true;
     protected boolean runAsFilter;
     private String resourcePackage;
@@ -39,13 +46,24 @@ public abstract class AbstractSwaggerFeature extends AbstractFeature {
     private String termsOfServiceUrl;
     private String filterClass;
     
+    private static boolean isSwaggerJaxRsAvailable() {
+        try {
+            Class.forName("io.swagger.jaxrs.DefaultParameterExtension");
+            return true;
+        } catch (Throwable ex) {
+            return false;
+        }    
+    }
+
     @Override
     public void initialize(Server server, Bus bus) {
-        calculateDefaultResourcePackage(server);
-        calculateDefaultBasePath(server);
-        addSwaggerResource(server);
-        
-        initializeProvider(server.getEndpoint(), bus);
+        if (SWAGGER_JAXRS_AVAILABLE) {
+            calculateDefaultResourcePackage(server);
+            calculateDefaultBasePath(server);
+            addSwaggerResource(server);
+
+            initializeProvider(server.getEndpoint(), bus);
+        }
     }
 
     protected abstract void addSwaggerResource(Server server);


Mime
View raw message