Source Code Cross Referenced for DeploymentManagerImpl.java in  » EJB-Server-resin-3.1.5 » resin » com » caucho » j2ee » deployclient » 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.j2ee.deployclient 
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:         *   Free SoftwareFoundation, Inc.
023:         *   59 Temple Place, Suite 330
024:         *   Boston, MA 02111-1307  USA
025:         *
026:         * @author Scott Ferguson
027:         */
028:
029:        package com.caucho.j2ee.deployclient;
030:
031:        import com.caucho.hessian.client.HessianProxyFactory;
032:        import com.caucho.util.L10N;
033:
034:        import javax.enterprise.deploy.model.DeployableObject;
035:        import javax.enterprise.deploy.shared.DConfigBeanVersionType;
036:        import javax.enterprise.deploy.shared.ModuleType;
037:        import javax.enterprise.deploy.spi.DeploymentConfiguration;
038:        import javax.enterprise.deploy.spi.DeploymentManager;
039:        import javax.enterprise.deploy.spi.Target;
040:        import javax.enterprise.deploy.spi.TargetModuleID;
041:        import javax.enterprise.deploy.spi.exceptions.DConfigBeanVersionUnsupportedException;
042:        import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
043:        import javax.enterprise.deploy.spi.exceptions.InvalidModuleException;
044:        import javax.enterprise.deploy.spi.exceptions.TargetException;
045:        import javax.enterprise.deploy.spi.status.ProgressObject;
046:        import java.io.File;
047:        import java.io.FileInputStream;
048:        import java.io.InputStream;
049:        import java.util.Locale;
050:        import java.util.logging.Level;
051:        import java.util.logging.Logger;
052:
053:        /**
054:         * Manager for the deployments.
055:         */
056:        public class DeploymentManagerImpl implements  DeploymentManager {
057:            private static final L10N L = new L10N(DeploymentManagerImpl.class);
058:            private static final Logger log = Logger
059:                    .getLogger(DeploymentManagerImpl.class.getName());
060:
061:            private String _uri;
062:
063:            private DeploymentProxyAPI _proxy;
064:
065:            DeploymentManagerImpl(String uri) {
066:                int p = uri.indexOf("http");
067:
068:                if (p < 0)
069:                    throw new IllegalArgumentException(L.l(
070:                            "'{0}' is an illegal URI for DeploymentManager.",
071:                            uri));
072:
073:                _uri = uri.substring(p);
074:            }
075:
076:            /**
077:             * Connect to the manager.
078:             */
079:            void connect(String user, String password)
080:                    throws DeploymentManagerCreationException {
081:                try {
082:                    HessianProxyFactory factory = new HessianProxyFactory();
083:
084:                    factory.setUser(user);
085:                    factory.setPassword(password);
086:                    factory.setReadTimeout(120000);
087:
088:                    if (log.isLoggable(Level.FINE))
089:                        log.fine("DeploymentManager[" + _uri
090:                                + "] creating proxy");
091:
092:                    _proxy = (DeploymentProxyAPI) factory.create(
093:                            DeploymentProxyAPI.class, _uri);
094:                } catch (Exception e) {
095:                    log.log(Level.FINE, e.toString(), e);
096:
097:                    DeploymentManagerCreationException exn;
098:
099:                    exn = new DeploymentManagerCreationException(e.getMessage());
100:                    exn.initCause(e);
101:                    throw exn;
102:                }
103:            }
104:
105:            /**
106:             * Returns the targets supported by the manager.
107:             */
108:            public Target[] getTargets() throws IllegalStateException {
109:                if (_proxy == null)
110:                    throw new IllegalStateException(
111:                            "DeploymentManager is disconnected");
112:
113:                Thread thread = Thread.currentThread();
114:                ClassLoader oldLoader = thread.getContextClassLoader();
115:                try {
116:                    thread.setContextClassLoader(getClass().getClassLoader());
117:
118:                    Target[] targets = _proxy.getTargets();
119:
120:                    if (targets == null)
121:                        return new Target[0];
122:
123:                    return targets;
124:                } catch (RuntimeException e) {
125:                    throw e;
126:                } catch (Exception e) {
127:                    e.printStackTrace();
128:
129:                    throw new RuntimeException(e);
130:                } finally {
131:                    thread.setContextClassLoader(oldLoader);
132:                }
133:            }
134:
135:            /**
136:             * Returns the current running modules.
137:             */
138:            public TargetModuleID[] getRunningModules(ModuleType moduleType,
139:                    Target[] targetList) throws TargetException,
140:                    IllegalStateException {
141:                return new TargetModuleID[0];
142:            }
143:
144:            /**
145:             * Returns the current non-running modules.
146:             */
147:            public TargetModuleID[] getNonRunningModules(ModuleType moduleType,
148:                    Target[] targetList) throws TargetException,
149:                    IllegalStateException {
150:                return new TargetModuleID[0];
151:            }
152:
153:            /**
154:             * Returns all available modules.
155:             */
156:            public TargetModuleID[] getAvailableModules(ModuleType moduleType,
157:                    Target[] targetList) throws TargetException,
158:                    IllegalStateException {
159:                if (_proxy == null)
160:                    throw new IllegalStateException(
161:                            "DeploymentManager is disconnected");
162:
163:                Thread thread = Thread.currentThread();
164:                ClassLoader oldLoader = thread.getContextClassLoader();
165:                try {
166:                    thread.setContextClassLoader(getClass().getClassLoader());
167:
168:                    return _proxy.getAvailableModules(moduleType.toString());
169:                } finally {
170:                    thread.setContextClassLoader(oldLoader);
171:                }
172:            }
173:
174:            /**
175:             * Returns a configuration for the deployable object.
176:             */
177:            public DeploymentConfiguration createConfiguration(
178:                    DeployableObject dObj) throws InvalidModuleException {
179:                throw new UnsupportedOperationException();
180:            }
181:
182:            /**
183:             * Deploys the object.
184:             */
185:            public ProgressObject distribute(Target[] targetList, File archive,
186:                    File deploymentPlan) throws IllegalStateException {
187:                InputStream archiveIn = null;
188:                InputStream ddIn = null;
189:
190:                try {
191:                    archiveIn = new FileInputStream(archive);
192:                    ddIn = new FileInputStream(deploymentPlan);
193:
194:                    return distribute(targetList, archiveIn, ddIn);
195:
196:                } catch (Exception e) {
197:                    throw new RuntimeException(e);
198:                } finally {
199:                    try {
200:                        if (archiveIn != null)
201:                            archiveIn.close();
202:                    } catch (Throwable e) {
203:                        log.log(Level.FINE, e.toString(), e);
204:                    }
205:
206:                    try {
207:                        if (ddIn != null)
208:                            ddIn.close();
209:                    } catch (Throwable e) {
210:                        log.log(Level.FINE, e.toString(), e);
211:                    }
212:                }
213:            }
214:
215:            /**
216:             * Deploys the object.
217:             */
218:            public ProgressObject distribute(Target[] targetList,
219:                    InputStream archive, InputStream deploymentPlan)
220:                    throws IllegalStateException {
221:                if (_proxy == null) {
222:                    String message = L.l("DeploymentManager is disconnected");
223:
224:                    log.log(Level.FINE, message);
225:
226:                    ProgressObjectImpl progress = new ProgressObjectImpl(
227:                            new TargetModuleID[] {});
228:                    progress.failed(message);
229:
230:                    return progress;
231:                }
232:
233:                if (deploymentPlan == null) {
234:                    String message = L.l("{0} is required", "deployment plan");
235:
236:                    log.log(Level.FINE, message);
237:
238:                    ProgressObjectImpl progress = new ProgressObjectImpl(
239:                            new TargetModuleID[] {});
240:                    progress.failed(message);
241:
242:                    return progress;
243:                }
244:
245:                Thread thread = Thread.currentThread();
246:                ClassLoader oldLoader = thread.getContextClassLoader();
247:                try {
248:                    thread.setContextClassLoader(getClass().getClassLoader());
249:
250:                    return _proxy.distribute(targetList, deploymentPlan,
251:                            archive);
252:                } finally {
253:                    thread.setContextClassLoader(oldLoader);
254:                }
255:            }
256:
257:            /**
258:             * Starts the modules.
259:             */
260:            public ProgressObject start(TargetModuleID[] moduleIDList)
261:                    throws IllegalStateException {
262:                if (_proxy == null)
263:                    throw new IllegalStateException(
264:                            "DeploymentManager is disconnected");
265:
266:                Thread thread = Thread.currentThread();
267:                ClassLoader oldLoader = thread.getContextClassLoader();
268:                try {
269:                    thread.setContextClassLoader(getClass().getClassLoader());
270:
271:                    return _proxy.start(moduleIDList);
272:                } finally {
273:                    thread.setContextClassLoader(oldLoader);
274:                }
275:            }
276:
277:            /**
278:             * Stops the modules.
279:             */
280:            public ProgressObject stop(TargetModuleID[] moduleIDList)
281:                    throws IllegalStateException {
282:                if (_proxy == null)
283:                    throw new IllegalStateException(
284:                            "DeploymentManager is disconnected");
285:
286:                Thread thread = Thread.currentThread();
287:                ClassLoader oldLoader = thread.getContextClassLoader();
288:                try {
289:                    thread.setContextClassLoader(getClass().getClassLoader());
290:
291:                    return _proxy.stop(moduleIDList);
292:                } finally {
293:                    thread.setContextClassLoader(oldLoader);
294:                }
295:            }
296:
297:            /**
298:             * Undeploys the modules.
299:             */
300:            public ProgressObject undeploy(TargetModuleID[] moduleIDList)
301:                    throws IllegalStateException {
302:                if (_proxy == null)
303:                    throw new IllegalStateException(
304:                            "DeploymentManager is disconnected");
305:
306:                Thread thread = Thread.currentThread();
307:                ClassLoader oldLoader = thread.getContextClassLoader();
308:                try {
309:                    thread.setContextClassLoader(getClass().getClassLoader());
310:
311:                    return _proxy.undeploy(moduleIDList);
312:                } finally {
313:                    thread.setContextClassLoader(oldLoader);
314:                }
315:            }
316:
317:            /**
318:             * Returns true if the redeploy is supported.
319:             */
320:            public boolean isRedeploySupported() {
321:                return false;
322:            }
323:
324:            /**
325:             * Redeploys the object.
326:             */
327:            public ProgressObject redeploy(TargetModuleID[] targetList,
328:                    File archive, File deploymentPlan)
329:                    throws IllegalStateException {
330:                throw new UnsupportedOperationException();
331:            }
332:
333:            /**
334:             * Redeploys the object.
335:             */
336:            public ProgressObject redeploy(TargetModuleID[] targetList,
337:                    InputStream archive, InputStream deploymentPlan)
338:                    throws IllegalStateException {
339:                throw new UnsupportedOperationException();
340:            }
341:
342:            /**
343:             * Frees any resources.
344:             */
345:            public void release() {
346:            }
347:
348:            /**
349:             * Returns the default locale.
350:             */
351:            public Locale getDefaultLocale() {
352:                throw new UnsupportedOperationException();
353:            }
354:
355:            /**
356:             * Returns the current locale.
357:             */
358:            public Locale getCurrentLocale() {
359:                throw new UnsupportedOperationException();
360:            }
361:
362:            /**
363:             * Sets the default locale.
364:             */
365:            public void setLocale(Locale locale) {
366:                throw new UnsupportedOperationException();
367:            }
368:
369:            /**
370:             * Returns the supported locales.
371:             */
372:            public Locale[] getSupportedLocales() {
373:                throw new UnsupportedOperationException();
374:            }
375:
376:            /**
377:             * Returns true if the locale is supported.
378:             */
379:            public boolean isLocaleSupported(Locale locale) {
380:                return false;
381:            }
382:
383:            /**
384:             * Returns the bean's J2EE version.
385:             */
386:            public DConfigBeanVersionType getDConfigBeanVersion() {
387:                return DConfigBeanVersionType.V1_4;
388:            }
389:
390:            /**
391:             * Returns true if the given version is supported.
392:             */
393:            public boolean isDConfigBeanVersionSupported(
394:                    DConfigBeanVersionType version) {
395:                return true;
396:            }
397:
398:            /**
399:             * Sets true if the given version is supported.
400:             */
401:            public void setDConfigBeanVersionSupported(
402:                    DConfigBeanVersionType version)
403:                    throws DConfigBeanVersionUnsupportedException {
404:            }
405:
406:            /**
407:             * Return the debug view of the manager.
408:             */
409:            public String toString() {
410:                return "DeploymentManagerImpl[" + _uri + "]";
411:            }
412:
413:            public ProgressObject distribute(Target[] arg0, ModuleType arg1,
414:                    InputStream arg2, InputStream arg3)
415:                    throws IllegalStateException {
416:                throw new UnsupportedOperationException("Not supported yet.");
417:            }
418:
419:            public void setDConfigBeanVersion(DConfigBeanVersionType arg0)
420:                    throws DConfigBeanVersionUnsupportedException {
421:                throw new UnsupportedOperationException("Not supported yet.");
422:            }
423:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.