1 19 20 package org.netbeans.modules.j2ee.ant; 21 22 import org.apache.tools.ant.BuildException; 23 import org.apache.tools.ant.Task; 24 25 import org.openide.util.Lookup; 26 import org.netbeans.modules.j2ee.deployment.devmodules.api.*; 27 import org.netbeans.api.project.FileOwnerQuery; 28 import org.openide.filesystems.*; 29 import org.apache.tools.ant.Project; 30 import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider; 31 import org.netbeans.modules.j2ee.deployment.plugins.api.ServerDebugInfo; 32 33 37 public class Deploy extends Task implements Deployment.Logger { 38 39 42 private boolean debugmode = false; 43 44 private boolean forceRedeploy = false; 45 46 49 private String clientModuleUri; 50 51 54 private String clientUrlPart; 55 56 57 public void execute() throws BuildException { 58 59 ClassLoader originalLoader = null; 60 61 try { 62 ClassLoader current = (ClassLoader )Lookup.getDefault().lookup(ClassLoader .class); 64 if (current == null) { 65 current = ClassLoader.getSystemClassLoader(); 66 } 67 if (current != null) { 68 originalLoader = Thread.currentThread().getContextClassLoader(); 69 Thread.currentThread().setContextClassLoader(current); 70 } 71 72 J2eeModuleProvider jmp = null; 73 try { 74 FileObject fob = FileUtil.toFileObject(getProject().getBaseDir()); 75 fob.refresh(); jmp = (J2eeModuleProvider) FileOwnerQuery.getOwner(fob).getLookup().lookup(J2eeModuleProvider.class); 77 } catch (Exception e) { 78 throw new BuildException(e); 79 } 80 81 try { 82 String clientUrl = Deployment.getDefault ().deploy (jmp, debugmode, clientModuleUri, clientUrlPart, forceRedeploy, this); 83 if (clientUrl != null) { 84 getProject().setProperty("client.url", clientUrl); 85 } 86 87 ServerDebugInfo sdi = jmp.getServerDebugInfo(); 88 89 if (sdi != null) { String h = sdi.getHost(); 91 String transport = sdi.getTransport(); 92 String address = ""; 94 if (transport.equals(ServerDebugInfo.TRANSPORT_SHMEM)) { 95 address = sdi.getShmemName(); 96 } else { 97 address = Integer.toString(sdi.getPort()); 98 } 99 100 getProject().setProperty("jpda.transport", transport); 101 getProject().setProperty("jpda.host", h); 102 getProject().setProperty("jpda.address", address); 103 } 104 } catch (Exception ex) { 105 throw new BuildException(ex); 106 } 107 } finally { 108 if (originalLoader != null) { 109 Thread.currentThread().setContextClassLoader(originalLoader); 110 } 111 } 112 } 113 114 118 public boolean getDebugmode() { 119 return this.debugmode; 120 } 121 122 126 public void setDebugmode(boolean debugmode) { 127 this.debugmode = debugmode; 128 } 129 130 public boolean getForceRedeploy() { 131 return this.forceRedeploy; 132 } 133 134 public void setForceRedeploy(boolean forceRedeploy) { 135 this.forceRedeploy = forceRedeploy; 136 } 137 138 142 public String getClientUrlPart() { 143 return this.clientUrlPart; 144 } 145 146 150 public void setClientUrlPart(String clientUrlPart) { 151 this.clientUrlPart = clientUrlPart; 152 } 153 154 157 public String getClientModuleUri() { 158 return this.clientModuleUri; 159 } 160 161 public void setClientModuleUri(String clientModuleUri) { 162 this.clientModuleUri = clientModuleUri; 163 } 164 } 165 | Popular Tags |