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