Source Code Cross Referenced for ViewProxy.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » alarm » beans » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » JOnAS 4.8.6 » org.objectweb.alarm.beans 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999-2004 Bull S.A.
004:         * Contact: jonas-team@objectweb.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * Initial developer: JOnAS Team
022:         * --------------------------------------------------------------------------
023:         * $Id: ViewProxy.java 8307 2006-04-27 13:36:00Z durieuxp $
024:         * --------------------------------------------------------------------------
025:         */package org.objectweb.alarm.beans;
026:
027:        import java.rmi.RemoteException;
028:
029:        import javax.naming.Context;
030:        import javax.naming.InitialContext;
031:        import javax.naming.NamingException;
032:        import javax.rmi.PortableRemoteObject;
033:
034:        /**
035:         * proxy used to access the "View" session bean. must be instantiated by JSP's
036:         * with a tag like this: <jsp:useBean id="myview" scope=session
037:         * class=org.objectweb.alarm.beans.ViewProxy >
038:         */
039:        public class ViewProxy {
040:
041:            /**
042:             * Initial context
043:             */
044:            private Context ictx = null;
045:
046:            /**
047:             * Home of the bean View
048:             */
049:            private ViewHome vh = null;
050:
051:            /**
052:             * Bean View
053:             */
054:            private View ejbview = null;
055:
056:            /**
057:             * Name of my profil
058:             */
059:            private String myprofil = null;
060:
061:            /**
062:             * Error message
063:             */
064:            private String errorMessage = null;
065:
066:            private View getEjbView() {
067:                if (ejbview == null) {
068:                    // Create the Session Bean
069:                    try {
070:                        ejbview = vh.create();
071:                    } catch (Exception e) {
072:                        errorMessage = "ViewProxy : Cannot create EJB:"
073:                                + e.toString();
074:                    }
075:                }
076:                return ejbview;
077:            }
078:
079:            /**
080:             * Init procedure
081:             * Gets the bean and create one
082:             */
083:            private void init() {
084:                // Get the ViewHome
085:                try {
086:                    ictx = new InitialContext();
087:                    vh = (ViewHome) PortableRemoteObject.narrow(ictx
088:                            .lookup("viewhome"), ViewHome.class);
089:                } catch (NamingException e) {
090:                    errorMessage = "ViewProxy : Cannot get ViewHome:"
091:                            + e.toString();
092:                    return;
093:                }
094:                getEjbView();
095:            }
096:
097:            /**
098:             * constructor: Create here the EJB session.
099:             */
100:            public ViewProxy() {
101:                init();
102:            }
103:
104:            /**
105:             * @return RO attribute: Get all Profils already created by Alarm Manager.
106:             */
107:            public String[] getProfils() {
108:                String[] ret = new String[0];
109:                try {
110:                    ret = getEjbView().getProfils();
111:                    errorMessage = null;
112:                } catch (RemoteException e) {
113:                    errorMessage = "ViewProxy : Cannot get Profil list:"
114:                            + e.toString();
115:                    ejbview = null;
116:                }
117:                return ret;
118:            }
119:
120:            /**
121:             * @return RW attribute: Profil used.
122:             */
123:            public String getProfil() {
124:                errorMessage = null;
125:                return myprofil;
126:            }
127:
128:            /**
129:             * Set the current profil
130:             * @param p the name of the profil
131:             */
132:            public void setProfil(String p) {
133:                try {
134:                    getEjbView().setProfil(p);
135:                    errorMessage = null;
136:                    // keep it on local for efficiency
137:                    myprofil = p;
138:                } catch (RemoteException e) {
139:                    errorMessage = "ViewProxy : Cannot set Profil:"
140:                            + e.toString();
141:                    ejbview = null;
142:                }
143:            }
144:
145:            /**
146:             * @return RO attribute: list of new alarms on the current Profil
147:             */
148:            public AlarmData[] getNewAlarms() {
149:                AlarmData[] ret = null;
150:                try {
151:                    ret = getEjbView().getNewAlarms();
152:                    errorMessage = null;
153:                } catch (RemoteException e) {
154:                    errorMessage = "ViewProxy : Cannot get new alarms:"
155:                            + e.toString();
156:                    ejbview = null;
157:                }
158:                return ret;
159:            }
160:
161:            /**
162:             * @return RO attribute: list of all alarms on the current Profil
163:             */
164:            public AlarmData[] getAllAlarms() {
165:                AlarmData[] ret = null;
166:                try {
167:                    ret = getEjbView().getAllAlarms();
168:                    errorMessage = null;
169:                } catch (RemoteException e) {
170:                    errorMessage = "ViewProxy : Cannot get all alarms:"
171:                            + e.toString();
172:                    ejbview = null;
173:                }
174:                return ret;
175:            }
176:
177:            /**
178:             * @param profilName the name of the profil
179:             * @return the maximum level of alarm for this Profil.
180:             */
181:            public int alarmLevel(String profilName) {
182:                int level = 0;
183:                try {
184:                    level = getEjbView().alarmLevel(profilName);
185:                    errorMessage = null;
186:                } catch (RemoteException e) {
187:                    errorMessage = "ViewProxy : Cannot get AlarmLevel:"
188:                            + e.toString();
189:                    ejbview = null;
190:                }
191:                return level;
192:            }
193:
194:            /**
195:             * @return error message if any
196:             */
197:            public String getErrorMessage() {
198:                return errorMessage;
199:            }
200:
201:            /**
202:             * Forget this Alarm because it has been treated.
203:             * @param pk primary key
204:             */
205:            public void forgetAlarm(String pk) {
206:                try {
207:                    getEjbView().forgetAlarm(pk);
208:                    errorMessage = null;
209:                } catch (RemoteException e) {
210:                    errorMessage = "ViewProxy : Cannot forget Alarm:"
211:                            + e.toString();
212:                    ejbview = null;
213:                }
214:            }
215:
216:            /**
217:             * Creates a new Profil
218:             * @param device the name of the device
219:             * @param level the severity level
220:             * @return the newly created profil
221:             */
222:            public String newProfil(String device, String level) {
223:                String ret = null;
224:                try {
225:                    ret = getEjbView().newProfil(device, level);
226:                    errorMessage = null;
227:                } catch (RemoteException e) {
228:                    errorMessage = "ViewProxy : Cannot create Profil:"
229:                            + e.toString();
230:                    ejbview = null;
231:                }
232:                return ret;
233:            }
234:
235:            /**
236:             * remove a Profil
237:             * @param profil name of the profil to remove
238:             */
239:            public void removeProfil(String profil) {
240:                try {
241:                    getEjbView().removeProfil(profil);
242:                    errorMessage = null;
243:                } catch (RemoteException e) {
244:                    errorMessage = "ViewProxy : Cannot remove Profil:"
245:                            + e.toString();
246:                    ejbview = null;
247:                }
248:            }
249:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.