Osgi 如何使用管理配置服务从rest服务URL动态删除CXF

Osgi 如何使用管理配置服务从rest服务URL动态删除CXF,osgi,cxf,karaf,blueprint-osgi,Osgi,Cxf,Karaf,Blueprint Osgi,我是OSGI的新手。我已经使用cxf和blueprint开发了一个学生休息服务。默认情况下,karaf的URL中有cxf。我发现我可以在etc文件夹中配置属性(org.apache.cxf.servlet.context=/student),也可以在karaf中运行config:edit/setprop/update/commands。这样我就可以用一些自定义值替换url中的cxf。但是现在我想从我的url中删除CXF,而不在karaf中做任何上述更改。我还有别的办法可以这样做吗?我发现,使用管

我是OSGI的新手。我已经使用cxf和blueprint开发了一个学生休息服务。默认情况下,karaf的URL中有cxf。我发现我可以在etc文件夹中配置属性(org.apache.cxf.servlet.context=/student),也可以在karaf中运行config:edit/setprop/update/commands。这样我就可以用一些自定义值替换url中的cxf。但是现在我想从我的url中删除CXF,而不在karaf中做任何上述更改。我还有别的办法可以这样做吗?我发现,使用管理配置服务和配置,我可以更新上述属性,但它不工作

我提到了以下链接: -这对我不起作用

当我使用blueprint时,我是否需要添加额外的内容?我必须传递给createFactoryConfiguration的factorypid和位置是什么


提前感谢。

我已经找到了解决问题的方法。将以下代码添加到activator的启动方法中

  Dictionary<String, String> props = new Hashtable<String, String>();
  props.put( "org.apache.cxf.servlet.context", "/student" );
  // Use OSGI admin configuration to update CXF url
  ServiceReference reference = context.getServiceReference( ConfigurationAdmin.class.getName() );
  ConfigurationAdmin admin = (ConfigurationAdmin) context.getService( reference );
  try
  {
     Configuration config = admin.getConfiguration( "org.apache.cxf.osgi", null );
     config.update( props );
  }
  catch ( Exception exception )
  {
              throw exception;
  }
Dictionary props=new Hashtable();
put(“org.apache.cxf.servlet.context”,“/student”);
//使用OSGI管理配置更新CXF url
ServiceReference=context.getServiceReference(ConfigurationAdmin.class.getName());
ConfigurationAdmin=(ConfigurationAdmin)context.getService(参考);
尝试
{
Configuration config=admin.getConfiguration(“org.apache.cxf.osgi”,null);
配置更新(道具);
}
捕获(异常)
{
抛出异常;
}

无需对blueprint.xml进行任何更改。它在卡拉夫和春分都有效。起初,我在equinox中尝试,但没有将位置参数传递给getConfiguration(),因此它不起作用

不知道你想做什么。您似乎已经找到了如何将CXFServlet上下文更改为其他内容。我记得您可以显式地在CXFBean上设置地址。这允许使用(admin.getConfiguration(“org.apache.CXF.osgi”).update(props)指定端口和urlAm,并使用新值ie/student对其进行更新(这里admin是ConfigurationAdmin参考变量,props是键为“org.apache.CXF.servlet.context”,值为“/student”的字典)。同样的方法在卡拉夫也很有效。但当我在春分点尝试同样的方法时,它不起作用。调试时,我看到从Equinox返回的配置有以下org.eclipse.Equinox.internal.cm。ConfigurationImpl@13e23499. 但是karaf有关于org.apache.cxf.osgi的详细信息。