play.Environment.isProd()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(159)

本文整理了Java中play.Environment.isProd()方法的一些代码示例,展示了Environment.isProd()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Environment.isProd()方法的具体详情如下:
包路径:play.Environment
类名称:Environment
方法名:isProd

Environment.isProd介绍

[英]Returns true if the application is PROD mode.
[中]如果应用程序为'PROD'模式,则返回'true'。

代码示例

代码示例来源:origin: com.typesafe.play/play_2.12

  1. /**
  2. * Convert the given exception to an exception that Play can report more information about.
  3. * <p>
  4. * This will generate an id for the exception, and in dev mode, will load the source code for the code that threw the
  5. * exception, making it possible to report on the location that the exception was thrown from.
  6. */
  7. protected final UsefulException throwableToUsefulException(final Throwable throwable) {
  8. return HttpErrorHandlerExceptions.throwableToUsefulException(sourceMapper.sourceMapper(), environment.isProd(), throwable);
  9. }

代码示例来源:origin: com.typesafe.play/play_2.12

  1. /**
  2. * Convert the given exception to an exception that Play can report more information about.
  3. * <p>
  4. * This will generate an id for the exception, and in dev mode, will load the source code for the code that threw the
  5. * exception, making it possible to report on the location that the exception was thrown from.
  6. */
  7. protected final UsefulException throwableToUsefulException(final Throwable throwable) {
  8. return HttpErrorHandlerExceptions.throwableToUsefulException(sourceMapper.sourceMapper(), environment.isProd(), throwable);
  9. }

代码示例来源:origin: com.typesafe.play/play_2.11

  1. /**
  2. * Convert the given exception to an exception that Play can report more information about.
  3. * <p>
  4. * This will generate an id for the exception, and in dev mode, will load the source code for the code that threw the
  5. * exception, making it possible to report on the location that the exception was thrown from.
  6. */
  7. protected final UsefulException throwableToUsefulException(final Throwable throwable) {
  8. return HttpErrorHandlerExceptions.throwableToUsefulException(sourceMapper.sourceMapper(), environment.isProd(), throwable);
  9. }

代码示例来源:origin: com.typesafe.play/play

  1. /**
  2. * Convert the given exception to an exception that Play can report more information about.
  3. * <p>
  4. * This will generate an id for the exception, and in dev mode, will load the source code for the code that threw the
  5. * exception, making it possible to report on the location that the exception was thrown from.
  6. */
  7. protected final UsefulException throwableToUsefulException(final Throwable throwable) {
  8. return HttpErrorHandlerExceptions.throwableToUsefulException(sourceMapper.sourceMapper(), environment.isProd(), throwable);
  9. }

代码示例来源:origin: com.typesafe.play/play_2.11

  1. /**
  2. * Convert the given exception to an exception that Play can report more information about.
  3. * <p>
  4. * This will generate an id for the exception, and in dev mode, will load the source code for the code that threw the
  5. * exception, making it possible to report on the location that the exception was thrown from.
  6. */
  7. protected final UsefulException throwableToUsefulException(final Throwable throwable) {
  8. return HttpErrorHandlerExceptions.throwableToUsefulException(sourceMapper.sourceMapper(), environment.isProd(), throwable);
  9. }

代码示例来源:origin: com.typesafe.play/play_2.10

  1. /**
  2. * Convert the given exception to an exception that Play can report more information about.
  3. *
  4. * This will generate an id for the exception, and in dev mode, will load the source code for the code that threw the
  5. * exception, making it possible to report on the location that the exception was thrown from.
  6. */
  7. private UsefulException throwableToUsefulException(final Throwable throwable) {
  8. return HttpErrorHandlerExceptions.throwableToUsefulException(sourceMapper.sourceMapper(), environment.isProd(), throwable);
  9. }

代码示例来源:origin: com.typesafe.play/play

  1. /**
  2. * Convert the given exception to an exception that Play can report more information about.
  3. * <p>
  4. * This will generate an id for the exception, and in dev mode, will load the source code for the code that threw the
  5. * exception, making it possible to report on the location that the exception was thrown from.
  6. */
  7. protected final UsefulException throwableToUsefulException(final Throwable throwable) {
  8. return HttpErrorHandlerExceptions.throwableToUsefulException(sourceMapper.sourceMapper(), environment.isProd(), throwable);
  9. }

代码示例来源:origin: com.typesafe.play/play_2.11

  1. /**
  2. * Invoked when a handler or resource is not found.
  3. * <p>
  4. * If the environment's mode is production, then returns Results.notFound (404) with the included template from `views.html.defaultpages.notFound` as the content.
  5. * <p>
  6. * Otherwise, Results.notFound (404) is rendered with {@code views.html.defaultpages.devNotFound} template.
  7. *
  8. * @param request The request that no handler was found to handle.
  9. * @param message A message, which is not used by the default implementation.
  10. * @return a CompletionStage containing the Result.
  11. */
  12. protected CompletionStage<Result> onNotFound(RequestHeader request, String message) {
  13. if (environment.isProd()) {
  14. return CompletableFuture.completedFuture(Results.notFound(views.html.defaultpages.notFound.render(
  15. request.method(), request.uri(), request.asScala())));
  16. } else {
  17. return CompletableFuture.completedFuture(Results.notFound(views.html.defaultpages.devNotFound.render(
  18. request.method(), request.uri(), Some.apply(routes.get()), request.asScala()
  19. )));
  20. }
  21. }

