KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > compiere > session > StatusBean


1 /******************************************************************************
2  * The contents of this file are subject to the Compiere License Version 1.1
3  * ("License"); You may not use this file except in compliance with the License
4  * You may obtain a copy of the License at http://www.compiere.org/license.html
5  * Software distributed under the License is distributed on an "AS IS" basis,
6  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
7  * the specific language governing rights and limitations under the License.
8  * The Original Code is Compiere ERP & CRM Business Solution
9  * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
10  * Portions created by Jorg Janke are Copyright (C) 1999-2002 Jorg Janke, parts
11  * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
12  * Contributor(s): ______________________________________.
13  *****************************************************************************/

14 package org.compiere.session;
15
16 import java.util.*;
17 import java.sql.*;
18
19 import java.rmi.RemoteException JavaDoc;
20 import javax.ejb.CreateException JavaDoc;
21 import javax.ejb.EJBException JavaDoc;
22 import javax.ejb.FinderException JavaDoc;
23 import javax.ejb.RemoveException JavaDoc;
24 import javax.ejb.SessionBean JavaDoc;
25 import javax.ejb.SessionContext JavaDoc;
26 import javax.naming.Context JavaDoc;
27 import javax.naming.InitialContext JavaDoc;
28 import javax.naming.NamingException JavaDoc;
29 import javax.rmi.PortableRemoteObject JavaDoc;
30
31 import org.apache.log4j.Logger;
32 import org.compiere.interfaces.*;
33
34 import org.compiere.Compiere;
35 import org.compiere.db.*;
36 import org.compiere.model.*;
37 import org.compiere.util.*;
38
39
40 /**
41  * Compiere Status Bean
42  *
43  * @ejb:bean name="compiere/Status"
44  * display-name="Compiere Status Session Bean"
45  * type="Stateless"
46  * transaction-type="Bean"
47  * jndi-name="ejb/compiere/Status"
48  *
49  * @ejb:ejb-ref ejb-name="compiere/Status"
50  * ref-name="compiere/Status"
51  *
52  * @author Jorg Janke
53  * @version $Id: StatusBean.java,v 1.7 2002/11/13 04:55:53 jjanke Exp $
54  */

