1 19 20 package org.netbeans.modules.tomcat5.ide; 21 22 import java.io.File ; 23 24 import org.netbeans.modules.j2ee.deployment.plugins.api.IncrementalDeployment; 25 import javax.enterprise.deploy.spi.*; 26 import javax.enterprise.deploy.model.*; 27 import javax.enterprise.deploy.shared.*; 28 import javax.enterprise.deploy.spi.status.ProgressObject ; 29 import javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException ; 30 import org.openide.util.RequestProcessor; 31 import org.netbeans.modules.tomcat5.progress.ProgressEventSupport; 32 import org.netbeans.modules.tomcat5.progress.Status; 33 34 import org.netbeans.modules.tomcat5.*; 35 36 40 public class TomcatIncrementalDeployment extends IncrementalDeployment { 41 42 private TomcatManager tm; 43 44 45 public TomcatIncrementalDeployment (DeploymentManager dm) { 46 this.tm = (TomcatManager) dm; 47 } 48 49 public boolean canFileDeploy (Target target, DeployableObject deployable) { 50 return deployable.getType ().equals (javax.enterprise.deploy.shared.ModuleType.WAR); 51 52 } 53 54 public File getDirectoryForModule (TargetModuleID module) { 55 return null; 56 62 } 63 64 public File getDirectoryForNewApplication (Target target, DeployableObject module, DeploymentConfiguration configuration) { 65 if (module.getType ().equals (ModuleType.WAR)) { 66 return null; 67 74 } 75 throw new IllegalArgumentException ("ModuleType:" + module == null ? null : module.getType () + " Configuration:"+configuration); } 77 78 public java.io.File getDirectoryForNewModule (java.io.File appDir, String uri, javax.enterprise.deploy.model.DeployableObject module, javax.enterprise.deploy.spi.DeploymentConfiguration configuration) { 79 throw new UnsupportedOperationException (); 80 } 81 82 public ProgressObject incrementalDeploy (final TargetModuleID module, org.netbeans.modules.j2ee.deployment.plugins.api.AppChangeDescriptor changes) { 83 if (changes.descriptorChanged () || changes.serverDescriptorChanged () || changes.classesChanged ()) { 84 TomcatManagerImpl tmi = new TomcatManagerImpl (tm); 85 if (changes.serverDescriptorChanged ()) { 86 new TomcatManagerImpl (tm).remove ((TomcatModule) module); 87 tmi.incrementalRedeploy ((TomcatModule) module); 88 } else if (changes.descriptorChanged()) { 89 new TomcatManagerImpl (tm).stop((TomcatModule) module); 90 tmi.start ((TomcatModule) module); 91 } else { 92 tmi.reload ((TomcatModule)module); 93 } 94 return tmi; 95 } else { 96 final P p = new P (module); 97 p.supp.fireHandleProgressEvent (module, new Status (ActionType.EXECUTE, CommandType.DISTRIBUTE, "", StateType.COMPLETED)); 98 RequestProcessor.getDefault().post(new Runnable () { 99 public void run() { 100 try { 101 p.supp.fireHandleProgressEvent (module, new Status (ActionType.EXECUTE, CommandType.DISTRIBUTE, "", StateType.COMPLETED)); 102 103 } catch (Throwable e) { 104 e.printStackTrace(); 105 } 106 } 107 }); 108 return p; 109 } 110 } 111 112 public ProgressObject initialDeploy (Target target, javax.enterprise.deploy.model.DeployableObject app, DeploymentConfiguration configuration, File dir) { 113 TomcatManagerImpl tmi = new TomcatManagerImpl (tm); 114 File contextXml = new File (dir.getAbsolutePath () + "/META-INF/context.xml"); tmi.initialDeploy (target, contextXml, dir); 116 return tmi; 117 } 118 119 public void notifyDeployment(TargetModuleID module) { 120 if (tm.isTomcat50() && tm.getTomcatProperties().getOpenContextLogOnRun()) { 121 tm.openLog(module); 122 } 123 } 124 125 private static class P implements ProgressObject { 126 127 ProgressEventSupport supp = new ProgressEventSupport (this); 128 TargetModuleID tmid; 129 130 P (TargetModuleID tmid) { 131 this.tmid = tmid; 132 } 133 134 public void addProgressListener (javax.enterprise.deploy.spi.status.ProgressListener progressListener) { 135 supp.addProgressListener (progressListener); 136 } 137 138 public void removeProgressListener (javax.enterprise.deploy.spi.status.ProgressListener progressListener) { 139 supp.removeProgressListener (progressListener); 140 } 141 142 public javax.enterprise.deploy.spi.status.ClientConfiguration getClientConfiguration (javax.enterprise.deploy.spi.TargetModuleID targetModuleID) { 143 return null; 144 } 145 146 public javax.enterprise.deploy.spi.status.DeploymentStatus getDeploymentStatus () { 147 return supp.getDeploymentStatus (); 148 } 149 150 public javax.enterprise.deploy.spi.TargetModuleID [] getResultTargetModuleIDs () { 151 return new TargetModuleID [] {tmid}; 152 } 153 154 public boolean isCancelSupported () { 155 return false; 156 } 157 158 public boolean isStopSupported () { 159 return false; 160 } 161 162 public void cancel () throws javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException { 163 throw new OperationUnsupportedException (""); 164 } 165 166 public void stop () throws javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException { 167 throw new OperationUnsupportedException (""); 168 } 169 170 } 171 } 172 | Popular Tags |