public class ServiceSessionControl extends SessionControl
Modifier and Type | Class and Description |
---|---|
(package private) static class |
ServiceSessionControl.FlushSessionAction
Flushes the given session before the transaction is committed.
|
(package private) static class |
ServiceSessionControl.ServicesKeyring
Our own keyring containing the only permission:
Permission.ACT_AS_ANOTHER_USER . |
class |
ServiceSessionControl.SessionFactoryConfiguration
Used for creating a configuration that is the basis for building a
session factory.
|
Modifier and Type | Field and Description |
---|---|
private static org.slf4j.Logger |
log |
Constructor and Description |
---|
ServiceSessionControl() |
Modifier and Type | Method and Description |
---|---|
SessionFactory |
buildSessionFactory(ServiceSessionControl.SessionFactoryConfiguration config)
Create a session factory for the given configuration.
|
ServiceSessionControl.SessionFactoryConfiguration |
createSessionFactoryConfiguration(java.lang.String appId,
java.lang.String schema,
int schemaVersion,
java.lang.ClassLoader classLoader)
Create an object that can be used for collecting configuration options
and other settings that are needed to create session factories for services.
|
(package private) java.lang.String |
getCatalog() |
Session |
newSession(SessionBuilder builder,
DbControl dc)
Create a new Hibernate session for the given session factory that
is piggy-backed on the given DbControl transaction.
|
(package private) boolean |
schemaExists(java.lang.String catalog,
java.lang.String schema) |
cleanUp, clearDbControlCache, close, deleteContext, deleteCurrentContexts, finalize, getActiveProjectId, getActiveProjectPermissions, getActiveRoles, getAllCurrentContexts, getAllPermissions, getAllPermissions, getAllRoles, getAuthenticationMethod, getClientDefaultSetting, getClientId, getContext, getContextNames, getContextNames, getCurrentContext, getCurrentContext, getCurrentContext, getCurrentContext, getCurrentSessionId, getExternalClientId, getFriends, getGroups, getId, getInactiveRoles, getItemKeyId, getItemKeys, getItemKeys, getJobId, getJobSessionControl, getLastAccess, getLocale, getLoggedInUserId, getPluginId, getPluginPermissions, getPluginSessionControl, getProjectKeyId, getProjectKeys, getProjectKeys, getProjectPermission, getProjects, getRemoteId, getRolePermissions, getRoles, getSessionSetting, getSharedPermissions, getUserClientSetting, getUserDefaultSetting, hasPermission, hasSystemPermission, impersonateLogin, impersonateLogin, isAllowedToUseClient, isClosed, isDenied, isFriendOf, isImpersonated, isLoggedIn, isMemberOf, isMemberOf, isMemberOf, isRoleInactive, loadContext, loadContext, login, login, login, logout, newDbControl, reloadPermissions, reloadSettings, saveCurrentContextAs, saveCurrentContextAs, setActiveProject, setRoleInactive, setSessionSetting, setUserClientSetting, setUserDefaultSetting, updateLastAccess, verifyUserInternal
public ServiceSessionControl.SessionFactoryConfiguration createSessionFactoryConfiguration(java.lang.String appId, java.lang.String schema, int schemaVersion, java.lang.ClassLoader classLoader)
An application id, schema and schema version is required. This information is used by BASE to check the currently installed schema version and only update the database if there is a change. Note that the schema version must always increase from one version to the next.
A class loader is needed so that Hibernate can load the classes from extension classes.
It is possible to use ServiceSessionControl.SessionFactoryConfiguration.getInstallMode()
and ServiceSessionControl.SessionFactoryConfiguration.getInstalledSchemaVersion()
to check
the current status of the database.
Use ServiceSessionControl.SessionFactoryConfiguration.getRegistryBuilder()
to get a Hibernate
object for setting things that are typically configured in hibernate.cfg.xml
.
Typically, StandardServiceRegistryBuilder.applySetting(String, Object)
is the main
method to use for this.
Use ServiceSessionControl.SessionFactoryConfiguration.getMetadataSources()
to get a
Hibernate object for adding mapped entity classes. Typically,
MetadataSources.addAnnotatedClass(Class)
is the main method to use for this.
Note that once the metadata sources object has been created it is not
possible to modify the registry settings.
Also note that by default the configured session factory need to be
"piggy-backed" on a BASE DbControl
transaction. Create
Hibernate sessions with newSession(org.hibernate.SessionBuilder, DbControl)
.
If you want to use connections/transactions that are independent from BASE
call ServiceSessionControl.SessionFactoryConfiguration.setUseSeparateConnections(boolean)
but make sure you also get connection pooling configured.
You can still use "piggy-backed" connections.
appId
- The ID of the extensions (which should be unique)schema
- The schema name the extension wants to use for it's database tablesschemaVersion
- The version of the current schema. If this is different from the
database scheme it will automatically be updated when buildSessionFactory(SessionFactoryConfiguration)
is called.classLoader
- A class loader is needed for Hibernate to be able to locate the
classes. Use the classloader returned from Class.getClassLoader()
using the
class from one of the classes in the extensionjava.lang.String getCatalog()
boolean schemaExists(java.lang.String catalog, java.lang.String schema)
public SessionFactory buildSessionFactory(ServiceSessionControl.SessionFactoryConfiguration config)
config
- A configuration instance containing information needed to build
the session factorypublic Session newSession(SessionBuilder builder, DbControl dc)
builder
- A session builder (eg. SessionFactory.withOptions())dc
- An open DbControl