You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ff...@apache.org on 2015/05/05 10:36:05 UTC

servicemix-bundles git commit: [SM-2541]add TCCL into SwaggerContext classloaders

Repository: servicemix-bundles
Updated Branches:
  refs/heads/master 3df7d770b -> 556fdbc1e


[SM-2541]add TCCL into SwaggerContext classloaders


Project: http://git-wip-us.apache.org/repos/asf/servicemix-bundles/repo
Commit: http://git-wip-us.apache.org/repos/asf/servicemix-bundles/commit/556fdbc1
Tree: http://git-wip-us.apache.org/repos/asf/servicemix-bundles/tree/556fdbc1
Diff: http://git-wip-us.apache.org/repos/asf/servicemix-bundles/diff/556fdbc1

Branch: refs/heads/master
Commit: 556fdbc1e89be821f00227ab7271360fec5abbdd
Parents: 3df7d77
Author: Freeman Fang <fr...@gmail.com>
Authored: Tue May 5 13:46:42 2015 +0800
Committer: Freeman Fang <fr...@gmail.com>
Committed: Tue May 5 13:46:42 2015 +0800

----------------------------------------------------------------------
 pom.xml                                         |  1 +
 swagger-core-1.3.2/pom.xml                      | 21 +++++++++++++
 .../wordnik/swagger/core/SwaggerContext.scala   | 33 ++++++++++++++++++++
 3 files changed, 55 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/servicemix-bundles/blob/556fdbc1/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 1829f65..a3f04ca 100644
--- a/pom.xml
+++ b/pom.xml
@@ -43,6 +43,7 @@
 
     <modules>
         <!-- add modules for all bundles to released in the next batch here -->
+        <module>swagger-core-1.3.2</module>
     </modules>
 
 </project>

http://git-wip-us.apache.org/repos/asf/servicemix-bundles/blob/556fdbc1/swagger-core-1.3.2/pom.xml
----------------------------------------------------------------------
diff --git a/swagger-core-1.3.2/pom.xml b/swagger-core-1.3.2/pom.xml
index 4d5ee48..56ab0ed 100644
--- a/swagger-core-1.3.2/pom.xml
+++ b/swagger-core-1.3.2/pom.xml
@@ -80,6 +80,27 @@
     <build>
         <plugins>
             <plugin>
+                <groupId>net.alchim31.maven</groupId>
+                <artifactId>scala-maven-plugin</artifactId>
+                    <executions>
+                        <execution>
+                            <id>scala-compile-first</id>
+                            <phase>process-resources</phase>
+                            <goals>
+                                <goal>add-source</goal>
+                                <goal>compile</goal>
+                            </goals>
+                        </execution>
+                        <execution>
+                            <id>scala-test-compile</id>
+                            <phase>process-test-resources</phase>
+                            <goals>
+                                <goal>testCompile</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+            </plugin>
+            <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-shade-plugin</artifactId>
                 <executions>

http://git-wip-us.apache.org/repos/asf/servicemix-bundles/blob/556fdbc1/swagger-core-1.3.2/src/main/scala/com/wordnik/swagger/core/SwaggerContext.scala
----------------------------------------------------------------------
diff --git a/swagger-core-1.3.2/src/main/scala/com/wordnik/swagger/core/SwaggerContext.scala b/swagger-core-1.3.2/src/main/scala/com/wordnik/swagger/core/SwaggerContext.scala
new file mode 100644
index 0000000..0924949
--- /dev/null
+++ b/swagger-core-1.3.2/src/main/scala/com/wordnik/swagger/core/SwaggerContext.scala
@@ -0,0 +1,33 @@
+package com.wordnik.swagger.core
+
+import collection.mutable.ListBuffer
+import org.slf4j.{ LoggerFactory, Logger }
+
+object SwaggerContext {
+  private val LOGGER = LoggerFactory.getLogger("com.wordnik.swagger.core.SwaggerContext")
+
+  var suffixResponseFormat = true
+
+  private val classLoaders = ListBuffer.empty[ClassLoader]
+  registerClassLoader(this.getClass.getClassLoader)
+  registerClassLoader(Thread.currentThread().getContextClassLoader())
+
+  def registerClassLoader(cl: ClassLoader) = this.classLoaders += cl
+
+  def loadClass(name: String) = {
+    var cls: Class[_] = null
+    val itr = classLoaders.reverse.iterator
+    while (cls == null && itr.hasNext) {
+      try {
+        cls = Class.forName(name.trim, true, itr.next)
+      } catch {
+        case e: ClassNotFoundException => {
+          LOGGER.debug("Class %s not found in classLoader".format(name))
+        }
+      }
+    }
+    if (cls == null)
+      throw new ClassNotFoundException("class " + name + " not found")
+    cls
+  }
+}