Source Code Cross Referenced for TestRecording.java in  » J2EE » Pustefix » de » schlund » pfixxml » testrecording » 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 » Pustefix » de.schlund.pfixxml.testrecording 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package de.schlund.pfixxml.testrecording;
002:
003:        import java.io.IOException;
004:        import java.lang.management.ManagementFactory;
005:        import java.util.ArrayList;
006:        import java.util.Iterator;
007:        import java.util.List;
008:        import java.util.Properties;
009:
010:        import javax.management.MBeanServer;
011:        import javax.management.ObjectName;
012:        import javax.servlet.http.HttpSession;
013:
014:        import org.apache.log4j.Logger;
015:
016:        import de.schlund.pfixxml.resources.FileResource;
017:        import de.schlund.pfixxml.resources.ResourceUtil;
018:        import de.schlund.pfixxml.serverutil.SessionAdmin;
019:        import de.schlund.pfixxml.serverutil.SessionData;
020:        import de.schlund.pfixxml.serverutil.SessionInfoStruct;
021:        import de.schlund.pfixxml.util.Xml;
022:
023:        public class TestRecording implements  TestRecordingMBean {
024:
025:            private final static Logger LOG = Logger
026:                    .getLogger(TestRecording.class);
027:
028:            private static TestRecording instance = new TestRecording();
029:
030:            private final List<String> knownClients = new ArrayList<String>();
031:
032:            public static TestRecording getInstance() {
033:                return instance;
034:            }
035:
036:            public void init(Properties props) {
037:                LOG.info("TestRecording init");
038:                try {
039:                    MBeanServer mbeanServer = ManagementFactory
040:                            .getPlatformMBeanServer();
041:                    ObjectName objectName = new ObjectName(
042:                            "Pustefix:type=TestRecording");
043:                    mbeanServer.registerMBean(this , objectName);
044:                    // otherwise, clients cannot instaniate TrailLogger objects:
045:                    ObjectName createName = new ObjectName(
046:                            "Pustefix:type=TestRecording,name=loader");
047:                    mbeanServer.registerMBean(this .getClass().getClassLoader(),
048:                            createName);
049:                } catch (Exception x) {
050:                    throw new RuntimeException(
051:                            "Can't register TestRecording MBean.", x);
052:                }
053:            }
054:
055:            public TestRecording() {
056:
057:            }
058:
059:            // TODO: who's responsible for unregister?
060:            public ObjectName startRecording(String sessionId)
061:                    throws IOException {
062:                ObjectName name;
063:                TrailLogger logger;
064:
065:                logger = new TrailLogger(TrailLogger
066:                        .getVisit(getSession(sessionId)));
067:
068:                try {
069:                    name = new ObjectName(
070:                            "Pustefix:type=TestRecording,name=TrailLogger,session="
071:                                    + sessionId);
072:                    MBeanServer mbeanServer = ManagementFactory
073:                            .getPlatformMBeanServer();
074:                    mbeanServer.registerMBean(logger, name);
075:                    return name;
076:                } catch (Exception x) {
077:                    LOG.error("Can't register TrailLogger MBean!", x);
078:                    throw new RuntimeException(
079:                            "Can't register TrailLogger MBean!", x);
080:                }
081:
082:            }
083:
084:            public ApplicationList getApplicationList(boolean tomcat,
085:                    String sessionSuffix) {
086:                FileResource file;
087:
088:                file = ResourceUtil
089:                        .getFileResourceFromDocroot("servletconf/projects.xml");
090:                try {
091:                    return ApplicationList.load(Xml.parseMutable(file), tomcat,
092:                            sessionSuffix);
093:                } catch (Exception e) {
094:                    throw new RuntimeException(e);
095:                }
096:            }
097:
098:            public List<SessionData> getSessions(String serverName,
099:                    String remoteAddr) {
100:                SessionAdmin admin;
101:                Iterator<String> iter;
102:                String id;
103:                List<SessionData> lst;
104:                SessionInfoStruct info;
105:
106:                lst = new ArrayList<SessionData>();
107:                admin = SessionAdmin.getInstance();
108:                iter = admin.getAllSessionIds().iterator();
109:                while (iter.hasNext()) {
110:                    id = (String) iter.next();
111:                    info = admin.getInfo(id);
112:                    if (serverName.equals(info.getData().getServerName())
113:                            && remoteAddr
114:                                    .equals(info.getData().getRemoteAddr())) {
115:                        lst.add(info.getData());
116:                    }
117:                }
118:                return lst;
119:            }
120:
121:            public void invalidateSession(String id) throws IOException {
122:                getSession(id).invalidate();
123:            }
124:
125:            public boolean isKnownClient(String remoteAddr) {
126:                return knownClients.contains(remoteAddr);
127:            }
128:
129:            public void addKnownClient(String remoteAddr) {
130:                knownClients.add(remoteAddr);
131:            }
132:
133:            public void removeKnownClient(String remoteAddr) {
134:                knownClients.remove(remoteAddr);
135:            }
136:
137:            public static HttpSession getSession(String id) throws IOException {
138:                SessionInfoStruct info;
139:
140:                info = SessionAdmin.getInstance().getInfo(id);
141:                if (info == null) {
142:                    throw new IOException("session not found: " + id);
143:                }
144:                return info.getSession();
145:            }
146:
147:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.