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

Quick Search    Search Deep

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


1   /*
2    * DisguiseFieldGateway.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 com.flexstor.common.data.ejb.disguise.field.DisguiseFieldData;
14  import com.flexstor.common.gateway.debug.GatewayDebugOutput;
15  import com.flexstor.common.gateway.exceptions.TransactionFailedException;
16  import com.flexstor.common.keys.ejb.DisguiseFieldKey;
17  import com.flexstor.ejb.EjbObject;
18  import com.flexstor.ejb.disguisefield.persist.DisguiseFieldPersist;
19  import com.flexstor.ejb.disguisefield.persist.DisguiseFieldPersistHome;
20  
21  /**
22   * A gateway for interacting with the DisguiseFieldPersistBean.
23   */
24  public class DisguiseFieldGateway
25     extends Gateway
26  {
27     // MKS macro expander
28     public final static String IDENTIFIER = "$Id: DisguiseFieldGateway.java,v 1.3 2003/08/11 02:22:29 aleric Exp $";
29  
30     private DisguiseFieldPersist disgField;
31  
32     protected String getHomeName()
33     {
34        return DISGUISE_FIELD_PERSIST_HOME;
35     }
36  
37     protected EjbObject getBeanObject()
38     {
39        return disgField;
40     }
41  
42     public void connect()
43        throws TransactionFailedException
44     {
45        try
46        {
47           if ( canLoadObject() )
48              return;
49  
50           DisguiseFieldPersistHome home = (DisguiseFieldPersistHome)getHome();
51           GatewayDebugOutput.println ( 3, "Getting DisguiseFieldPersist object" );
52           disgField = home.create();
53        }
54        catch ( Throwable e )
55        {
56           throw buildException(e, "Connecting to DisguiseFieldPersist", IDENTIFIER );
57        }
58     }
59  
60     /**
61      * This will get the Data Object based upon key.
62      *
63      * @param key A reference to a  DisguiseField row
64      * @exception java.rmi.RemoteException
65      * @since FlexDB 3.0
66      */
67     public DisguiseFieldData getField( DisguiseFieldKey key )
68        throws TransactionFailedException
69     {
70        try
71        {
72           if ( canLoadObject() )
73              return (DisguiseFieldData)retrieveObject ( "DisguiseField_getField" );
74  
75           GatewayDebugOutput.println ( 3, "Getting Disguise Field" );
76  
77           DisguiseFieldData data = disgField.getDataObject( key );
78  
79           if ( canSaveObject() )
80              storeObject ( "DisguiseField_getField", data );
81  
82           return data;
83        }
84        catch ( Throwable e )
85        {
86           throw buildException(e);
87        }
88     }
89  
90     /**
91      * Insert a new  DisguiseField column in the  DisguiseField table. This will
92      * insert a new field and return a DisguiseField key.
93      *
94      * @param fieldDat DisguiseFieldData Object
95      *
96      * @return com.flexstor.ejb.key.DisguiseFieldKey
97      *
98      * @exception com.flexstor.ejb.exceptions.ServerException
99      * @exception java.rmi.RemoteException
100     */
101    public DisguiseFieldKey insert( DisguiseFieldData data )
102       throws TransactionFailedException
103    {
104       try
105       {
106          if ( canLoadObject() )
107             return (DisguiseFieldKey)retrieveObject ( "DisguiseField_insert" );
108 
109          GatewayDebugOutput.println ( 3, "Inserting Disguise Field" );
110 
111          DisguiseFieldKey key = disgField.insert( data );
112 
113          if ( canSaveObject() )
114             storeObject ( "DisguiseField_insert", key );
115 
116          return key;
117       }
118       catch ( Throwable e )
119       {
120          throw buildException(e);
121       }
122    }
123 
124    /**
125     * Remove a DisguiseField From database Based upon key. Throws
126     * exception if error removing row.
127     *
128     * @param key DisguiseFieldKey Object
129     * @exception com.flexstor.ejb.exceptions.EjbException
130     * @exception java.rmi.RemoteException
131     */
132    public void remove( DisguiseFieldKey key )
133       throws TransactionFailedException
134    {
135       try
136       {
137          GatewayDebugOutput.println ( 3, "remove Disguise Field" );
138          disgField.remove( key );
139       }
140       catch ( Throwable e )
141       {
142          throw buildException( e, "Removing Disguise Field", IDENTIFIER );
143       }
144    }
145 }