use of org.gluu.persist.PersistenceEntryManager in project oxAuth by GluuFederation.
the class AppInitializer method reloadConfiguration.
private void reloadConfiguration() {
PersistenceEntryManager localPersistenceEntryManager = persistenceEntryManagerInstance.get();
log.trace("Attempting to use {}: {}", ApplicationFactory.PERSISTENCE_ENTRY_MANAGER_NAME, localPersistenceEntryManager.getOperationService());
GluuConfiguration newConfiguration = loadConfiguration(localPersistenceEntryManager, "oxIDPAuthentication", "oxAuthenticationMode");
List<GluuLdapConfiguration> newPersistenceAuthConfigs = loadPersistenceAuthConfigs(newConfiguration);
if (!this.persistenceAuthConfigs.equals(newPersistenceAuthConfigs)) {
recreatePersistenceAuthEntryManagers(newPersistenceAuthConfigs);
this.persistenceAuthConfigs = newPersistenceAuthConfigs;
event.select(ReloadAuthScript.Literal.INSTANCE).fire(ExternalAuthenticationService.MODIFIED_INTERNAL_TYPES_EVENT_TYPE);
}
setDefaultAuthenticationMethod(newConfiguration);
}
use of org.gluu.persist.PersistenceEntryManager in project oxAuth by GluuFederation.
the class AppInitializer method destroy.
public void destroy(@Observes @BeforeDestroyed(ApplicationScoped.class) ServletContext init) {
log.info("Stopping services and closing DB connections at server shutdown...");
log.debug("Checking who intiated destory", new Throwable());
metricService.close();
PersistenceEntryManager persistenceEntryManager = persistenceEntryManagerInstance.get();
closePersistenceEntryManager(persistenceEntryManager, ApplicationFactory.PERSISTENCE_ENTRY_MANAGER_NAME);
List<PersistenceEntryManager> persistenceAuthEntryManagers = persistenceAuthEntryManagerInstance.get();
closePersistenceEntryManagers(persistenceAuthEntryManagers);
}
use of org.gluu.persist.PersistenceEntryManager in project oxAuth by GluuFederation.
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: {}", new Object[] { ApplicationFactory.PERSISTENCE_METRIC_ENTRY_MANAGER_NAME, persistenceEntryManager, persistenceEntryManager.getOperationService() });
externalPersistenceExtensionService.executePersistenceExtensionAfterCreate(connectionProperties, persistenceEntryManager);
return persistenceEntryManager;
}
use of org.gluu.persist.PersistenceEntryManager in project oxAuth by GluuFederation.
the class AppInitializer method createPersistenceAuthEntryManager.
@Produces
@ApplicationScoped
@Named(ApplicationFactory.PERSISTENCE_AUTH_ENTRY_MANAGER_NAME)
public List<PersistenceEntryManager> createPersistenceAuthEntryManager() {
List<PersistenceEntryManager> persistenceAuthEntryManagers = new ArrayList<PersistenceEntryManager>();
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 {}#{}: {}", new Object[] { ApplicationFactory.PERSISTENCE_AUTH_ENTRY_MANAGER_NAME, i, persistenceAuthEntryManager });
persistenceAuthEntryManagers.add(persistenceAuthEntryManager);
externalPersistenceExtensionService.executePersistenceExtensionAfterCreate(persistenceAuthProperties.get(i), persistenceAuthEntryManager);
}
return persistenceAuthEntryManagers;
}
use of org.gluu.persist.PersistenceEntryManager in project oxAuth by GluuFederation.
the class AppInitializer method recreatePersistenceAuthEntryManagers.
public void recreatePersistenceAuthEntryManagers(List<GluuLdapConfiguration> newPersistenceAuthConfigs) {
// Get existing application scoped instance
List<PersistenceEntryManager> oldPersistenceAuthEntryManagers = CdiUtil.getContextBean(beanManager, new ParameterizedTypeImpl(List.class, PersistenceEntryManager.class), ApplicationFactory.PERSISTENCE_AUTH_ENTRY_MANAGER_NAME);
// Recreate components
this.persistenceAuthConfigs = newPersistenceAuthConfigs;
// Close existing connections
closePersistenceEntryManagers(oldPersistenceAuthEntryManagers);
// Destroy old Ldap auth entry managers
for (PersistenceEntryManager oldPersistenceAuthEntryManager : oldPersistenceAuthEntryManagers) {
log.debug("Attempting to destroy {}: {}", ApplicationFactory.PERSISTENCE_AUTH_ENTRY_MANAGER_NAME, oldPersistenceAuthEntryManager);
oldPersistenceAuthEntryManager.destroy();
log.debug("Destroyed {}: {}", ApplicationFactory.PERSISTENCE_AUTH_ENTRY_MANAGER_NAME, oldPersistenceAuthEntryManager);
externalPersistenceExtensionService.executePersistenceExtensionAfterDestroy(oldPersistenceAuthEntryManager);
}
// Force to create new Ldap auth entry managers bean
List<PersistenceEntryManager> persistenceAuthEntryManagers = persistenceAuthEntryManagerInstance.get();
persistenceAuthEntryManagerInstance.destroy(persistenceAuthEntryManagers);
log.info("Recreated instance {}: {}", ApplicationFactory.PERSISTENCE_AUTH_ENTRY_MANAGER_NAME, persistenceAuthEntryManagers);
// Force to create new auth configuration bean
List<GluuLdapConfiguration> oldPersistenceAuthConfigs = persistenceAuthConfigInstance.get();
persistenceAuthConfigInstance.destroy(oldPersistenceAuthConfigs);
}
Aggregations