|
| 1 | +/* |
| 2 | + * Copyright 2017 Google Inc. All Rights Reserved. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package com.google.cloud; |
| 18 | + |
| 19 | +public final class PlatformInformation { |
| 20 | + public static final String SPECIFICATION_VERSION = |
| 21 | + System.getProperty("java.specification.version"); |
| 22 | + public static final String GAE_RUNTIME_VERSION = |
| 23 | + System.getProperty("com.google.appengine.runtime.version"); |
| 24 | + public static final String RUNTIME_JETTY_LOGGER = |
| 25 | + System.getProperty("org.eclipse.jetty.util.log.class"); |
| 26 | + public static final String JETTY_LOGGER_ON_GAE8_PROD = |
| 27 | + "com.google.apphosting.runtime.jetty9.JettyLogger"; |
| 28 | + public static final String JETTY_LOGGER_ON_GAE8_DEVSERVER = |
| 29 | + " com.google.appengine.development.jetty9.JettyLogger"; |
| 30 | + |
| 31 | + public static boolean isOnGAE() { |
| 32 | + return GAE_RUNTIME_VERSION != null; |
| 33 | + } |
| 34 | + |
| 35 | + public static boolean isOnGAEStandard7() { |
| 36 | + //edge case: when a Java 7 GAE app is deployed to DevServer running on J8, SPECIFICATION_VERSION will be "1.8", |
| 37 | + //but RUNTIME_JETTY_LOGGER is unset |
| 38 | + return isOnGAE() && SPECIFICATION_VERSION.equals("1.7") |
| 39 | + || isOnGAE() && RUNTIME_JETTY_LOGGER == null; |
| 40 | + } |
| 41 | + |
| 42 | + public static boolean isOnGAEStandard8() { |
| 43 | + return isOnGAE() |
| 44 | + && !SPECIFICATION_VERSION.equals("1.7") |
| 45 | + && RUNTIME_JETTY_LOGGER != null |
| 46 | + && (RUNTIME_JETTY_LOGGER.equals(JETTY_LOGGER_ON_GAE8_DEVSERVER) |
| 47 | + || RUNTIME_JETTY_LOGGER.equals(JETTY_LOGGER_ON_GAE8_PROD)); |
| 48 | + } |
| 49 | +} |
0 commit comments