代码示例来源:origin: com.typesafe.play/play

  1. /**
  2. * Invoked when a handler or resource is not found.
  3. * <p>
  4. * If the environment's mode is production, then returns Results.notFound (404) with the included template from `views.html.defaultpages.notFound` as the content.
  5. * <p>
  6. * Otherwise, Results.notFound (404) is rendered with {@code views.html.defaultpages.devNotFound} template.
  7. *
  8. * @param request The request that no handler was found to handle.
  9. * @param message A message, which is not used by the default implementation.
  10. * @return a CompletionStage containing the Result.
  11. */
  12. protected CompletionStage<Result> onNotFound(RequestHeader request, String message) {
  13. if (environment.isProd()) {
  14. return CompletableFuture.completedFuture(Results.notFound(views.html.defaultpages.notFound.render(
  15. request.method(), request.uri(), request.asScala())));
  16. } else {
  17. return CompletableFuture.completedFuture(Results.notFound(views.html.defaultpages.devNotFound.render(
  18. request.method(), request.uri(), Some.apply(routes.get()), request.asScala()
  19. )));
  20. }
  21. }

代码示例来源:origin: com.typesafe.play/play_2.12

  1. /**
  2. * Invoked when a handler or resource is not found.
  3. * <p>
  4. * If the environment's mode is production, then returns Results.notFound (404) with the included template from `views.html.defaultpages.notFound` as the content.
  5. * <p>
  6. * Otherwise, Results.notFound (404) is rendered with {@code views.html.defaultpages.devNotFound} template.
  7. *
  8. * @param request The request that no handler was found to handle.
  9. * @param message A message, which is not used by the default implementation.
  10. * @return a CompletionStage containing the Result.
  11. */
  12. protected CompletionStage<Result> onNotFound(RequestHeader request, String message) {
  13. if (environment.isProd()) {
  14. return CompletableFuture.completedFuture(Results.notFound(views.html.defaultpages.notFound.render(
  15. request.method(), request.uri(), request.asScala())));
  16. } else {
  17. return CompletableFuture.completedFuture(Results.notFound(views.html.defaultpages.devNotFound.render(
  18. request.method(), request.uri(), Some.apply(routes.get()), request.asScala()
  19. )));
  20. }
  21. }

代码示例来源:origin: com.typesafe.play/play_2.10

  1. /**
  2. * Invoked when a handler or resource is not found.
  3. *
  4. * @param request The request that no handler was found to handle.
  5. * @param message A message.
  6. */
  7. protected F.Promise<Result> onNotFound(RequestHeader request, String message){
  8. if (environment.isProd()) {
  9. return F.Promise.<Result>pure(Results.notFound(views.html.defaultpages.notFound.render(
  10. request.method(), request.uri())));
  11. } else {
  12. return F.Promise.<Result>pure(Results.notFound(views.html.defaultpages.devNotFound.render(
  13. request.method(), request.uri(), Some.apply(routes.get())
  14. )));
  15. }
  16. }

代码示例来源:origin: stackoverflow.com

  1. public class CustomApplicationLoader extends GuiceApplicationLoader {
  2. @Override
  3. public GuiceApplicationBuilder builder(ApplicationLoader.Context context) {
  4. final Environment environment = context.environment();
  5. GuiceApplicationBuilder builder = initialBuilder.in(environment);
  6. Configuration config = context.initialConfiguration();
  7. if (environment.isTest()) {
  8. config = merge("test.conf", config);
  9. builder = builder.bindings(new TestModule());
  10. } else if (environment.isDev()) {
  11. config = merge("dev.conf", config);
  12. builder = builder.bindings(new DevModule());
  13. } else if (environment.isProd()) {
  14. config = merge("prod.conf", config);
  15. builder = builder.bindings(new DevModule());
  16. } else {
  17. throw new IllegalStateException("No such mode.");
  18. }
  19. return builder.in(environment).loadConfig(config);
  20. }
  21. private Configuration merge(String configName, Configuration currentConfig) {
  22. return new Configuration(currentConfig.getWrappedConfiguration().$plus$plus(new play.api.Configuration(ConfigFactory.load(configName))));
  23. }
  24. }

代码示例来源:origin: com.typesafe.play/play-ebean

  1. /**
  2. * Generate evolutions.
  3. */
  4. @Override
  5. public void create() {
  6. if (!environment.isProd()) {
  7. config.serverConfigs().forEach((key, serverConfig) -> {
  8. String evolutionScript = generateEvolutionScript(servers.get(key));
  9. if (evolutionScript != null) {
  10. File evolutions = environment.getFile("conf/evolutions/" + key + "/1.sql");
  11. try {
  12. String content = "";
  13. if (evolutions.exists()) {
  14. content = new String(Files.readAllBytes(evolutions.toPath()), "utf-8");
  15. }
  16. if (content.isEmpty() || content.startsWith("# --- Created by Ebean DDL")) {
  17. environment.getFile("conf/evolutions/" + key).mkdirs();
  18. if (!content.equals(evolutionScript)) {
  19. Files.write(evolutions.toPath(), evolutionScript.getBytes("utf-8"));
  20. }
  21. }
  22. } catch (IOException e) {
  23. throw new RuntimeException(e);
  24. }
  25. }
  26. });
  27. }
  28. }

代码示例来源:origin: com.lightbend.lagom/lagom-javadsl-jackson

  1. errorCode = transportException.errorCode();
  2. message = transportException.exceptionMessage();
  3. } else if (environment.isProd()) {
  4. errorCode = TransportErrorCode.InternalServerError;

相关文章