Source Code Cross Referenced for StandardGenerator.java in  » Testing » jakarta-jmeter » org » apache » jmeter » protocol » http » util » accesslog » 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 » Testing » jakarta jmeter » org.apache.jmeter.protocol.http.util.accesslog 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *   http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         * 
017:         */
018:
019:        package org.apache.jmeter.protocol.http.util.accesslog;
020:
021:        import java.io.File;
022:        import java.io.FileOutputStream;
023:        import java.io.FileWriter;
024:        import java.io.IOException;
025:        import java.io.OutputStream;
026:        import java.io.Serializable;
027:
028:        import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
029:        import org.apache.jmeter.protocol.http.sampler.HTTPSamplerFactory;
030:        import org.apache.jorphan.util.JOrphanUtils;
031:
032:        /**
033:         * Description:<br>
034:         * <br>
035:         * StandardGenerator will be the default generator used to pre-process logs. It
036:         * uses JMeter classes to generate the .jmx file. The first version of the
037:         * utility only generated the HTTP requests as XML, but it required users to
038:         * copy and paste it into a blank jmx file. Doing that way isn't flexible and
039:         * would require changes to keep the format in sync.
040:         * <p>
041:         * This version is a completely new class with a totally different
042:         * implementation, since generating the XML is no longer handled by the
043:         * generator. The generator is only responsible for handling the parsed results
044:         * and passing it to the appropriate JMeter class.
045:         * <p>
046:         * Notes:<br>
047:         * the class needs to first create a thread group and add it to the HashTree.
048:         * Then the samplers should be added to the thread group. Listeners shouldn't be
049:         * added and should be left up to the user. One option is to provide parameters,
050:         * so the user can pass the desired listener to the tool.
051:         * <p>
052:         * 
053:         * author Peter Lin<br>
054:         * Created on: Jul 1, 2003<br>
055:         */
056:
057:        public class StandardGenerator implements  Generator, Serializable {
058:
059:            protected HTTPSamplerBase SAMPLE = null;
060:
061:            transient protected FileWriter WRITER = null;
062:
063:            transient protected OutputStream OUTPUT = null;
064:
065:            protected String FILENAME = null;
066:
067:            protected File FILE = null;
068:
069:            // NOT USED transient protected ThreadGroup THREADGROUP = null;
070:            // Anyway, was this supposed to be the class from java.lang, or
071:            // jmeter.threads?
072:
073:            /**
074:             * The constructor is used by GUI and samplers to generate request objects.
075:             */
076:            public StandardGenerator() {
077:                super ();
078:                init();
079:            }
080:
081:            /**
082:             * 
083:             * @param file
084:             */
085:            public StandardGenerator(String file) {
086:                FILENAME = file;
087:                init();
088:            }
089:
090:            /**
091:             * initialize the generator. It should create the following objects.
092:             * <p>
093:             * <ol>
094:             * <li> ListedHashTree</li>
095:             * <li> ThreadGroup</li>
096:             * <li> File object</li>
097:             * <li> Writer</li>
098:             * </ol>
099:             */
100:            protected void init() {
101:                generateRequest();
102:            }
103:
104:            /**
105:             * Create the FileWriter to save the JMX file.
106:             */
107:            protected void initStream() {
108:                try {
109:                    this .OUTPUT = new FileOutputStream(FILE);
110:                } catch (IOException exception) {
111:                    // do nothing
112:                }
113:            }
114:
115:            /*
116:             * (non-Javadoc)
117:             * 
118:             * @see org.apache.jmeter.protocol.http.util.accesslog.Generator#close()
119:             */
120:            public void close() {
121:                JOrphanUtils.closeQuietly(OUTPUT);
122:                JOrphanUtils.closeQuietly(WRITER);
123:            }
124:
125:            /*
126:             * (non-Javadoc)
127:             * 
128:             * @see org.apache.jmeter.protocol.http.util.accesslog.Generator#setHost(java.lang.String)
129:             */
130:            public void setHost(String host) {
131:                SAMPLE.setDomain(host);
132:            }
133:
134:            /*
135:             * (non-Javadoc)
136:             * 
137:             * @see org.apache.jmeter.protocol.http.util.accesslog.Generator#setLabel(java.lang.String)
138:             */
139:            public void setLabel(String label) {
140:
141:            }
142:
143:            /*
144:             * (non-Javadoc)
145:             * 
146:             * @see org.apache.jmeter.protocol.http.util.accesslog.Generator#setMethod(java.lang.String)
147:             */
148:            public void setMethod(String post_get) {
149:                SAMPLE.setMethod(post_get);
150:            }
151:
152:            /*
153:             * (non-Javadoc)
154:             * 
155:             * @see org.apache.jmeter.protocol.http.util.accesslog.Generator#setParams(org.apache.jmeter.protocol.http.util.accesslog.NVPair[])
156:             */
157:            public void setParams(NVPair[] params) {
158:                for (int idx = 0; idx < params.length; idx++) {
159:                    SAMPLE.addArgument(params[idx].getName(), params[idx]
160:                            .getValue());
161:                }
162:            }
163:
164:            /*
165:             * (non-Javadoc)
166:             * 
167:             * @see org.apache.jmeter.protocol.http.util.accesslog.Generator#setPath(java.lang.String)
168:             */
169:            public void setPath(String path) {
170:                SAMPLE.setPath(path);
171:            }
172:
173:            /*
174:             * (non-Javadoc)
175:             * 
176:             * @see org.apache.jmeter.protocol.http.util.accesslog.Generator#setPort(int)
177:             */
178:            public void setPort(int port) {
179:                SAMPLE.setPort(port);
180:            }
181:
182:            /*
183:             * (non-Javadoc)
184:             * 
185:             * @see org.apache.jmeter.protocol.http.util.accesslog.Generator#setQueryString(java.lang.String)
186:             */
187:            public void setQueryString(String querystring) {
188:                SAMPLE.parseArguments(querystring);
189:            }
190:
191:            /*
192:             * (non-Javadoc)
193:             * 
194:             * @see org.apache.jmeter.protocol.http.util.accesslog.Generator#setSourceLogs(java.lang.String)
195:             */
196:            public void setSourceLogs(String sourcefile) {
197:            }
198:
199:            /*
200:             * (non-Javadoc)
201:             * 
202:             * @see org.apache.jmeter.protocol.http.util.accesslog.Generator#setTarget(java.lang.Object)
203:             */
204:            public void setTarget(Object target) {
205:            }
206:
207:            /*
208:             * (non-Javadoc)
209:             * 
210:             * @see org.apache.jmeter.protocol.http.util.accesslog.Generator#generateRequest()
211:             */
212:            public Object generateRequest() {
213:                try {
214:                    SAMPLE = HTTPSamplerFactory.newInstance();
215:                } catch (NullPointerException e) {
216:                    e.printStackTrace();
217:                }
218:                return SAMPLE;
219:            }
220:
221:            /**
222:             * save must be called to write the jmx file, otherwise it will not be
223:             * saved.
224:             */
225:            public void save() {
226:                try {
227:                    // no implementation at this time, since
228:                    // we bypass the idea of having a console
229:                    // tool to generate test plans. Instead
230:                    // I decided to have a sampler that uses
231:                    // the generator and parser directly
232:                } catch (Exception exception) {
233:                }
234:            }
235:
236:            /**
237:             * Reset the HTTPSampler to make sure it is a new instance.
238:             */
239:            public void reset() {
240:                SAMPLE = null;
241:                generateRequest();
242:            }
243:
244:            // TODO write some tests
245:        }
w___ww__._ja___v__a2__s___.___c__o__m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.