Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/flexstor/common/gateway/VirDeviceGateway.java


1   /*
2    * VirDeviceGateway.java
3    *
4    * Copyright $Date: 2003/08/11 02:22:29 $ FLEXSTOR.net Inc.
5    *
6    * This work is licensed for use and distribution under license terms found at
7    * http://www.flexstor.org/license.html
8    *
9    */
10  
11  package com.flexstor.common.gateway;
12  
13  import java.util.Vector;
14  
15  import com.flexstor.common.exceptions.ejb.NotFoundException;
16  import com.flexstor.common.gateway.debug.GatewayDebugOutput;
17  import com.flexstor.common.gateway.exceptions.TransactionFailedException;
18  import com.flexstor.ejb.EjbObject;
19  import com.flexstor.ejb.vir.indexing.VirDevice;
20  import com.flexstor.ejb.vir.indexing.VirDeviceHome;
21  
22  /**
23   * Gateway for connecting and using the Context Bean
24   * @author David Cardozo
25   * @version 3.0
26   */
27  public class VirDeviceGateway
28  extends Gateway
29  {
30     // MKS macro expander
31     public final static String IDENTIFIER = "$Id: VirDeviceGateway.java,v 1.3 2003/08/11 02:22:29 aleric Exp $";
32  
33     private VirDevice virDevice = null;
34  
35     protected String getHomeName ( )
36     {
37        return VIR_DEVICE_HOME;
38     }
39  
40     protected EjbObject getBeanObject ( )
41     {
42        return virDevice;
43     }
44  
45     /**
46      * Sends the request for the assetPath data to the server.
47      * @throws TransactionFailedException Throws if this transaction fails.
48      */
49     public void connect ()
50        throws TransactionFailedException
51     {
52        try
53        {
54           if ( canLoadObject() )
55              return;
56  
57           VirDeviceHome home = (VirDeviceHome) getHome ( );
58  
59           GatewayDebugOutput.println ( 3, "Getting VirDeviceHome object" );
60           virDevice = home.create();
61        }
62        catch ( NotFoundException e )
63        {
64           throw new TransactionFailedException ( e );
65        }
66        catch ( Throwable e )
67        {
68           throw buildException(e, "Connecting to VirDevice", IDENTIFIER );
69        }
70     }
71  
72     public Vector createSignature( Vector vAssetId )
73        throws TransactionFailedException
74     {
75        try
76        {
77           GatewayDebugOutput.println ( 3, "Creating Signature" );
78  
79           if ( canLoadObject() )
80              return (Vector)retrieveObject( "VIRDevice_createSignature" );
81  
82           Vector data = virDevice.createSignature( vAssetId );
83  
84           if ( canSaveObject() )
85              storeObject( "VIRDevice_createSignature", data );
86  
87           return data;
88        }
89        catch ( Throwable e )
90        {
91           throw buildException(e, "Creating Signature", IDENTIFIER );
92        }
93     }
94  }