高度なカスタマイズ > サービスおよびインフラストラクチャのカスタマイズ > システム生成 > ビジネスオブジェクトのモデル化 > サービス
  
サービス
Windchill サービスには、モデル化されたビジネスオブジェクトを管理するための API とロジックが用意されています。Windchill サービスは、以下の要素で構成されます。
静的フィールド (一般的に servicemanager などの名前が付けられている、サービスを参照する静的フィールドを含む) およびメソッドで構成される (オプションの) ヘルパー。
リモートで呼び出すことができるメソッド宣言で構成されるサービスインタフェース。
サービスを実装しており、メソッドサーバーでサービスとして実行されるように登録されている標準サービス。
サービスについては、このドキュメントのほかのセクションで説明していますが、これが基本的なパターンです。
リスト 17: ExampleHelper.java
01 package com.acme.example;
02
03 import wt.services.ServiceFactory;
04
05 /** Helpers are not instantiated and should consist of only static
fields/methods **/
06 public final class ExampleHelper {
07 /** Use the ServiceFactory to acquire an instance of the service. **/
08 public static final ExampleService service = ServiceFactory.
getService(ExampleService.class);
09 }
リスト 18: ExampleService.java
01 package com.acme.example;
02
03 import wt.method.RemoteInterface;
04 import wt.util.WTException;
05
06 /** RemoteInterface annotation is required for all service interfaces **/
07 @RemoteInterface
08 public interface ExampleService {
09 /** All interface methods are callable via RMI and must
throw WTException **/
10 SimpleExample createSimpleExampleByName(final String name)
throws WTException;
11 }
リスト 19: StandardExampleService.java
01 package com.acme.example;
02
03 import wt.fc.PersistenceHelper;
04 import wt.services.StandardManager;
05 import wt.util.WTException;
06 import wt.util.WTPropertyVetoException;
07
08 /** service must extend StandardManager, implement service interface **/
09 public class StandardExampleService extends StandardManager implements
ExampleService {
10 /** MethodServer refectively calls this API during startup **/
11 public static StandardExampleService newStandardExampleService()
throws WTException {
12 final StandardExampleService instance = new StandardExampleService();
13 instance.initialize();
14 return instance;
15 }
16
17 @Override
18 public SimpleExample createSimpleExampleByName(final String name)
throws WTException {
19 final SimpleExample example = SimpleExample.newSimpleExample();
20 try {
21 example.setName(name);
22 }
23 catch (WTPropertyVetoException wtpve) {
24 throw new WTException(wtpve);
25 }
26 return (SimpleExample) PersistenceHelper.manager.store(example);
27 }
28 }
サービスはsite.xconf で登録されている必要があります。番号 99999 は既存のサービスを上書きしないよう一意の値である必要があります。site.xconf に対する変更は、xconfmanager を使用して適用する必要があります。すべてのカスタマイズサービスを site.xconf に登録する必要があります。
リスト 20: site.xconf のフラグメント
01 <Property name="wt.services.service.99999"
02 targetFile="codebase/wt.properties"
03 value="com.acme.training.MyService/com.acme.
training.StandardMyService"/>
このサービスを使用すると、SimpleExample を永続化するための Jython の例を次のように縮小できます。
リスト 21: サービスによる SimpleExample の永続化
01 from com. acme . example import
02
03 se = ExampleHelper.service.createSimpleExampleByName(’test’)