Source Code Cross Referenced for DeployGenerator.java in  » EJB-Server-resin-3.1.5 » resin » com » caucho » server » deploy » 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.server.deploy 
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.server.deploy;
031:
032:        import com.caucho.config.ConfigException;
033:        import com.caucho.lifecycle.Lifecycle;
034:        import com.caucho.loader.Environment;
035:        import com.caucho.loader.EnvironmentClassLoader;
036:        import com.caucho.loader.EnvironmentListener;
037:        import com.caucho.util.L10N;
038:        import com.caucho.vfs.Dependency;
039:
040:        import javax.annotation.PostConstruct;
041:        import java.util.Set;
042:        import java.util.logging.Level;
043:        import java.util.logging.Logger;
044:
045:        /**
046:         * The generator for the deploy
047:         */
048:        abstract public class DeployGenerator<E extends DeployController>
049:                implements  Dependency, EnvironmentListener {
050:            private static final Logger log = Logger
051:                    .getLogger(DeployGenerator.class.getName());
052:            private static final L10N L = new L10N(DeployGenerator.class);
053:
054:            // The owning deployment container
055:            private DeployContainer<E> _container;
056:
057:            private ClassLoader _parentClassLoader;
058:
059:            private String _startupMode = DeployController.STARTUP_AUTOMATIC;
060:            private String _redeployMode = DeployController.REDEPLOY_AUTOMATIC;
061:
062:            private Throwable _configException;
063:
064:            private final Lifecycle _lifecycle = new Lifecycle(getLog());
065:
066:            /**
067:             * Creates the deploy.
068:             */
069:            public DeployGenerator(DeployContainer<E> container) {
070:                _parentClassLoader = Thread.currentThread()
071:                        .getContextClassLoader();
072:                _container = container;
073:
074:                _lifecycle.setName(toString());
075:                _lifecycle.setLevel(Level.FINEST);
076:            }
077:
078:            /**
079:             * Returns the deploy container.
080:             */
081:            public DeployContainer<E> getDeployContainer() {
082:                return _container;
083:            }
084:
085:            /**
086:             * Returns the parent class loader.
087:             */
088:            public ClassLoader getParentClassLoader() {
089:                return _parentClassLoader;
090:            }
091:
092:            /**
093:             * Sets the startup mode.
094:             */
095:            public void setStartupMode(String mode) throws ConfigException {
096:                _startupMode = DeployController.toStartupCode(mode);
097:            }
098:
099:            /**
100:             * Gets the startup mode.
101:             */
102:            public String getStartupMode() throws ConfigException {
103:                return _startupMode;
104:            }
105:
106:            /**
107:             * Sets the redeploy mode.
108:             */
109:            public void setRedeployMode(String mode) throws ConfigException {
110:                _redeployMode = DeployController.toRedeployCode(mode);
111:            }
112:
113:            /**
114:             * Gets the redeploy mode.
115:             */
116:            public String getRedeployMode() throws ConfigException {
117:                return _redeployMode;
118:            }
119:
120:            @PostConstruct
121:            final public void init() throws ConfigException {
122:                try {
123:                    initImpl();
124:                } catch (RuntimeException ex) {
125:                    _configException = ex;
126:                    throw ex;
127:                }
128:
129:                _lifecycle.setName(toString());
130:            }
131:
132:            /**
133:             * Derived class implementation of init
134:             */
135:            protected void initImpl() {
136:            }
137:
138:            /**
139:             * Returns true if the deployment has modified.
140:             */
141:            public boolean isModified() {
142:                return false;
143:            }
144:
145:            /**
146:             * Returns true if the deployment has modified.
147:             */
148:            public boolean logModified(Logger log) {
149:                return false;
150:            }
151:
152:            public String getState() {
153:                return _lifecycle.getStateName();
154:            }
155:
156:            /**
157:             * Starts the deployment.
158:             */
159:            final public void start() {
160:                try {
161:                    init();
162:                } catch (Exception e) {
163:                    log.log(Level.WARNING, e.toString(), e);
164:                }
165:
166:                if (!_lifecycle.toActive())
167:                    return;
168:
169:                startImpl();
170:            }
171:
172:            public boolean isActive() {
173:                return _lifecycle.isActive();
174:            }
175:
176:            public boolean isDestroyed() {
177:                return _lifecycle.isDestroyed();
178:            }
179:
180:            /**
181:             * Derived class implentation of start.
182:             */
183:            protected void startImpl() {
184:                Environment.addEnvironmentListener(this );
185:            }
186:
187:            /**
188:             * lazy-start
189:             */
190:            public void request() {
191:            }
192:
193:            /**
194:             * Forces an update.
195:             */
196:            public void update() {
197:            }
198:
199:            /**
200:             * Returns the deployed keys.
201:             */
202:            protected void fillDeployedKeys(Set<String> keys) {
203:            }
204:
205:            /**
206:             * Generates the controller.
207:             */
208:            protected E generateController(String key) {
209:                return null;
210:            }
211:
212:            /**
213:             * Merges the entry with other matching entries, returning the
214:             * new entry.
215:             */
216:            protected E mergeController(E controller, String key) {
217:                return controller;
218:            }
219:
220:            /**
221:             * Returns the log.
222:             */
223:            protected Logger getLog() {
224:                return log;
225:            }
226:
227:            /**
228:             * Stops the deploy
229:             */
230:            final public void stop() {
231:                if (!_lifecycle.toStop())
232:                    return;
233:
234:                stopImpl();
235:            }
236:
237:            /**
238:             * Derived class implentation of stop.
239:             */
240:            protected void stopImpl() {
241:            }
242:
243:            public Throwable getConfigException() {
244:                return _configException;
245:            }
246:
247:            /**
248:             * Closes the deploy
249:             */
250:            final public void destroy() {
251:                try {
252:                    stop();
253:                } catch (Throwable e) {
254:                    log.log(Level.WARNING, e.toString(), e);
255:                }
256:
257:                if (!_lifecycle.toDestroy())
258:                    return;
259:
260:                destroyImpl();
261:            }
262:
263:            /**
264:             * Derived class implentation of destroy.
265:             */
266:            protected void destroyImpl() {
267:                _container.remove(this );
268:            }
269:
270:            /**
271:             * Handles the case where the environment is starting (after init).
272:             */
273:            public void environmentConfig(EnvironmentClassLoader loader) {
274:            }
275:
276:            /**
277:             * Handles the case where the environment is starting (after init).
278:             */
279:            public void environmentStart(EnvironmentClassLoader loader) {
280:                start();
281:            }
282:
283:            /**
284:             * Handles the case where the environment is stopping
285:             */
286:            public void environmentStop(EnvironmentClassLoader loader) {
287:                destroy();
288:            }
289:
290:            public String toString() {
291:                String name = getClass().getName();
292:                int p = name.lastIndexOf('.');
293:                if (p > 0)
294:                    name = name.substring(p + 1);
295:
296:                return name + "[]";
297:            }
298:
299:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.