1 19 20 21 package org.netbeans.modules.j2ee.deployment.impl; 22 23 import javax.enterprise.deploy.spi.status.ProgressObject ; 24 import org.openide.nodes.Node; 25 import javax.enterprise.deploy.spi.Target ; 26 import org.openide.util.NbBundle; 27 import org.netbeans.modules.j2ee.deployment.plugins.api.*; 28 29 public class ServerTarget implements Node.Cookie { 32 33 ServerInstance instance; 34 Target target; 35 37 public ServerTarget(ServerInstance instance, Target target) { 38 this.instance = instance; 39 this.target = target; 40 } 41 42 public ServerInstance getInstance() { 43 return instance; 44 } 45 46 public String getName() { 47 return target.getName(); 48 } 49 50 public boolean hasWebContainerOnly() { 51 Server server = instance.getServer(); 52 return (server.canDeployWars() && ! server.canDeployEars() && ! server.canDeployEjbJars()); 53 } 54 55 public Target getTarget() { 56 return target; 57 } 58 59 public boolean isAlsoServerInstance() { 60 return instance.getStartServer().isAlsoTargetServer(target); 61 } 62 63 public boolean isRunning() { 64 if (isAlsoServerInstance()) 65 return instance.isRunning(); 66 67 StartServer ss = instance.getStartServer(); 68 if (ss != null) { 69 return ss.isRunning(target); 70 } 71 return false; 72 } 73 74 public ProgressObject start() { 75 StartServer ss = instance.getStartServer(); 76 if (ss != null && ss.supportsStartTarget(target)) { 77 ProgressObject po = ss.startTarget(target); 78 if (po != null) { 79 return po; 80 } 81 } 82 String name = target == null ? "null" : target.getName(); String msg = NbBundle.getMessage(ServerTarget.class, "MSG_StartStopTargetNotSupported", name); 84 throw new UnsupportedOperationException (msg); 85 } 86 87 public ProgressObject stop() { 88 StartServer ss = instance.getStartServer(); 89 if (ss != null && ss.supportsStartTarget(target)) { 90 ProgressObject po = ss.stopTarget(target); 91 if (po != null) { 92 return po; 93 } 94 } 95 String name = target == null ? "null" : target.getName(); String msg = NbBundle.getMessage(ServerTarget.class, "MSG_StartStopTargetNotSupported", name); 97 throw new UnsupportedOperationException (msg); 98 } 99 } 100 | Popular Tags |