55 public class StatusBean implements SessionBean JavaDoc
56 {
57     /** Context */
58     private SessionContext JavaDoc m_Context;
59     /** Logging */
60     private transient Logger log = Logger.getLogger(getClass());
61
62     private static int s_no = 0;
63     private int m_no = 0;
64     //
65
private int m_versionCount = 0;
66     private int m_databaseCount = 0;
67
68
69     /**
70      * Get Version (Date)
71      * @ejb:interface-method view-type="remote"
72      * @return version e.g. 2002-09-02
73      * @throws RemoteException
74      */

75     public String JavaDoc getDateVersion() throws RemoteException JavaDoc
76     {
77         m_versionCount++;
78         log.info ("getDateVersion " + m_versionCount);
79         return Compiere.DATE_VERSION;
80     } // getDateVersion
81

82     /**
83      * Get Main Version
84      * @ejb:interface-method view-type="remote"
85      * @return main version - e.g. Version 2.4.3b
86      * @throws RemoteException
87      */

88     public String JavaDoc getMainVersion() throws RemoteException JavaDoc
89     {
90         return Compiere.MAIN_VERSION;
91     } // getMainVersion
92

93     /**
94      * Get Database Host
95      * @ejb:interface-method view-type="remote"
96      * @return Database Host Name
97      * @throws RemoteException
98      */

99     public String JavaDoc getDbHost() throws RemoteException JavaDoc
100     {
101         m_databaseCount++;
102         log.info ("getDbHost " + m_databaseCount);
103         return CConnection.get().getDbHost();
104     } // getDbHost
105

106     /**
107      * Get Database Port
108      * @ejb:interface-method view-type="remote"
109      * @return Database Posrt
110      * @throws RemoteException
111      */

112     public int getDbPort() throws RemoteException JavaDoc
113     {
114         return CConnection.get().getDbPort();
115     } // getDbPort
116

117     /**
118      * Get Database SID
119      * @ejb:interface-method view-type="remote"
120      * @return Database SID
121      * @throws RemoteException
122      */

123     public String JavaDoc getDbName() throws RemoteException JavaDoc
124     {
125         return CConnection.get().getDbName();
126     } // getDbSID
127

128     /**
129      * Get Database UID
130      * @ejb:interface-method view-type="remote"
131      * @return Database User Name
132      * @throws RemoteException
133      */

134     public String JavaDoc getDbUid() throws RemoteException JavaDoc
135     {
136         return CConnection.get().getDbUid();
137     } // getDbUID
138

139     /**
140      * Get Database PWD
141      * @ejb:interface-method view-type="remote"
142      * @return Database User Password
143      * @throws RemoteException
144      */

145     public String JavaDoc getDbPwd() throws RemoteException JavaDoc
146     {
147         return CConnection.get().getDbPwd();
148     } // getDbPWD
149

150     /**
151      * Get Connection Manager Host
152      * @ejb:interface-method view-type="remote"
153      * @return Connection Manager Host
154      * @throws RemoteException
155      */

156     public String JavaDoc getFwHost() throws RemoteException JavaDoc
157     {
158         return CConnection.get().getFwHost();
159     } // getCMHost
160

161     /**
162      * Get Connection Manager Port
163      * @ejb:interface-method view-type="remote"
164      * @return Connection Manager Port
165      * @throws RemoteException
166      */

167     public int getFwPort() throws RemoteException JavaDoc
168     {
169         return CConnection.get().getFwPort();
170     } // getCMPort
171

172     /*************************************************************************/
173
174     /**
175      * Get Version Count
176      * @ejb:interface-method view-type="remote"
177      * @return number of version inquiries
178      */

179     public int getVersionCount()
180     {
181         return m_versionCount;
182     } // getVersionCount
183

184     /**
185      * Get Database Count
186      * @ejb:interface-method view-type="remote"
187      * @return number of database inquiries
188      */

189     public int getDatabaseCount()
190     {
191         return m_databaseCount;
192     } // getVersionCount
193

194     /**
195      * Describes the instance and its content for debugging purpose
196      * @ejb:interface-method view-type="remote"
197      * @return Debugging information about the instance and its content
198      */

199     public String JavaDoc getStatus()
200     {
201         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("StatusBean[No=");
202         sb.append(m_no)
203             .append(",VersionCount=").append(m_versionCount)
204             .append(",DatabaseCount=").append(m_versionCount)
205             .append("]");
206         return sb.toString();
207     } // getStatus
208

209
210     /**
211      * String Representation
212      * @return info
213      */

214     public String JavaDoc toString()
215     {
216         return getStatus();
217     } // toString
218

219     /*************************************************************************/
220
221     /**
222      * Create the Session Bean
223      * @throws CreateException
224      * @ejb:create-method view-type="remote"
225      */

226     public void ejbCreate() throws CreateException JavaDoc
227     {
228         m_no = ++s_no;
229         log.info("ejbCreate " + m_no);
230         try
231         {
232             org.compiere.Compiere.startupServer(new InitialContext JavaDoc());
233         }
234         catch (Exception JavaDoc ex)
235         {
236             log.error("ejbCreate", ex);
237         // throw new CreateException ();
238
}
239     } // ejbCreate
240

241
242     // -------------------------------------------------------------------------
243
// Framework Callbacks
244
// -------------------------------------------------------------------------
245

246     public void setSessionContext (SessionContext JavaDoc aContext) throws EJBException JavaDoc
247     {
248         m_Context = aContext;
249     }
250
251     public void ejbActivate() throws EJBException JavaDoc
252     {
253         if (log == null)
254             log = Logger.getLogger(getClass());
255         log.debug("ejbActivate");
256     }
257
258     public void ejbPassivate() throws EJBException JavaDoc
259     {
260         log.debug("ejbPassivate");
261     }
262
263     public void ejbRemove() throws EJBException JavaDoc
264     {
265         log.debug("ejbRemove");
266     }
267
268 } // StatusBean
269
Popular Tags