View Javadoc

1   package com.atlassian.johnson.setup;
2   
3   import com.atlassian.johnson.JohnsonEventContainer;
4   
5   import javax.annotation.Nonnull;
6   
7   /**
8    * Allows applications using Johnson to provide custom {@link JohnsonEventContainer} implementations for use as part
9    * of their configuration.
10   * <p>
11   * For example, multi-tenant applications need a way to group events in the container per-tenant, allowing tenants to
12   * see only those application and request events which relate to their view of the system. In such a scenario, the
13   * application may register a custom {@code ContainerFactory} which returns a tenant-aware container. This keeps any
14   * dependency on or knowledge of multi-tenancy libraries Johnson.
15   *
16   * @since 1.1
17   */
18  public interface ContainerFactory {
19  
20      /**
21       * Creates a {@link JohnsonEventContainer} for use storing events.
22       * <p>
23       * This method will be called <i>exactly once</i> during Johnson initialisation, and the returned event container
24       * will be used to service all requests on all threads. As a result, the returned implementation is required to be
25       * thread-safe. For multi-tenant systems, handling the differentiation between events for each tenant must happen
26       * below the interface, on a single instance (at least from Johnson's perspective) of the container.
27       *
28       * @return an event container
29       */
30      @Nonnull
31      JohnsonEventContainer create();
32  }