Source Code Cross Referenced for POAMonitorImpl.java in  » Collaboration » JacORB » org » jacorb » poa » 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 » Collaboration » JacORB » org.jacorb.poa 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.jacorb.poa;
002:
003:        /*
004:         *        JacORB - a free Java ORB
005:         *
006:         *   Copyright (C) 1997-2004 Gerald Brose.
007:         *
008:         *   This library is free software; you can redistribute it and/or
009:         *   modify it under the terms of the GNU Library General Public
010:         *   License as published by the Free Software Foundation; either
011:         *   version 2 of the License, or (at your option) any later version.
012:         *
013:         *   This library is distributed in the hope that it will be useful,
014:         *   but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
016:         *   Library General Public License for more details.
017:         *
018:         *   You should have received a copy of the GNU Library General Public
019:         *   License along with this library; if not, write to the Free
020:         *   Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021:         */
022:
023:        import org.apache.avalon.framework.logger.Logger;
024:        import org.apache.avalon.framework.configuration.*;
025:
026:        import org.jacorb.poa.except.*;
027:        import org.jacorb.poa.util.*;
028:        import org.jacorb.poa.gui.*;
029:
030:        import org.jacorb.orb.dsi.ServerRequest;
031:
032:        import org.omg.PortableServer.*;
033:        import org.omg.PortableServer.POAManagerPackage.State;
034:
035:        import java.util.Enumeration;
036:
037:        /**
038:         * This class extends the POA with a monitoring gui. It implements all
039:         * poa related listener interfaces and will set up and update the gui.
040:         *
041:         * @author Reimo Tiedemann, FU Berlin
042:         * @version 1.06, 12/08/99, RT
043:         */
044:
045:        public class POAMonitorImpl extends POAAdapter implements  POAMonitor,
046:                POAMonitorController, Configurable {
047:            private POA poaModel;
048:            private AOM aomModel;
049:            private RequestQueue queueModel;
050:            private RPPoolManager pmModel;
051:
052:            private POAMonitorView view;
053:            private String prefix;
054:
055:            private int aomSize;
056:            private int queueSize;
057:            private int poolCount;
058:            private int poolSize;
059:
060:            private boolean terminate;
061:            private boolean aomChanged;
062:            private boolean queueChanged;
063:            private boolean pmChanged;
064:
065:            /** the configuration object for this POA instance */
066:            private org.jacorb.config.Configuration configuration = null;
067:            private Logger logger;
068:            private int threadPoolMin = 0;
069:            private int threadPoolMax = 0;
070:
071:            public void configure(Configuration myConfiguration)
072:                    throws ConfigurationException {
073:                this .configuration = (org.jacorb.config.Configuration) myConfiguration;
074:                logger = configuration.getNamedLogger("jacorb.poa.monitor");
075:
076:                threadPoolMin = configuration.getAttributeAsInteger(
077:                        "jacorb.poa.thread_pool_min", 5);
078:
079:                threadPoolMax = configuration.getAttributeAsInteger(
080:                        "jacorb.poa.thread_pool_max", 20);
081:
082:            }
083:
084:            public void actionCloseView() {
085:                closeMonitor();
086:            }
087:
088:            public void actionDeactivateObject(String oidStr) {
089:
090:                if (poaModel != null) {
091:                    try {
092:                        poaModel.deactivate_object(oidStr.getBytes());
093:                    } catch (Throwable e) {
094:                        printMessage("Exception occurred in deactivateObject() of POAMonitor: "
095:                                + e);
096:                    }
097:                }
098:            }
099:
100:            public void actionRemoveRequestFromQueue(String ridStr) {
101:
102:                if (queueModel != null && poaModel != null) {
103:                    try {
104:                        ServerRequest request = queueModel
105:                                .getElementAndRemove(Integer.parseInt(ridStr));
106:                        if (request == null)
107:                            throw new ApplicationError("error: rid " + ridStr
108:                                    + " is not contained in queue");
109:                        poaModel.getRequestController().rejectRequest(request,
110:                                new org.omg.CORBA.OBJ_ADAPTER());
111:                    } catch (Throwable e) {
112:                        printMessage("Exception occurred in removeRequestFromQueue() of POAMonitor: "
113:                                + e);
114:                    }
115:                }
116:            }
117:
118:            public StringPair[] actionRetrieveAOMContent() {
119:
120:                if (aomModel != null) {
121:                    try {
122:                        return aomModel != null ? aomModel.deliverContent()
123:                                : null;
124:                    } catch (Throwable e) {
125:                        printMessage("Exception occurred in retrieveAOMContent() of POAMonitor: "
126:                                + e);
127:                    }
128:                }
129:                return null;
130:            }
131:
132:            public StringPair[] actionRetrieveQueueContent() {
133:                if (queueModel != null) {
134:                    try {
135:                        return queueModel.deliverContent();
136:                    } catch (Throwable e) {
137:                        printMessage("Exception during retrieveQueueContent() of POAMonitor: "
138:                                + e);
139:                    }
140:                }
141:                return null;
142:            }
143:
144:            public synchronized void changeState(String state) {
145:                if (view != null) {
146:                    try {
147:                        view._setState(state);
148:                    } catch (Throwable exception) {
149:                        if (logger.isWarnEnabled()) {
150:                            logger
151:                                    .warn("Exception during changeState() of POAMonitor"
152:                                            + exception.getMessage());
153:                        }
154:                    }
155:                }
156:            }
157:
158:            public synchronized void closeMonitor() {
159:                if (view != null) {
160:                    try {
161:                        terminate = true;
162:                        poaModel._removePOAEventListener(this );
163:                        POAMonitor newMonitor = (POAMonitor) Class.forName(
164:                                "org.jacorb.poa.POAMonitorLightImpl")
165:                                .newInstance();
166:                        newMonitor.init(poaModel, aomModel, queueModel,
167:                                pmModel, prefix);
168:                        newMonitor.configure(configuration);
169:                        poaModel.setMonitor(newMonitor);
170:                        POAMonitorView tmp = view;
171:                        view = null;
172:                        tmp._destroy();
173:
174:                    } catch (Throwable exception) {
175:                        if (logger.isWarnEnabled()) {
176:                            logger
177:                                    .warn("Exception during closeMonitor() of POAMonitorImpl"
178:                                            + exception.getMessage());
179:                        }
180:                    }
181:                }
182:            }
183:
184:            public void init(POA poa, AOM aom, RequestQueue queue,
185:                    RPPoolManager pm, String _prefix) {
186:                poaModel = poa;
187:                aomModel = aom;
188:                queueModel = queue;
189:                pmModel = pm;
190:                prefix = _prefix;
191:            }
192:
193:            private void initView() {
194:                if (view != null) {
195:                    try {
196:                        String name = poaModel._getQualifiedName();
197:                        view
198:                                ._setName(name.equals("") ? POAConstants.ROOT_POA_NAME
199:                                        : POAConstants.ROOT_POA_NAME
200:                                                + POAConstants.OBJECT_KEY_SEPARATOR
201:                                                + name);
202:
203:                        view._setState(POAUtil.convert(poaModel.getState()));
204:
205:                        view._setPolicyThread(POAUtil.convert(
206:                                poaModel.threadPolicy, THREAD_POLICY_ID.value));
207:                        view._setPolicyLifespan(POAUtil.convert(
208:                                poaModel.lifespanPolicy,
209:                                LIFESPAN_POLICY_ID.value));
210:                        view._setPolicyIdUniqueness(POAUtil.convert(
211:                                poaModel.idUniquenessPolicy,
212:                                ID_UNIQUENESS_POLICY_ID.value));
213:                        view._setPolicyIdAssignment(POAUtil.convert(
214:                                poaModel.idAssignmentPolicy,
215:                                ID_ASSIGNMENT_POLICY_ID.value));
216:                        view._setPolicyServantRetention(POAUtil.convert(
217:                                poaModel.servantRetentionPolicy,
218:                                SERVANT_RETENTION_POLICY_ID.value));
219:                        view._setPolicyRequestProcessing(POAUtil.convert(
220:                                poaModel.requestProcessingPolicy,
221:                                REQUEST_PROCESSING_POLICY_ID.value));
222:                        view._setPolicyImplicitActivation(POAUtil.convert(
223:                                poaModel.implicitActivationPolicy,
224:                                IMPLICIT_ACTIVATION_POLICY_ID.value));
225:
226:                        view._initAOMBar(aomModel != null ? 10 : 0, true);
227:
228:                        view._initQueueBar(10, true);
229:
230:                        view._initActiveRequestsBar(poaModel
231:                                .isSingleThreadModel() ? 1 : threadPoolMin,
232:                                poaModel.isSingleThreadModel() ? 1
233:                                        : threadPoolMax);
234:                        view._initThreadPoolBar(0);
235:
236:                    } catch (Throwable exception) {
237:                        if (logger.isWarnEnabled()) {
238:                            logger
239:                                    .warn("Exception during initView() of POAMonitor"
240:                                            + exception.getMessage());
241:                        }
242:                    }
243:                }
244:            }
245:
246:            public void objectActivated(byte[] oid, Servant servant,
247:                    int aom_size) {
248:                aomSize = aom_size;
249:                aomChanged = true;
250:                refreshAOM();
251:            }
252:
253:            public void objectDeactivated(byte[] oid, Servant servant,
254:                    int aom_size) {
255:                aomSize = aom_size;
256:                aomChanged = true;
257:                refreshAOM();
258:            }
259:
260:            public synchronized void openMonitor() {
261:                if (view == null) {
262:                    try {
263:                        aomSize = aomModel != null ? aomModel.size() : 0;
264:                        queueSize = queueModel.size();
265:                        poolCount = pmModel.getPoolCount();
266:                        poolSize = pmModel.getPoolSize();
267:
268:                        view = new org.jacorb.poa.gui.poa.POAFrame(this );
269:
270:                        initView();
271:                        refreshView();
272:
273:                        poaModel._addPOAEventListener(this );
274:
275:                        view._setVisible(true);
276:
277:                    } catch (Throwable exception) {
278:                        if (logger.isWarnEnabled()) {
279:                            logger
280:                                    .warn("Exception occurred in openMonitor() of POAMonitor"
281:                                            + exception.getMessage());
282:                        }
283:                    }
284:                }
285:            }
286:
287:            private synchronized void printMessage(String str) {
288:                if (view != null) {
289:                    try {
290:                        view._printMessage(str);
291:                    } catch (Throwable exception) {
292:                        System.err
293:                                .println("Exception occurred in _printMessage() of POAMonitor");
294:                    }
295:                }
296:            }
297:
298:            public void processorAddedToPool(RequestProcessor processor,
299:                    int pool_count, int pool_size) {
300:                poolCount = pool_count;
301:                poolSize = pool_size;
302:                pmChanged = true;
303:                refreshPM();
304:            }
305:
306:            public void processorRemovedFromPool(RequestProcessor processor,
307:                    int pool_count, int pool_size) {
308:                poolCount = pool_count;
309:                poolSize = pool_size;
310:                pmChanged = true;
311:                refreshPM();
312:            }
313:
314:            private/* synchronized */void refreshAOM() {
315:                if (view != null) {
316:                    try {
317:                        view._setValueAOMBar(aomSize);
318:                    } catch (Throwable exception) {
319:                        if (logger.isWarnEnabled()) {
320:                            logger
321:                                    .warn("Exception during refreshAOM() of POAMonitor"
322:                                            + exception.getMessage());
323:                        }
324:                    }
325:                }
326:            }
327:
328:            private/* synchronized */void refreshPM() {
329:                if (view != null) {
330:                    try {
331:                        view._setValueActiveRequestsBar(poolSize - poolCount);
332:                        view._setMaxThreadPoolBar(poolSize);
333:                        view._setValueThreadPoolBar(poolCount);
334:                    } catch (Throwable exception) {
335:                        if (logger.isWarnEnabled()) {
336:                            logger
337:                                    .warn("Exception occurred in refreshPM() of POAMonitor"
338:                                            + exception.getMessage());
339:                        }
340:                    }
341:                }
342:            }
343:
344:            private/* synchronized */void refreshQueue() {
345:                if (view != null) {
346:                    try {
347:                        view._setValueQueueBar(queueSize);
348:                    } catch (Throwable exception) {
349:                        if (logger.isWarnEnabled()) {
350:                            logger
351:                                    .warn("Exception occurred in refreshQueue() of POAMonitor: "
352:                                            + exception.getMessage());
353:                        }
354:                    }
355:                }
356:            }
357:
358:            private void refreshView() {
359:                refreshAOM();
360:                refreshQueue();
361:                refreshPM();
362:            }
363:
364:            public void requestAddedToQueue(ServerRequest request,
365:                    int queue_size) {
366:                queueSize = queue_size;
367:                queueChanged = true;
368:                refreshQueue();
369:            }
370:
371:            public void requestRemovedFromQueue(ServerRequest request,
372:                    int queue_size) {
373:                queueSize = queue_size;
374:                queueChanged = true;
375:                refreshQueue();
376:            }
377:
378:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.