所以我正在复习该Camel-GAE
组件,我发现的所有教程/代码示例似乎都表明您必须使用 Spring DSL (XML) 才能让 Camel 在 GAE 上运行。
这是因为Camel-GAE
取决于Camel-Servlet
,而我发现的用于配置CamelServlet
in的唯一代码示例web.xml
涉及:
<web-app>
<servlet>
<servlet-name>CamelServlet</servlet-name>
<display-name>Camel Http Transport Servlet</display-name>
<servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>appctx.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>CamelServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
</web-app>
我真的不是 Spring 的忠实粉丝,我更愿意用 GIN 或 Guice 之类的东西来做我所有的 DI。有没有办法在CamelContext
不使用 Spring 的情况下创建 Camel Servlet 并定义它?提前致谢。
更新- 在 GAE 上使用 JNDI 注册表时出现的错误:
java.lang.NoClassDefFoundError: javax.naming.InitialContext is a restricted class. Please see the Google App Engine developer's guide for more details.
at com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:51)
at org.apache.camel.impl.JndiRegistry.createContext(JndiRegistry.java:103)
at org.apache.camel.impl.JndiRegistry.getContext(JndiRegistry.java:92)
at org.apache.camel.impl.JndiRegistry.lookup(JndiRegistry.java:65)
at org.apache.camel.impl.JndiRegistry.lookup(JndiRegistry.java:47)
at org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.lookup(PropertyPlaceholderDelegateRegistry.java:62)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1557)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1444)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1412)
at com.ourapp.server.servlets.CamelServlet.doGet(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)