Source Code Cross Referenced for HoToFileSessionRecorder.java in  » J2EE » WiSerFramework » de » ug2t » channel » ho » session » 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 » WiSerFramework » de.ug2t.channel.ho.session 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // @@
002:        // @@
003:        /*
004:         * Wi.Ser Framework
005:         *
006:         * Version: 1.8.1, 20-September-2007  
007:         * Copyright (C) 2005 Dirk von der Weiden <dvdw@imail.de>
008:         *
009:         * This library is free software; you can redistribute it and/or
010:         * modify it under the terms of the GNU Lesser General Public
011:         * License as published by the Free Software Foundation; either
012:         * version 2 of the License, or (at your option) any later version.
013:         *
014:         * This library is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
017:         * Lesser General Public License for more details.
018:         *
019:         * You should have received a copy of the GNU Lesser General Public
020:         * License along with this library located in LGPL.txt in the 
021:         * license directory; if not, write to the 
022:         * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
023:         * Boston, MA  02111-1307, USA.
024:         * 
025:         * If this agreement does not cover your requirements, please contact us
026:         * via email to get detailed information about the commercial license 
027:         * or our service offerings!
028:         *
029:         */
030:        // @@
031:        package de.ug2t.channel.ho.session;
032:
033:        import java.io.*;
034:        import java.nio.*;
035:        import java.nio.channels.*;
036:
037:        import de.ug2t.kernel.*;
038:        import de.ug2t.unifiedGui.interfaces.*;
039:        import de.ug2t.xmlScript.*;
040:
041:        public class HoToFileSessionRecorder implements  IHoSessionRecorder {
042:            private String pem_recFolder = null;
043:            private int pem_rCnt = 0;
044:            private boolean pem_record = false;
045:            private IHoSession pem_session = null;
046:
047:            public HoToFileSessionRecorder(IHoSession xSession) {
048:                KeLog.pcmf_log("ug2t", "HoToFileSessionRecorder created", this ,
049:                        KeLog.MESSAGE);
050:
051:                this .pem_session = xSession;
052:                this .pem_recFolder = KeEnvironment.pcmf_buildPath(xSession
053:                        .pcmf_getId());
054:            }
055:
056:            public HoToFileSessionRecorder() {
057:                KeLog.pcmf_log("ug2t", "HoToFileSessionRecorder created", this ,
058:                        KeLog.MESSAGE);
059:            }
060:
061:            /*
062:             * (non-Javadoc)
063:             * 
064:             * @see de.ug2t.channel.ho.session.IHoSessionRecorder#pcmf_setSession()
065:             */
066:            public void pcmf_setSession(IHoSession xSession) {
067:                this .pem_session = xSession;
068:                this .pem_recFolder = KeEnvironment.pcmf_buildPath(xSession
069:                        .pcmf_getId());
070:            }
071:
072:            /*
073:             * (non-Javadoc)
074:             * 
075:             * @see de.ug2t.channel.ho.session.IHoSessionRecorder#pcmf_isRecord()
076:             */
077:            public boolean pcmf_isRecord() {
078:                return (this .pem_record);
079:            }
080:
081:            /*
082:             * (non-Javadoc)
083:             * 
084:             * @see de.ug2t.channel.ho.session.IHoSessionRecorder#pcmf_recordMessage(java.lang.String)
085:             */
086:            public void pcmf_recordMessage(String xCall) {
087:                if (this .pem_record == false)
088:                    return;
089:
090:                try {
091:                    FileWriter l_fwriter = new FileWriter(this .pem_recFolder
092:                            + File.separator + this .pem_session.pcmf_getId()
093:                            + "_"
094:                            + KeTools.pcmf_formatNumber(this .pem_rCnt, 10)
095:                            + ".record");
096:                    this .pem_rCnt++;
097:                    l_fwriter.write(xCall);
098:                    l_fwriter.close();
099:                } catch (Exception e) {
100:                    KeLog.pcmf_logException("ug2t", this , e);
101:                }
102:            }
103:
104:            /*
105:             * (non-Javadoc)
106:             * 
107:             * @see de.ug2t.channel.ho.session.IHoSessionRecorder#pcmf_enableRecord(boolean)
108:             */
109:            public String pcmf_enableRecord(boolean xRecord) {
110:                this .pem_recFolder = null;
111:
112:                if (xRecord && !this .pem_record) {
113:                    this .pem_recFolder = KeEnvironment.pcmf_getRootDir()
114:                            + this .pem_session.pcmf_getId() + ".recorded";
115:                    this .pem_record = true;
116:                    this .pem_rCnt = 0;
117:                    File l_dir = new File(this .pem_recFolder);
118:                    KeTools.pcmf_deleteFiles(l_dir, true);
119:                    l_dir.mkdir();
120:                } else if (!xRecord && this .pem_record) {
121:                    this .pem_record = false;
122:                }
123:
124:                if (this .pem_record)
125:                    KeLog.pcmf_log("ug2t",
126:                            "HoToFileSessionRecorder started, records to folder: "
127:                                    + this .pem_recFolder, this , KeLog.MESSAGE);
128:                else
129:                    KeLog.pcmf_log("ug2t", "HoToFileSessionRecorder stopped",
130:                            this , KeLog.MESSAGE);
131:
132:                return (this .pem_recFolder);
133:            }
134:
135:            /*
136:             * (non-Javadoc)
137:             * 
138:             * @see de.ug2t.channel.ho.session.IHoSessionRecorder#pcmf_playback(java.lang.String,
139:             *      int)
140:             */
141:            public void pcmf_playback(String xFile, int xMax) {
142:                if (this .pem_record == true) {
143:                    KeLog.pcmf_log("ug2t",
144:                            "session is in record mode, can not replay", this ,
145:                            KeLog.ERROR);
146:                    return;
147:                }
148:                ;
149:
150:                File l_folder = new File(KeEnvironment.pcmf_buildPath(xFile));
151:                File l_frag[] = l_folder.listFiles();
152:
153:                if (xMax == -1)
154:                    xMax = l_frag.length;
155:
156:                this .pem_session.pcmf_beginTr();
157:
158:                KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper(
159:                        "");
160:                ScXmlScript.pcmf_createPBody(l_remCall);
161:                ScXmlScript.pcmf_addCall(l_remCall, null,
162:                        IHoSession.SESSION_NAME, "pcmf_setDisabled");
163:                ScXmlScript.pcmf_addCallPar(l_remCall, "true", "false",
164:                        "boolean");
165:                ScXmlScript.pcmf_endAll(l_remCall);
166:
167:                this .pem_session.pcmf_call(l_remCall.toString());
168:
169:                l_remCall = new KeStringTemplateWrapper("");
170:                ScXmlScript.pcmf_createPBody(l_remCall);
171:                ScXmlScript.pcmf_addCall(l_remCall, null,
172:                        IHoSession.SESSION_NAME, "pcmf_setInResume");
173:                ScXmlScript.pcmf_addCallPar(l_remCall, "true", "false",
174:                        "boolean");
175:                ScXmlScript.pcmf_endAll(l_remCall);
176:
177:                this .pem_session.pcmf_call(l_remCall.toString());
178:
179:                try {
180:                    StringBuffer l_cbuffer = new StringBuffer();
181:
182:                    if (l_frag.length < xMax) {
183:                        KeLog.pcmf_log("ug2t",
184:                                "number of recorded transactions is to low",
185:                                this , KeLog.ERROR);
186:                        throw (new Exception());
187:                    }
188:
189:                    for (this .pem_rCnt = 0; this .pem_rCnt < xMax; this .pem_rCnt++) {
190:                        FileInputStream l_reader = new FileInputStream(
191:                                l_frag[this .pem_rCnt]);
192:                        FileChannel l_ch = l_reader.getChannel();
193:                        long l_size = l_ch.size();
194:                        byte[] l_bytes = new byte[(int) l_size];
195:                        ByteBuffer l_buffer = ByteBuffer.wrap(l_bytes);
196:                        l_ch.read(l_buffer);
197:
198:                        l_cbuffer.append(ScXmlScript.pcmf_extractShortProc(
199:                                new String(l_bytes), null));
200:                        l_reader.close();
201:                    }
202:                    this .pem_session.pcmf_call(l_cbuffer.toString());
203:                } catch (Exception e) {
204:                    KeLog.pcmf_logException("ug2t", this , e);
205:                    KeLog.pcmf_log("ug2t", "error during session replay: "
206:                            + xFile, this , KeLog.ERROR);
207:                }
208:
209:                l_remCall = new KeStringTemplateWrapper("");
210:
211:                ScXmlScript.pcmf_createPBody(l_remCall);
212:                ScXmlScript.pcmf_addCall(l_remCall, null,
213:                        IHoSession.SESSION_NAME, "pcmf_setInResume");
214:                ScXmlScript.pcmf_addCallPar(l_remCall, "false", "false",
215:                        "boolean");
216:                ScXmlScript.pcmf_endAll(l_remCall);
217:
218:                this .pem_session.pcmf_call(l_remCall.toString());
219:
220:                l_remCall = new KeStringTemplateWrapper("");
221:
222:                ScXmlScript.pcmf_createPBody(l_remCall);
223:                ScXmlScript.pcmf_addCall(l_remCall, null,
224:                        ((KeRegisteredObject) KeRegisteredObject
225:                                .pcmf_getObjByName(IUnApplication.MY_APPL))
226:                                .pcmf_getRemName(), "pcmf_showWaitDlg");
227:                ScXmlScript.pcmf_endAll(l_remCall);
228:
229:                this .pem_session.pcmf_call(l_remCall.toString());
230:
231:                this .pem_session.pcmf_commitTr();
232:
233:                return;
234:            }
235:
236:            /*
237:             * (non-Javadoc)
238:             * 
239:             * @see de.ug2t.channel.ho.session.IHoSessionRecorder#pcmf_toCheckPoint(int)
240:             */
241:            public void pcmf_toCheckPoint(int xPoint) {
242:                for (int i = xPoint; i < this .pem_rCnt; i++) {
243:                    File l_file = new File(this .pem_recFolder + File.separator
244:                            + this .pem_session.pcmf_getId() + "_" + i
245:                            + ".record");
246:                    l_file.delete();
247:                }
248:                this .pem_rCnt = xPoint;
249:            }
250:
251:            /*
252:             * (non-Javadoc)
253:             * 
254:             * @see de.ug2t.channel.ho.session.IHoSessionRecorder#pcmf_getCheckPointValue()
255:             */
256:            public int pcmf_getCheckPointValue() {
257:                return (this.pem_rCnt);
258:            }
259:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.