Cloud Software Group, Inc. EBX®
ドキュメント>開発者ガイド>ユーザーインターフェイス>ユーザーサービス
ナビゲーションモードドキュメント>開発者ガイド>ユーザーインターフェイス>ユーザーサービス

ユーザーサービスの宣言

宣言インターフェイス

次の表は、各ネイチャーに対してユーザーサービスの宣言クラスが実装する必要のあるインターフェイスを示しています。

ネイチャー

宣言インターフェイス

データスペースUserServiceDeclaration.OnDataspace
DatasetUserServiceDeclaration.OnDataset
TableViewUserServiceDeclaration.OnTableView
レコードUserServiceDeclaration.OnRecord
HierarchyUserServiceDeclaration.OnHierarchy
HierarchyNodeUserServiceDeclaration.OnHierarchyNode
AssociationUserServiceDeclaration.OnAssociation
AssociationRecordUserServiceDeclaration.OnAssociationRecord

ライフサイクルとスレッドモデル

ユーザーサービス宣言クラスはTIBCO EBX®の起動時にインスタンス化され、スレッドセーフになるようにコーディングする必要があります。ほとんどの実装は不変のクラスである必要があるため、これは通常問題にはなりません。

登録

ユーザーサービス宣言は、モジュールまたはデータモデルによって登録する必要があります。

モジュールによる登録は、次のようなコードによるモジュール登録サーブレットによって実現されます。

public class CustomRegistrationServlet extends ModuleRegistrationServlet 
{
	@Override
	public void handleServiceRegistration(ModuleServiceRegistrationContext aContext)
	{
		// Register custom user service declaration.
		aContext.registerUserService(new CustomServiceDeclaration());
	}
}

モジュール登録サーブレットの詳細については、モジュール登録および ModuleRegistrationServlet を参照してください。

データモデルによる登録は、次のようなコードによって実現されます。

public class CustomSchemaExtensions implements SchemaExtensions
{
	@Override
	public void defineExtensions(SchemaExtensionsContext aContext)
	{
		// Register custom user service declaration.
		aContext.registerUserService(new CustomServiceDeclaration());
	}
}

データモデル拡張の詳細については、SchemeExtensionsを参照してください。

サービスプロパティ

ユーザーサービスのプロパティには、そのラベル説明確認メッセージ、およびサービスを所有するグループが含まれます。すべてオプションですが、少なくともラベルを定義することをお勧めします。

詳細については、UserServiceDeclaration.defineProperties を参照してください。

サービスアクティベーションスコープ

アクティベーションスコープは、サービスが利用可能な選択を定義します。

サービスアクティベーション定義の例:

public class CustomServiceDeclaration implements UserServiceDeclaration.OnTableView
{	
	...
	
	@Override
	public void defineActivation(ActivationContextOnTableView aContext)
	{
		// activates the service in all dataspaces except the "Reference" branch.
		aContext.includeAllDataspaces(DataspaceType.BRANCH);
		aContext.excludeDataspacesMatching(Repository.REFERENCE, DataspaceChildrenPolicy.NONE);

		// activates the service only on tables "table01" and "table03".
		aContext.includeSchemaNodesMatching(
			CustomDataModelPath._Root_Table01.getPathInSchema(),
			CustomDataModelPath._Root_Table03.getPathInSchema());

		// service will be enabled only when at least one record is selected.
		aContext.forbidEmptyRecordSelection();

		// service will not be displayed in hierarchical views (neither in the
		// top toolbar, nor in the hierarchy nodes' menu).
		aContext.setDisplayForLocations(
			ActionDisplaySpec.HIDDEN,
			ToolbarLocation.HIERARCHICAL_VIEW_TOP,
			ToolbarLocation.HIERARCHICAL_VIEW_NODE);

		// service will be considered as disabled if not explicitly enabled
		// via the UI.
		aContext.setDefaultPermission(UserServicePermission.getDisabled());
	}
}

アクティベーションスコープの宣言の詳細については、UserServiceDeclaration.defineActivation を参照してください。

ユーザーサービスの可用性の解決の詳細については、サービスのアクセス許可の解決を参照してください。

Webコンポーネント宣言

ワークフローとパースペクティブでのパラメーター宣言と可用性

ユーザーサービスは,サービスの性質に応じたビルトインパラメーターを持つWebコンポーネントとして自動的に利用可能になります。カスタムパラメーターを定義したり、ワークフローのユーザタスク、パースペクティブメニューのアクション、ツールバーのWebコンポーネントアクションを構成する際にサービスのWebコンポーネントを利用できるように設定するには、 UserServiceDeclaration.declareWebComponent を使用する必要があります。

Webコンポーネント宣言の例:

