我想启动具有许多服务的 DS 组件是可选的,如果某些服务未启动,则这些组件不会被激活。所以我将这些可选服务的基数设置为可选,所以如果这些可选服务不可用,那么也可以激活目标组件。
但是现在的问题是,如果我将这些可选服务中的任何一个的配置更改为有效,因此服务变得可用,但它不会反映在该目标组件中
@Component(immediate = true, configurationPolicy = ConfigurationPolicy.IGNORE,name="directory.comp")
public class DirectoryControllers
{
@Reference(policy=ReferencePolicy.DYNAMIC)
private volatile IZimbra zimbra;
@Reference(policy=ReferencePolicy.DYNAMIC,cardinality=ReferenceCardinality.OPTIONAL)
private volatile IOpenDJ opendj;
@Reference(policy=ReferencePolicy.DYNAMIC,cardinality=ReferenceCardinality.OPTIONAL)
private volatile IOpenIDM openidm;
private ServletRegistration _registration;
@Activate void activate(BundleContext bc) throws ServletException, NamespaceException
{
AppProvisioners provisioners=new AppProvisioners(zimbra,openidm,opendj);
_registration = ServletRegistration.register(
bc, _httpService, "/middleware",
new ProvisioningController(_db,provisioners),
new UserEnrollmentController(_db,provisioners)
);
}
}
在这里,zimbra 组件不是可选的,所以每当我更改配置时,它都会在 DirectoryControllers 组件中受到影响,但对于 openidm、opendj 组件来说并非如此,当然它是可选的,但是在更改它们的配置有效时,它不会在 DirectoryControllers 组件中受到影响
我也尝试过绑定/取消绑定:
private volatile IOpenIDM openidm;
@Reference(name = "openidm.service", service = IOpenIDM.class, cardinality = ReferenceCardinality.OPTIONAL, policy = ReferencePolicy.DYNAMIC, unbind = "unbindOpenIDMService")
public void bindOpenIDMService(IOpenIDM openidm) {
this.openidm = openidm;
}
public void unbindOpenIDMService(IOpenIDM openidm) {
this.openidm = null;
}
我是否遗漏了导致此问题的任何内容?
谢谢你。