本文整理匯總了Java中org.osgi.service.cm.ConfigurationException類的典型用法代碼示例。如果您正苦於以下問題:Java ConfigurationException類的具體用法?Java ConfigurationException怎麽用?Java ConfigurationException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ConfigurationException類屬於org.osgi.service.cm包,在下文中一共展示了ConfigurationException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updated
import org.osgi.service.cm.ConfigurationException; //導入依賴的package包/類
@Override
public void updated(Dictionary<String, ?> properties) throws ConfigurationException {
if(properties == null) {
if(configured.getAndSet(false)) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("The configuration has been deleted for persistence unit {}. Destroying the EMF", pUnitName);
}
builder.closeEMF();
} else {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Ignoring the unset configuration for persistence unit {}", pUnitName);
}
return;
}
}
Map<String, Object> overrides = (properties != null) ? asMap(properties) : null;
LOGGER.info("Configuration received for persistence unit {}", pUnitName);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Using properties override {}", overrides);
}
builder.createEntityManagerFactory(overrides);
configured.set(true);
}
示例2: testRegistersManagedEMF
import org.osgi.service.cm.ConfigurationException; //導入依賴的package包/類
@Test
public void testRegistersManagedEMF() throws InvalidSyntaxException, ConfigurationException {
AriesEntityManagerFactoryBuilder emfb = new AriesEntityManagerFactoryBuilder(
containerContext, provider, providerBundle, punit);
verify(containerContext).registerService(eq(ManagedService.class),
any(ManagedService.class), argThat(servicePropsMatcher(
SERVICE_PID, "org.apache.aries.jpa.test-props")));
// No EMF created as incomplete
verifyZeroInteractions(msReg, provider);
emfb.close();
verify(msReg).unregister();
}
示例3: testPUWithJtaDSGetsCreatedAutomatically
import org.osgi.service.cm.ConfigurationException; //導入依賴的package包/類
@Test
public void testPUWithJtaDSGetsCreatedAutomatically() throws InvalidSyntaxException, ConfigurationException {
when(containerContext.getServiceReferences((String) null,
"(&(objectClass=javax.sql.DataSource)(osgi.jndi.service.name=testds))"))
.thenReturn(new ServiceReference<?>[] {dsRef});
when(punit.getJtaDataSourceName()).thenReturn(
"osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=testds)");
when(provider.createContainerEntityManagerFactory(eq(punit),
any(Map.class))).thenReturn(emf);
AriesEntityManagerFactoryBuilder emfb = new AriesEntityManagerFactoryBuilder(
containerContext, provider, providerBundle, punit);
verify(punit).setJtaDataSource(ds);
verify(punitContext).registerService(eq(EntityManagerFactory.class),
any(EntityManagerFactory.class), argThat(servicePropsMatcher(JPA_UNIT_NAME, "test-props")));
emfb.close();
}
示例4: testPUWithNonJtaDSGetsCreatedAutomatically
import org.osgi.service.cm.ConfigurationException; //導入依賴的package包/類
@Test
public void testPUWithNonJtaDSGetsCreatedAutomatically() throws InvalidSyntaxException, ConfigurationException {
when(containerContext.getServiceReferences((String) null,
"(&(objectClass=javax.sql.DataSource)(osgi.jndi.service.name=testds))"))
.thenReturn(new ServiceReference<?>[] {dsRef});
when(punit.getTransactionType()).thenReturn(RESOURCE_LOCAL);
when(punit.getNonJtaDataSourceName()).thenReturn(
"osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=testds)");
when(provider.createContainerEntityManagerFactory(eq(punit),
any(Map.class))).thenReturn(emf);
AriesEntityManagerFactoryBuilder emfb = new AriesEntityManagerFactoryBuilder(
containerContext, provider, providerBundle, punit);
verify(punit).setNonJtaDataSource(ds);
verify(punitContext).registerService(eq(EntityManagerFactory.class),
any(EntityManagerFactory.class), argThat(servicePropsMatcher(JPA_UNIT_NAME, "test-props")));
emfb.close();
}
示例5: TransactionManagerService
import org.osgi.service.cm.ConfigurationException; //導入依賴的package包/類
public TransactionManagerService(String pid, Dictionary<String, ?> properties, BundleContext bundleContext) throws ConfigurationException {
this.pid = pid;
this.properties = properties;
this.bundleContext = bundleContext;
// Transaction timeout
int transactionTimeout = getInt(TRANSACTION_TIMEOUT, DEFAULT_TRANSACTION_TIMEOUT);
if (transactionTimeout <= 0) {
throw new ConfigurationException(TRANSACTION_TIMEOUT, "The transaction timeout property must be greater than zero.");
}
OsgiAssembler.setConfig(properties);
Configuration.init();
Configuration.getTransactionService();
new J2eeUserTransaction();
uts = new UserTransactionServiceImp();
uts.init();
tm = (TransactionManagerImp) TransactionManagerImp.getTransactionManager();
}
示例6: updated
import org.osgi.service.cm.ConfigurationException; //導入依賴的package包/類
@Override
public void updated(String pid, Dictionary<String, ?> properties) throws ConfigurationException {
this.initInfinispan();
String cacheName = (String) properties.get(CACHE_NAME);
Long cacheTTL = (Long) properties.get(CACHE_TTL);
Long cacheEntries = (Long) properties.get(CACHE_ENTRIES);
CacheConfig newCacheConfig = new CacheConfig(cacheName, pid, cacheTTL, cacheEntries);
CacheConfig storedCacheConfig = this.cacheConfigs.get(pid);
// If no CacheConfig against the given PID, create one.
if (storedCacheConfig == null) {
this.cacheConfigs.put(pid, newCacheConfig);
} else if (storedCacheConfig.equals(newCacheConfig)) {
// If CacheConfig unchanged(user just saved the Factory configuration without changing values), do nothing.
LOGGER.warn("Unchanged CacheConfig, ignoring it!!");
} else {
// Just remove the cache from CacheManager and update the CacheConfig.
String oldCacheName = storedCacheConfig.getCacheName();
LOGGER.info("Removing old cache with name: [{}] from Infinispan.", oldCacheName);
this.cacheManager.removeCache(oldCacheName);
storedCacheConfig.setCacheEntries(cacheEntries);
storedCacheConfig.setTtlSeconds(cacheTTL);
storedCacheConfig.setCacheName(cacheName);
}
}
示例7: updated
import org.osgi.service.cm.ConfigurationException; //導入依賴的package包/類
@Override
public void updated(String pid, Dictionary<String, ?> properties) throws ConfigurationException {
String cacheName = (String) Objects.requireNonNull(properties.get(CACHE_NAME), "Cache name can't be null!!");
Long cacheTTL = (Long) properties.get(CACHE_TTL);
Long cacheEntries = (Long) properties.get(CACHE_ENTRIES);
CacheConfig newCacheConfig = new CacheConfig(cacheName, pid, cacheTTL, cacheEntries);
CacheConfig storedCacheConfig = this.cacheConfigs.get(pid);
// If no CacheConfig against the given PID, create one.
if (storedCacheConfig == null) {
this.cacheConfigs.put(pid, newCacheConfig);
} else if (storedCacheConfig.equals(newCacheConfig)) {
// If CacheConfig unchanged(user just saved the Factory configuration without changing values), do nothing.
LOGGER.warn("Unchanged CacheConfig, ignoring it!!");
} else {
// Just remove the cache from CacheManager and update the CacheConfig.
LOGGER.info("Removing cache with name: [{}] from Ehcache CacheManager.", cacheName);
this.cacheMgr.removeCache(cacheName);
storedCacheConfig.setCacheEntries(cacheEntries);
storedCacheConfig.setTtlSeconds(cacheTTL);
storedCacheConfig.setCacheName(cacheName);
}
}
示例8: updated
import org.osgi.service.cm.ConfigurationException; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public void updated(String pid, Dictionary<String, ?> properties) throws ConfigurationException {
String username = Objects.requireNonNull((String) properties.get(KEY_USERNAME), USERNAME_NULL_MSG);
String password = Objects.requireNonNull((String) properties.get(KEY_PWD), PWD_NULL_MSG);
LOGGER.info("Creating JaxRSAuthenticationInfo for User: [{}]", username);
if (this.pidVsUserMappings.containsKey(pid)) {
// This is an update
this.pidVsUserMappings.put(pid, username);
this.authInfoMap.put(username, new JaxRSAuthenticationInfo(username, password.toCharArray()));
} else if (!this.pidVsUserMappings.containsKey(pid) && this.pidVsUserMappings.containsValue(username)) {
LOGGER.warn("User: [{}] already present, ignoring this config!!");
throw new ConfigurationException(KEY_USERNAME, "User already present!!");
} else if (!this.pidVsUserMappings.containsKey(pid) && !this.pidVsUserMappings.containsValue(username)) {
this.pidVsUserMappings.put(pid, username);
this.authInfoMap.put(username, new JaxRSAuthenticationInfo(username, password.toCharArray()));
}
}
示例9: updated
import org.osgi.service.cm.ConfigurationException; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public synchronized void updated(Dictionary<String, ?> dict) throws ConfigurationException {
LOG.debug("Received configuration update for Zookeeper Server: " + dict);
try {
if (dict != null) {
setDefaults((Dictionary<String, String>)dict);
}
Map<String, ?> configMap = Utils.toMap(dict);
if (!configMap.equals(curConfiguration)) { // only if something actually changed
shutdown();
curConfiguration = configMap;
// config is null if it doesn't exist, is being deleted or has not yet been loaded
// in which case we just stop running
if (dict != null) {
startFromConfig(parseConfig(dict));
LOG.info("Applied configuration update: " + dict);
}
}
} catch (Exception th) {
LOG.error("Problem applying configuration update: " + dict, th);
}
}
示例10: updated
import org.osgi.service.cm.ConfigurationException; //導入依賴的package包/類
public synchronized void updated(Dictionary<String, ?> configuration) throws ConfigurationException {
LOG.debug("Received configuration update for Zookeeper Discovery: {}", configuration);
// make changes only if config actually changed, to prevent unnecessary ZooKeeper reconnections
if (!ZooKeeperDiscovery.toMap(configuration).equals(ZooKeeperDiscovery.toMap(curConfiguration))) {
stop(false);
curConfiguration = configuration;
// config is null if it doesn't exist, is being deleted or has not yet been loaded
// in which case we just stop running
if (!closed && configuration != null) {
try {
createZookeeper(configuration);
} catch (IOException e) {
throw new ConfigurationException(null, "Error starting zookeeper client", e);
}
}
}
}
示例11: testDefaults
import org.osgi.service.cm.ConfigurationException; //導入依賴的package包/類
@Test
public void testDefaults() throws ConfigurationException {
IMocksControl c = EasyMock.createControl();
BundleContext bctx = c.createMock(BundleContext.class);
ZooKeeperDiscovery zkd = new ZooKeeperDiscovery(bctx) {
@Override
protected ZooKeeper createZooKeeper(String host, String port, int timeout) {
Assert.assertEquals("localhost", host);
Assert.assertEquals("2181", port);
Assert.assertEquals(3000, timeout);
return null;
}
};
Dictionary<String, Object> configuration = new Hashtable<String, Object>();
zkd.updated(configuration);
}
示例12: testConfig
import org.osgi.service.cm.ConfigurationException; //導入依賴的package包/類
@Test
public void testConfig() throws ConfigurationException {
IMocksControl c = EasyMock.createControl();
BundleContext bctx = c.createMock(BundleContext.class);
ZooKeeperDiscovery zkd = new ZooKeeperDiscovery(bctx) {
@Override
protected ZooKeeper createZooKeeper(String host, String port, int timeout) {
Assert.assertEquals("myhost", host);
Assert.assertEquals("1", port);
Assert.assertEquals(1000, timeout);
return null;
}
};
Dictionary<String, Object> configuration = new Hashtable<String, Object>();
configuration.put("zookeeper.host", "myhost");
configuration.put("zookeeper.port", "1");
configuration.put("zookeeper.timeout", "1000");
zkd.updated(configuration);
}
示例13: updated
import org.osgi.service.cm.ConfigurationException; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public void updated(final String pid, @SuppressWarnings("rawtypes") final Dictionary config) throws ConfigurationException {
final ServiceRegistration registration = registeredConfigurations.get(pid);
OSGiProxyConfiguration proxyConfiguration;
if (registration == null) {
proxyConfiguration = new OSGiProxyConfiguration();
final ServiceRegistration configurationRegistration = context.registerService(ProxyConfiguration.class.getName(),
proxyConfiguration,
config);
registeredConfigurations.put(pid, configurationRegistration);
} else {
proxyConfiguration = (OSGiProxyConfiguration) context.getService(registration.getReference());
}
@SuppressWarnings("unchecked") // data type is known
final
Dictionary<String, Object> properties = config;
proxyConfiguration.update(properties);
}
示例14: updated
import org.osgi.service.cm.ConfigurationException; //導入依賴的package包/類
@Override
public void updated(String pid, Dictionary<String, ?> properties)
throws ConfigurationException {
ClassLoader prev = null;
try {
prev = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
JedisPool pool = new JedisPool((String)properties.get("host.ip"),Integer.parseInt((String) properties.get("host.port")) );
pools.put(pid, pool);
ServiceRegistration<JedisPool> registered = bundleContext.registerService(JedisPool.class, pool, properties);
serviceRegistrations.put(pool, registered);
} catch (Throwable e) {
logger.error("Error: ", e);
} finally {
Thread.currentThread().setContextClassLoader(prev);
}
}
示例15: updated
import org.osgi.service.cm.ConfigurationException; //導入依賴的package包/類
@Override
public void updated(Dictionary<String, ?> properties) throws ConfigurationException {
if (properties == null || properties.isEmpty()) {
logger.trace("No config properties available.");
return;
}
brokerName = getProperty(properties, "broker");
topic = getProperty(properties, "topic");
messageTemplate = getProperty(properties, "message");
configured = true;
logger.debug("Configuration updated for MQTT Persistence.");
deactivate();
activate();
}