Source Code Cross Referenced for RotateLog.java in  » EJB-Server-resin-3.1.5 » resin » com » caucho » log » 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 » EJB Server resin 3.1.5 » resin » com.caucho.log 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003:         *
004:         * This file is part of Resin(R) Open Source
005:         *
006:         * Each copy or derived work must preserve the copyright notice and this
007:         * notice unmodified.
008:         *
009:         * Resin Open Source is free software; you can redistribute it and/or modify
010:         * it under the terms of the GNU General Public License as published by
011:         * the Free Software Foundation; either version 2 of the License, or
012:         * (at your option) any later version.
013:         *
014:         * Resin Open Source 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, or any warranty
017:         * of NON-INFRINGEMENT.  See the GNU General Public License for more
018:         * details.
019:         *
020:         * You should have received a copy of the GNU General Public License
021:         * along with Resin Open Source; if not, write to the
022:         *
023:         *   Free Software Foundation, Inc.
024:         *   59 Temple Place, Suite 330
025:         *   Boston, MA 02111-1307  USA
026:         *
027:         * @author Scott Ferguson
028:         */
029:
030:        package com.caucho.log;
031:
032:        import com.caucho.config.ConfigException;
033:        import com.caucho.config.types.Bytes;
034:        import com.caucho.config.types.Period;
035:        import com.caucho.util.L10N;
036:        import com.caucho.vfs.Path;
037:
038:        import javax.annotation.PostConstruct;
039:        import java.io.IOException;
040:
041:        /**
042:         * Configuration for a rotating log
043:         */
044:        public class RotateLog {
045:            private final static L10N L = new L10N(RotateLog.class);
046:
047:            private static final long ROLLOVER_SIZE = Long.MAX_VALUE / 2;
048:
049:            private Path _path;
050:            private String _pathFormat;
051:            private String _archiveFormat;
052:
053:            private Period _rolloverPeriod;
054:            private Bytes _rolloverSize;
055:            private int _rolloverCount = -1;
056:
057:            private RotateStream _rotateStream;
058:
059:            private String _timestamp;
060:
061:            /**
062:             * Gets the output path.
063:             */
064:            public Path getPath() {
065:                return _path;
066:            }
067:
068:            /**
069:             * Sets the output path.
070:             */
071:            public void setPath(Path path) {
072:                _path = path;
073:            }
074:
075:            /**
076:             * Gets the output path.
077:             */
078:            public String getPathFormat() {
079:                return _pathFormat;
080:            }
081:
082:            /**
083:             * Sets the output path.
084:             */
085:            public void setPathFormat(String path) {
086:                _pathFormat = path;
087:            }
088:
089:            /**
090:             * Sets the output path (backward compat).
091:             */
092:            public void setHref(Path path) {
093:                setPath(path);
094:            }
095:
096:            /**
097:             * Sets the rollover period.
098:             */
099:            public void setRolloverPeriod(Period period) {
100:                _rolloverPeriod = period;
101:            }
102:
103:            /**
104:             * Sets the rollover size.
105:             */
106:            public void setRolloverSize(Bytes size) {
107:                _rolloverSize = size;
108:            }
109:
110:            /**
111:             * Sets the rollover count
112:             */
113:            public int getRolloverCount() {
114:                return _rolloverCount;
115:            }
116:
117:            /**
118:             * Sets the rollover count.
119:             */
120:            public void setRolloverCount(int count) {
121:                _rolloverCount = count;
122:            }
123:
124:            /**
125:             * Sets the timestamp
126:             */
127:            public String getTimestamp() {
128:                return _timestamp;
129:            }
130:
131:            /**
132:             * Sets the timestamp.
133:             */
134:            /*
135:            public void setTimestamp(String timestamp)
136:            {
137:              _timestamp = timestamp;
138:            }
139:             */
140:
141:            /**
142:             * Gets the archive format
143:             */
144:            public String getArchiveFormat() {
145:                return _archiveFormat;
146:            }
147:
148:            /**
149:             * Sets the archive format.
150:             */
151:            public void setArchiveFormat(String format) {
152:                _archiveFormat = format;
153:            }
154:
155:            /**
156:             * Returns the rotated stream.
157:             */
158:            public RotateStream getRotateStream() {
159:                return _rotateStream;
160:            }
161:
162:            /**
163:             * Returns the tag name.
164:             */
165:            public String getTagName() {
166:                return "rotate-log";
167:            }
168:
169:            /**
170:             * Initialize the log.
171:             */
172:            @PostConstruct
173:            public void init() throws ConfigException, IOException {
174:                if (_path != null)
175:                    _rotateStream = RotateStream.create(_path);
176:                else if (_pathFormat != null)
177:                    _rotateStream = RotateStream.create(_pathFormat);
178:                else
179:                    throw new ConfigException(
180:                            L
181:                                    .l(
182:                                            "`path' is a required attribute of <{0}>.  Each <{0}> must configure the destination stream.",
183:                                            getTagName()));
184:
185:                if (_path != null
186:                        && _path.exists()
187:                        && !_path.canRead()
188:                        && (_rolloverPeriod != null || _rolloverSize != null || _archiveFormat != null)) {
189:                    throw new ConfigException(
190:                            L
191:                                    .l(
192:                                            "log path '{0}' is not readable and therefore cannot be rotated.",
193:                                            _path.getURL()));
194:                }
195:
196:                AbstractRolloverLog rolloverLog = _rotateStream
197:                        .getRolloverLog();
198:
199:                if (_rolloverPeriod != null)
200:                    rolloverLog.setRolloverPeriod(_rolloverPeriod);
201:
202:                if (_rolloverSize != null)
203:                    rolloverLog.setRolloverSize(_rolloverSize);
204:                _rotateStream.setMaxRolloverCount(_rolloverCount);
205:                if (_archiveFormat != null)
206:                    rolloverLog.setArchiveFormat(_archiveFormat);
207:
208:                _rotateStream.init();
209:            }
210:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.