1 19 20 package org.netbeans.tests.j2eeserver.plugin; 21 22 import javax.enterprise.deploy.spi.DeploymentManager ; 23 import javax.enterprise.deploy.spi.status.ProgressObject ; 24 import javax.enterprise.deploy.spi.Target ; 25 import javax.enterprise.deploy.shared.CommandType ; 26 27 import org.netbeans.modules.j2ee.deployment.plugins.api.*; 28 import org.netbeans.tests.j2eeserver.plugin.jsr88.*; 29 import org.netbeans.modules.j2ee.deployment.plugins.api.StartServer; 30 31 35 public class ServerLifecycle extends StartServer { 36 37 private DepManager dm; 38 39 40 public ServerLifecycle(DeploymentManager dm) { 41 this.dm = (DepManager)dm; 42 } 43 44 public ServerDebugInfo getDebugInfo(Target target) { 45 return null; 46 } 47 48 public boolean isAlsoTargetServer(Target target) { 49 return true; 50 } 51 52 public boolean isDebuggable(Target target) { 53 return false; } 55 56 public boolean isRunning() { 57 return dm.getState() == DepManager.RUNNING; 58 } 59 60 public boolean needsStartForConfigure() { 61 return false; 62 } 63 64 public void setDeploymentManager(DeploymentManager manager) { 65 this.dm = (DepManager) manager; 66 } 67 68 public ProgressObject startDebugging(Target target) { 69 return dm.createServerProgress(); 70 } 71 72 public ProgressObject startDeploymentManager() { 73 final ServerProgress sp = dm.createServerProgress(); 74 Runnable r = new Runnable () { 75 public void run() { 76 try { Thread.sleep(500); } catch (Exception e) {} 78 dm.setState(DepManager.STARTING); 79 sp.setStatusStartRunning("TestPluginDM: "+dm.getName()+" is starting."); 80 try { Thread.sleep(2000); } catch (Exception e) {} 82 if (dm.getTestBehavior() == DepManager.START_FAILED) { 83 dm.setState(DepManager.FAILED); 84 sp.setStatusStartFailed("TestPluginDM: "+dm.getName()+" startup failed"); 85 } else { 86 dm.setState(DepManager.RUNNING); 87 sp.setStatusStartCompleted("TestPluginDM "+dm.getName()+" startup finished"); 88 } 89 } 90 }; 91 92 (new Thread (r)).start(); 93 return sp; 94 } 95 96 public ProgressObject stopDeploymentManager() { 97 final ServerProgress sp = dm.createServerProgress(); 98 Runnable r = new Runnable () { 99 public void run() { 100 try { Thread.sleep(500); } catch (Exception e) {} 102 dm.setState(DepManager.STOPPING); 103 sp.setStatusStopRunning("TestPluginDM is preparing to stop "+dm.getName()+"..."); 104 try { Thread.sleep(2000); } catch (Exception e) {} 106 if (dm.getTestBehavior() == DepManager.STOP_FAILED) { 107 dm.setState(DepManager.FAILED); 108 sp.setStatusStopFailed("TestPluginDM stop "+dm.getName()+" failed"); 109 } else { 110 dm.setState(DepManager.STOPPED); 111 sp.setStatusStopCompleted("TestPluginDM startup "+dm.getName()+" finished"); 112 } 113 } 114 }; 115 116 (new Thread (r)).start(); 117 return sp; 118 } 119 120 public boolean supportsStartDeploymentManager() { 121 return true; 122 } 123 124 public boolean needsStartForAdminConfig() { 125 return true; 126 } 127 128 public boolean needsStartForTargetList() { 129 return true; 130 } 131 132 } 133 | Popular Tags |