use of org.osgi.service.component.ComponentException in project felix by apache.
the class ComponentFactoryImpl method newInstance.
/* (non-Javadoc)
* @see org.osgi.service.component.ComponentFactory#newInstance(java.util.Dictionary)
*/
public ComponentInstance newInstance(Dictionary<String, ?> dictionary) {
final SingleComponentManager<S> cm = createComponentManager();
log(LogService.LOG_DEBUG, "Creating new instance from component factory {0} with configuration {1}", new Object[] { getComponentMetadata().getName(), dictionary }, null);
cm.setFactoryProperties(dictionary);
// configure the properties
cm.reconfigure(m_configuration, false, null);
// enable
cm.enableInternal();
ComponentInstance instance;
if (getComponentMetadata().isPersistentFactoryComponent()) {
instance = new ModifyComponentInstance<S>(cm);
} else {
instance = cm.getComponentInstance();
if (instance == null || instance.getInstance() == null) {
// activation failed, clean up component manager
cm.dispose(ComponentConstants.DEACTIVATION_REASON_DISPOSED);
throw new ComponentException("Failed activating component");
}
}
synchronized (m_componentInstances) {
m_componentInstances.put(cm, cm);
}
return instance;
}
use of org.osgi.service.component.ComponentException in project fabric8 by jboss-fuse.
the class FabricDetectingGateway method createDetectingGateway.
protected DetectingGateway createDetectingGateway() {
DetectingGateway gateway = new DetectingGateway();
VertxService vertxService = getVertxService();
LoadBalancer serviceLoadBalancer = LoadBalancers.createLoadBalancer(loadBalancerType, stickyLoadBalancerCacheSize);
gateway.setVertx(vertxService.getVertx());
gateway.setPort(port);
gateway.setServiceMap(serviceMap);
gateway.setShutdownTacker(shutdownTacker);
gateway.setServiceLoadBalancer(serviceLoadBalancer);
gateway.setDefaultVirtualHost(defaultVirtualHost);
ArrayList<Protocol> protocols = new ArrayList<Protocol>();
if (isStompEnabled()) {
protocols.add(new StompProtocol());
}
if (isMqttEnabled()) {
protocols.add(new MqttProtocol());
}
if (isAmqpEnabled()) {
protocols.add(new AmqpProtocol());
}
if (isOpenWireEnabled()) {
protocols.add(new OpenwireProtocol());
}
if (isHttpEnabled()) {
protocols.add(new HttpProtocol());
}
if (isSslEnabled()) {
SslConfig sslConfig = new SslConfig();
if (Strings.isNotBlank(sslAlgorithm)) {
sslConfig.setAlgorithm(sslAlgorithm);
}
if (Strings.isNotBlank(keyAlias)) {
sslConfig.setKeyAlias(keyAlias);
}
if (Strings.isNotBlank(keyPassword)) {
sslConfig.setKeyPassword(keyPassword);
}
if (Strings.isNotBlank(keyStorePassword)) {
sslConfig.setKeyStorePassword(keyStorePassword);
}
if (keyStoreURL != null) {
sslConfig.setKeyStoreURL(keyStoreURL);
}
if (Strings.isNotBlank(sslProtocol)) {
sslConfig.setProtocol(sslProtocol);
}
if (Strings.isNotBlank(sslStoreType)) {
sslConfig.setStoreType(sslStoreType);
}
if (Strings.isNotBlank(trustStorePassword)) {
sslConfig.setTrustStorePassword(trustStorePassword);
}
if (trustStoreURL != null) {
sslConfig.setTrustStoreURL(trustStoreURL);
}
if (Strings.isNotBlank(enabledCipherSuites)) {
sslConfig.setEnabledCipherSuites(enabledCipherSuites);
}
if (Strings.isNotBlank(disabledCypherSuites)) {
sslConfig.setDisabledCypherSuites(disabledCypherSuites);
}
gateway.setSslConfig(sslConfig);
// validating configuration
try {
SSLContext sslContext = SSLContext.getInstance(sslConfig.getProtocol());
sslContext.init(sslConfig.getKeyManagers(), sslConfig.getTrustManagers(), null);
} catch (Exception e) {
throw new ComponentException(e);
}
protocols.add(new SslProtocol());
}
if (protocols.isEmpty()) {
return null;
}
gateway.setProtocols(protocols);
return gateway;
}
use of org.osgi.service.component.ComponentException in project opencast by opencast.
the class IndexServiceImplTest method setupCommonCatalogUIAdapter.
private Tuple<CommonEventCatalogUIAdapter, VCell<Option<MetadataCollection>>> setupCommonCatalogUIAdapter(Workspace workspace) throws org.osgi.service.cm.ConfigurationException {
// Create Common Event Catalog UI Adapter
final VCell<Option<MetadataCollection>> metadataCell = VCell.ocell();
CommonEventCatalogUIAdapter commonEventCatalogUIAdapter = new CommonEventCatalogUIAdapter() {
@Override
public Catalog storeFields(MediaPackage mediaPackage, MetadataCollection metadata) {
metadataCell.set(Option.some(metadata));
return super.storeFields(mediaPackage, metadata);
}
};
Properties episodeCatalogProperties = new Properties();
InputStream in = null;
try {
in = getClass().getResourceAsStream("/episode-catalog.properties");
episodeCatalogProperties.load(in);
} catch (IOException e) {
throw new ComponentException(e);
} finally {
IoSupport.closeQuietly(in);
}
commonEventCatalogUIAdapter.updated(PropertiesUtil.toDictionary(episodeCatalogProperties));
commonEventCatalogUIAdapter.setWorkspace(workspace);
return Tuple.tuple(commonEventCatalogUIAdapter, metadataCell);
}
use of org.osgi.service.component.ComponentException in project opencast by opencast.
the class CatalogAdapterUtil method getCatalogProperties.
/**
* Get the catalog properties from the given file
*
* @param sourceClass
* Source from where the the method is called
* @param sourceFile
* the path to the source file
* @return the catalog {@link Properties}
*/
public static Properties getCatalogProperties(Class<?> sourceClass, String sourceFile) {
Properties episodeCatalogProperties = new Properties();
InputStream in = null;
try {
in = sourceClass.getResourceAsStream(sourceFile);
episodeCatalogProperties.load(in);
} catch (IOException e) {
throw new ComponentException(e);
} finally {
IoSupport.closeQuietly(in);
}
return episodeCatalogProperties;
}
use of org.osgi.service.component.ComponentException in project opencast by opencast.
the class MetadataListTest method setUp.
@Before
public void setUp() throws Exception {
episodeDublinCoreCatalogUIAdapter = new CommonEventCatalogUIAdapter();
Properties episodeCatalogProperties = new Properties();
InputStream in = null;
try {
in = getClass().getResourceAsStream("/episode-catalog.properties");
episodeCatalogProperties.load(in);
} catch (IOException e) {
throw new ComponentException(e);
} finally {
IoSupport.closeQuietly(in);
}
episodeDublinCoreCatalogUIAdapter.updated(PropertiesUtil.toDictionary(episodeCatalogProperties));
}
Aggregations