Repository: camel
Updated Branches:
  refs/heads/master 2854e18ff -> 5094d6006


CAMEL-7689: camel-swagger has a servletlistener servlet when using that to 
lookup CamelContext.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/5094d600
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/5094d600
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/5094d600

Branch: refs/heads/master
Commit: 5094d60061af6b2bb874a4c05e557c3a5c4c5699
Parents: 374dbd9
Author: Claus Ibsen <davscl...@apache.org>
Authored: Tue Aug 26 11:54:57 2014 +0200
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Tue Aug 26 11:56:08 2014 +0200

----------------------------------------------------------------------
 ...stenerRestSwaggerApiDeclarationServlet.scala | 40 ++++++++++++++++++++
 1 file changed, 40 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/5094d600/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/servletlistener/ServletListenerRestSwaggerApiDeclarationServlet.scala
----------------------------------------------------------------------
diff --git 
a/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/servletlistener/ServletListenerRestSwaggerApiDeclarationServlet.scala
 
b/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/servletlistener/ServletListenerRestSwaggerApiDeclarationServlet.scala
new file mode 100644
index 0000000..56cd25e
--- /dev/null
+++ 
b/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/servletlistener/ServletListenerRestSwaggerApiDeclarationServlet.scala
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.camel.component.swagger.servletlistener
+
+import javax.servlet.ServletConfig
+
+import com.wordnik.swagger.core.SwaggerContext
+
+import org.apache.camel.component.swagger.RestSwaggerApiDeclarationServlet
+import org.apache.camel.CamelContext
+
+/**
+ * To lookup CamelContext from the <a 
href="http://camel.apache.org/servletlistener-component.html";>servletlistener</a>
 component.
+ */
+class ServletListenerRestSwaggerApiDeclarationServlet extends 
RestSwaggerApiDeclarationServlet {
+
+  override def lookupCamelContext(config: ServletConfig): CamelContext = {
+    val obj = config.getServletContext.getAttribute("CamelContext")
+    if (obj != null) {
+      camel = obj.asInstanceOf[CamelContext]
+      
SwaggerContext.registerClassLoader(camel.getApplicationContextClassLoader)
+    }
+    camel
+  }
+
+}

Reply via email to