use of org.hibernate.secure.spi.JaccService in project hibernate-orm by hibernate.
the class SessionFactoryImpl method applyCfgXmlValues.
private void applyCfgXmlValues(LoadedConfig aggregatedConfig, SessionFactoryServiceRegistry serviceRegistry) {
final JaccService jaccService = serviceRegistry.getService(JaccService.class);
if (jaccService.getContextId() != null) {
final JaccPermissionDeclarations permissions = aggregatedConfig.getJaccPermissions(jaccService.getContextId());
if (permissions != null) {
for (GrantedPermission grantedPermission : permissions.getPermissionDeclarations()) {
jaccService.addPermission(grantedPermission);
}
}
}
if (aggregatedConfig.getEventListenerMap() != null) {
final ClassLoaderService cls = serviceRegistry.getService(ClassLoaderService.class);
final EventListenerRegistry eventListenerRegistry = serviceRegistry.getService(EventListenerRegistry.class);
for (Map.Entry<EventType, Set<String>> entry : aggregatedConfig.getEventListenerMap().entrySet()) {
final EventListenerGroup group = eventListenerRegistry.getEventListenerGroup(entry.getKey());
for (String listenerClassName : entry.getValue()) {
try {
group.appendListener(cls.classForName(listenerClassName).newInstance());
} catch (Exception e) {
throw new ConfigurationException("Unable to instantiate event listener class : " + listenerClassName, e);
}
}
}
}
}
Aggregations