use of org.wso2.carbon.identity.notification.mgt.NotificationMgtConfigBuilder in project carbon-identity-framework by wso2.
the class NotificationManagementServiceComponent method activate.
@Activate
protected void activate(ComponentContext context) {
// messages on a registered event
try {
// Pass the bundle context to read property file in a case it is not found in default location.
try {
configBuilder = new NotificationMgtConfigBuilder(context.getBundleContext());
} catch (NotificationManagementException e) {
log.error("Error while building Notification Mgt configuration", e);
}
// Read the thread pool size from configurations. If not present in configurations use default value.
if (configBuilder != null && configBuilder.getThreadPoolSize() != null) {
try {
threadPoolSize = Integer.parseInt(configBuilder.getThreadPoolSize());
} catch (NumberFormatException e) {
if (log.isDebugEnabled()) {
log.debug("Error while parsing thread pool size configuration, " + "setting default size :" + NotificationMgtConstants.THREAD_POOL_DEFAULT_SIZE);
}
threadPoolSize = NotificationMgtConstants.THREAD_POOL_DEFAULT_SIZE;
}
} else {
if (log.isDebugEnabled()) {
log.debug("No configuration found for thread pool size, " + "setting default size :" + NotificationMgtConstants.THREAD_POOL_DEFAULT_SIZE);
}
threadPoolSize = NotificationMgtConstants.THREAD_POOL_DEFAULT_SIZE;
}
if (log.isDebugEnabled()) {
log.debug("Notification mgt thread pool size " + threadPoolSize);
}
// Register Notification sender as the service class
notificationSender = new NotificationSender(notificationSendingModules, threadPoolSize);
context.getBundleContext().registerService(NotificationSender.class.getName(), notificationSender, null);
if (log.isDebugEnabled()) {
log.debug("Notification Management bundle is activated");
}
// Catch throwable since there may be run time exceptions.
} catch (Throwable e) {
log.error("Error while initiating Notification Management component", e);
}
}
use of org.wso2.carbon.identity.notification.mgt.NotificationMgtConfigBuilder in project carbon-identity-framework by wso2.
the class AbstractEventHandlerTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
String home = IdentityEventConfigBuilder.class.getResource("/").getFile();
String config = IdentityEventConfigBuilder.class.getResource("/").getFile();
System.setProperty("carbon.home", home);
System.setProperty("carbon.config.dir.path", config);
subscriptionList = new ArrayList<>();
moduleConfiguration = Mockito.mock(ModuleConfiguration.class);
Mockito.doReturn(subscriptionList).when(moduleConfiguration).getSubscriptions();
IdentityEventConfigBuilder identityEventConfigBuilder = Mockito.mock(IdentityEventConfigBuilder.class);
Field field = IdentityEventConfigBuilder.class.getDeclaredField("notificationMgtConfigBuilder");
field.setAccessible(true);
field.set(null, identityEventConfigBuilder);
Mockito.doReturn(moduleConfiguration).when(identityEventConfigBuilder).getModuleConfigurations(moduleName);
moduleConfigurationMap = new HashMap<>();
Mockito.doReturn(moduleConfigurationMap).when(identityEventConfigBuilder).getModuleConfiguration();
Mockito.doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
return moduleConfigurationMap.get(invocationOnMock.getArguments()[0]);
}
}).when(identityEventConfigBuilder).getModuleConfigurations(Matchers.anyString());
ModuleConfiguration moduleConfiguration2 = new ModuleConfiguration(new Properties(), subscriptionList);
moduleConfigurationMap.put("TestEventHandler", moduleConfiguration2);
}
Aggregations