我有两个OSGi包部署在Apache Karaf. A和B。我的A OSGi捆绑包用作基本身份验证处理程序。我已经设置了我的安全处理程序,它工作正常:
<bean id="securityHandler" class="org.eclipse.jetty.security.ConstraintSecurityHandler">
<property name="authenticator">
<bean class="org.eclipse.jetty.security.authentication.BasicAuthenticator"/>
</property>
<property name="constraintMappings">
<list>
<ref bean="constraintMapping"/>
</list>
</property>
<property name="loginService" ref="loginService"/>
<property name="strict" value="false"/>
<property name="identityService" ref="identityService"/>
</bean>
此处理程序位于 bundle 中A。我需要做的是使这个处理程序成为OSGi其他捆绑包使用的服务,在这种情况下,由 bundle 使用B。我无法实现任何ConstraintSecurityHandler类接口,因为它来自org.eclipse.jetty.security包。
我试图创建自己的 Handler 类,然后扩展ConstraintSecurityHandler并实现我的接口。所以OSGi服务看起来像这样:
<osgi:service ref="securityHandler" interface="my.company.MyInterface" />
这不起作用,我得到了例外:
org.apache.camel.RuntimeCamelException: org.apache.camel.FailedToCreateRouteException: Failed to create route route1: Route[[From[jetty:http://0.0.0.0:8019/TARGETjobs/Indeed?hand... because of Failed to resolve endpoint: jetty://http://0.0.0.0:8019/TARGETjobs/Indeed?handlers=securityHandler&matchOnUriPrefix=true due to: null
所以问题是我怎样才能让这个securityHandlerbean 作为OSGi服务提供给其他OSGi捆绑包?