use of io.jans.orm.PersistenceEntryManager in project jans by JanssenProject.
the class AppInitializer method createMetricPersistenceEntryManager.
@Produces
@ApplicationScoped
@Named(ApplicationFactory.PERSISTENCE_METRIC_ENTRY_MANAGER_NAME)
@ReportMetric
public PersistenceEntryManager createMetricPersistenceEntryManager() {
Properties connectionProperties = prepareCustomPersistanceProperties(ApplicationFactory.PERSISTENCE_METRIC_CONFIG_GROUP_NAME);
PersistenceEntryManager persistenceEntryManager = applicationFactory.getPersistenceEntryManagerFactory().createEntryManager(connectionProperties);
log.info("Created {}: {} with operation service: {}", ApplicationFactory.PERSISTENCE_METRIC_ENTRY_MANAGER_NAME, persistenceEntryManager, persistenceEntryManager.getOperationService());
externalPersistenceExtensionService.executePersistenceExtensionAfterCreate(connectionProperties, persistenceEntryManager);
return persistenceEntryManager;
}
use of io.jans.orm.PersistenceEntryManager in project jans by JanssenProject.
the class AppInitializer method createPersistenceAuthEntryManager.
@Produces
@ApplicationScoped
@Named(ApplicationFactory.PERSISTENCE_AUTH_ENTRY_MANAGER_NAME)
public List<PersistenceEntryManager> createPersistenceAuthEntryManager() {
List<PersistenceEntryManager> persistenceAuthEntryManagers = new ArrayList<>();
if (this.persistenceAuthConfigs.size() == 0) {
return persistenceAuthEntryManagers;
}
PersistenceEntryManagerFactory persistenceEntryManagerFactory = applicationFactory.getPersistenceEntryManagerFactory(LdapEntryManagerFactory.class);
List<Properties> persistenceAuthProperties = prepareAuthConnectionProperties(this.persistenceAuthConfigs, persistenceEntryManagerFactory.getPersistenceType());
log.trace("Attempting to create LDAP auth PersistenceEntryManager with properties: {}", persistenceAuthProperties);
for (int i = 0; i < persistenceAuthProperties.size(); i++) {
PersistenceEntryManager persistenceAuthEntryManager = persistenceEntryManagerFactory.createEntryManager(persistenceAuthProperties.get(i));
log.debug("Created {}#{}: {}", ApplicationFactory.PERSISTENCE_AUTH_ENTRY_MANAGER_NAME, i, persistenceAuthEntryManager);
persistenceAuthEntryManagers.add(persistenceAuthEntryManager);
externalPersistenceExtensionService.executePersistenceExtensionAfterCreate(persistenceAuthProperties.get(i), persistenceAuthEntryManager);
}
return persistenceAuthEntryManagers;
}
use of io.jans.orm.PersistenceEntryManager in project jans by JanssenProject.
the class AppInitializer method applicationInitialized.
public void applicationInitialized(@Observes @Initialized(ApplicationScoped.class) Object init) {
log.debug("Initializing application services");
configurationFactory.create();
PersistenceEntryManager localPersistenceEntryManager = persistenceEntryManagerInstance.get();
log.trace("Attempting to use {}: {}", ApplicationFactory.PERSISTENCE_ENTRY_MANAGER_NAME, localPersistenceEntryManager.getOperationService());
GluuConfiguration newConfiguration = loadConfiguration(localPersistenceEntryManager, "jansDbAuth", "jansAuthMode");
this.persistenceAuthConfigs = loadPersistenceAuthConfigs(newConfiguration);
// Initialize python interpreter
pythonService.initPythonInterpreter(configurationFactory.getBaseConfiguration().getString("pythonModulesDir", null));
// Initialize script manager
List<CustomScriptType> supportedCustomScriptTypes = Lists.newArrayList(CustomScriptType.values());
supportedCustomScriptTypes.remove(CustomScriptType.CACHE_REFRESH);
supportedCustomScriptTypes.remove(CustomScriptType.UPDATE_USER);
supportedCustomScriptTypes.remove(CustomScriptType.USER_REGISTRATION);
supportedCustomScriptTypes.remove(CustomScriptType.SCIM);
supportedCustomScriptTypes.remove(CustomScriptType.IDP);
statService.init();
// Start timer
initSchedulerService();
// Schedule timer tasks
metricService.initTimer();
configurationFactory.initTimer();
loggerService.initTimer();
ldapStatusTimer.initTimer();
cleanerTimer.initTimer();
customScriptManager.initTimer(supportedCustomScriptTypes);
keyGeneratorTimer.initTimer();
statTimer.initTimer();
expirationNotificatorTimer.initTimer();
initTimer();
initCibaRequestsProcessor();
// Set default authentication method after
setDefaultAuthenticationMethod(newConfiguration);
// Notify plugins about finish application initialization
eventApplicationInitialized.select(ApplicationInitialized.Literal.APPLICATION).fire(new ApplicationInitializedEvent());
}
use of io.jans.orm.PersistenceEntryManager in project jans by JanssenProject.
the class AppInitializer method recreatePersistanceEntryManagerImpl.
protected void recreatePersistanceEntryManagerImpl(Instance<PersistenceEntryManager> instance, String persistenceEntryManagerName, Annotation... qualifiers) {
// Get existing application scoped instance
PersistenceEntryManager oldPersistenceEntryManager = CdiUtil.getContextBean(beanManager, PersistenceEntryManager.class, persistenceEntryManagerName);
// Close existing connections
closePersistenceEntryManager(oldPersistenceEntryManager, persistenceEntryManagerName);
// Force to create new bean
PersistenceEntryManager persistenceEntryManager = instance.get();
instance.destroy(persistenceEntryManager);
log.info("Recreated instance {}: {} with operation service: {}", persistenceEntryManagerName, persistenceEntryManager, persistenceEntryManager.getOperationService());
}
use of io.jans.orm.PersistenceEntryManager in project jans by JanssenProject.
the class AppInitializer method closePersistenceEntryManagers.
private void closePersistenceEntryManagers(List<PersistenceEntryManager> oldPersistenceEntryManagers) {
// Close existing connections
for (PersistenceEntryManager oldPersistenceEntryManager : oldPersistenceEntryManagers) {
log.debug("Attempting to destroy {}: {}", ApplicationFactory.PERSISTENCE_AUTH_ENTRY_MANAGER_NAME, oldPersistenceEntryManager);
oldPersistenceEntryManager.destroy();
log.debug("Destroyed {}: {}", ApplicationFactory.PERSISTENCE_AUTH_ENTRY_MANAGER_NAME, oldPersistenceEntryManager);
externalPersistenceExtensionService.executePersistenceExtensionAfterDestroy(oldPersistenceEntryManager);
}
}
Aggregations