當前位置: 首頁>>代碼示例>>Java>>正文


Java ConfigurationException類代碼示例

本文整理匯總了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);
}
 
開發者ID:apache,項目名稱:aries-jpa,代碼行數:27,代碼來源:ManagedEMF.java

示例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();
}
 
開發者ID:apache,項目名稱:aries-jpa,代碼行數:17,代碼來源:PropsConfigurationTest.java

示例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();
}
 
開發者ID:apache,項目名稱:aries-jpa,代碼行數:23,代碼來源:PropsConfigurationTest.java

示例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();
}
 
開發者ID:apache,項目名稱:aries-jpa,代碼行數:25,代碼來源:PropsConfigurationTest.java

示例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();
}
 
開發者ID:ops4j,項目名稱:org.ops4j.pax.transx,代碼行數:19,代碼來源:TransactionManagerService.java

示例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);
	}
}
 
開發者ID:AdeptJ,項目名稱:adeptj-modules,代碼行數:25,代碼來源:InfinispanCacheProvider.java

示例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);
	}
}
 
開發者ID:AdeptJ,項目名稱:adeptj-modules,代碼行數:23,代碼來源:EhcacheCacheProvider.java

示例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()));
    }
}
 
開發者ID:AdeptJ,項目名稱:adeptj-modules,代碼行數:21,代碼來源:DefaultJaxRSAuthenticationRealm.java

示例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);
    }
}
 
開發者ID:apache,項目名稱:aries-rsa,代碼行數:23,代碼來源:ZookeeperStarter.java

示例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);
            }
        }
    }
}
 
開發者ID:apache,項目名稱:aries-rsa,代碼行數:18,代碼來源:ZooKeeperDiscovery.java

示例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);
}
 
開發者ID:apache,項目名稱:aries-rsa,代碼行數:18,代碼來源:ZookeeperDiscoveryTest.java

示例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);
}
 
開發者ID:apache,項目名稱:aries-rsa,代碼行數:21,代碼來源:ZookeeperDiscoveryTest.java

示例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);
}
 
開發者ID:MyPureCloud,項目名稱:purecloud-iot,代碼行數:24,代碼來源:HttpProxyConfigurationActivator.java

示例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);
	}
	
}
 
開發者ID:flyaruu,項目名稱:tasman,代碼行數:20,代碼來源:RedisUpdater.java

示例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();
}
 
開發者ID:andrey-desman,項目名稱:openhab-hdl,代碼行數:19,代碼來源:MqttPersistenceService.java


注:本文中的org.osgi.service.cm.ConfigurationException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。