Class PersistenceService

java.lang.Object
org.openremote.container.persistence.PersistenceService
All Implemented Interfaces:
Consumer<org.openremote.model.PersistenceEvent<?>>, org.openremote.model.ContainerService

public class PersistenceService extends Object implements org.openremote.model.ContainerService, Consumer<org.openremote.model.PersistenceEvent<?>>
  • Field Details

  • Constructor Details

    • PersistenceService

      public PersistenceService()
  • Method Details

    • isPersistenceEventForEntityType

      public static org.apache.camel.Predicate isPersistenceEventForEntityType(Class<?> type)
    • getPriority

      public int getPriority()
      Description copied from interface: org.openremote.model.ContainerService
      Gets the priority of this service which is used to determine initialization order when services are auto discovered; services with a lower priority are initialized and started first.
      Specified by:
      getPriority in interface org.openremote.model.ContainerService
    • init

      public void init(org.openremote.model.Container container) throws Exception
      Description copied from interface: org.openremote.model.ContainerService
      All services are initialized in the order they have been added to the container (if container started with explicit list of services) otherwise they are initialized in order of ContainerService.getPriority().
      Specified by:
      init in interface org.openremote.model.ContainerService
      Throws:
      Exception
    • getEntityManagerFactory

      protected jakarta.persistence.EntityManagerFactory getEntityManagerFactory(Properties properties, List<String> classNames)
    • start

      public void start(org.openremote.model.Container container) throws Exception
      Description copied from interface: org.openremote.model.ContainerService
      After initialization, services are started in the order they have been added to the container (if container started with explicit list of services) otherwise they are started in order of ContainerService.getPriority().
      Specified by:
      start in interface org.openremote.model.ContainerService
      Throws:
      Exception
    • stop

      public void stop(org.openremote.model.Container container) throws Exception
      Description copied from interface: org.openremote.model.ContainerService
      When the container is shutting down, it stops all services in the reverse order they were started.
      Specified by:
      stop in interface org.openremote.model.ContainerService
      Throws:
      Exception
    • isCleanInstall

      public boolean isCleanInstall()
    • createEntityManager

      public jakarta.persistence.EntityManager createEntityManager()
    • doTransaction

      public void doTransaction(Consumer<jakarta.persistence.EntityManager> entityManagerConsumer)
    • doReturningTransaction

      public <R> R doReturningTransaction(Function<jakarta.persistence.EntityManager,R> entityManagerFunction)
    • getEntityManagerFactory

      public jakarta.persistence.EntityManagerFactory getEntityManagerFactory()
    • getDefaultSchemaLocations

      public Set<String> getDefaultSchemaLocations()
    • getSchemas

      public Set<String> getSchemas()
    • publishPersistenceEvent

      public void publishPersistenceEvent(org.openremote.model.PersistenceEvent.Cause cause, Object currentEntity, Object previousEntity, Class<?> clazz, List<String> includeFields, List<String> excludeFields)
      Generate PersistenceEvents for entities not managed by JPA (i.e. Keycloak entities)
    • publishPersistenceEvent

      public void publishPersistenceEvent(org.openremote.model.PersistenceEvent.Cause cause, Object entity, String[] propertyNames, Object[] currentState, Object[] previousState)
      Generate PersistenceEvents for entities not managed by JPA (i.e. Keycloak entities)
    • openDatabase

      protected void openDatabase(org.openremote.model.Container container, Database database, String username, String password, String connectionUrl)
    • prepareSchema

      protected void prepareSchema(org.openremote.model.Container container, String connectionUrl, String databaseUsername, String databasePassword, String schemaName)
    • appendSchemaLocations

      protected void appendSchemaLocations(List<String> locations)
    • appendSchemas

      protected void appendSchemas(List<String> schemas)
    • accept

      public void accept(org.openremote.model.PersistenceEvent<?> persistenceEvent)
      Specified by:
      accept in interface Consumer<org.openremote.model.PersistenceEvent<?>>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getStorageDir

      public Path getStorageDir()
    • resolvePath

      public Path resolvePath(String path)
      Will resolve relative paths relative to getStorageDir()
    • resolvePath

      public Path resolvePath(Path path)
      Will resolve relative paths relative to getStorageDir()
    • getEntityPropertyFields

      public static Field[] getEntityPropertyFields(Class<?> clazz, List<String> includeFields, List<String> excludeFields)