# Interface BackendService (5.0.3)

    public interface BackendService

[BackendService](https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.backends.BackendService) allows you to retrieve information about
backend servers. Backend servers are long running addressable
servers that can be used for applications that need to keep
persistent state in ram between requests.


This API is deprecated and has been replaced by
[com.google.appengine.api.modules.ModulesService](https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.modules.ModulesService). Please update your code as soon as
possible. See the modules documentation for more information:
<https://developers.google.com/appengine/docs/java/modules/converting>


This API allows you to retrieve information about the backend
handling the current request. It also allows you to to get the
address of a specific backend instance in such a way that a local
server is used during development and a production server is used
in production.

## Static Fields

### BACKEND_ID_ENV_ATTRIBUTE

    public static final String BACKEND_ID_ENV_ATTRIBUTE

Environment attribute key where the backend name is stored.
See Also: [BackendService#getCurrentBackend()](https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.backends.BackendService#com_google_appengine_api_backends_BackendService_getCurrentBackend__)

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### DEVAPPSERVER_PORTMAPPING_KEY

    public static final String DEVAPPSERVER_PORTMAPPING_KEY

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### INSTANCE_ID_ENV_ATTRIBUTE

    public static final String INSTANCE_ID_ENV_ATTRIBUTE

Environment attribute key where the instance id is stored.
See Also: [BackendService#getCurrentInstance()](https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.backends.BackendService#com_google_appengine_api_backends_BackendService_getCurrentInstance__)

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### REQUEST_HEADER_BACKEND_REDIRECT

    public static final String REQUEST_HEADER_BACKEND_REDIRECT

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### REQUEST_HEADER_INSTANCE_REDIRECT

    public static final String REQUEST_HEADER_INSTANCE_REDIRECT

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

## Methods

### getBackendAddress(String backend)

    public abstract String getBackendAddress(String backend)

Get the address of a specific backend in such a way that a local server is
used during development and a production server is used in production.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `backend` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` The name of the backend |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` | The address of the backend |

### getBackendAddress(String backend, int instance)

    public abstract String getBackendAddress(String backend, int instance)

Get the address of a specific backend instance in such a way that a local
instance is used during development and a production server instance is
used in production.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `backend` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` The name of the backend |
| `instance` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` The instance id |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` | The address of the backend instance |

### getCurrentBackend()

    public abstract String getCurrentBackend()

Get the name of the backend handling the current request.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` | The name of the backend or null if the request is not handled by a backend. |

### getCurrentInstance()

    public abstract int getCurrentInstance()

Get the instance handling the current request.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` | The instance id or -1 if the request is not handled by a backend. |