001package io.ebean.plugin;
002
003import io.ebean.Database;
004import io.ebean.bean.BeanLoader;
005import io.ebean.bean.EntityBeanIntercept;
006import io.ebean.config.DatabaseConfig;
007import io.ebean.config.dbplatform.DatabasePlatform;
008
009import java.util.List;
010
011/**
012 * Extensions to Database API made available to plugins.
013 */
014public interface SpiServer extends Database {
015
016  /**
017   * Return the DatabaseConfig.
018   */
019  DatabaseConfig config();
020
021  /**
022   * Migrate to config().
023   */
024  @Deprecated
025  default DatabaseConfig getServerConfig() {
026    return config();
027  }
028
029  /**
030   * Return the DatabasePlatform for this database.
031   */
032  DatabasePlatform databasePlatform();
033
034  /**
035   * Migrate to config().
036   */
037  @Deprecated
038  default DatabasePlatform getDatabasePlatform() {
039    return databasePlatform();
040  }
041
042  /**
043   * Return all the bean types registered on this server instance.
044   */
045  List<? extends BeanType<?>> beanTypes();
046
047  /**
048   * Migrate to beanTypes().
049   */
050  @Deprecated
051  default List<? extends BeanType<?>> getBeanTypes() {
052    return beanTypes();
053  }
054
055  /**
056   * Return the bean type for a given entity bean class.
057   */
058  <T> BeanType<T> beanType(Class<T> beanClass);
059
060  /**
061   * Migrate to beanType().
062   */
063  @Deprecated
064  default <T> BeanType<T> getBeanType(Class<T> beanClass) {
065    return beanType(beanClass);
066  }
067
068  /**
069   * Return the bean types mapped to the given base table.
070   */
071  List<? extends BeanType<?>> beanTypes(String baseTableName);
072
073  /**
074   * Migrate to beanTypes().
075   */
076  @Deprecated
077  default List<? extends BeanType<?>> getBeanTypes(String baseTableName) {
078    return beanTypes(baseTableName);
079  }
080
081  /**
082   * Return the bean type for a given doc store queueId.
083   */
084  BeanType<?> beanTypeForQueueId(String queueId);
085
086  /**
087   * Migrate to beanTypes().
088   */
089  @Deprecated
090  default BeanType<?> getBeanTypeForQueueId(String queueId) {
091    return beanTypeForQueueId(queueId);
092  }
093
094  /**
095   * Return a BeanLoader.
096   */
097  BeanLoader beanLoader();
098
099  /**
100   * Invoke lazy loading on this single bean (reference bean).
101   */
102  void loadBeanRef(EntityBeanIntercept ebi);
103
104  /**
105   * Invoke lazy loading on this single bean (L2 cache bean).
106   */
107  void loadBeanL2(EntityBeanIntercept ebi);
108
109  /**
110   * Invoke lazy loading on this single bean when no BeanLoader is set.
111   * Typically due to serialisation or multiple stateless updates.
112   */
113  void loadBean(EntityBeanIntercept ebi);
114}