Source Code Cross Referenced for ServiceService.java in  » ESB » mule » org » mule » module » management » mbean » 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 » ESB » mule » org.mule.module.management.mbean 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: ServiceService.java 11234 2008-03-06 23:44:34Z tcarlson $
003:         * --------------------------------------------------------------------------------------
004:         * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
005:         *
006:         * The software in this package is published under the terms of the CPAL v1.0
007:         * license, a copy of which has been included with this distribution in the
008:         * LICENSE.txt file.
009:         */
010:
011:        package org.mule.module.management.mbean;
012:
013:        import org.mule.MuleServer;
014:        import org.mule.api.MuleException;
015:        import org.mule.api.lifecycle.LifecycleTransitionResult;
016:        import org.mule.api.service.Service;
017:        import org.mule.management.stats.ServiceStatistics;
018:        import org.mule.model.seda.SedaService;
019:        import org.mule.service.AbstractService;
020:
021:        import javax.management.MBeanRegistration;
022:        import javax.management.MBeanServer;
023:        import javax.management.ObjectName;
024:
025:        import org.apache.commons.logging.Log;
026:        import org.apache.commons.logging.LogFactory;
027:
028:        /**
029:         * <code>ServiceService</code> exposes service information about a Mule Managed
030:         * service.
031:         */
032:        public class ServiceService implements  ServiceServiceMBean,
033:                MBeanRegistration, ServiceStatsMBean {
034:
035:            /**
036:             * logger used by this class
037:             */
038:            private static Log LOGGER = LogFactory.getLog(ServiceService.class);
039:
040:            private MBeanServer server;
041:
042:            private String name;
043:
044:            private ObjectName statsName;
045:
046:            private ObjectName objectName;
047:
048:            private ServiceStatistics statistics;
049:
050:            public ServiceService(String name) {
051:                this .name = name;
052:                this .statistics = getComponent().getStatistics();
053:
054:            }
055:
056:            public int getQueueSize() {
057:                Service c = getComponent();
058:                if (c instanceof  SedaService) {
059:                    return ((SedaService) c).getQueueSize();
060:                } else {
061:                    return -1;
062:                }
063:            }
064:
065:            /**
066:             * Pauses event processing for theComponent. Unlike stop(), a paused service
067:             * will still consume messages from the underlying transport, but those messages
068:             * will be queued until the service is resumed. <p/> In order to persist these
069:             * queued messages you can set the 'recoverableMode' property on the
070:             * Muleconfiguration to true. this causes all internal queues to store their
071:             * state.
072:             * 
073:             * @throws org.mule.api.MuleException if the service failed to pause.
074:             * @see org.mule.config.MuleConfiguration
075:             */
076:            public void pause() throws MuleException {
077:                getComponent().pause();
078:            }
079:
080:            /**
081:             * Resumes the Service that has been paused. If the service is not paused
082:             * nothing is executed.
083:             * 
084:             * @throws org.mule.api.MuleException if the service failed to resume
085:             */
086:            public void resume() throws MuleException {
087:                getComponent().resume();
088:            }
089:
090:            public boolean isPaused() {
091:                return getComponent().isPaused();
092:            }
093:
094:            public boolean isStopped() {
095:                return getComponent().isStopped();
096:            }
097:
098:            public LifecycleTransitionResult stop() throws MuleException {
099:                return getComponent().stop();
100:            }
101:
102:            public void forceStop() throws MuleException {
103:                getComponent().forceStop();
104:            }
105:
106:            public boolean isStopping() {
107:                return getComponent().isStopping();
108:            }
109:
110:            public void dispose() throws MuleException {
111:                getComponent().dispose();
112:            }
113:
114:            public LifecycleTransitionResult start() throws MuleException {
115:                return getComponent().start();
116:            }
117:
118:            /*
119:             * (non-Javadoc)
120:             * 
121:             * @see org.mule.management.mbeans.ServiceServiceMBean#getStatistics()
122:             */
123:            public ObjectName getStatistics() {
124:                return statsName;
125:            }
126:
127:            /*
128:             * (non-Javadoc)
129:             * 
130:             * @see javax.management.MBeanRegistration#preRegister(javax.management.MBeanServer,
131:             *      javax.management.ObjectName)
132:             */
133:            public ObjectName preRegister(MBeanServer server, ObjectName name)
134:                    throws Exception {
135:                this .server = server;
136:                this .objectName = name;
137:                return name;
138:            }
139:
140:            /*
141:             * (non-Javadoc)
142:             * 
143:             * @see javax.management.MBeanRegistration#postRegister(java.lang.Boolean)
144:             */
145:            public void postRegister(Boolean registrationDone) {
146:                try {
147:                    if (getComponent().getStatistics() != null) {
148:                        statsName = new ObjectName(objectName.getDomain()
149:                                + ":type=org.mule.Statistics,service="
150:                                + getName());
151:                        // unregister old version if exists
152:                        if (this .server.isRegistered(statsName)) {
153:                            this .server.unregisterMBean(statsName);
154:                        }
155:
156:                        this .server
157:                                .registerMBean(new ServiceStats(getComponent()
158:                                        .getStatistics()), this .statsName);
159:                    }
160:                } catch (Exception e) {
161:                    LOGGER.error("Error post-registering the MBean", e);
162:                }
163:            }
164:
165:            /*
166:             * (non-Javadoc)
167:             * 
168:             * @see javax.management.MBeanRegistration#preDeregister()
169:             */
170:            public void preDeregister() throws Exception {
171:                try {
172:                    if (this .server.isRegistered(statsName)) {
173:                        this .server.unregisterMBean(statsName);
174:                    }
175:                } catch (Exception ex) {
176:                    LOGGER.error("Error unregistering ServiceService child "
177:                            + statsName.getCanonicalName(), ex);
178:                }
179:            }
180:
181:            /*
182:             * (non-Javadoc)
183:             * 
184:             * @see javax.management.MBeanRegistration#postDeregister()
185:             */
186:            public void postDeregister() {
187:                // nothing to do
188:            }
189:
190:            private AbstractService getComponent() {
191:                return (AbstractService) MuleServer.getMuleContext()
192:                        .getRegistry().lookupService(getName());
193:            }
194:
195:            // ///// Service stats impl /////////
196:
197:            /**
198:             *
199:             */
200:            public void clearStatistics() {
201:                statistics.clear();
202:            }
203:
204:            /**
205:             * @return
206:             */
207:            public long getAsyncEventsReceived() {
208:                return statistics.getAsyncEventsReceived();
209:            }
210:
211:            /**
212:             * @return
213:             */
214:            public long getAsyncEventsSent() {
215:                return statistics.getAsyncEventsSent();
216:            }
217:
218:            /**
219:             * @return
220:             */
221:            public long getAverageExecutionTime() {
222:                return statistics.getAverageExecutionTime();
223:            }
224:
225:            /**
226:             * @return
227:             */
228:            public long getAverageQueueSize() {
229:                return statistics.getAverageQueueSize();
230:            }
231:
232:            /**
233:             * @return
234:             */
235:            public long getExecutedEvents() {
236:                return statistics.getExecutedEvents();
237:            }
238:
239:            /**
240:             * @return
241:             */
242:            public long getExecutionErrors() {
243:                return statistics.getExecutionErrors();
244:            }
245:
246:            /**
247:             * @return
248:             */
249:            public long getFatalErrors() {
250:                return statistics.getFatalErrors();
251:            }
252:
253:            /**
254:             * @return
255:             */
256:            public long getMaxExecutionTime() {
257:                return statistics.getMaxExecutionTime();
258:            }
259:
260:            /**
261:             * @return
262:             */
263:            public long getMaxQueueSize() {
264:                return statistics.getMaxQueueSize();
265:            }
266:
267:            /**
268:             * @return
269:             */
270:            public long getMinExecutionTime() {
271:                return statistics.getMinExecutionTime();
272:            }
273:
274:            /**
275:             * @return
276:             */
277:            public String getName() {
278:                return name;
279:            }
280:
281:            /**
282:             * @return
283:             */
284:            public long getQueuedEvents() {
285:                return statistics.getQueuedEvents();
286:            }
287:
288:            /**
289:             * @return
290:             */
291:            public long getReplyToEventsSent() {
292:                return statistics.getReplyToEventsSent();
293:            }
294:
295:            /**
296:             * @return
297:             */
298:            public long getSyncEventsReceived() {
299:                return statistics.getSyncEventsReceived();
300:            }
301:
302:            /**
303:             * @return
304:             */
305:            public long getSyncEventsSent() {
306:                return statistics.getSyncEventsSent();
307:            }
308:
309:            /**
310:             * @return
311:             */
312:            public long getTotalEventsReceived() {
313:                return statistics.getTotalEventsReceived();
314:            }
315:
316:            /**
317:             * @return
318:             */
319:            public long getTotalEventsSent() {
320:                return statistics.getTotalEventsSent();
321:            }
322:
323:            /**
324:             * @return
325:             */
326:            public long getTotalExecutionTime() {
327:                return statistics.getTotalExecutionTime();
328:            }
329:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.