1 19 24 25 package org.netbeans.modules.j2ee.sun.ide.j2ee.incrdeploy; 26 import java.io.File ; 27 28 import org.netbeans.modules.j2ee.deployment.plugins.api.IncrementalDeployment; 29 30 import javax.enterprise.deploy.spi.Target ; 31 import javax.enterprise.deploy.spi.TargetModuleID ; 32 import javax.enterprise.deploy.spi.DeploymentManager ; 33 import javax.enterprise.deploy.spi.DeploymentConfiguration ; 34 import javax.enterprise.deploy.model.DeployableObject ; 35 import javax.enterprise.deploy.shared.ModuleType ; 36 import javax.enterprise.deploy.spi.status.ProgressObject ; 37 import org.netbeans.modules.j2ee.sun.ide.j2ee.DeploymentManagerProperties; 38 import org.netbeans.modules.j2ee.sun.ide.j2ee.Utils; 39 import org.netbeans.modules.j2ee.sun.ide.j2ee.runtime.actions.ViewLogAction; 40 import org.netbeans.modules.j2ee.sun.share.configbean.SunONEDeploymentConfiguration; 41 import org.netbeans.modules.j2ee.sun.api.SunDeploymentManagerInterface; 42 import org.netbeans.modules.j2ee.deployment.plugins.api.AppChangeDescriptor; 43 44 import org.netbeans.modules.j2ee.sun.api.ServerInterface; 45 import org.openide.ErrorManager; 46 import org.netbeans.modules.j2ee.sun.api.ServerLocationManager; 47 48 52 public class DirectoryDeploymentFacade extends IncrementalDeployment { 53 54 Object inner = null; 55 private File [] resourceDirs = null; 56 private SunDeploymentManagerInterface dm; 57 58 59 60 public DirectoryDeploymentFacade(DeploymentManager dm) { 61 try { 63 setDeploymentManager(dm); 64 Class [] cls= new Class [1]; 65 cls[0]=DeploymentManager .class; 66 java.lang.reflect.Constructor ctr =null; 67 SunDeploymentManagerInterface sdm = (SunDeploymentManagerInterface)dm; 68 ClassLoader loader = ServerLocationManager.getNetBeansAndServerClassLoader(sdm.getPlatformRoot()); 69 ctr = loader.loadClass("org.netbeans.modules.j2ee.sun.bridge.DirectoryDeployment").getConstructor(cls); 70 Object [] o= new Object [1]; 71 o[0]=dm; 72 73 inner = ctr.newInstance(o); 74 } catch (Throwable t) { 75 t.printStackTrace(); 76 } 77 } 78 81 public void setDeploymentManager(DeploymentManager manager) { 82 if (null == manager){ 83 throw new IllegalArgumentException ("invalid null argumment"); 84 } 85 86 if (manager instanceof SunDeploymentManagerInterface) 87 this.dm = (SunDeploymentManagerInterface) manager; 88 else 89 throw new IllegalArgumentException ("setDeploymentManager: Invalid manager type, expecting SunDeploymentManager and got "+manager.getClass().getName()); 90 } 91 92 93 94 public java.io.File getDirectoryForModule(javax.enterprise.deploy.spi.TargetModuleID module) { 95 if (null == inner){ 96 return null; 97 } 98 return ((IncrementalDeployment)inner).getDirectoryForModule(module); 99 } 100 101 public String getModuleUrl(javax.enterprise.deploy.spi.TargetModuleID module) { 102 if (null == inner){ 103 return null; 104 } 105 return ((IncrementalDeployment)inner).getModuleUrl(module); 106 } 107 108 public ProgressObject incrementalDeploy(TargetModuleID module, AppChangeDescriptor changes) { 109 111 if((resourceDirs != null) && (dm != null)){ 117 Utils.registerResources(resourceDirs, (ServerInterface)dm.getManagement()); 118 } 119 if (null!=dm){ 120 ViewLogAction.viewLog(dm); 121 } 122 123 return ((IncrementalDeployment)inner).incrementalDeploy(module, changes); 124 } 125 126 127 128 129 public ProgressObject initialDeploy(Target target, DeployableObject deployableObject, DeploymentConfiguration deploymentConfiguration, File file) { 130 File [] resourceDirs = Utils.getResourceDirs(deployableObject); 132 if((resourceDirs != null) && (dm != null)) { 133 Utils.registerResources(resourceDirs, (ServerInterface)dm.getManagement()); 134 } 135 if (null != dm){ 136 ViewLogAction.viewLog(dm); 137 } 138 return ((IncrementalDeployment)inner).initialDeploy(target,deployableObject,deploymentConfiguration, file); 139 } 140 141 147 public boolean canFileDeploy(Target target, DeployableObject deployableObject) { 148 if (null == dm){ 149 return false; 150 } 151 if (null == deployableObject){ 152 return false; 153 } 154 if (org.netbeans.modules.j2ee.sun.ide.j2ee.PluginProperties.getDefault().isIncrementalDeploy()==false){ 155 return false; 156 } 157 158 resourceDirs = Utils.getResourceDirs(deployableObject); 159 if (null == target){ 160 return false; 161 } 162 163 if ((deployableObject.getType() != ModuleType.WAR)){ 165 return false; 166 } 167 return dm.isLocal(); 168 } 169 170 public File getDirectoryForNewApplication(javax.enterprise.deploy.spi.Target target, DeployableObject deployableObject, DeploymentConfiguration deploymentConfiguration) { 171 return ((IncrementalDeployment)inner).getDirectoryForNewApplication(target,deployableObject,deploymentConfiguration); 172 } 173 public File getDirectoryForNewApplication(String deploymentName, Target target, DeploymentConfiguration configuration){ 174 SunONEDeploymentConfiguration s1dc =(SunONEDeploymentConfiguration) configuration; 175 s1dc.setDeploymentModuleName(deploymentName); 176 return null; 177 } 178 179 public File getDirectoryForNewModule(File file, String str, DeployableObject deployableObject, DeploymentConfiguration deploymentConfiguration) { 180 return ((IncrementalDeployment)inner).getDirectoryForNewModule(file,str, deployableObject,deploymentConfiguration); 181 } 182 183 } 184 | Popular Tags |