本文整理汇总了Java中com.google.cloud.tools.appengine.api.devserver.StopConfiguration类的典型用法代码示例。如果您正苦于以下问题:Java StopConfiguration类的具体用法?Java StopConfiguration怎么用?Java StopConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StopConfiguration类属于com.google.cloud.tools.appengine.api.devserver包,在下文中一共展示了StopConfiguration类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getStopConfiguration
import com.google.cloud.tools.appengine.api.devserver.StopConfiguration; //导入依赖的package包/类
/** Return a stop configuration based on serverVersion. */
public StopConfiguration getStopConfiguration(RunExtension run) {
String serverVersion = run.getServerVersion();
validator.validateServerVersion(serverVersion);
DefaultStopConfiguration stop = new DefaultStopConfiguration();
switch (serverVersion) {
case V1:
stop.setAdminHost(run.getHost());
stop.setAdminPort(run.getPort());
return stop;
case V2:
stop.setAdminHost(run.getAdminHost());
stop.setAdminPort(run.getAdminPort());
return stop;
default:
throw new AssertionError("Unexpected serverVersion " + run.getServerVersion());
}
}
示例2: stop
import com.google.cloud.tools.appengine.api.devserver.StopConfiguration; //导入依赖的package包/类
/** Stops the local development server. */
@Override
public void stop(StopConfiguration config) throws AppEngineException {
Preconditions.checkNotNull(config);
try {
URL adminServerUrl =
new URL(
"http",
config.getAdminHost() != null ? config.getAdminHost() : DEFAULT_ADMIN_HOST,
config.getAdminPort() != null ? config.getAdminPort() : DEFAULT_ADMIN_PORT,
"/quit");
HttpURLConnection connection = (HttpURLConnection) adminServerUrl.openConnection();
connection.setReadTimeout(4000);
connection.connect();
connection.disconnect();
int responseCode = connection.getResponseCode();
if (responseCode < 200 || responseCode > 299) {
throw new AppEngineException(
"The development server responded with " + connection.getResponseMessage() + ".");
}
} catch (IOException e) {
throw new AppEngineException(e);
}
}
示例3: getStopConfiguration_v1
import com.google.cloud.tools.appengine.api.devserver.StopConfiguration; //导入依赖的package包/类
@Test
public void getStopConfiguration_v1() {
when(run.getServerVersion()).thenReturn("1");
when(run.getHost()).thenReturn("v1.com");
when(run.getPort()).thenReturn(1234);
StopConfiguration config = helper.getStopConfiguration(run);
Assert.assertEquals("v1.com", config.getAdminHost());
Assert.assertEquals(new Integer(1234), config.getAdminPort());
verify(validator, times(1)).validateServerVersion(run.getServerVersion());
}
示例4: getStopConfiguration_v2
import com.google.cloud.tools.appengine.api.devserver.StopConfiguration; //导入依赖的package包/类
@Test
public void getStopConfiguration_v2() {
when(run.getServerVersion()).thenReturn("2-alpha");
when(run.getAdminHost()).thenReturn("v2.com");
when(run.getAdminPort()).thenReturn(4321);
StopConfiguration config = helper.getStopConfiguration(run);
Assert.assertEquals("v2.com", config.getAdminHost());
Assert.assertEquals(new Integer(4321), config.getAdminPort());
verify(validator, times(1)).validateServerVersion(run.getServerVersion());
}
示例5: stop
import com.google.cloud.tools.appengine.api.devserver.StopConfiguration; //导入依赖的package包/类
/** Stops the local development server. */
@Override
public void stop(StopConfiguration configuration) throws AppEngineException {
Preconditions.checkNotNull(configuration);
HttpURLConnection connection = null;
String adminHost =
configuration.getAdminHost() != null ? configuration.getAdminHost() : DEFAULT_HOST;
int adminPort =
configuration.getAdminPort() != null ? configuration.getAdminPort() : DEFAULT_PORT;
URL adminServerUrl = null;
try {
adminServerUrl = new URL("http", adminHost, adminPort, "/_ah/admin/quit");
connection = (HttpURLConnection) adminServerUrl.openConnection();
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setRequestMethod("POST");
connection.getOutputStream().write('\n');
connection.disconnect();
int responseCode = connection.getResponseCode();
if (responseCode < 200 || responseCode > 299) {
throw new AppEngineException(
adminServerUrl + " responded with " + connection.getResponseMessage() + ".");
}
} catch (IOException ex) {
throw new AppEngineException("Error connecting to " + adminServerUrl, ex);
} finally {
if (connection != null) {
try {
connection.getInputStream().close();
} catch (IOException ignore) {
// ignored
}
}
}
}