Source Code Cross Referenced for ResinStartServer.java in  » EJB-Server-resin-3.1.5 » netbeans-plugin » com » caucho » netbeans » 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 » netbeans plugin » com.caucho.netbeans 
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 Sam
028:         */
029:
030:        package com.caucho.netbeans;
031:
032:        import org.netbeans.modules.j2ee.deployment.plugins.api.ServerDebugInfo;
033:        import org.netbeans.modules.j2ee.deployment.plugins.spi.StartServer;
034:        import org.openide.util.RequestProcessor;
035:
036:        import javax.enterprise.deploy.shared.CommandType;
037:        import javax.enterprise.deploy.shared.StateType;
038:        import javax.enterprise.deploy.spi.Target;
039:        import javax.enterprise.deploy.spi.TargetModuleID;
040:        import javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException;
041:        import javax.enterprise.deploy.spi.status.ClientConfiguration;
042:        import javax.enterprise.deploy.spi.status.DeploymentStatus;
043:        import javax.enterprise.deploy.spi.status.ProgressListener;
044:        import javax.enterprise.deploy.spi.status.ProgressObject;
045:        import java.util.logging.Level;
046:        import java.util.logging.Logger;
047:
048:        public final class ResinStartServer extends StartServer {
049:            private static final PluginL10N L = new PluginL10N(
050:                    ResinStartServer.class);
051:            private static final Logger log = Logger
052:                    .getLogger(ResinStartServer.class.getName());
053:
054:            private enum Mode {
055:                RUN, DEBUG
056:            }
057:
058:            private final ResinDeploymentManager _manager;
059:
060:            public ResinStartServer(ResinDeploymentManager manager) {
061:                _manager = manager;
062:            }
063:
064:            public boolean isAlsoTargetServer(Target target) {
065:                return true;
066:            }
067:
068:            public boolean supportsStartDeploymentManager() {
069:                return true;
070:            }
071:
072:            public boolean supportsStartDebugging(Target target) {
073:                return true;
074:            }
075:
076:            public ProgressObject startDeploymentManager() {
077:                StartRunnable start = new StartRunnable(Mode.RUN,
078:                        CommandType.START);
079:                RequestProcessor.getDefault().post(start);
080:                return start;
081:            }
082:
083:            public ProgressObject stopDeploymentManager() {
084:                StartRunnable start = new StartRunnable(Mode.RUN,
085:                        CommandType.STOP);
086:                RequestProcessor.getDefault().post(start);
087:                return start;
088:            }
089:
090:            public boolean needsStartForConfigure() {
091:                return false;
092:            }
093:
094:            public boolean needsStartForTargetList() {
095:                return true;
096:            }
097:
098:            public boolean needsStartForAdminConfig() {
099:                return false;
100:            }
101:
102:            public boolean isRunning() {
103:                return _manager.getResinProcess().isActive()
104:                        && _manager.getResinProcess().isResponding();
105:            }
106:
107:            public boolean isDebuggable(Target target) {
108:                return _manager.getResinProcess().isActive()
109:                        && _manager.getResinProcess().isDebug();
110:            }
111:
112:            public ProgressObject startDebugging(Target target) {
113:                StartRunnable start = new StartRunnable(Mode.DEBUG,
114:                        CommandType.START);
115:                RequestProcessor.getDefault().post(start);
116:
117:                return start;
118:            }
119:
120:            public ServerDebugInfo getDebugInfo(Target target) {
121:                ResinConfiguration resinConfiguration = _manager
122:                        .getResinConfiguration();
123:
124:                String address = resinConfiguration.getServerAddress();
125:                int debugPort = resinConfiguration.getDebugPort();
126:
127:                return new ServerDebugInfo(address, debugPort);
128:            }
129:
130:            private class StartRunnable implements  Runnable, ProgressObject {
131:                private final Mode _mode;
132:                private final CommandType _command;
133:                private final ProgressEventSupport _eventSupport;
134:                private Process _process;
135:
136:                public StartRunnable(Mode mode, CommandType command) {
137:                    _mode = mode;
138:                    _command = command;
139:                    _eventSupport = new ProgressEventSupport(this );
140:
141:                    // must be in constructor to stop netbeans nullpointer
142:                    if (_command == CommandType.START)
143:                        fireProgressEvent(StateType.RUNNING, L
144:                                .l("Waiting for Resin to start..."));
145:                    else if (_command == CommandType.STOP)
146:                        fireProgressEvent(StateType.RUNNING, L
147:                                .l("Waiting for Resin to stop..."));
148:                    else
149:                        throw new AssertionError(_command.toString());
150:                }
151:
152:                private void fireProgressEvent(StateType state, String msg) {
153:                    log.log(state == StateType.FAILED ? Level.WARNING
154:                            : Level.INFO, msg);
155:
156:                    DeploymentStatusImpl deploymentStatusImpl = new DeploymentStatusImpl(
157:                            _command, msg, state);
158:
159:                    _eventSupport.fireProgressEvent(null, deploymentStatusImpl);
160:                }
161:
162:                public void run() {
163:                    if (_command == CommandType.START) {
164:                        ResinProcess resinProcess = _manager.getResinProcess();
165:
166:                        try {
167:                            if (_mode == Mode.DEBUG)
168:                                resinProcess.startDebug();
169:                            else
170:                                resinProcess.start();
171:
172:                            fireProgressEvent(StateType.COMPLETED, L
173:                                    .l("Resin start completed"));
174:                        } catch (IllegalStateException ex) {
175:                            fireProgressEvent(StateType.FAILED, ex
176:                                    .getLocalizedMessage());
177:                            log.log(Level.FINE, ex.toString(), ex);
178:                        } catch (Exception ex) {
179:                            fireProgressEvent(StateType.FAILED, ex.toString());
180:                            log.log(Level.WARNING, ex.toString(), ex);
181:                        }
182:                    } else if (_command == CommandType.STOP) {
183:                        ResinProcess resinProcess = _manager.getResinProcess();
184:
185:                        if (!resinProcess.isActive()) {
186:                            fireProgressEvent(
187:                                    StateType.COMPLETED,
188:                                    L
189:                                            .l("Resin stop completed, but there was no process to stop."));
190:                        } else {
191:                            try {
192:                                resinProcess.stop();
193:                                fireProgressEvent(StateType.COMPLETED, L
194:                                        .l("Resin stop completed."));
195:                            } catch (Exception ex) {
196:                                log.log(Level.WARNING, ex.toString(), ex);
197:
198:                                fireProgressEvent(StateType.COMPLETED, L.l(
199:                                        "Error stopping Resin: {0}", ex
200:                                                .toString()));
201:                            }
202:                        }
203:                    } else
204:                        throw new AssertionError(_command.toString());
205:                }
206:
207:                public DeploymentStatus getDeploymentStatus() {
208:                    return _eventSupport.getDeploymentStatus();
209:                }
210:
211:                public TargetModuleID[] getResultTargetModuleIDs() {
212:                    return null;
213:                }
214:
215:                public ClientConfiguration getClientConfiguration(
216:                        TargetModuleID targetModuleID) {
217:                    return null;
218:                }
219:
220:                public boolean isCancelSupported() {
221:                    return false;
222:                }
223:
224:                public void cancel() throws OperationUnsupportedException {
225:                    throw new OperationUnsupportedException(
226:                            "Cancel is not supported");
227:                }
228:
229:                public boolean isStopSupported() {
230:                    return false;
231:                }
232:
233:                public void stop() throws OperationUnsupportedException {
234:                    throw new OperationUnsupportedException(
235:                            "Stop is not supported");
236:                }
237:
238:                public void addProgressListener(
239:                        ProgressListener progressListener) {
240:                    _eventSupport.addProgressListener(progressListener);
241:                }
242:
243:                public void removeProgressListener(
244:                        ProgressListener progressListener) {
245:                    _eventSupport.removeProgressListener(progressListener);
246:                }
247:            }
248:
249:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.