本文整理汇总了Java中org.osgi.service.component.annotations.ReferencePolicy类的典型用法代码示例。如果您正苦于以下问题:Java ReferencePolicy类的具体用法?Java ReferencePolicy怎么用?Java ReferencePolicy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ReferencePolicy类属于org.osgi.service.component.annotations包,在下文中一共展示了ReferencePolicy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bindExtensionService
import org.osgi.service.component.annotations.ReferencePolicy; //导入依赖的package包/类
@Reference(
policy = ReferencePolicy.DYNAMIC,
service = RuntimeExtension.class,
cardinality = ReferenceCardinality.MULTIPLE
)
@SuppressWarnings("unused")
protected synchronized void bindExtensionService(RuntimeExtension extension, Map<String, Object> properties) {
Integer newPriority = PropertiesUtil.toInteger(properties.get(Constants.SERVICE_RANKING), 0);
String extensionName = PropertiesUtil.toString(properties.get(RuntimeExtension.NAME), "");
Integer priority = PropertiesUtil.toInteger(mappingPriorities.get(extensionName), 0);
if (newPriority > priority) {
mapping = Collections.unmodifiableMap(add(mapping, extension, extensionName));
mappingPriorities.put(extensionName, newPriority);
} else {
if (!mapping.containsKey(extensionName)) {
mapping = Collections.unmodifiableMap(add(mapping, extension, extensionName));
mappingPriorities.put(extensionName, newPriority);
}
}
}
示例2: onJNDIReady
import org.osgi.service.component.annotations.ReferencePolicy; //导入依赖的package包/类
@Reference(
name = "org.wso2.carbon.datasource.jndi",
service = JNDIContextManager.class,
cardinality = ReferenceCardinality.AT_LEAST_ONE,
policy = ReferencePolicy.DYNAMIC,
unbind = "onJNDIUnregister") protected void onJNDIReady(JNDIContextManager jndiContextManager) {
try {
Context ctx = jndiContextManager.newInitialContext();
DataSource dsObject = (DataSource) ctx.lookup("java:comp/env/jdbc/WSO2CARBON_DB");
if (dsObject != null) {
jdbcTemplate = new JdbcTemplate(dsObject);
initializeDao(jdbcTemplate);
} else {
log.error("Could not find WSO2CarbonDB");
}
} catch (NamingException e) {
log.error("Error occurred while looking up the Datasource", e);
}
}
示例3: addVerticle
import org.osgi.service.component.annotations.ReferencePolicy; //导入依赖的package包/类
@Reference(unbind = "removeVerticle", policy=ReferencePolicy.DYNAMIC, cardinality = ReferenceCardinality.MULTIPLE)
public void addVerticle(Verticle verticle) {
LOGGER.info("Deploying verticle " + verticle);
verticles.add(verticle);
if (verticle == null)
return;
if (vertxService != null)
vertxService.deployVerticle(verticle, deploy -> {
if (deploy.succeeded()) {
LOGGER.info("Deployment of verticle succeeded");
String id = deploy.result();
deployedVerticles.put(verticle, id);
} else {
LOGGER.log(Level.SEVERE, "Deployment of verticle failed", deploy.cause());
}
});
}
示例4: bindJNDIContextManager
import org.osgi.service.component.annotations.ReferencePolicy; //导入依赖的package包/类
@Reference(
name = "org.osgi.service.jndi",
service = JNDIContextManager.class,
cardinality = ReferenceCardinality.AT_LEAST_ONE,
policy = ReferencePolicy.DYNAMIC,
unbind = "unbindNDIContextManager"
)
protected void bindJNDIContextManager(JNDIContextManager jndiContextManager) throws NamingException {
Context initialContext = jndiContextManager.newInitialContext();
Context envContext = initialContext.createSubcontext("java:comp/env");
envContext.bind("company", "wso2");
String value = (String) initialContext.lookup("java:comp/env/company");
logger.info("JNDI Lookup(java:comp/env/company) value: {}", value);
}
示例5: setRealmService
import org.osgi.service.component.annotations.ReferencePolicy; //导入依赖的package包/类
/**
* @param realmService
*/
@Reference(
name = "user.realmservice.default",
service = RealmService.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.DYNAMIC,
unbind = "unsetRealmService")
protected void setRealmService(RealmService realmService) {
try {
ClaimManagementServiceDataHolder.getInstance().setRealmService(realmService);
} catch (Throwable e) {
log.error("Failed to get a reference to the Realm Service.", e);
}
if (log.isDebugEnabled()) {
log.debug("RealmService set in Claim Management bundle");
}
}
示例6: setRegistryService
import org.osgi.service.component.annotations.ReferencePolicy; //导入依赖的package包/类
@Reference(
name = "registry.service",
service = RegistryService.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.DYNAMIC,
unbind = "unsetRegistryService")
protected void setRegistryService(RegistryService registryService) {
try {
ClaimManagementServiceDataHolder.getInstance().setRegistryService(registryService);
} catch (Throwable e) {
log.error("Failed to get a reference to the Registry Service.", e);
}
if (log.isDebugEnabled()) {
log.debug("RegistryService set in Claim Management bundle");
}
}
示例7: setProvisioningConnectorFactory
import org.osgi.service.component.annotations.ReferencePolicy; //导入依赖的package包/类
@Reference(
name = "provisioning.connector.factory",
service = org.wso2.carbon.identity.provisioning.AbstractProvisioningConnectorFactory.class,
cardinality = ReferenceCardinality.AT_LEAST_ONE,
policy = ReferencePolicy.DYNAMIC,
unbind = "unsetProvisioningConnectorFactory")
protected void setProvisioningConnectorFactory(AbstractProvisioningConnectorFactory connectorFactory) {
ProvisioningServiceDataHolder.getInstance().getConnectorFactories().put(connectorFactory.getConnectorType(), connectorFactory);
if (log.isDebugEnabled()) {
log.debug("Added provisioning connector : " + connectorFactory.getConnectorType());
}
ProvisioningConnectorConfig provisioningConnectorConfig = new ProvisioningConnectorConfig();
provisioningConnectorConfig.setName(connectorFactory.getConnectorType());
Property[] property = new Property[connectorFactory.getConfigurationProperties().size()];
provisioningConnectorConfig.setProvisioningProperties(connectorFactory.getConfigurationProperties().toArray(property));
ProvisioningConnectorService.getInstance().addProvisioningConnectorConfigs(provisioningConnectorConfig);
}
示例8: setRegistryService
import org.osgi.service.component.annotations.ReferencePolicy; //导入依赖的package包/类
@Reference(
name = "registry.service",
service = RegistryService.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.DYNAMIC,
unbind = "unsetRegistryService"
)
protected void setRegistryService(RegistryService registryService) {
if (log.isDebugEnabled()) {
log.debug("Registry service in Identity idp-mgt bundle");
}
try {
IdpMgtServiceComponentHolder.getInstance().setRegistryService(registryService);
} catch (Throwable e) {
log.error("Failed to get a reference to the Registry in idp-mgt bundle", e);
}
}
示例9: setMetadataConverterService
import org.osgi.service.component.annotations.ReferencePolicy; //导入依赖的package包/类
@Reference(
name = "identity.provider.saml.service.component",
service = MetadataConverter.class,
cardinality = ReferenceCardinality.MULTIPLE,
policy = ReferencePolicy.DYNAMIC,
unbind = "unsetMetadataConverterService"
)
protected void setMetadataConverterService(MetadataConverter converter) {
if (log.isDebugEnabled()) {
log.debug("Metadata converter set in Identity idp-mgt bundle");
}
try {
IdpMgtServiceComponentHolder.getInstance().addMetadataConverter(converter);
} catch (Throwable e) {
log.error("Failed to get a reference to the Metadata Converter in idp-mgt bundle", e);
}
}
示例10: addPluginListener
import org.osgi.service.component.annotations.ReferencePolicy; //导入依赖的package包/类
@Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC)
void addPluginListener(PluginListener listener) {
synchronized (this.pluginListeners) {
if (!this.listenersActive) {
// Early joiner waits for startup
this.pluginListeners.put(listener, emptyList());
return;
}
}
// Started already - time to join!
// Always create trackers without holding any monitors or locks
// to avoid potential deadlock
List<PluginTracker<?>> trackers = createTrackers(listener);
// Dynamic references may be set at any time, even while the
// component is deactivating, therefore we only add the listener
// if it should be active
synchronized (this.pluginListeners) {
if (this.listenersActive) {
this.pluginListeners.put(listener, trackers);
trackers = emptyList();
}
}
// If the component was stopped then we may have dangling
// trackers in this list which should be closed. Otherwise
// the list will be empty (see above).
trackers.forEach(PluginTracker::close);
}
示例11: registerIdP
import org.osgi.service.component.annotations.ReferencePolicy; //导入依赖的package包/类
@Reference(
name = "org.wso2.carbon.analytics.idp.client.core.api.IdPClient",
service = IdPClient.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.DYNAMIC,
unbind = "unregisterIdP"
)
protected void registerIdP(IdPClient client) {
HttpIODataHolder.getInstance().setClient(client);
}
示例12: setIdentityEventService
import org.osgi.service.component.annotations.ReferencePolicy; //导入依赖的package包/类
@Reference(
name = "EventService",
service = EventService.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.DYNAMIC,
unbind = "unsetIdentityEventService"
)
protected void setIdentityEventService(EventService eventService) {
TestIdentityStoreHandlerDataHolder.getInstance().setIdentityEventService(eventService);
}
示例13: addMediatorProviderRegistry
import org.osgi.service.component.annotations.ReferencePolicy; //导入依赖的package包/类
@Reference(
name = "mediator-provider-registry-service",
service = org.wso2.carbon.gateway.core.flow.ProviderRegistry.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.DYNAMIC,
unbind = "removeMediatorProviderRegistry")
protected void addMediatorProviderRegistry(org.wso2.carbon.gateway.core.flow.ProviderRegistry registry) {
}
示例14: registerIdentityStoreConnectorFactory
import org.osgi.service.component.annotations.ReferencePolicy; //导入依赖的package包/类
@Reference(
name = "IdentityStoreConnectorFactory",
service = IdentityStoreConnectorFactory.class,
cardinality = ReferenceCardinality.AT_LEAST_ONE,
policy = ReferencePolicy.DYNAMIC,
unbind = "unregisterIdentityStoreConnectorFactory"
)
protected void registerIdentityStoreConnectorFactory(IdentityStoreConnectorFactory identityStoreConnectorFactory,
Map<String, String> properties) {
String connectorId = properties.get(CONNECTOR_TYPE);
IdentityMgtDataHolder.getInstance().registerIdentityStoreConnectorFactory(connectorId,
identityStoreConnectorFactory);
}
示例15: registerCredentialStoreConnectorFactory
import org.osgi.service.component.annotations.ReferencePolicy; //导入依赖的package包/类
@Reference(
name = "CredentialStoreConnectorFactory",
service = CredentialStoreConnectorFactory.class,
cardinality = ReferenceCardinality.AT_LEAST_ONE,
policy = ReferencePolicy.DYNAMIC,
unbind = "unregisterCredentialStoreConnectorFactory"
)
protected void registerCredentialStoreConnectorFactory(
CredentialStoreConnectorFactory credentialStoreConnectorFactory, Map<String, String> properties) {
String connectorId = properties.get(CONNECTOR_TYPE);
IdentityMgtDataHolder.getInstance().registerCredentialStoreConnectorFactory(connectorId,
credentialStoreConnectorFactory);
}