public class CustomServiceDeclaration implements UserServiceDeclaration.OnDataset
{
	...
	
	@Override
	public void declareWebComponent(WebComponentDeclarationContext aContext)
	{
		// makes this web component available when configuring a workflow user task.
		aContext.setAvailableAsWorkflowUserTask(true);

		// adds a custom input parameter.
		aContext.addInputParameter(
			"source",
			UserMessage.createInfo("Source"),
			UserMessage.createInfo("Source of the imported data."));
		
		// modifies the built-in "instance" parameter to be "input/output" instead of "input".
		aContext.getBuiltInParameterForOverride("instance").setOutput(true);
	}
}

詳細については、「TIBCO EBX®のWebコンポーネントとしての使用」を参照してください。

ユーザーサービス拡張

これらのサービスをWebコンポーネントとして使用する場合、入力/出力パラメーターを追加するために、既存のユーザーサービス(ビルトインまたはカスタム)を拡張することができます。

そのためには、ユーザーサービス拡張機能を最初にモジュールまたはデータモデルで登録する必要があります。

モジュールによる登録は、次のようなコードによるモジュール登録サーブレットによって実現されます。

public class CustomRegistrationServlet extends ModuleRegistrationServlet 
{
	...
	
	@Override
	public void handleServiceRegistration(ModuleServiceRegistrationContext aContext)
	{
		// Register user service extension declaration.
		aContext.registerUserServiceExtension(new ServiceExtensionDeclaration());
	}
}

モジュール登録サーブレットの詳細については、モジュール登録および ModuleRegistrationServlet を参照してください。

データモデルによる登録は、次のようなコードによって実現されます。

public class CustomSchemaExtensions implements SchemaExtensions
{
	...
	
	@Override
	public void defineExtensions(SchemaExtensionsContext aContext)
	{
		// Register user service extension declaration.
		aContext.registerUserServiceExtension(new ServiceExtensionDeclaration());
	}
}

データモデル拡張の詳細については、SchemeExtensionsを参照してください。

ユーザーサービスグループ

ユーザーサービスグループは、メニューおよび権限管理画面でのユーザーサービスの表示を整理するために使用されます。

次のタイプのサービスグループを利用できます。

グループとサービス間のリンクは、サービスの宣言時に作成されます。 サービスのグループへの関連付けを参照してください。

ビルトインのユーザーサービスグループ

利用可能なビルトインサービスグループ:

サービスグループキー

Description

@ebx-importExport

EBX®が提供するすべてのビルトインのインポートおよびエクスポートサービスを含むグループ。デフォルトのメニューでは、これらのサービスは「インポート/エクスポート」サブメニューに表示されます。

@ebx-views

[表示]メニューに表示するサービスを含むグループ。他のサービスグループとは異なり、このグループに関連付けられているサービスはデフォルトメニューには表示されませんが、テーブルトップツールバーのカスタマイズできない部分に表示される[表示]メニューにのみ表示されます。これらのサービスは、カスタムツールバーに手動で追加できます。

ユーザーサービスグループの宣言

ユーザーサービスグループは、モジュールの登録時に、メソッドModuleServiceRegistrationContext.registerServiceGroup を使用して宣言する必要があります。

public class CustomRegistrationServlet extends ModuleRegistrationServlet 
{
	...
	
	@Override
	public void handleServiceRegistration(ModuleServiceRegistrationContext aContext)
	{
		// In CustomModuleConstants,
		// CUSTOM_SERVICE_GROUP_KEY = ServiceGroupKey.forServiceGroupInModule("customModule", "customGroup")
		
		// registers CUSTOM_SERVICE_GROUP_KEY service group
		aContext.registerServiceGroup(
			CustomModuleConstants.CUSTOM_SERVICE_GROUP_KEY,
			UserMessage.createInfo("Custom group"),
			UserMessage.createInfo("This group contains services related to..."));
	}
}

サービスのグループへの関連付け

サービスとグループの関連付けは、宣言で、メソッド UserServicePropertiesDefinitionContext.setGroup を使用して行われます。

public class CustomServiceDeclaration implements UserServiceDeclaration.OnDataset
{
	...
	
	@Override
	public void defineProperties(UserServicePropertiesDefinitionContext aContext)
	{
		// associates the current service to the CUSTOM_SERVICE_GROUP_KEY group
		aContext.setGroup(CustomModuleConstants.CUSTOM_SERVICE_GROUP_KEY);
	}
}

サービスは、ビルトインサービスグループまたはカスタムサービスグループのいずれかに関連付けることができます。後者の場合、このサービスは、このグループに属する他のビルトインサービスと同様に、このビルトイングループに表示されます。

ドキュメント>開発者ガイド>ユーザーインターフェイス>ユーザーサービス