Source Code Cross Referenced for Profil.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-2005 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: Profil.java 6920 2005-06-10 09:43:41Z benoitf $
024:         * --------------------------------------------------------------------------
025:         */package org.objectweb.alarm.beans;
026:
027:        import java.rmi.RemoteException;
028:        import java.util.Collection;
029:        import java.util.Iterator;
030:        import java.util.LinkedList;
031:
032:        import javax.ejb.FinderException;
033:        import javax.rmi.PortableRemoteObject;
034:
035:        /**
036:         * Helper class Profil Profils are managed by AlarmManager and used by View
037:         * session beans We do not use an Entity because we need neither persistence nor
038:         * remote accesses. We cannot use a Session bean because it's accessed from
039:         * several clients, and from the AlarmManager.
040:         */
041:        public class Profil {
042:
043:            /**
044:             * Device name or "all"
045:             */
046:            private String device;
047:
048:            /**
049:             * max severity level
050:             */
051:            private int maxsev; //
052:
053:            /**
054:             * Name
055:             */
056:            private String name;
057:
058:            /**
059:             * Is the device is all ?
060:             */
061:            private boolean fromAll;
062:
063:            /**
064:             * Home of the bean AlarmRecord
065:             */
066:            private AlarmRecordHome arh;
067:
068:            /**
069:             * A list of AlarmRecord objects
070:             */
071:            private LinkedList alarmList = new LinkedList();
072:
073:            /**
074:             * constructor
075:             * @param device the device name
076:             * @param sev the severity level
077:             * @param arh the home of the eban
078:             */
079:
080:            public Profil(String device, String sev, AlarmRecordHome arh) {
081:
082:                // init object
083:                this .device = device;
084:                this .arh = arh;
085:                fromAll = device.equals("all");
086:                if (sev.startsWith("S")) {
087:                    maxsev = 1;
088:                    sev = "S";
089:                } else if (sev.startsWith("W")) {
090:                    maxsev = 2;
091:                    sev = "W";
092:                } else {
093:                    maxsev = 3;
094:                    sev = "I";
095:                }
096:                name = device + "-" + sev;
097:
098:                // find alarms already arrived and matching this Profil
099:                Collection knal = null;
100:                try {
101:                    if (fromAll) {
102:                        knal = arh.findBySeverity(maxsev);
103:                    } else {
104:                        knal = arh.findByInterest(device, maxsev);
105:                    }
106:                    alarmList.addAll(knal);
107:                } catch (FinderException e) {
108:                    System.out.println("Profil constructor: No Alarm found");
109:                } catch (RemoteException e) {
110:                    System.out.println("Error getting AlarmRecords:" + e);
111:                }
112:            }
113:
114:            /**
115:             * @return the device
116:             */
117:            public String getDevice() {
118:                return device;
119:            }
120:
121:            /**
122:             * @return the severity watched
123:             */
124:            public String getSeverity() {
125:                switch (maxsev) {
126:                case 1:
127:                    return "S";
128:                case 2:
129:                    return "W";
130:                case 3:
131:                    return "I";
132:                default:
133:                    return "A";
134:                }
135:            }
136:
137:            /**
138:             * @return the profil name
139:             */
140:            public String getName() {
141:                return name;
142:            }
143:
144:            /**
145:             * get Alarms for this Profil.
146:             * @param  all true if get all alarms, false if get only new alarms
147:             * @return Alarms for this Profil.
148:             */
149:            public synchronized Collection getAlarms(boolean all) {
150:                LinkedList ret = new LinkedList();
151:                Iterator it = alarmList.iterator();
152:                while (it.hasNext()) {
153:                    AlarmRecord arec = (AlarmRecord) PortableRemoteObject
154:                            .narrow(it.next(), AlarmRecord.class);
155:                    AlarmData ad = null;
156:                    try {
157:                        ad = arec.getAlarmData();
158:                        if (all || (ad.getState() == 1)) {
159:                            ret.add(ad);
160:                        }
161:                    } catch (RemoteException e) {
162:                        System.out.println("Error getting AlarmRecord:" + e);
163:                    }
164:                }
165:                return ret;
166:            }
167:
168:            /**
169:             * Gets current Alarm level
170:             * @return current Alarm level
171:             */
172:            public synchronized int getCurrentLevel() {
173:                int ret = 1000;
174:                Iterator it = alarmList.iterator();
175:                while (it.hasNext()) {
176:                    AlarmRecord arec = (AlarmRecord) PortableRemoteObject
177:                            .narrow(it.next(), AlarmRecord.class);
178:                    try {
179:                        AlarmData ad = arec.getAlarmData();
180:                        if (ad.getState() == 1 && ad.getSev() <= ret) {
181:                            ret = ad.getSev();
182:                        }
183:                    } catch (RemoteException e) {
184:                        System.out.println("Error getting AlarmRecord:" + e);
185:                    }
186:                }
187:                return ret;
188:            }
189:
190:            /**
191:             * @param ad alarm data object
192:             * @return true if this Profil is interested by this AlarmRecord.
193:             */
194:            public boolean interestedBy(AlarmData ad) {
195:                return ((fromAll || ad.getDevice().equals(device)) && ad
196:                        .getSev() <= maxsev);
197:            }
198:
199:            /**
200:             * add an Alarm Record to this Profil.
201:             * @param arec the record
202:             */
203:            public synchronized void noticeAlarm(AlarmRecord arec) {
204:                alarmList.add(arec);
205:            }
206:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.