001 /*
002 * Copyright (c) 2009 The openGion Project.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
013 * either express or implied. See the License for the specific language
014 * governing permissions and limitations under the License.
015 */
016 package org.opengion.hayabusa.common;
017
018 import java.io.Serializable;
019 import java.sql.Connection;
020 import java.sql.PreparedStatement;
021 import java.sql.SQLException;
022 import java.util.ArrayList;
023 import java.util.Arrays;
024 import java.util.Comparator;
025 import java.util.HashMap;
026 import java.util.List;
027 import java.util.Map;
028 import java.util.Locale;
029
030 import javax.servlet.http.HttpSession;
031
032 import org.opengion.fukurou.db.ConnectionFactory;
033 import org.opengion.fukurou.util.Cleanable;
034 import org.opengion.fukurou.util.Closer;
035 import org.opengion.fukurou.util.LogWriter;
036 import org.opengion.fukurou.db.DBSimpleTable;
037
038 /**
039 * Webアプリケーション全体で使用してã�?‚‹オブジェクト類ã?トã?タルの管ç�?‚¯ラスですã?
040 *
041 * SystemManager はã€?
042 *
043 * session オブジェクトã?管ç�?�¨アクセス?�開放
044 *
045 * の作業を行いますã?
046 *
047 * 上記ã?クラス(staticメソãƒ?ƒ‰)へのアクセスは、もちろん直接呼び出して
048 * 操作することも可能ですが、サーバã?のクリーンシャãƒ?ƒˆãƒ?‚¦ン時やセãƒ?‚·ョンの
049 * 開放時ã?初期化å?ç�?�ªど、ある種の統合的なトリガを受けてã€?–¢係するクラスに
050 * イベントを伝えるよã�?�«することで、Webアプリケーションサーバã?とのã‚?‚Š取りã‚?
051 * ä¸??管ç�?�™る目çš?�§作æ?されてã�?�¾すã?
052 *
053 * @og.group 初期åŒ?
054 *
055 * @version 4.0
056 * @author Kazuhiko Hasegawa
057 * @since JDK5.0,
058 */
059 public final class SystemManager {
060 // 3.1.0.0 (2003/03/20) Hashtable を使用してã�?‚‹ç®?‰€でã€?�ž同期でも構わなã�?®?‰€をã?HashMap に置換えã€?
061 private static final Map<String,UserSummary> map = new HashMap<String,UserSummary>( HybsSystem.BUFFER_MIDDLE );
062
063 /** 4.0.0 (2005/01/31) Cleanable インターフェースを実è£?�—たオブジェクトを管ç�?�—ますã? */
064 private static final List<Cleanable> clearList = new ArrayList<Cleanable>() ;
065
066 /** 4.3.6.2 (2009/04/15) Context終äº?™‚のみclear()されã‚?Cleanable ブジェクトを管ç�?�—ますã? */
067 private static final List<Cleanable> contextClearList = new ArrayList<Cleanable>() ;
068
069 // 4.1.0.0 (2008/01/11) GE12クリア用
070 // 4.3.6.6 (2009/05/15) ENGINE_INFOは削除しなã�?
071 /** エンジン個別(SYSTEM_ID='個別' KBSAKU='0' CONTXT_PATH='自身')パラメータのä¸?‹¬削除のクエリー {@value} */
072 private static final String DEL_SYS = "DELETE FROM GE12 WHERE SYSTEM_ID=? AND KBSAKU='0' AND CONTXT_PATH=? AND PARAM_ID != 'ENGINE_INFO'";
073
074 /**
075 * ãƒ?ƒ•ォルトコンストラクターをprivateにしてã€?
076 * オブジェクトã?生æ?をさせなã�?‚ˆã�?�«するã€?
077 *
078 */
079 private SystemManager() {
080 }
081
082 /**
083 * session を記録しますã?
084 *
085 * 管ç�??権限で、強制ログアウトさせる場合などに、使用しますã?
086 * Servlet 2.1 では、HttpSessio#getSessionContext() より取り出した
087 * HttpSessionContextのgetSession(java.lang.String sessionId) で
088 * すべての session を取りå?せましたã�?Deprecated になりましたã€?
089 * セキュリãƒ?‚£ー上ã?好ましくなã�??ç�?�§すã?で,注意して使用してくださいã€?
090 * common\session_init.jsp より登録しまã�?
091 *
092 * @og.rev 5.5.9.1 (2012/12/07) セãƒ?‚·ョン作æ?時に、規定ã?キーでセãƒ?‚·ョンIDを保存しておくã€?
093 *
094 * @param session Httpセãƒ?‚·ョン
095 */
096 public static void addSession( final HttpSession session ) {
097 String sessionID = session.getId();
098
099 UserSummary userInfo = (UserSummary)session.getAttribute( HybsSystem.USERINFO_KEY );
100 if( userInfo != null ) {
101 synchronized( map ) {
102 map.put( sessionID,userInfo );
103 }
104 session.setAttribute( HybsSystem.SESSION_KEY, sessionID ); // 5.5.9.1 (2012/12/07) セãƒ?‚·ョンIDを保å?
105 }
106 }
107
108 /**
109 * session を削除しますã?
110 *
111 * 管ç�??権限で、強制ログアウトさせる場合などに、使用しますã?
112 * Servlet 2.1 では、HttpSessio#getSessionContext() より取り出した
113 * HttpSessionContextのgetSession(java.lang.String sessionId) で
114 * すべての session を取りå?せましたã�?Deprecated になりましたã€?
115 * セキュリãƒ?‚£ー上ã?好ましくなã�??ç�?�§すã?で,注意して使用してくださいã€?
116 *
117 * @og.rev 5.5.9.1 (2012/12/07) セãƒ?‚·ョン作æ?時に登録した規定ã?キーで userInfo を削除しますã?
118 * @og.rev 5.6.6.0 (2013/07/05) セãƒ?‚·ョンの Attribute に SESSION_KEY で登録してã�?‚‹ sessionID も削除しますã?
119 *
120 * @param session Httpセãƒ?‚·ョン
121 */
122 // public static void removeSession( final String sessionID ) {
123 public static void removeSession( final HttpSession session ) {
124
125 String sessionID = (String)session.getAttribute( HybsSystem.SESSION_KEY ); // 5.5.9.1 (2012/12/07) セãƒ?‚·ョンIDを取りå?ã�?
126
127 // 5.6.6.0 (2013/07/05) userInfo の map からの削除とuserInfo の clear を簡ç´?Œ–ã€?
128 synchronized( map ) {
129 UserSummary userInfo = map.remove( sessionID );
130 if( userInfo != null ) { userInfo.clear(); }
131 }
132
133 // final UserSummary userInfo ;
134 // synchronized( map ) {
135 // userInfo = map.remove( sessionID );
136 // }
137 // if( userInfo != null ) { userInfo.clear(); }
138
139 // 5.6.6.0 (2013/07/05) セãƒ?‚·ョンの Attribute に SESSION_KEY で登録してã�?‚‹ sessionID も削除しますã?
140 session.removeAttribute( HybsSystem.USERINFO_KEY );
141 session.removeAttribute( HybsSystem.SESSION_KEY );
142 }
143
144 /**
145 * すべてのシスãƒ?ƒ にログイン中のUserSummary オブジェクトを取得しますã?
146 *
147 * キーは、UserSummary の Attribute も含めた値が使用できますã?
148 * 引数のキーは、å?部で大æ–?—に変換されたã?ち、å?部キーとして使用されますã?
149 *
150 * @og.rev 4.0.0.0 (2005/01/31) å†?ƒ¨ロジãƒ?‚¯大å¹?¤‰更
151 * @og.rev 5.6.6.0 (2013/07/05) Comparator の作り方をã?簡ç´?Œ–しますã?キーのæŒ?®šç¯?›²も増やしますã?
152 *
153 * @param key ソートするキーé ?›®を指å®?
154 * @param direction ソートする方向[true:æ˜??/false:降é?]
155 *
156 * @return ログイン中のオブジェクãƒ?
157 */
158 public static UserSummary[] getRunningUserSummary( final String key,final boolean direction ) {
159 final UserSummary[] users ;
160 synchronized( map ) {
161 users = map.values().toArray( new UserSummary[map.size()] );
162 }
163
164 if( key != null ) {
165 // Comparator<UserSummary> comp = getUserSummaryComparator( key,direction );
166 Comparator<UserSummary> comp = new ATTRI_Comparator( key.toUpperCase( Locale.JAPAN ),direction );
167 Arrays.sort( users,comp );
168 }
169
170 return users ;
171 }
172
173 /**
174 * シスãƒ?ƒ にログイン中の、すべてのセãƒ?‚·ョン数をã?取得しますã?
175 *
176 * ちなみに、不正なãƒ??タが存在した場合ã?、ここでMapから削除しておきますã?
177 *
178 * @og.rev 4.0.0.0 (2005/01/31) 新規作æ?
179 *
180 * @return ログイン中の有効なすべてのセãƒ?‚·ョン数
181 */
182 public static int getRunningCount() {
183 final int rtnSize;
184 synchronized( map ) {
185 String[] keys = map.keySet().toArray( new String[map.size()] );
186 for( int i=0; i<keys.length; i++ ) {
187 if( map.get( keys[i] ) == null ) {
188 map.remove( keys[i] );
189 }
190 }
191 rtnSize = map.size() ;
192 }
193
194 return rtnSize;
195 }
196
197 /**
198 * contextDestroyed 時に、すべてのセãƒ?‚·ョンをã?invalidate()しますã?
199 * <del>永続化セãƒ?‚·ョン(SESSIONS.ser)対ç?/del>
200 * 注意:キャãƒ?‚·ュでå†?ƒ¨管ç�?�—てã�?�Ÿセãƒ?‚·ョンがã?すべて無効化されてしまã�?�¾すã?
201 * よって、å?部にセãƒ?‚·ョンを管ç�?�—なくなったためã?invalidate() もできませんã€?
202 * 不å?合が出るかもしれませんã€?
203 *
204 * @og.rev 3.5.2.1 (2003/10/27) 新規作æ?
205 * @og.rev 4.0.0.0 (2005/01/31) セãƒ?‚·ョン â‡?UserSummary に変更
206 */
207 static void sessionDestroyed() {
208 final UserSummary[] users ;
209 synchronized( map ) {
210 users = map.values().toArray( new UserSummary[map.size()] );
211 map.clear();
212 }
213
214 for( int i=0; i<users.length; i++ ) {
215 users[i].clear();
216 }
217 System.out.println( " [" + users.length + "] Session Destroyed " );
218 }
219
220 /**
221 * 初期化したいオブジェクトを登録しますã?
222 * オブジェクトã?、Cleanable インターフェースを実è£?�—ておくå¿?¦�がありますã?
223 * 実際に、clear() する場合ã?、ここで登録した全てのオブジェクトã? clear()
224 * メソãƒ?ƒ‰が呼び出されますã?
225 *
226 * @og.rev 4.0.0.0 (2005/01/31) 新規作æ?
227 * @og.rev 4.3.6.2 (2009/04/15) コンãƒ?‚スト終äº?™‚のみのclear()対å¿?
228 *
229 * @param obj インターフェースの実è£?
230 */
231 public static void addCleanable( final Cleanable obj ) {
232 // synchronized( clearList ) {
233 // clearList.add( obj );
234 // }
235 addCleanable( obj, false );
236 }
237
238 /**
239 * 初期化したいオブジェクトを登録しますã?
240 * オブジェクトã?、Cleanable インターフェースを実è£?�—ておくå¿?¦�がありますã?
241 * 実際に、clear() する場合ã?、ここで登録した全てのオブジェクトã? clear()
242 * メソãƒ?ƒ‰が呼び出されますã?
243 *
244 * @og.rev 4.0.0.0 (2005/01/31) 新規作æ?
245 * @og.rev 4.3.6.2 (2009/04/15) コンãƒ?‚スト終äº?™‚のみのclear()対å¿?
246 *
247 * @param obj インターフェースの実è£?
248 * @param flag trueの場合ã?コンãƒ?‚スト停止時ã?みclear()を呼び出ã�?
249 */
250 public static void addCleanable( final Cleanable obj, final boolean flag ) {
251 if( flag ) {
252 synchronized( contextClearList ) {
253 contextClearList.add( obj );
254 }
255 }
256 else {
257 synchronized( clearList ) {
258 clearList.add( obj );
259 }
260 }
261 }
262
263 /**
264 * addCleanable( final Cleanable ) で登録したすべてのオブジェクトを初期化しますã?
265 * 処ç�??、Cleanable インターフェースの clear()メソãƒ?ƒ‰をé?次呼び出しますã?
266 *
267 * @og.rev 4.0.0.0 (2005/01/31) 新規作æ?
268 * @og.rev 4.3.6.2 (2009/04/15) コンãƒ?‚スト終äº?™‚のみのclear()対å¿?
269 *
270 * @param flag 完å?終äº?™‚に、true
271 */
272 public static void allClear( final boolean flag ) {
273 final Cleanable[] clr ;
274 synchronized( clearList ) {
275 clr = clearList.toArray( new Cleanable[clearList.size()] );
276 if( flag ) { clearList.clear() ; } // contextDestroyed の場合ã?み実è¡?
277 }
278 // 登録のé€??で処ç�?�—てã�?��ますã?
279 for( int i=clr.length-1; i>=0; i-- ) {
280 clr[i].clear();
281 }
282
283 // コンãƒ?‚スト停止時ã?みclear()
284 if( flag ) {
285 final Cleanable[] clr2 ;
286 synchronized( contextClearList ) {
287 clr2 = contextClearList.toArray( new Cleanable[contextClearList.size()] );
288 contextClearList.clear();
289 }
290 // 登録のé€??で処ç�?�—てã�?��ますã?
291 for( int i=clr2.length-1; i>=0; i-- ) {
292 clr2[i].clear();
293 }
294 }
295 }
296
297 /**
298 * GE12からCONTXT PATHをhost:port/context/で登録してã�?‚‹物を削除しますã?
299 * (web.xmlにTOMCAT_PORTを指定したå?合に上記CONTEXT_PATHで登録されまã�?
300 *
301 * @og.rev 4.1.0.0 (2007/12/26) 新規作æ?
302 * @og.rev 5.5.4.5 (2012/07/27) 初期起動時のDB接続å?は、RESOURCE_DBID とするã€?
303 */
304 protected static void clearGE12() {
305 String HOST_URL = HybsSystem.sys( "HOST_URL" );
306 String RESOURCE_DBID = HybsSystem.sys( "RESOURCE_DBID" ); // 5.5.4.5 (2012/07/27) 初期起動時のDB接続å?
307 if( HOST_URL != null && !"**".equals( HOST_URL ) ) {
308 Connection connection = null;
309 PreparedStatement pstmt = null;
310 try {
311 // connection = ConnectionFactory.connection( null, null );
312 connection = ConnectionFactory.connection( RESOURCE_DBID, null ); // 5.5.4.5 (2012/07/27) 初期起動時のDB接続å?は、RESOURCE_DBID とするã€?
313 pstmt = connection.prepareStatement( DEL_SYS );
314 pstmt.setString( 1, HybsSystem.sys( "SYSTEM_ID" ) );
315 pstmt.setString( 2, HOST_URL );
316 int delCnt = pstmt.executeUpdate();
317 connection.commit();
318 System.out.println( HOST_URL + " DELETE FROM GE12[" + delCnt + "]" );
319 } catch (HybsSystemException e) {
320 LogWriter.log( e );
321 } catch (SQLException e) {
322 Closer.rollback( connection );
323 LogWriter.log( e );
324 }
325 finally {
326 Closer.stmtClose( pstmt );
327 ConnectionFactory.close( connection, null );
328 }
329 }
330 }
331
332 /**
333 * soffice.binをkillする処ç�?‚’callしますã?
334 *
335 * @og.rev 4.3.0.0 (2008/07/18) 新規作æ?
336 * @og.rev 5.2.2.0 (2010/11/01) 循環参ç?解消ã?ため、SystemManager から ProcessFactory へ移å‹?
337 */
338 // protected static void sofficeKill() {
339 // System.out.println("Kill all soffice.bin");
340 // ProcessFactory.kill();
341 // }
342
343 // deleteGUIAccessInfo() メソãƒ?ƒ‰でしか使用しなã�??定数宣è¨?
344 private static final int C_DEL_SYSTEM_ID = 0;
345 private static final int C_DEL_DYSET = 1;
346
347 /**
348 * アクセス統計テーブル(GE15)の再編成を行いますã?
349 * ãƒ??タの保存期間につã�?�¦は、シスãƒ?ƒ リソースのACCESS_TOKEI_ALIVE_DAYSでæŒ?®šしますã?
350 * ãƒ??タの作æ?された日時を基準として、上記ã?期間よりも古ã�?ƒ‡ータは、物ç�?‰Š除されますã?
351 * ACCESS_TOKEI_ALIVE_DAYSが指定されてã�?�ªã�??合ã?ãƒ??タの削除は行われませんã€?
352 *
353 * @og.rev 5.0.2.0 (2009/11/01) 新規作æ?
354 * @og.rev 5.5.5.1 (2012/08/07) リソース系DBID 付け忘れ対ç?
355 */
356 protected static void deleteGUIAccessInfo() {
357 String aliveDays = HybsSystem.sys( "ACCESS_TOKEI_ALIVE_DAYS" );
358 if( aliveDays == null || aliveDays.length() == 0 ) {
359 return;
360 }
361 String delBaseDate = HybsSystem.getDate( HybsSystem.getDate( "yyyyMMdd" ), -1 * Integer.valueOf( aliveDays ) );
362
363 String[] names = new String[] { "SYSTEM_ID","DYSET" };
364 String[] values = new String[names.length];
365 values[C_DEL_SYSTEM_ID ] = HybsSystem.sys( "SYSTEM_ID" );
366 values[C_DEL_DYSET ] = delBaseDate + "000000";
367
368 String RESOURCE_DBID = HybsSystem.sys( "RESOURCE_DBID" ); // 5.5.5.1 (2012/08/07) リソース系DBID 付け忘れ対å¿?
369 DBSimpleTable dbTable = new DBSimpleTable( names );
370 dbTable.setApplicationInfo( null );
371 dbTable.setConnectionID( RESOURCE_DBID ); // 5.5.5.1 (2012/08/07)
372 dbTable.setTable( "GE15" );
373 dbTable.setWhere( "SYSTEM_ID = [SYSTEM_ID] and DYSET <= [DYSET]" );
374
375 boolean okFlag = false;
376 try {
377 dbTable.startDelete();
378 dbTable.execute( values );
379 okFlag = true;
380 }
381 catch (SQLException ex) {
382 LogWriter.log( " アクセス統計テーブル削除時にエラーが発生しました" );
383 LogWriter.log( ex.getMessage() );
384 }
385 finally {
386 int cnt = dbTable.close( okFlag );
387 System.out.println();
388 System.out.println( " アクセス統計テーブルから、[" + cnt + "]件、削除しましたã€? );
389 }
390 }
391
392 /**
393 * UserSummary のæŒ?®šã?キーに対応したé?目をソートすã‚?Comparator を返しますã?
394 *
395 * キーは、JNAME,ID,IPADDRESS,LOGINTIME のã�?�¡のどれかですã?
396 *
397 * @og.rev 3.8.5.3 (2006/08/07) 新規追åŠ?
398 * @og.rev 5.6.6.0 (2013/07/05) Comparator の作り方をã?簡ç´?Œ–しますã?そã?ため、å»?¢ã€?
399 *
400 * @param key ソートするキーé ?›®を指å®?
401 * @param direction ソートする方向[true:æ˜??/false:降é?]
402 *
403 * @return æŒ?®šã?キーに対応したé?目をソートすã‚?Comparator
404 */
405 // public static Comparator<UserSummary> getUserSummaryComparator( final String key,final boolean direction ) {
406 // if( "JNAME,ID,ROLES,IPADDRESS,LOGINTIME".indexOf( key ) < 0 ) {
407 // String errMsg = "ソートキーには、JNAME,ID,ROLES,IPADDRESS,LOGINTIME 以外ã?æŒ?®šできませんã€?
408 // + " Key=" + key ;
409 // throw new HybsSystemException( errMsg );
410 // }
411 //
412 // Comparator<UserSummary> comp = null;
413 //
414 // if( "JNAME".equals( key ) ) {
415 // comp = new JNAME_Comparator( direction );
416 // }
417 // else if( "ID".equals( key ) ) {
418 // comp = new ID_Comparator( direction );
419 // }
420 // else if( "ROLES".equals( key ) ) {
421 // comp = new ROLES_Comparator( direction );
422 // }
423 // else if( "IPADDRESS".equals( key ) ) {
424 // comp = new IPADDRESS_Comparator( direction );
425 // }
426 // else if( "LOGINTIME".equals( key ) ) {
427 // comp = new LOGINTIME_Comparator( direction );
428 // }
429 //
430 // return comp ;
431 // }
432
433 /**
434 * UserSummary の Attribute で比è¼?�™ã‚?Comparator å†?ƒ¨クラスの定義ã€?
435 *
436 * key がã?Attribute のキーになりますが、使用するのは、大æ–?—化してからですã?
437 *
438 * @og.rev 5.6.6.0 (2013/07/05) 新規追åŠ?
439 */
440 private static final class ATTRI_Comparator implements Comparator<UserSummary>, Serializable {
441 private static final long serialVersionUID = 5660 ; // 5.6.6.0 (2013/07/05)
442 private final String key ;
443 private final boolean direct ;
444
445 /**
446 * ソートã?方向を引数にとるコンストラクタã€?
447 *
448 * @og.rev 5.6.6.0 (2013/07/05) 新規追åŠ?
449 *
450 * @param direction ソートã?方向[true:æ˜??/false:降é?]
451 */
452 public ATTRI_Comparator( final String key,final boolean direction ) {
453 this.key = key;
454 direct = direction;
455 }
456
457 /**
458 * getAttribute 比è¼?ƒ¡ソãƒ?ƒ‰
459 * インタフェース Comparable の 実è£?�§すã?
460 *
461 * キーとして、getAttribute( String ) の取得結果を使用する為、null もあり得ますã?そã?場合ã?equals 整合æ?は取れませんがã?
462 * 処ç�?�¨しては、正常に動作するよã�?�«しておきますã?つまりã?null はもっとも小さã�??としã?比è¼?¯¾象がともに null の
463 * 場合ã?、同じと判断しますã?
464 *
465 * @og.rev 5.6.6.0 (2013/07/05) 新規追åŠ?
466 *
467 * @param o1 比è¼?¯¾象のæœ??のオブジェクãƒ?
468 * @param o2 比è¼?¯¾象の 2 番目のオブジェクãƒ?
469 * @return æœ??の引数ã�?2 番目の引数より小さã�??合ã?è²??整数、両方が等しã�??合ã? 0、最初ã?引数ã�?2 番目の引数より大きい場合ã?正の整数
470 */
471 public int compare( final UserSummary o1, final UserSummary o2 ) {
472 String key1 = o1.getAttribute( key );
473 String key2 = o2.getAttribute( key );
474
475 int rtn ;
476 if( key1 == null && key2 == null ) { rtn = 0; }
477 else if( key1 == null ) { rtn = -1; }
478 else if( key2 == null ) { rtn = 1; }
479 else { rtn = key1.compareTo( key2 ) ; }
480
481 return ( direct ) ? rtn : -rtn; // マイナス 0 が気になるが、まあã?良しとするã€?
482 }
483 }
484
485 // /**
486 // * JNAME で比è¼?�™ã‚?Comparator å†?ƒ¨クラスの定義ã€?
487 // *
488 // * @og.rev 4.0.0.0 (2006/09/31) 新規追åŠ?
489 // * @og.rev 5.6.6.0 (2013/07/05) ATTRI_Comparator に統合ã?ため、å»?¢
490 // */
491 // private static final class JNAME_Comparator implements Comparator<UserSummary>, Serializable {
492 // private static final long serialVersionUID = 4000 ; // 4.0.0 (2006/09/31)
493 // private final boolean direct ;
494 //
495 // /**
496 // * ソートã?方向を引数にとるコンストラクタã€?
497 // *
498 // * @og.rev 4.0.0.0 (2006/09/31) 新規追åŠ?
499 // *
500 // * @param direction ソートã?方向[true:æ˜??/false:降é?]
501 // */
502 // public JNAME_Comparator( final boolean direction ) {
503 // direct = direction;
504 // }
505 //
506 // /**
507 // * getJname 比è¼?ƒ¡ソãƒ?ƒ‰
508 // * インタフェース Comparable の 実è£?�§すã?
509 // *
510 // * @og.rev 4.0.0.0 (2006/09/31) 新規追åŠ?
511 // *
512 // * @param o1 比è¼?¯¾象のæœ??のオブジェクãƒ?
513 // * @param o2 比è¼?¯¾象の 2 番目のオブジェクãƒ?
514 // * @return æœ??の引数ã�?2 番目の引数より小さã�??合ã?è²??整数、両方が等しã�??合ã? 0、最初ã?引数ã�?2 番目の引数より大きい場合ã?正の整数
515 // */
516 // public int compare( final UserSummary o1, final UserSummary o2 ) {
517 // String key1 = o1.getJname();
518 // String key2 = o2.getJname();
519 // return ( direct ) ? key1.compareTo( key2 ) : key2.compareTo( key1 );
520 // }
521 // }
522 //
523 // /**
524 // * ID で比è¼?�™ã‚?Comparator å†?ƒ¨クラスの定義ã€?
525 // *
526 // * @og.rev 4.0.0.0 (2006/09/31) 新規追åŠ?
527 // * @og.rev 5.6.6.0 (2013/07/05) ATTRI_Comparator に統合ã?ため、å»?¢
528 // */
529 // private static final class ID_Comparator implements Comparator<UserSummary>, Serializable {
530 // private static final long serialVersionUID = 4000 ; // 4.0.0 (2006/09/31)
531 // private final boolean direct ;
532 //
533 // /**
534 // * ソートã?方向を引数にとるコンストラクタã€?
535 // *
536 // * @og.rev 4.0.0.0 (2006/09/31) 新規追åŠ?
537 // *
538 // * @param direction ソートã?方向[true:æ˜??/false:降é?]
539 // */
540 // public ID_Comparator( final boolean direction ) {
541 // direct = direction;
542 // }
543 //
544 // /**
545 // * getUserID 比è¼?ƒ¡ソãƒ?ƒ‰
546 // * インタフェース Comparable の 実è£?�§すã?
547 // *
548 // * @og.rev 4.0.0.0 (2006/09/31) 新規追åŠ?
549 // *
550 // * @param o1 比è¼?¯¾象のæœ??のオブジェクãƒ?
551 // * @param o2 比è¼?¯¾象の 2 番目のオブジェクãƒ?
552 // * @return æœ??の引数ã�?2 番目の引数より小さã�??合ã?è²??整数、両方が等しã�??合ã? 0、最初ã?引数ã�?2 番目の引数より大きい場合ã?正の整数
553 // */
554 // public int compare( final UserSummary o1, final UserSummary o2 ) {
555 // String key1 = o1.getUserID();
556 // String key2 = o2.getUserID();
557 // return ( direct ) ? key1.compareTo( key2 ) : key2.compareTo( key1 );
558 // }
559 // }
560 //
561 // /**
562 // * ROLES で比è¼?�™ã‚?Comparator å†?ƒ¨クラスの定義ã€?
563 // *
564 // * @og.rev 4.0.0.0 (2006/09/31) 新規追åŠ?
565 // * @og.rev 5.6.6.0 (2013/07/05) ATTRI_Comparator に統合ã?ため、å»?¢
566 // */
567 // private static final class ROLES_Comparator implements Comparator<UserSummary>, Serializable {
568 // private static final long serialVersionUID = 4000 ; // 4.0.0 (2006/09/31)
569 // private final boolean direct ;
570 //
571 // /**
572 // * ソートã?方向を引数にとるコンストラクタã€?
573 // *
574 // * @og.rev 4.0.0.0 (2006/09/31) 新規追åŠ?
575 // *
576 // * @param direction ソートã?方向[true:æ˜??/false:降é?]
577 // */
578 // public ROLES_Comparator( final boolean direction ) {
579 // direct = direction;
580 // }
581 //
582 // /**
583 // * getRoles 比è¼?ƒ¡ソãƒ?ƒ‰
584 // * インタフェース Comparable の 実è£?�§すã?
585 // *
586 // * @og.rev 4.0.0.0 (2006/09/31) 新規追åŠ?
587 // *
588 // * @param o1 比è¼?¯¾象のæœ??のオブジェクãƒ?
589 // * @param o2 比è¼?¯¾象の 2 番目のオブジェクãƒ?
590 // * @return æœ??の引数ã�?2 番目の引数より小さã�??合ã?è²??整数、両方が等しã�??合ã? 0、最初ã?引数ã�?2 番目の引数より大きい場合ã?正の整数
591 // */
592 // public int compare( final UserSummary o1, final UserSummary o2 ) {
593 // String key1 = o1.getRoles();
594 // String key2 = o2.getRoles();
595 // return ( direct ) ? key1.compareTo( key2 ) : key2.compareTo( key1 );
596 // }
597 // }
598 //
599 // /**
600 // * IPADDRESS で比è¼?�™ã‚?Comparator å†?ƒ¨クラスの定義ã€?
601 // *
602 // * @og.rev 4.0.0.0 (2006/09/31) 新規追åŠ?
603 // * @og.rev 5.6.6.0 (2013/07/05) ATTRI_Comparator に統合ã?ため、å»?¢
604 // */
605 // private static final class IPADDRESS_Comparator implements Comparator<UserSummary>, Serializable {
606 // private static final long serialVersionUID = 4000 ; // 4.0.0 (2006/09/31)
607 // private final boolean direct ;
608 //
609 // /**
610 // * ソートã?方向を引数にとるコンストラクタã€?
611 // *
612 // * @og.rev 4.0.0.0 (2006/09/31) 新規追åŠ?
613 // *
614 // * @param direction ソートã?方向[true:æ˜??/false:降é?]
615 // */
616 // public IPADDRESS_Comparator( final boolean direction ) {
617 // direct = direction;
618 // }
619 //
620 // /**
621 // * getIPAddress 比è¼?ƒ¡ソãƒ?ƒ‰
622 // * インタフェース Comparable の 実è£?�§すã?
623 // *
624 // * @og.rev 4.0.0.0 (2006/09/31) 新規追åŠ?
625 // *
626 // * @param o1 比è¼?¯¾象のæœ??のオブジェクãƒ?
627 // * @param o2 比è¼?¯¾象の 2 番目のオブジェクãƒ?
628 // * @return æœ??の引数ã�?2 番目の引数より小さã�??合ã?è²??整数、両方が等しã�??合ã? 0、最初ã?引数ã�?2 番目の引数より大きい場合ã?正の整数
629 // */
630 // public int compare( final UserSummary o1, final UserSummary o2 ) {
631 // String key1 = o1.getIPAddress();
632 // String key2 = o2.getIPAddress();
633 // return ( direct ) ? key1.compareTo( key2 ) : key2.compareTo( key1 );
634 // }
635 // }
636 //
637 // /**
638 // * LOGINTIME で比è¼?�™ã‚?Comparator å†?ƒ¨クラスの定義ã€?
639 // *
640 // * @og.rev 4.0.0.0 (2006/09/31) 新規追åŠ?
641 // * @og.rev 5.6.6.0 (2013/07/05) ATTRI_Comparator に統合ã?ため、å»?¢
642 // */
643 // private static final class LOGINTIME_Comparator implements Comparator<UserSummary>, Serializable {
644 // private static final long serialVersionUID = 4000 ; // 4.0.0 (2006/09/31)
645 // private final boolean direct ;
646 //
647 // /**
648 // * ソートã?方向を引数にとるコンストラクタã€?
649 // *
650 // * @og.rev 4.0.0.0 (2006/09/31) 新規追åŠ?
651 // *
652 // * @param direction ソートã?方向[true:æ˜??/false:降é?]
653 // */
654 // public LOGINTIME_Comparator( final boolean direction ) {
655 // direct = direction;
656 // }
657 //
658 // /**
659 // * getLoginTime 比è¼?ƒ¡ソãƒ?ƒ‰
660 // * インタフェース Comparable の 実è£?�§すã?
661 // *
662 // * @og.rev 4.0.0.0 (2006/09/31) 新規追åŠ?
663 // *
664 // * @param o1 比è¼?¯¾象のæœ??のオブジェクãƒ?
665 // * @param o2 比è¼?¯¾象の 2 番目のオブジェクãƒ?
666 // * @return æœ??の引数ã�?2 番目の引数より小さã�??合ã?è²??整数、両方が等しã�??合ã? 0、最初ã?引数ã�?2 番目の引数より大きい場合ã?正の整数
667 // */
668 // public int compare( final UserSummary o1, final UserSummary o2 ) {
669 // long key1 = o1.getLoginTime();
670 // long key2 = o2.getLoginTime();
671 // int rtn = (direct) ? 1:-1 ;
672 // return ( key1 == key2 ) ? 0 : (key1 < key2) ? rtn : -rtn ;
673 // }
674 // }
675 }