View Javadoc
1   package com.atlassian.activeobjects.external;
2   
3   import com.atlassian.activeobjects.spi.DatabaseType;
4   import net.java.ao.RawEntity;
5   
6   import java.util.concurrent.ExecutionException;
7   import java.util.concurrent.TimeUnit;
8   import java.util.concurrent.TimeoutException;
9   
10  /**
11   * This interface provides information about the state of the active objects module itself, in the context of the
12   * current data source.
13   *
14   * @since 0.24
15   */
16  public interface ActiveObjectsModuleMetaData {
17      /**
18       * Awaits initialization of the ActiveObjects model,this method will block until the active objects schema has been
19       * initialized for the current data source.
20       * <p>
21       * This method cannot be called from within an UpgradeTask
22       * <p>
23       * Blocks indefinitely.
24       *
25       * @throws com.atlassian.activeobjects.external.NoDataSourceException
26       */
27      void awaitInitialization() throws ExecutionException, InterruptedException;
28  
29      /**
30       * See {@link #awaitInitialization()}
31       *
32       * @param timeout the maximum time to wait
33       * @param unit    the time unit of the timeout argument
34       * @since 0.26
35       */
36      void awaitInitialization(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException;
37  
38      /**
39       * Indicates if initialization has completed successfully. If this returns true a call to awaitInitialization will
40       * return immediately and won't throw an exception, providing a tenant is present.
41       *
42       * @return true if initialized, false otherwise
43       */
44      boolean isInitialized();
45  
46      /**
47       * @return the configured database type that active objects is using
48       * @throws com.atlassian.activeobjects.external.NoDataSourceException
49       */
50      DatabaseType getDatabaseType();
51  
52      /**
53       * Indicates whether there is a data source (i.e. a tenant) present.
54       *
55       * If this returns true, calls to {@link #awaitInitialization()},
56       * {@link #awaitInitialization(long, java.util.concurrent.TimeUnit)} and {@link #getDatabaseType()} will not throw a
57       * {@link com.atlassian.activeobjects.external.NoDataSourceException}
58       *
59       * @since 0.26
60       */
61      boolean isDataSourcePresent();
62  
63      /**
64       * Checks if the table corresponding to given type exists in the database.
65       *
66       * @param type to check against
67       * @return true if the table exists, false otherwise
68       * @since 1.2.1
69       */
70      boolean isTablePresent(Class<? extends RawEntity<?>> type);
71  }