1 19 20 package org.netbeans.modules.j2ee.sun.ide; 21 22 import java.io.File ; 23 import javax.enterprise.deploy.spi.factories.DeploymentFactory ; 24 import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties; 25 import org.netbeans.modules.j2ee.sun.api.ServerLocationManager; 26 import org.netbeans.modules.j2ee.sun.ide.j2ee.ui.DomainCreator; 27 import org.netbeans.modules.j2ee.sun.ide.j2ee.PluginProperties; 28 import org.openide.modules.ModuleInstall; 29 import org.openide.util.NbPreferences; 30 import org.openide.windows.WindowManager; 31 32 public class Installer extends ModuleInstall { 33 34 private static DeploymentFactory facadeDF = null; 35 36 private static final String PROP_FIRST_RUN = "first_run"; 37 38 40 public static synchronized Object create() { 41 if (facadeDF == null){ 42 PluginProperties.configureDefaultServerInstance(); 44 facadeDF = new org.netbeans.modules.j2ee.sun.ide.dm.SunDeploymentFactory(); 45 } 46 return facadeDF; 47 } 48 49 public void restored() { 50 WindowManager.getDefault().invokeWhenUIReady(new PrepareEnvironment()); 51 } 52 53 public void close() { 54 } 55 56 public void uninstalled() { 57 } 58 59 private static class PrepareEnvironment implements Runnable { 60 public void run() { 61 if (!NbPreferences.forModule(DomainCreator.class).getBoolean(PROP_FIRST_RUN, false)) { 63 String prop = System.getProperty(ServerLocationManager.INSTALL_ROOT_PROP_NAME); 64 65 if (null != prop && prop.trim().length() > 0) { 66 File propFile = new File (prop); 68 ClassLoader cl = ServerLocationManager.getNetBeansAndServerClassLoader(propFile); 69 if (null != cl && !propFile.canWrite()) { 70 createDomainAndRecord(propFile); 71 } 72 } 73 } 74 } 75 } 76 77 static private void createDomainAndRecord(final File propFile) { 78 InstanceProperties ip = DomainCreator.createPersonalDefaultDomain(propFile.getAbsolutePath()); 81 NbPreferences.forModule(DomainCreator.class).putBoolean(PROP_FIRST_RUN, true); 83 } 84 } 85 | Popular Tags |