1 package com
.google
.appengine
.tools
.development
;
3 import com
.google
.apphosting
.api
.ApiProxy
;
8 * Holder for both configuration and runtime information for a single
9 * {@link DevAppServer} module and all its instances.
12 public interface Module
{
14 * Configure this {@link Module}.
16 * Note {@link #configure} fits into the {@link DevAppServer} startup
17 * sequence. The user may adjust {@link DevAppServer#setServiceProperties}
18 * values after construction and before calling {@link DevAppServer#start()}
19 * which calls {@link #configure}. To retain compatibility operations that
20 * make use of these user specified settings such as port selection must not
21 * not be performed during construction.
22 * @param containerConfigProperties container configuration properties.
25 void configure(Map
<String
, Object
>containerConfigProperties
) throws Exception
;
28 * Sets the {@link com.google.apphosting.api.ApiProxy.Delegate}.
30 void setApiProxyDelegate(ApiProxy
.Delegate
<?
> apiProxyDelegate
);
33 * Creates the network connections for this {@link Module}.
36 void createConnection() throws Exception
;
39 * Starts all the instances for this {@link Module}. Once this returns the
40 * {@link Module} can handle HTTP requests.
43 void startup() throws Exception
;
46 * Stops all the instances for this {@link Module}. Once this returns the
47 * {@link Module} cannot handle HTTP requests.
50 void shutdown() throws Exception
;
53 * Simulates stopping the module in production.
55 * @throws UnsupportedOperationException if this is not a manual module.
58 void stopServing() throws Exception
;
61 * Simulates starting the module in production.
63 * @throws UnsupportedOperationException if this is not a manual module.
66 void startServing() throws Exception
;
69 * Returns the module name for this {@link Module}.
71 String
getModuleName();
74 * Returns the {@link ContainerService} for the primary instance for this
77 ContainerService
getMainContainer();
80 * Returns the {@link LocalServerEnvironment} for the primary instance for
81 * this {@link Module}.
83 LocalServerEnvironment
getLocalServerEnvironment();
86 * Returns the host and port for the requested instance or null if the
87 * instance does not exist.
88 * @param instance The instance number or {@link LocalEnvironment#MAIN_INSTANCE}.
90 String
getHostAndPort(int instance
);
93 * Returns the requested {@link InstanceHolder} or null if the instance does
95 * @param instance the instance number or {@link LocalEnvironment#MAIN_INSTANCE}.
97 InstanceHolder
getInstanceHolder(int instance
);
100 * Returns the number of instances for this module. This will return 0 for
101 * an {@link AutomaticModule}.
103 int getInstanceCount();
106 * Acquires a serving permit and returns an {@link InstanceHolder} for an
107 * instance which is available to handle a request or returns null if there
108 * is no such instance.
110 * throws {@link UnsupportedOperationException} unless this is a
111 * {@link ManualModule}.
113 InstanceHolder
getAndReserveAvailableInstanceHolder();