本文整理了Java中play.Environment.isProd()
方法的一些代码示例,展示了Environment.isProd()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Environment.isProd()
方法的具体详情如下:
包路径:play.Environment
类名称:Environment
方法名:isProd
[英]Returns true
if the application is PROD
mode.
[中]如果应用程序为'PROD'模式,则返回'true'。
代码示例来源:origin: com.typesafe.play/play_2.12
/**
* Convert the given exception to an exception that Play can report more information about.
* <p>
* This will generate an id for the exception, and in dev mode, will load the source code for the code that threw the
* exception, making it possible to report on the location that the exception was thrown from.
*/
protected final UsefulException throwableToUsefulException(final Throwable throwable) {
return HttpErrorHandlerExceptions.throwableToUsefulException(sourceMapper.sourceMapper(), environment.isProd(), throwable);
}
代码示例来源:origin: com.typesafe.play/play_2.12
/**
* Convert the given exception to an exception that Play can report more information about.
* <p>
* This will generate an id for the exception, and in dev mode, will load the source code for the code that threw the
* exception, making it possible to report on the location that the exception was thrown from.
*/
protected final UsefulException throwableToUsefulException(final Throwable throwable) {
return HttpErrorHandlerExceptions.throwableToUsefulException(sourceMapper.sourceMapper(), environment.isProd(), throwable);
}
代码示例来源:origin: com.typesafe.play/play_2.11
/**
* Convert the given exception to an exception that Play can report more information about.
* <p>
* This will generate an id for the exception, and in dev mode, will load the source code for the code that threw the
* exception, making it possible to report on the location that the exception was thrown from.
*/
protected final UsefulException throwableToUsefulException(final Throwable throwable) {
return HttpErrorHandlerExceptions.throwableToUsefulException(sourceMapper.sourceMapper(), environment.isProd(), throwable);
}
代码示例来源:origin: com.typesafe.play/play
/**
* Convert the given exception to an exception that Play can report more information about.
* <p>
* This will generate an id for the exception, and in dev mode, will load the source code for the code that threw the
* exception, making it possible to report on the location that the exception was thrown from.
*/
protected final UsefulException throwableToUsefulException(final Throwable throwable) {
return HttpErrorHandlerExceptions.throwableToUsefulException(sourceMapper.sourceMapper(), environment.isProd(), throwable);
}
代码示例来源:origin: com.typesafe.play/play_2.11
/**
* Convert the given exception to an exception that Play can report more information about.
* <p>
* This will generate an id for the exception, and in dev mode, will load the source code for the code that threw the
* exception, making it possible to report on the location that the exception was thrown from.
*/
protected final UsefulException throwableToUsefulException(final Throwable throwable) {
return HttpErrorHandlerExceptions.throwableToUsefulException(sourceMapper.sourceMapper(), environment.isProd(), throwable);
}
代码示例来源:origin: com.typesafe.play/play_2.10
/**
* Convert the given exception to an exception that Play can report more information about.
*
* This will generate an id for the exception, and in dev mode, will load the source code for the code that threw the
* exception, making it possible to report on the location that the exception was thrown from.
*/
private UsefulException throwableToUsefulException(final Throwable throwable) {
return HttpErrorHandlerExceptions.throwableToUsefulException(sourceMapper.sourceMapper(), environment.isProd(), throwable);
}
代码示例来源:origin: com.typesafe.play/play
/**
* Convert the given exception to an exception that Play can report more information about.
* <p>
* This will generate an id for the exception, and in dev mode, will load the source code for the code that threw the
* exception, making it possible to report on the location that the exception was thrown from.
*/
protected final UsefulException throwableToUsefulException(final Throwable throwable) {
return HttpErrorHandlerExceptions.throwableToUsefulException(sourceMapper.sourceMapper(), environment.isProd(), throwable);
}
代码示例来源:origin: com.typesafe.play/play_2.11
/**
* Invoked when a handler or resource is not found.
* <p>
* If the environment's mode is production, then returns Results.notFound (404) with the included template from `views.html.defaultpages.notFound` as the content.
* <p>
* Otherwise, Results.notFound (404) is rendered with {@code views.html.defaultpages.devNotFound} template.
*
* @param request The request that no handler was found to handle.
* @param message A message, which is not used by the default implementation.
* @return a CompletionStage containing the Result.
*/
protected CompletionStage<Result> onNotFound(RequestHeader request, String message) {
if (environment.isProd()) {
return CompletableFuture.completedFuture(Results.notFound(views.html.defaultpages.notFound.render(
request.method(), request.uri(), request.asScala())));
} else {
return CompletableFuture.completedFuture(Results.notFound(views.html.defaultpages.devNotFound.render(
request.method(), request.uri(), Some.apply(routes.get()), request.asScala()
)));
}
}
代码示例来源:origin: com.typesafe.play/play
/**
* Invoked when a handler or resource is not found.
* <p>
* If the environment's mode is production, then returns Results.notFound (404) with the included template from `views.html.defaultpages.notFound` as the content.
* <p>
* Otherwise, Results.notFound (404) is rendered with {@code views.html.defaultpages.devNotFound} template.
*
* @param request The request that no handler was found to handle.
* @param message A message, which is not used by the default implementation.
* @return a CompletionStage containing the Result.
*/
protected CompletionStage<Result> onNotFound(RequestHeader request, String message) {
if (environment.isProd()) {
return CompletableFuture.completedFuture(Results.notFound(views.html.defaultpages.notFound.render(
request.method(), request.uri(), request.asScala())));
} else {
return CompletableFuture.completedFuture(Results.notFound(views.html.defaultpages.devNotFound.render(
request.method(), request.uri(), Some.apply(routes.get()), request.asScala()
)));
}
}
代码示例来源:origin: com.typesafe.play/play_2.12
/**
* Invoked when a handler or resource is not found.
* <p>
* If the environment's mode is production, then returns Results.notFound (404) with the included template from `views.html.defaultpages.notFound` as the content.
* <p>
* Otherwise, Results.notFound (404) is rendered with {@code views.html.defaultpages.devNotFound} template.
*
* @param request The request that no handler was found to handle.
* @param message A message, which is not used by the default implementation.
* @return a CompletionStage containing the Result.
*/
protected CompletionStage<Result> onNotFound(RequestHeader request, String message) {
if (environment.isProd()) {
return CompletableFuture.completedFuture(Results.notFound(views.html.defaultpages.notFound.render(
request.method(), request.uri(), request.asScala())));
} else {
return CompletableFuture.completedFuture(Results.notFound(views.html.defaultpages.devNotFound.render(
request.method(), request.uri(), Some.apply(routes.get()), request.asScala()
)));
}
}
代码示例来源:origin: com.typesafe.play/play_2.10
/**
* Invoked when a handler or resource is not found.
*
* @param request The request that no handler was found to handle.
* @param message A message.
*/
protected F.Promise<Result> onNotFound(RequestHeader request, String message){
if (environment.isProd()) {
return F.Promise.<Result>pure(Results.notFound(views.html.defaultpages.notFound.render(
request.method(), request.uri())));
} else {
return F.Promise.<Result>pure(Results.notFound(views.html.defaultpages.devNotFound.render(
request.method(), request.uri(), Some.apply(routes.get())
)));
}
}
代码示例来源:origin: stackoverflow.com
public class CustomApplicationLoader extends GuiceApplicationLoader {
@Override
public GuiceApplicationBuilder builder(ApplicationLoader.Context context) {
final Environment environment = context.environment();
GuiceApplicationBuilder builder = initialBuilder.in(environment);
Configuration config = context.initialConfiguration();
if (environment.isTest()) {
config = merge("test.conf", config);
builder = builder.bindings(new TestModule());
} else if (environment.isDev()) {
config = merge("dev.conf", config);
builder = builder.bindings(new DevModule());
} else if (environment.isProd()) {
config = merge("prod.conf", config);
builder = builder.bindings(new DevModule());
} else {
throw new IllegalStateException("No such mode.");
}
return builder.in(environment).loadConfig(config);
}
private Configuration merge(String configName, Configuration currentConfig) {
return new Configuration(currentConfig.getWrappedConfiguration().$plus$plus(new play.api.Configuration(ConfigFactory.load(configName))));
}
}
代码示例来源:origin: com.typesafe.play/play-ebean
/**
* Generate evolutions.
*/
@Override
public void create() {
if (!environment.isProd()) {
config.serverConfigs().forEach((key, serverConfig) -> {
String evolutionScript = generateEvolutionScript(servers.get(key));
if (evolutionScript != null) {
File evolutions = environment.getFile("conf/evolutions/" + key + "/1.sql");
try {
String content = "";
if (evolutions.exists()) {
content = new String(Files.readAllBytes(evolutions.toPath()), "utf-8");
}
if (content.isEmpty() || content.startsWith("# --- Created by Ebean DDL")) {
environment.getFile("conf/evolutions/" + key).mkdirs();
if (!content.equals(evolutionScript)) {
Files.write(evolutions.toPath(), evolutionScript.getBytes("utf-8"));
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
});
}
}
代码示例来源:origin: com.lightbend.lagom/lagom-javadsl-jackson
errorCode = transportException.errorCode();
message = transportException.exceptionMessage();
} else if (environment.isProd()) {
errorCode = TransportErrorCode.InternalServerError;
内容来源于网络,如有侵权,请联系作者删除!