nimbus (1.2.4) | 2018-01-25 20:02 |
nimbus-sample (1.2.4) | 2018-01-26 17:06 |
jp.ossc.nimbus.service.aop.interceptor.servlet.BlockadeInterceptorServiceは、開閉塞を制御するInterceptor実装サービスです。
このサービスは、複合的なサービスで、以下のサービスを下位サービスとして使用します。
下位サービスインタフェース | 用途 |
jp.ossc.nimbus.service.codemaster.CodeMasterFinder | 開閉塞マスタや特権ユーザマスタを取得する。 |
以下に簡単なサービス定義を示します。
- <?xml version="1.0" encoding="Shift_JIS"?>
- <!DOCTYPE server PUBLIC
- "-//Nimbus//DTD Nimbus 1.0//JA"
- "http://nimbus.sourceforge.jp/dtd/nimbus-service_1_0.dtd">
- <server>
- <manager>
- <!-- 開閉塞を制御するInterceptorサービス -->
- <service name="BlockadeInterceptor"
- code="jp.ossc.nimbus.service.aop.interceptor.servlet.BlockadeInterceptorService">
- <!-- 開閉塞マスタや特権ユーザマスタを取得するCodeMasterFinderサービスのサービス名を設定する -->
- <attribute name="CodeMasterFinderServiceName">#CodeMasterFinder</attribute>
- <!-- 開閉塞マスタのマスタ名を設定する -->
- <attribute name="BlockadeCodeMasterKey">BLOCKADE_MST</attribute>
- <!-- 特権ユーザマスタのマスタ名を設定する -->
- <attribute name="SpecialUserCodeMasterKey">SPECIAL_USER_MST</attribute>
- <!-- 要求オブジェクトと特権ユーザマスタのユーザIDの取得方法を設定する -->
- <attribute name="SpecialUserMapping">{Header(RequestHeader).UserID}|{Header(Login).UserID}=userId</attribute>
- <depends>CodeMasterFinder</depends>
- </service>
- <!-- 以下はコードマスタサービス定義 -->
- <service name="CodeMasterFinder"
- code="jp.ossc.nimbus.service.codemaster.CodeMasterService">
- <attribute name="MasterNames">
- BLOCKADE_MST,
- SPECIAL_USER_MST
- </attribute>
- <attribute name="BeanFlowInvokerFactoryServiceName">#BeanFlowInvokerFactory</attribute>
- <attribute name="MessageReceiverServiceName">#MessageReceiver</attribute>
- <attribute name="Subjects">CodeMaster</attribute>
- <depends>BeanFlowInvokerFactory</depends>
- <depends>MessageReceiver</depends>
- </service>
- <!-- 業務フローを生成するBeanFlowInvokerFactoryサービス -->
- <service name="BeanFlowInvokerFactory"
- code="jp.ossc.nimbus.service.beancontrol.DefaultBeanFlowInvokerFactoryService">
- <attribute name="DirPaths">flow</attribute>
- <attribute name="BeanFlowInvokerAccessClass">jp.ossc.nimbus.service.beancontrol.BeanFlowInvokerAccessImpl2</attribute>
- <depends>JDBCTransactionResourceFactory</depends>
- <depends>PersistentManager</depends>
- </service>
- <!-- JDBCコネクションのTransactionResourceを生成するResourceFactoryサービス -->
- <service name="JDBCTransactionResourceFactory"
- code="jp.ossc.nimbus.service.resource.datasource.JdbcConnectionFactoryService">
- <attribute name="ConnectionFactoryServiceName">#ConnectionFactory</attribute>
- <depends>
- <!-- JDBCドライバ経由でコネクションを取得するConnectionFactoryサービス -->
- <service name="ConnectionFactory"
- code="jp.ossc.nimbus.service.connection.JDBCConnectionFactoryService">
- <attribute name="DriverName">org.hsqldb.jdbcDriver</attribute>
- <attribute name="ConnectionURL">jdbc:hsqldb:./localDB</attribute>
- <attribute name="UserName">sa</attribute>
- <attribute name="Password"></attribute>
- <attribute name="AutoCommit">false</attribute>
- </service>
- </depends>
- </service>
- <!-- 永続化を管理するPersistentManagerサービス -->
- <service name="PersistentManager"
- code="jp.ossc.nimbus.service.connection.DefaultPersistentManagerService"/>
- <!-- メッセージ受信サービス -->
- <service name="MessageReceiver"
- code="jp.ossc.nimbus.service.publish.MessageReceiverService">
- <attribute name="ClientConnectionFactoryServiceName">#ClusterClientConnectionFactory</attribute>
- <attribute name="StartReceiveOnStart">true</attribute>
- <depends>#ClusterClientConnectionFactory</depends>
- </service>
- <!-- クラスタクライアントコネクションファクトリサービス -->
- <service name="ClusterClientConnectionFactory"
- code="jp.ossc.nimbus.service.publish.ClusterClientConnectionFactoryService">
- <attribute name="ClusterServiceName">#Cluster</attribute>
- <attribute name="FlexibleConnect">true</attribute>
- <depends>
- <!-- クラスタサービス -->
- <service name="Cluster"
- code="jp.ossc.nimbus.service.keepalive.ClusterService">
- <attribute name="MulticastGroupAddress">239.0.0.10</attribute>
- <attribute name="Client">true</attribute>
- </service>
- </depends>
- </service>
- </manager>
- </server>
上記で使用している開閉塞マスタと、特権ユーザマスタのコードマスタ用の業務フローを示す。
- <?xml version="1.0" encoding="Shift_JIS"?>
- <!DOCTYPE flows PUBLIC
- "-//Nimbus//DTD Nimbus Bean Flow 1.0//JA"
- "http://nimbus.sourceforge.jp/dtd/beanflow_1_0.dtd">
- <flows>
- <!-- 開閉塞マスタを読み込む業務フロー -->
- <flow name="BLOCKADE_MST">
- <!-- JDBC接続のリソース宣言 -->
- <resource name="Connection" service="Nimbus#JDBCTransactionResourceFactory" trancontrol="true"/>
- <!-- マスタ読み込み用のRecordListを定義する -->
- <step name="Master">
- <target><object code="jp.ossc.nimbus.beans.dataset.RecordList"/></target>
- <attribute name="Name">BLOCKADE_MST</attribute>
- <attribute name="Schema">
- :path,java.lang.String
- :state,int
- :message,java.lang.String
- </attribute>
- </step>
- <!-- マスタをデータベースから読み込む -->
- <step name="Load">
- <target><service-ref>Nimbus#PersistentManager</service-ref></target>
- <result>
- <invoke name="loadQuery">
- <argument type="java.sql.Connection"><resource-ref>Connection</resource-ref></argument>
- <argument>select PATH->{path}, STATE->{state}, MESSAGE->{message} from BLOCKADE_MST</argument>
- <argument type="java.lang.Object" nullValue="true"/>
- <argument type="java.lang.Object"><step-ref>Master</step-ref></argument>
- </invoke>
- </result>
- </step>
- </flow>
- <!-- 特権ユーザマスタを読み込む業務フロー -->
- <flow name="SPECIAL_USER_MST">
- <!-- JDBC接続のリソース宣言 -->
- <resource name="Connection" service="Nimbus#JDBCTransactionResourceFactory" trancontrol="true"/>
- <!-- マスタ読み込み用のRecordListを定義する -->
- <step name="Master">
- <target><object code="jp.ossc.nimbus.beans.dataset.RecordList"/></target>
- <attribute name="Name">SPECIAL_USER_MST</attribute>
- <attribute name="Schema">
- :userId,java.lang.String,,,,1
- </attribute>
- </step>
- <!-- マスタをデータベースから読み込む -->
- <step name="Load">
- <target><service-ref>Nimbus#PersistentManager</service-ref></target>
- <result>
- <invoke name="loadQuery">
- <argument type="java.sql.Connection"><resource-ref>Connection</resource-ref></argument>
- <argument>select USER_ID->{userId} from SPECIAL_USER_MST</argument>
- <argument type="java.lang.Object" nullValue="true"/>
- <argument type="java.lang.Object"><step-ref>Master</step-ref></argument>
- </invoke>
- </result>
- </step>
- </flow>
- </flows>