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 */ 016package org.opengion.hayabusa.io; 017 018import jakarta.servlet.http.HttpSession; 019 020import org.opengion.hayabusa.common.HybsSystemException; 021 022/** 023 * クラウド別のクラス生成 024 * 025 * @og.rev 5.9.25.0 (2017/10/06) 新規作成 026 * @og.group 027 * 028 * @version 5.0 029 * @author T.OTA 030 * @since JDK7.0 031 */ 032public final class StorageAPIFactory { 033 /** 034 * デフォルトコンストラクタを private 化しておきます。 035 */ 036 private StorageAPIFactory(){}; 037 038 /** 039 * 指定されたクラウド対象クラスを生成する。 040 * 041 * @param storage クラウド種別 042 * @param container コンテナ 043 * @param hsession セッション 044 * @return StorageAPIを継承したクラス 045 */ 046 public static StorageAPI newStorageAPI(final String storage, final String container, final HttpSession hsession){ 047 StorageAPI storageapi; 048 try{ 049 // StorageAPIの実装クラスをstorage別に生成する 050 final Object[] args = new Object[]{container, hsession}; 051 storageapi = (StorageAPI)Class.forName( "org.opengion.plugin.cloud.StorageAPI_" + storage ) 052 .getConstructor(String.class, HttpSession.class) 053 .newInstance(args); 054// } catch( final Exception ex ) { 055 } catch( final Throwable th ) { // PMD : 6.9.9.4 (2018/10/01) 056 final StringBuilder sbErrMsg = new StringBuilder() 057 .append("クラウドストレージ用のクラス生成に失敗しました。storage:").append(storage) 058 .append(" container:").append(container) 059 .append(" errInfo:" ).append(th) 060 .append(" errCause:" ).append(th.getCause()); 061// throw new HybsSystemException(sbErrMsg.toString()); 062 throw new HybsSystemException(sbErrMsg.toString() , th); // 8.0.0.0 (2021/07/31) original stack trace may be lost 063 } 064 return storageapi; 065 } 066}