Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 具有OSGi包uri的Camel xquery端点_Spring_Osgi_Xquery_Apache Camel_Apache Karaf - Fatal编程技术网

Spring 具有OSGi包uri的Camel xquery端点

Spring 具有OSGi包uri的Camel xquery端点,spring,osgi,xquery,apache-camel,apache-karaf,Spring,Osgi,Xquery,Apache Camel,Apache Karaf,我有一个OSGi包(部署到Karaf2.2.4中),它启动了一个驼峰(2.10.0)上下文。骆驼上下文的routebuilder有一些xquery端点URI,例如 "xquery:classpath:Dir1/Dir2/example.xq" 当上下文试图解析该URI时,它失败了,因为Camel包与.xq文件所在的类路径不同。因此,我创建了一个url扩展函数 "xquery:classpath:..." 进入 因为我在项目早期处理ClassPathScanningCandidateCompo

我有一个OSGi包(部署到Karaf2.2.4中),它启动了一个驼峰(2.10.0)上下文。骆驼上下文的routebuilder有一些xquery端点URI,例如

"xquery:classpath:Dir1/Dir2/example.xq"
当上下文试图解析该URI时,它失败了,因为Camel包与.xq文件所在的类路径不同。因此,我创建了一个url扩展函数

"xquery:classpath:..."
进入

因为我在项目早期处理
ClassPathScanningCandidateComponentProvider
(Spring 3.1.1)时处理了bundle URI和
OsgiBundleResourcePatternResolver
。不幸的是,我似乎找不到一种方法让Camel的
XQueryComponent
使用我的
OsgiBundleResourcePatternResolver

  • 我这样做对吗?有没有更简单的方法
  • 如果是,如何确保
    XQueryComponent
    能够理解
    捆绑包:
    URI
  • 另外,我是否可以确保任何camel组件都能理解
    包:
    URI

  • 具有上述xquery端点的驼峰路由的应用程序需要导入xq文件所在的包,例如表示“Dir1.Dir2”的包

    因此,在META-INF/MANIFEST.MF中,包含OSGi导入|导出。您应该具有该给定包的导入

    回答你的3颗子弹

  • 不,见上文
  • 您需要扩展此组件并为“bundle”添加自己的逻辑
  • 不,不是真的,因为您需要向camel-core/camel-core osgi添加逻辑

  • 另外,应用程序的bundle id可能会更改,因此不建议按其id引用bundle。而且您无法分配由osgi容器自行分配的bundle id。

    多亏了Claus的回答,我才意识到我的.xq文件不在其.jar的正确目录中


    Dir1位于其.jar文件的根目录中。虽然在非OSGi web容器中运行应用程序效果很好,但Karaf似乎对资源应该在my.war文件中的位置要求更严格。当代码使用
    xquery:classpath:Dir1/Dir2/example.xq>时,我将.xq文件移动到
    WEB-INF/classes/Dir1/…
    ,现在不再接收
    FileNotFoundExceptions
    ,而Camel捆绑包是独立的,Camel上下文及其routebuilder与.xq文件位于同一捆绑包中。我在写问题时假设驼峰包访问.xq文件有问题,但您的回答让我相信这不是问题所在。如果routebuilder和.xq在同一个捆绑包中,它们不应该已经能够看到对方了吗?
    "xquery:bundle://42.0:6/..."