Java 8 はサポートが終了しており、2026 年 1 月 31 日に
非推奨になります。非推奨になると、過去に組織のポリシーを使用して以前のランタイムのデプロイを再度有効にしていた場合でも、Java 8 アプリケーションをデプロイできなくなります。既存の Java 8 アプリケーションは、
非推奨になる日付以降も引き続き実行され、トラフィックを受信します。
サポートされている最新バージョンの Java に移行することをおすすめします。
以前のバンドル サービス用の Namespaces API
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Google App Engine の Namespaces API を使用すると、Google App Engine のデータを簡単に区分けできます。この API は名前空間マネージャーという新しいパッケージを経由して実装され、名前空間に対応した特定の API に組み込まれます。
名前空間マネージャーで名前空間を設定すると、これらの API は現在の名前空間を取得し、それをグローバルに使用します。名前空間はローカルで明示的に宣言することもできますが、データ漏洩やその他のバグの原因になることがあるため、明示的に名前空間を宣言するときは注意が必要です。App Engine リクエストはいずれも任意の名前空間にアクセスでき、当該アプリケーションは引き続き、アクセス制御ポリシーをすべての名前空間にわたって適用します。
Namespaces API は、幅広いアプリケーションの構築に使用できます。ここでは、この API が最もよく利用されるアプリケーションの 1 つであるマルチテナント アプリケーションについて説明します。
マルチテナンシーについて
マルチテナンシーとは、リモート サーバーで実行される 1 つのアプリケーション インスタンスで複数のクライアント組織(テナント)にサービスを提供するソフトウェア アーキテクチャのことを指します。
マルチテナント アーキテクチャを使用すると、テナントの管理やプロビジョニングがシンプルになります。ユーザー エクスペリエンスをより合理的にカスタマイズできるほか、各種のデータのサイロを単一のデータベース スキーマに集約することもできます。これにより、アプリケーションの拡張性が向上し、拡張時のコスト効果も高まります。すべてのテナントで同じデータベース スキーマを共有するため、テナント間でのデータの分離や分析も簡単です。それぞれのユーザー グループに対して、1 つの効率的なアプリケーションにラップされたカスタムのコンテンツが表示されます。
Namespaces API を使用したマルチテナント アプリケーションの構築
Namespaces API を使用すると、各テナントに固有の名前空間文字列を指定するだけで、データをテナント間で簡単に分割できます。必要な作業は、名前空間マネージャーを使用して各テナントの名前空間を設定することだけです(個々のリクエストに対して明示的に設定する必要はありません)。これにより、名前空間に対応した API で常に現在の名前空間がデフォルトで使用されるようになります。
Namespaces API は Google Workspace と統合されており、Google Workspace ドメインを現在の名前空間として使用できます。Google Workspace では所有している任意のドメインにアプリをデプロイできるため、Google Workspace アカウントにリンクされているすべてのドメインに簡単に固有の名前空間を設定できます。
マルチテナント アプリケーションを設計する際は、名前空間でデータ漏洩が発生しないように注意が必要です。詳しくは、データ漏洩の防止をご覧ください。
名前空間を使用する App Engine API
現在、App Engine では次の API で名前空間がサポートされています。
名前空間を使用したサンプル プロジェクト
名前空間を使用したサンプルのゲストブック アプリケーションが 2 つ用意されています。
Namespace API のその他の用途
Namespaces API には、App Engine でマルチテナンシーを有効にする以外にも次のような用途があります。
- ユーザー情報を区分けする
- 管理データをアプリケーション データから切り離す
- テスト用と本番用に個別のデータストア インスタンスを作成する
- 単一の App Engine インスタンスで複数のアプリを実行する
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-09-04 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-09-04 UTC。"],[[["\u003cp\u003eThe Namespaces API in Google App Engine allows for easy compartmentalization of data, primarily for multitenant applications.\u003c/p\u003e\n"],["\u003cp\u003eMultitenancy, where one application instance serves multiple client organizations, is simplified through the use of unique namespace strings for each tenant.\u003c/p\u003e\n"],["\u003cp\u003eThe API integrates with Google Workspace, enabling the use of Google Workspace domains as namespaces and allowing for unique namespaces to be set for each linked domain.\u003c/p\u003e\n"],["\u003cp\u003eSeveral App Engine APIs, including Datastore, Memcache, Task Queue, and Search, support the use of namespaces.\u003c/p\u003e\n"],["\u003cp\u003eThe Namespaces API has various applications beyond multitenancy, such as separating admin and application data, compartmentalizing user information, and creating separate data stores for testing and production environments.\u003c/p\u003e\n"]]],[],null,["# Namespaces API for legacy bundled services\n\nThe Namespaces API in Google App Engine makes it easy to compartmentalize your Google App Engine data. This API is implemented via a new package called the [namespace manager](/appengine/docs/legacy/standard/java/javadoc/com/google/appengine/api/NamespaceManager), and is incorporated in certain [namespace-enabled APIs](#App_Engine_APIs_that_use_namespaces).\n| This API is supported for first-generation runtimes and can be used when [upgrading to corresponding second-generation runtimes](/appengine/docs/standard/\n| java-gen2\n|\n| /services/access). If you are updating to the App Engine Java 11/17 runtime, refer to the [migration guide](/appengine/migration-center/standard/migrate-to-second-gen/java-differences) to learn about your migration options for legacy bundled services.\n\nWhen you set a namespace in the namespace manager, these APIs get the current namespace and use it globally. You can explicitly declare a namespace locally, but you need to exercise caution when explicitly declaring namespaces, because you could inadvertently create data leaks and other bugs. Any App Engine request can access any namespace, leaving the application to enforce an access control policy across namespaces.\n\nYou can use the Namespaces API to build a wide range of applications. One of the most compelling uses of this API is for multitenant applications, as described below.\n\nAbout multitenancy\n------------------\n\n*Multitenancy* is the name given to a software architecture in which one instance of an application, running on a remote server, serves many client organizations (also known as *tenants*).\n\nUsing a multitenant architecture simplifies administration and provisioning of tenants. You can provide a more streamlined, customized user experience, and also aggregate different silos of data under a single database schema. As a result, your applications become more scalable as well as more cost-effective as you scale. Data becomes easier to segregate and analyze across tenants because all tenants share the same database schema. Different user groups see custom content wrapped within a more efficient application.\n\nBuilding a multitenant application with the Namespaces API\n----------------------------------------------------------\n\nUsing the Namespaces API, you can easily partition data across tenants simply by specifying a unique namespace string for each tenant. You simply [set the namespace](/appengine/docs/legacy/standard/java/multitenancy/multitenancy#Setting_the_current_namespace) for each tenant globally using the namespace manager (as opposed to setting it explicitly for a specific request). The [namespace-enabled APIs](#App_Engine_APIs_that_use_namespaces) always use this current namespace by default.\n\nThe Namespaces API is integrated with Google Workspace, allowing you to use your Google Workspace domain as the current namespace. Because Google Workspace lets you deploy your app to any domain that you own, you can easily [set unique namespaces](/appengine/docs/legacy/standard/java/multitenancy/multitenancy#Setting_the_current_namespace) for all domains linked to your Google Workspace account.\n\nWhen designing multitenant applications, you need to prevent data from leaking across namespaces. For more information, please see [Avoiding Data Leaks](/appengine/docs/legacy/standard/java/multitenancy/multitenancy#Avoiding_data_leaks).\n\nApp Engine APIs that use namespaces\n-----------------------------------\n\nApp Engine currently supports namespaces in the following APIs:\n\n- [Datastore](/appengine/docs/legacy/standard/java/multitenancy/multitenancy#Using_namespaces_with_the_Datastore)\n- [Memcache](/appengine/docs/legacy/standard/java/multitenancy/multitenancy#Using_namespaces_with_the_Memcache)\n- [Task Queue](/appengine/docs/legacy/standard/java/multitenancy/multitenancy#Using_namespaces_with_the_Task_Queue)\n- [Search](/appengine/docs/legacy/standard/java/multitenancy/multitenancy#Using_namespaces_with_Search)\n\nSample projects using namespaces\n--------------------------------\n\nTwo sample guestbook applications using namespaces are provided:\n\n- Python App Engine: [appengine-multitenancy](https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/appengine/standard/multitenancy) -- A namespace-aware sample guestbook application.\n- Java App Engine: [appengine-gwtguestbook-namespaces-java](https://github.com/GoogleCloudPlatform/appengine-gwtguestbook-namespaces-java) -- A namespace-aware sample guestbook application using GWT.\n\nOther uses for the Namespace API\n--------------------------------\n\nWhile the Namespaces API enables multitenancy on App Engine, it has a number of other uses, including:\n\n- Compartmentalizing user information\n- Separating admin data from application data\n- Creating separate datastore instances for testing and production\n- Running multiple apps on a single App Engine instance"]]