Source Code Cross Referenced for SubjectTrackingMBeanServer.java in  » J2EE » enhydra » mx4j » examples » remote » interception » 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 » enhydra » mx4j.examples.remote.interception 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) The MX4J Contributors.
003:         * All rights reserved.
004:         *
005:         * This software is distributed under the terms of the MX4J License version 1.0.
006:         * See the terms of the MX4J License in the documentation provided with this software.
007:         */
008:
009:        package mx4j.examples.remote.interception;
010:
011:        import java.io.ObjectInputStream;
012:        import java.security.AccessController;
013:        import java.util.Set;
014:        import javax.management.Attribute;
015:        import javax.management.AttributeList;
016:        import javax.management.AttributeNotFoundException;
017:        import javax.management.InstanceAlreadyExistsException;
018:        import javax.management.InstanceNotFoundException;
019:        import javax.management.IntrospectionException;
020:        import javax.management.InvalidAttributeValueException;
021:        import javax.management.ListenerNotFoundException;
022:        import javax.management.MBeanException;
023:        import javax.management.MBeanInfo;
024:        import javax.management.MBeanRegistrationException;
025:        import javax.management.MBeanServer;
026:        import javax.management.NotCompliantMBeanException;
027:        import javax.management.NotificationFilter;
028:        import javax.management.NotificationListener;
029:        import javax.management.ObjectInstance;
030:        import javax.management.ObjectName;
031:        import javax.management.OperationsException;
032:        import javax.management.QueryExp;
033:        import javax.management.ReflectionException;
034:        import javax.management.loading.ClassLoaderRepository;
035:        import javax.management.remote.MBeanServerForwarder;
036:        import javax.security.auth.Subject;
037:
038:        /**
039:         * This class tracks the Subject of the current invocation, and prints it to System.out.
040:         * It should be better implemented as JDK 1.3 dynamic proxy, but this is left as a simple
041:         * exercise to the reader ;)
042:         *
043:         * @version $Revision: 1.1 $
044:         */
045:        public class SubjectTrackingMBeanServer implements  MBeanServerForwarder {
046:            private MBeanServer server;
047:
048:            public synchronized MBeanServer getMBeanServer() {
049:                return server;
050:            }
051:
052:            public synchronized void setMBeanServer(MBeanServer server)
053:                    throws IllegalArgumentException {
054:                if (server == null)
055:                    throw new IllegalArgumentException(
056:                            "Cannot forward to a null MBeanServer");
057:                this .server = server;
058:            }
059:
060:            private void trackSubject() {
061:                Subject subject = Subject.getSubject(AccessController
062:                        .getContext());
063:                System.out.println("Subject = " + subject);
064:            }
065:
066:            public void addNotificationListener(ObjectName observed,
067:                    NotificationListener listener, NotificationFilter filter,
068:                    Object handback) throws InstanceNotFoundException {
069:                trackSubject();
070:                getMBeanServer().addNotificationListener(observed, listener,
071:                        filter, handback);
072:            }
073:
074:            public void addNotificationListener(ObjectName observed,
075:                    ObjectName listener, NotificationFilter filter,
076:                    Object handback) throws InstanceNotFoundException {
077:                trackSubject();
078:                getMBeanServer().addNotificationListener(observed, listener,
079:                        filter, handback);
080:            }
081:
082:            public void removeNotificationListener(ObjectName observed,
083:                    ObjectName listener) throws InstanceNotFoundException,
084:                    ListenerNotFoundException {
085:                trackSubject();
086:                getMBeanServer().removeNotificationListener(observed, listener);
087:            }
088:
089:            public void removeNotificationListener(ObjectName observed,
090:                    NotificationListener listener)
091:                    throws InstanceNotFoundException, ListenerNotFoundException {
092:                trackSubject();
093:                getMBeanServer().removeNotificationListener(observed, listener);
094:            }
095:
096:            public void removeNotificationListener(ObjectName observed,
097:                    ObjectName listener, NotificationFilter filter,
098:                    Object handback) throws InstanceNotFoundException,
099:                    ListenerNotFoundException {
100:                trackSubject();
101:                getMBeanServer().removeNotificationListener(observed, listener,
102:                        filter, handback);
103:            }
104:
105:            public void removeNotificationListener(ObjectName observed,
106:                    NotificationListener listener, NotificationFilter filter,
107:                    Object handback) throws InstanceNotFoundException,
108:                    ListenerNotFoundException {
109:                trackSubject();
110:                getMBeanServer().removeNotificationListener(observed, listener,
111:                        filter, handback);
112:            }
113:
114:            public MBeanInfo getMBeanInfo(ObjectName objectName)
115:                    throws InstanceNotFoundException, IntrospectionException,
116:                    ReflectionException {
117:                trackSubject();
118:                return getMBeanServer().getMBeanInfo(objectName);
119:            }
120:
121:            public boolean isInstanceOf(ObjectName objectName, String className)
122:                    throws InstanceNotFoundException {
123:                trackSubject();
124:                return getMBeanServer().isInstanceOf(objectName, className);
125:            }
126:
127:            public String[] getDomains() {
128:                trackSubject();
129:                return getMBeanServer().getDomains();
130:            }
131:
132:            public String getDefaultDomain() {
133:                trackSubject();
134:                return getMBeanServer().getDefaultDomain();
135:            }
136:
137:            public ObjectInstance createMBean(String className,
138:                    ObjectName objectName) throws ReflectionException,
139:                    InstanceAlreadyExistsException, MBeanRegistrationException,
140:                    MBeanException, NotCompliantMBeanException {
141:                trackSubject();
142:                return getMBeanServer().createMBean(className, objectName);
143:            }
144:
145:            public ObjectInstance createMBean(String className,
146:                    ObjectName objectName, ObjectName loaderName)
147:                    throws ReflectionException, InstanceAlreadyExistsException,
148:                    MBeanRegistrationException, MBeanException,
149:                    NotCompliantMBeanException, InstanceNotFoundException {
150:                trackSubject();
151:                return getMBeanServer().createMBean(className, objectName,
152:                        loaderName);
153:            }
154:
155:            public ObjectInstance createMBean(String className,
156:                    ObjectName objectName, Object[] args, String[] parameters)
157:                    throws ReflectionException, InstanceAlreadyExistsException,
158:                    MBeanRegistrationException, MBeanException,
159:                    NotCompliantMBeanException {
160:                trackSubject();
161:                return getMBeanServer().createMBean(className, objectName,
162:                        args, parameters);
163:            }
164:
165:            public ObjectInstance createMBean(String className,
166:                    ObjectName objectName, ObjectName loaderName,
167:                    Object[] args, String[] parameters)
168:                    throws ReflectionException, InstanceAlreadyExistsException,
169:                    MBeanRegistrationException, MBeanException,
170:                    NotCompliantMBeanException, InstanceNotFoundException {
171:                trackSubject();
172:                return getMBeanServer().createMBean(className, objectName,
173:                        loaderName, args, parameters);
174:            }
175:
176:            public void unregisterMBean(ObjectName objectName)
177:                    throws InstanceNotFoundException,
178:                    MBeanRegistrationException {
179:                trackSubject();
180:                getMBeanServer().unregisterMBean(objectName);
181:            }
182:
183:            public Object getAttribute(ObjectName objectName, String attribute)
184:                    throws MBeanException, AttributeNotFoundException,
185:                    InstanceNotFoundException, ReflectionException {
186:                trackSubject();
187:                return getMBeanServer().getAttribute(objectName, attribute);
188:            }
189:
190:            public void setAttribute(ObjectName objectName, Attribute attribute)
191:                    throws InstanceNotFoundException,
192:                    AttributeNotFoundException, InvalidAttributeValueException,
193:                    MBeanException, ReflectionException {
194:                trackSubject();
195:                getMBeanServer().setAttribute(objectName, attribute);
196:            }
197:
198:            public AttributeList getAttributes(ObjectName objectName,
199:                    String[] attributes) throws InstanceNotFoundException,
200:                    ReflectionException {
201:                trackSubject();
202:                return getMBeanServer().getAttributes(objectName, attributes);
203:            }
204:
205:            public AttributeList setAttributes(ObjectName objectName,
206:                    AttributeList attributes) throws InstanceNotFoundException,
207:                    ReflectionException {
208:                trackSubject();
209:                return getMBeanServer().setAttributes(objectName, attributes);
210:            }
211:
212:            public Object invoke(ObjectName objectName, String methodName,
213:                    Object[] args, String[] parameters)
214:                    throws InstanceNotFoundException, MBeanException,
215:                    ReflectionException {
216:                trackSubject();
217:                return getMBeanServer().invoke(objectName, methodName, args,
218:                        parameters);
219:            }
220:
221:            public Integer getMBeanCount() {
222:                trackSubject();
223:                return getMBeanServer().getMBeanCount();
224:            }
225:
226:            public boolean isRegistered(ObjectName objectname) {
227:                trackSubject();
228:                return getMBeanServer().isRegistered(objectname);
229:            }
230:
231:            public ObjectInstance getObjectInstance(ObjectName objectName)
232:                    throws InstanceNotFoundException {
233:                trackSubject();
234:                return getMBeanServer().getObjectInstance(objectName);
235:            }
236:
237:            public Set queryMBeans(ObjectName patternName, QueryExp filter) {
238:                trackSubject();
239:                return getMBeanServer().queryMBeans(patternName, filter);
240:            }
241:
242:            public Set queryNames(ObjectName patternName, QueryExp filter) {
243:                trackSubject();
244:                return getMBeanServer().queryNames(patternName, filter);
245:            }
246:
247:            public Object instantiate(String className)
248:                    throws ReflectionException, MBeanException {
249:                trackSubject();
250:                return getMBeanServer().instantiate(className);
251:            }
252:
253:            public Object instantiate(String className, ObjectName loaderName)
254:                    throws ReflectionException, MBeanException,
255:                    InstanceNotFoundException {
256:                trackSubject();
257:                return getMBeanServer().instantiate(className, loaderName);
258:            }
259:
260:            public Object instantiate(String className, Object[] args,
261:                    String[] parameters) throws ReflectionException,
262:                    MBeanException {
263:                trackSubject();
264:                return getMBeanServer()
265:                        .instantiate(className, args, parameters);
266:            }
267:
268:            public Object instantiate(String className, ObjectName loaderName,
269:                    Object[] args, String[] parameters)
270:                    throws ReflectionException, MBeanException,
271:                    InstanceNotFoundException {
272:                trackSubject();
273:                return getMBeanServer().instantiate(className, loaderName,
274:                        args, parameters);
275:            }
276:
277:            public ObjectInstance registerMBean(Object mbean,
278:                    ObjectName objectName)
279:                    throws InstanceAlreadyExistsException,
280:                    MBeanRegistrationException, NotCompliantMBeanException {
281:                trackSubject();
282:                return registerMBean(mbean, objectName);
283:            }
284:
285:            public ObjectInputStream deserialize(String className,
286:                    ObjectName loaderName, byte[] bytes)
287:                    throws InstanceNotFoundException, OperationsException,
288:                    ReflectionException {
289:                trackSubject();
290:                return getMBeanServer().deserialize(className, loaderName,
291:                        bytes);
292:            }
293:
294:            public ObjectInputStream deserialize(String className, byte[] bytes)
295:                    throws OperationsException, ReflectionException {
296:                trackSubject();
297:                return getMBeanServer().deserialize(className, bytes);
298:            }
299:
300:            public ObjectInputStream deserialize(ObjectName objectName,
301:                    byte[] bytes) throws InstanceNotFoundException,
302:                    OperationsException {
303:                trackSubject();
304:                return getMBeanServer().deserialize(objectName, bytes);
305:            }
306:
307:            public ClassLoader getClassLoaderFor(ObjectName mbeanName)
308:                    throws InstanceNotFoundException {
309:                trackSubject();
310:                return getMBeanServer().getClassLoaderFor(mbeanName);
311:            }
312:
313:            public ClassLoader getClassLoader(ObjectName loaderName)
314:                    throws InstanceNotFoundException {
315:                trackSubject();
316:                return getMBeanServer().getClassLoader(loaderName);
317:            }
318:
319:            public ClassLoaderRepository getClassLoaderRepository() {
320:                trackSubject();
321:                return getMBeanServer().getClassLoaderRepository();
322:            }
323:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.