001package org.opengion.fukurou.queue; 002 003import java.util.Locale; 004 005import org.opengion.fukurou.util.StringUtil; 006 007/** 008 * キュータイプ別の受信クラス生成 009 * 指定されたキュータイプの受信クラスを生成します。 010 * 011 * 下記のキュータイプを指定可能です。 012 * MQ:Active MQ or Amazon MQ 013 * SQS:Amazon SQS。 014 * 015 * @og.group メッセージ連携 016 * 017 * @og.rev 5.10.15.2 (2019/09/20) 新規作成 018 * 019 * @version 5 020 * @author oota 021 * @since JDK7 022 * 023 */ 024final public class QueueReceiveFactory { 025 private static final int BUFFER_MIDDLE = 200; 026 027 /** 028 * デフォルトコンストラクター 029 * static用クラスのため、クラス生成は不可にします。 030 */ 031 private QueueReceiveFactory() { 032 } 033 034 /** 035 * キュー受信クラス生成 036 * 037 * 引数のキュータイプのキュー受信クラスを生成します。 038 * MQ:Apache ActiveMq、amazonMQの場合に設定します。 039 * SQS:Amazon SQSの場合に設定します。 040 * 041 * @param queueType キュータイプ 042 * @return キュータイプのキュー受信クラス 043 */ 044 public static QueueReceive newQueueReceive(final String queueType) { 045 QueueReceive queueReceive = null; 046 String setQueueType = null; 047 048 final StringBuilder path = new StringBuilder(BUFFER_MIDDLE); 049 050 // 1. 前処理 051 // 大文字変換 052 if (!StringUtil.isNull(queueType)) { 053 setQueueType = queueType.toUpperCase(Locale.JAPAN); 054 } 055 056 // 2. 生成クラスの文字列生成 057 path.append("org.opengion.fukurou.queue."); 058 path.append("QueueReceive_"); 059 path.append(setQueueType); 060 061 try { 062 // 3. 対象クラスの生成 063// queueReceive = (QueueReceive) Class.forName(path.toString()).newInstance(); 064 queueReceive = (QueueReceive) Class.forName(path.toString()).getDeclaredConstructor().newInstance(); 065 } catch (final Throwable th) { 066 // キャッチしたエラー情報をスロー 067 throw new RuntimeException(th); 068 } 069 070 return queueReceive; 071 } 072}