package com.vci.client.volumn; import com.vci.client.common.providers.ServiceProvider; import com.vci.corba.common.VCIError; //import com.vci.corba.framework.method.VolumeManagerPrx; import com.vci.corba.volume.VolumeServicePrx; import com.vci.corba.framework.data.PvolumeInfo; /** *

Title: 卷服务Session

*

Description: 获取卷服务的工厂,并通过工厂获取系统提供的卷服务

*

Copyright: Copyright (c) 2011

*

Company: VCI

* @author Administrator * @time 2011-7-3 * @version 1.0 */ public class VolumnSession { // private static VolumeManagerPrx VF = null; // private static VolumeServicePrx volumeService = null; // static // { // try // { // VF = ServiceProvider.getVolumeManager(); // } // catch(Exception e) // { // e.printStackTrace(); // } // } public static PvolumeInfo getVolumnInfo(String volName) throws Exception { try { PvolumeInfo[] vols = ServiceProvider.getFrameService().getAllPvolumes(); for (PvolumeInfo vol : vols) { if (volName.equalsIgnoreCase(vol.name)) return vol; } return new PvolumeInfo(); } catch (VCIError ve) { ve.printStackTrace(); throw ve; } } // public static VolumnService getVolumnService() throws VCIError{ // try { // if (volumnService == null) { // volumnService = VF.getVolumnService(); // } // return volumnService; // } catch (VCIError ve) { // throw ve; // } // } public static VolumeServicePrx getVolumnService(String serviceName) throws VCIError{ try { VolumeServicePrx vs = ServiceProvider.getVolumeService(serviceName); return vs; } catch (Exception e) { // TODO Auto-generated catch block throw new VCIError("VolumnSession-001", new String[] {e.getMessage()}); } } public static VolumeServicePrx getVolumnServiceByVolumn(String volName) throws VCIError{ try { PvolumeInfo[] vols = ServiceProvider.getFrameService().getAllPvolumes(); String serviceName = ""; for (PvolumeInfo vol : vols) { if (vol.name.equalsIgnoreCase(volName)){ serviceName = vol.service; break; } } if (serviceName.isEmpty()) throw new VCIError("VolumnSession-002", new String[] {"卷对应的卷服务为空,请修改卷配置!"}); return getVolumnService(serviceName); //return vm; } catch (VCIError ve) { throw ve; } catch (Exception e) { // TODO Auto-generated catch block throw new VCIError("VolumnSession-003", new String[] {e.getMessage()}); } } }