1 // Copyright 2009 Google Inc. All Rights Reserved.
3 package com
.google
.appengine
.api
.utils
;
6 * Global system properties which are set by App Engine.
10 * if (SystemProperty.environment.value() == SystemProperty.Environment.Value.Production) {
11 * // do something that's production-only
13 * String version = SystemProperty.version.get();
17 public class SystemProperty
{
20 * The current executing environment. Has the key,
21 * {@code "com.google.appengine.runtime.environment"}.
22 * Has the values {@code "Production"} and {@code "Development"}.
24 public static final Environment environment
= new Environment();
27 * The current executing runtime version. Has the key,
28 * {@code "com.google.appengine.runtime.version"}.
29 * A Version value is composed of period-separated integers, for example,
32 public static final SystemProperty version
=
33 new SystemProperty("com.google.appengine.runtime.version");
36 * The application identifier for the current application. Has the
37 * key, {@code "com.google.appengine.application.id"}.
39 public static final SystemProperty applicationId
=
40 new SystemProperty("com.google.appengine.application.id");
43 * The version identifier for the current application version. Result is of
44 * the form {@literal <major>.<minor>} where {@literal <major>} is the version
45 * name supplied at deploy time and {@literal <minor>} is a timestamp value
46 * maintained by App Engine. Has the key
47 * {@code "com.google.appengine.application.version"}.
49 public static final SystemProperty applicationVersion
=
50 new SystemProperty("com.google.appengine.application.version");
53 * @deprecated Use {@link
54 * com.google.appengine.api.modules.ModulesService#getCurrentInstanceId()}
57 public static final SystemProperty instanceReplicaId
=
58 new SystemProperty("deprecated");
61 * The current executing environment. Has the key,
62 * {@code "com.google.appengine.runtime.environment"}.
63 * The set of values are specified by {@link Environment.Value Value}.
65 public static class Environment
extends SystemProperty
{
68 * The set of possible values for Environment.
74 public String
value() {
79 private Environment() {
80 super("com.google.appengine.runtime.environment");
84 * Returns the Value that the SystemProperty is set to.
86 * @return null if the Environment is not set, or is set to a value that
87 * does not correspond to any predefined {@code Value}.
89 public Value
value() {
91 String propertyValue
= get();
92 return propertyValue
!= null ? Value
.valueOf(get()) : null;
93 } catch (IllegalArgumentException e
) {
99 * Sets the Environment to {@code value}. Equivalent to
100 * {@code set(value.value())}.
103 public void set(Value value
) {
108 private SystemProperty(String key
) {
115 * The key for the system property.
117 public String
key() {
122 * Gets the value of the system property.
123 * Equivalent to {@code System.getProperty(key())}.
125 public String
get() {
126 return System
.getProperty(key());
130 * Sets the value of the system property.
131 * Equivalent to {@code System.setProperty(key(), value)}.
133 public void set(String value
) {
134 System
.setProperty(key(), value
);