geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlaskow...@apache.org
Subject svn commit: r558562 - in /geronimo/sandbox/geronimo-netbeans-plugin: nbproject/ src/org/apache/geronimo/netbeans/ src/org/apache/geronimo/netbeans/status/ src/org/apache/geronimo/netbeans/util/ src/org/apache/geronimo/netbeans/wizard/
Date Sun, 22 Jul 2007 22:11:14 GMT
Author: jlaskowski
Date: Sun Jul 22 15:11:13 2007
New Revision: 558562

URL: http://svn.apache.org/viewvc?view=rev&rev=558562
Log:
Start the server (missing a proper check whether it's run or not)

Added:
    geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoPluginProperties.java   (with props)
    geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/
    geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/Bundle.properties   (with props)
    geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/GeronimoDeploymentStatus.java   (with props)
    geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/GeronimoProgressObject.java   (with props)
    geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/util/
    geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/util/GeronimoTailer.java   (with props)
Modified:
    geronimo/sandbox/geronimo-netbeans-plugin/nbproject/genfiles.properties
    geronimo/sandbox/geronimo-netbeans-plugin/nbproject/project.xml
    geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/Bundle.properties
    geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoDeploymentFactory.java
    geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoDeploymentManager.java
    geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoInstantiatingIterator.java
    geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoOptionalDeploymentManagerFactory.java
    geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoPluginUtils.java
    geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoStartServer.java
    geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/wizard/GeronimoServerLocationPanel.java

Modified: geronimo/sandbox/geronimo-netbeans-plugin/nbproject/genfiles.properties
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/nbproject/genfiles.properties?view=diff&rev=558562&r1=558561&r2=558562
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/nbproject/genfiles.properties (original)
+++ geronimo/sandbox/geronimo-netbeans-plugin/nbproject/genfiles.properties Sun Jul 22 15:11:13 2007
@@ -1,8 +1,8 @@
-build.xml.data.CRC32=6eb541c4
+build.xml.data.CRC32=ca9529ea
 build.xml.script.CRC32=06cbcef2
 build.xml.stylesheet.CRC32=05353c81
 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=6eb541c4
+nbproject/build-impl.xml.data.CRC32=ca9529ea
 nbproject/build-impl.xml.script.CRC32=47f49d5d
 nbproject/build-impl.xml.stylesheet.CRC32=3f8b4615

Modified: geronimo/sandbox/geronimo-netbeans-plugin/nbproject/project.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/nbproject/project.xml?view=diff&rev=558562&r1=558561&r2=558562
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/nbproject/project.xml (original)
+++ geronimo/sandbox/geronimo-netbeans-plugin/nbproject/project.xml Sun Jul 22 15:11:13 2007
@@ -68,6 +68,30 @@
                     </run-dependency>
                 </dependency>
                 <dependency>
+                    <code-name-base>org.openide.execution</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <specification-version>1.10</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.openide.filesystems</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <specification-version>7.2</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.openide.io</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <specification-version>1.11</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
                     <code-name-base>org.openide.nodes</code-name-base>
                     <build-prerequisite/>
                     <compile-dependency/>

Modified: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/Bundle.properties
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/Bundle.properties?view=diff&rev=558562&r1=558561&r2=558562
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/Bundle.properties (original)
+++ geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/Bundle.properties Sun Jul 22 15:11:13 2007
@@ -20,8 +20,20 @@
 LBL_DisplayName=Apache Geronimo 2.0
 LBL_FactoryVersion=Deployment Factory for Apache Geronimo 2.0 Plugin 
 
-MSG_InstallerName=Apache Geronimo Installer XYZ
+MSG_InstallerName=Apache Geronimo Installer
 MSG_CreateFailed=Cannot create {0} server instance.
 MSG_GeronimoServerPlatform=Apache Geronimo Platform
 MSG_InvalidUri=Invalid URI: {0}
-MSG_DmInstantiateFailed=Error at Deployment Manager instantiation
\ No newline at end of file
+MSG_DmInstantiateFailed=Error at Deployment Manager instantiation
+MSG_UnknownDeploymentManagerType=Unknown deployment manager type: {0}
+MSG_ExceptionThrownButShouldHaveNot=Exception {0} thrown but it must've not: {1}
+MSG_StartServerInProgress=Starting {0}
+MSG_HttpPortInUse={0} Start Failed. HTTP Connector port {1} is in use
+MSG_RmiPortInUse={0} Start Failed. RMI Naming Service port {1} is in use.
+MSG_ProcessExecutionFailed={0} Start Failed. Check whether the {1} script is executable.
+MSG_StartupScriptNotFound={0} Start Failed. Startup script {1} not found or permission denied.
+MSG_ServerStarted={0} Started
+MSG_StartFailed={0} Start Failed
+MSG_StartServerTimeout=IDE can't recognize whether the server has been started, \
+please use the Refresh button or context menu item to update its status.
+MSG_InstanceRegistrationFailed={0} Registration Failed
\ No newline at end of file

Modified: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoDeploymentFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoDeploymentFactory.java?view=diff&rev=558562&r1=558561&r2=558562
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoDeploymentFactory.java (original)
+++ geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoDeploymentFactory.java Sun Jul 22 15:11:13 2007
@@ -29,6 +29,7 @@
 import javax.enterprise.deploy.spi.DeploymentManager;
 import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
 import javax.enterprise.deploy.spi.factories.DeploymentFactory;
+import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
 import org.openide.util.NbBundle;
 
 /**
@@ -55,7 +56,6 @@
      */
     private Map<String, DeploymentFactory> factories = new HashMap<String, DeploymentFactory>();
 
-
     /**
      * Executed by NB when the Geronimo deployment factory is required
      * It's the method pointed out by layer.xml file in Factory.instance
@@ -74,17 +74,18 @@
 
     public DeploymentManager getDeploymentManager(String uri, String username, String password) throws DeploymentManagerCreationException {
         if (!handlesURI(uri)) {
-            String errorMsg = NbBundle.getMessage(GeronimoDeploymentFactory.class, "MSG_InvalidUri", uri);
-            throw new DeploymentManagerCreationException(errorMsg);
+            String msg = NbBundle.getMessage(GeronimoDeploymentFactory.class, "MSG_InvalidUri", uri);
+            throw new DeploymentManagerCreationException(msg);
         }
 
         DeploymentFactory df = getFactory(uri);
         if (df == null) {
-            String errorMsg = NbBundle.getMessage(GeronimoDeploymentFactory.class, "MSG_DmInstantiateFailed", uri);
-            throw new DeploymentManagerCreationException(errorMsg);
+            String msg = NbBundle.getMessage(GeronimoDeploymentFactory.class, "MSG_DmInstantiateFailed", uri);
+            throw new DeploymentManagerCreationException(msg);
         }
 
-        return new GeronimoDeploymentManager();
+        DeploymentManager dm = df.getDeploymentManager(uri, username, password);
+        return new GeronimoDeploymentManager(dm, uri);
     }
 
     public DeploymentManager getDisconnectedDeploymentManager(String uri) throws DeploymentManagerCreationException {
@@ -99,11 +100,18 @@
         return NbBundle.getMessage(GeronimoDeploymentFactory.class, "LBL_FactoryVersion");
     }
 
-    private DeploymentFactory getFactory(String instanceURL) {
+    private DeploymentFactory getFactory(String uri) {
         DeploymentFactory factory = null;
         try {
-            String serverDir = "c:/apps/geronimo-tomcat6-jee5-2.0-SNAPSHOT";
+            String serverDir = GeronimoPluginUtils.getInstanceProperties(uri).getProperty(GeronimoPluginProperties.PROPERTY_SERVER_DIR);
 
+            // According to other serverplugins modules:
+            // It happens when we're in a server instance registration process
+            // so InstanceProperties doesn't hold the value, but the singleton does
+            if (serverDir == null) {
+                serverDir = GeronimoPluginProperties.getInstance().getInstallLocation();
+            }
+            
             factory = factories.get(serverDir);
             if (factory == null) {
                 URLClassLoader loader = getGeronimoClassLoader(serverDir);

Modified: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoDeploymentManager.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoDeploymentManager.java?view=diff&rev=558562&r1=558561&r2=558562
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoDeploymentManager.java (original)
+++ geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoDeploymentManager.java Sun Jul 22 15:11:13 2007
@@ -30,12 +30,34 @@
 import javax.enterprise.deploy.spi.exceptions.InvalidModuleException;
 import javax.enterprise.deploy.spi.exceptions.TargetException;
 import javax.enterprise.deploy.spi.status.ProgressObject;
+import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
 
 /**
+ * The DeploymentManager object provides the core set of functions a J2EE platform must provide for J2EE application deployment.
+ * It provides server related information, such as, a list of deployment targets, and vendor unique runtime configuration information.
+ *
  * @version $Rev$ $Date$
  */
 public class GeronimoDeploymentManager implements DeploymentManager {
 
+    private DeploymentManager dm;
+
+    private String uri;
+    
+    private InstanceProperties instanceProperties;
+
+    public GeronimoDeploymentManager(DeploymentManager dm, String uri) {
+        this.dm = dm;
+        this.uri = uri;
+    }
+
+    public InstanceProperties getInstanceProperties() {
+        if (instanceProperties == null) {
+            this.instanceProperties = GeronimoPluginUtils.getInstanceProperties(uri);
+        }
+        return instanceProperties;
+    }
+
     public Target[] getTargets() throws IllegalStateException {
         return null;
     }
@@ -60,13 +82,12 @@
         return null;
     }
 
-    @SuppressWarnings("deprecation")
     public ProgressObject distribute(Target[] target, InputStream is, InputStream is2) throws IllegalStateException {
         return null;
     }
 
-    public ProgressObject distribute(Target[] arg0, ModuleType arg1, InputStream arg2, InputStream arg3) throws IllegalStateException {
-        throw new UnsupportedOperationException("Not supported yet.");
+    public ProgressObject distribute(Target[] target, ModuleType moduleType, InputStream is, InputStream is2) throws IllegalStateException {
+        return null;
     }
 
     public ProgressObject start(TargetModuleID[] targetModuleId) throws IllegalStateException {

Modified: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoInstantiatingIterator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoInstantiatingIterator.java?view=diff&rev=558562&r1=558561&r2=558562
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoInstantiatingIterator.java (original)
+++ geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoInstantiatingIterator.java Sun Jul 22 15:11:13 2007
@@ -48,6 +48,7 @@
 
     private WizardDescriptor.Panel serverLocationPanel;
     private WizardDescriptor wizard;
+    private String installLocation;
 
     public Set instantiate() throws IOException {
         Set<InstanceProperties> result = new HashSet<InstanceProperties>();
@@ -57,9 +58,12 @@
         String password = "password";
         try {
             InstanceProperties ip = InstanceProperties.createInstanceProperties(url, username, password, displayName);
+            ip.setProperty(GeronimoPluginProperties.PROPERTY_SERVER_DIR, installLocation);
             result.add(ip);
         } catch (Exception ex) {
-            logger.log(Level.INFO, ex.getMessage());
+            String msg = NbBundle.getMessage(GeronimoInstantiatingIterator.class, "MSG_InstanceRegistrationFailed", displayName);
+            GeronimoPluginUtils.showInformation(ex.getLocalizedMessage(), msg);
+            logger.log(Level.INFO, ex.getMessage(), ex);
         }
         return result;
     }
@@ -103,5 +107,13 @@
     }
 
     public void removeChangeListener(ChangeListener l) {
+    }
+
+    public void setInstallLocation(String installLocation) {
+        this.installLocation = installLocation;
+    }
+
+    public String getInstallLocation() {
+        return this.installLocation;
     }
 }

Modified: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoOptionalDeploymentManagerFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoOptionalDeploymentManagerFactory.java?view=diff&rev=558562&r1=558561&r2=558562
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoOptionalDeploymentManagerFactory.java (original)
+++ geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoOptionalDeploymentManagerFactory.java Sun Jul 22 15:11:13 2007
@@ -29,7 +29,7 @@
 public class GeronimoOptionalDeploymentManagerFactory extends OptionalDeploymentManagerFactory {
 
     public StartServer getStartServer(DeploymentManager dm) {
-        return new GeronimoStartServer();
+        return new GeronimoStartServer(dm);
     }
 
     public IncrementalDeployment getIncrementalDeployment(DeploymentManager dm) {
@@ -40,6 +40,7 @@
         return null;
     }
 
+    @Override
     public WizardDescriptor.InstantiatingIterator getAddInstanceIterator() {
         return new GeronimoInstantiatingIterator();
     }

Added: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoPluginProperties.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoPluginProperties.java?view=auto&rev=558562
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoPluginProperties.java (added)
+++ geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoPluginProperties.java Sun Jul 22 15:11:13 2007
@@ -0,0 +1,147 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.netbeans;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.openide.filesystems.FileLock;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileSystem;
+import org.openide.filesystems.Repository;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class GeronimoPluginProperties {
+
+    public static final String PROPERTY_SERVER_DIR = "server-dir";
+    public static final String RMI_PORT_NUMBER = "rmiportnumber";
+
+    private static final Logger logger = Logger.getLogger(GeronimoPluginProperties.class.getName());
+
+    private static GeronimoPluginProperties pluginProperties;
+
+    private String installLocation;
+
+    private FileObject propertiesFile;
+
+    public static GeronimoPluginProperties getInstance() {
+        if (pluginProperties == null) {
+            pluginProperties = new GeronimoPluginProperties();
+        }
+        return pluginProperties;
+    }
+
+
+    public String getInstallLocation() {
+        return this.installLocation;
+    }
+
+    public void setInstallLocation(String installLocation) {
+        if (installLocation.endsWith("/") || installLocation.endsWith("\\")) {
+            installLocation = installLocation.substring(0, installLocation.length() - 1);
+        }
+        this.installLocation = installLocation;
+    }
+
+    private GeronimoPluginProperties() {
+        InputStream is = null;
+        try {
+            try {
+                propertiesFile = getPropertiesFile();
+                if (propertiesFile != null) {
+                    is = propertiesFile.getInputStream();
+                }
+            } catch (FileNotFoundException fnfe) {
+                logger.log(Level.INFO, fnfe.getLocalizedMessage(), fnfe);
+            } catch (IOException ioe) {
+                logger.log(Level.INFO, ioe.getLocalizedMessage(), ioe);
+            } finally {
+                loadPluginProperties(is);
+                if (null != is) {
+                    is.close();
+                }
+            }
+        } catch (java.io.IOException e) {
+            logger.log(Level.INFO, e.getLocalizedMessage(), e);
+        }
+    }
+
+    private FileObject getPropertiesFile() throws IOException {
+        FileSystem fs = Repository.getDefault().getDefaultFileSystem();
+        FileObject dir = fs.findResource("J2EE");
+        FileObject retVal = null;
+        if (null != dir) {
+            retVal = dir.getFileObject("geronimo", "properties"); // NOI18N
+            if (null == retVal) {
+                retVal = dir.createData("geronimo", "properties"); // NOI18N
+            }
+        }
+        return retVal;
+    }
+
+    private void loadPluginProperties(java.io.InputStream inStream) {
+        Properties inProps = new Properties();
+        if (null != inStream) {
+            try {
+                inProps.load(inStream);
+            } catch (java.io.IOException e) {
+                logger.log(Level.INFO, e.getLocalizedMessage(), e);
+            }
+        }
+        String loc = inProps.getProperty(PROPERTY_SERVER_DIR);
+        if (loc != null) {
+            setInstallLocation(loc);
+        }
+    }
+
+    public void saveProperties() {
+        Properties outProp = new Properties();
+        String installRoot = getInstallLocation();
+        if (installRoot != null) {
+            outProp.setProperty(PROPERTY_SERVER_DIR, installRoot);
+        }
+        FileLock l = null;
+        java.io.OutputStream outStream = null;
+        try {
+            if (null != propertiesFile) {
+                try {
+                    l = propertiesFile.lock();
+                    outStream = propertiesFile.getOutputStream(l);
+                    if (null != outStream) {
+                        outProp.store(outStream, "");
+                    }
+                } catch (IOException ioe) {
+                    logger.log(Level.INFO, ioe.getLocalizedMessage(), ioe);
+                } finally {
+                    if (null != outStream) {
+                        outStream.close();
+                    }
+                    if (null != l) {
+                        l.releaseLock();
+                    }
+                }
+            }
+        } catch (IOException ioe) {
+            logger.log(Level.INFO, ioe.getLocalizedMessage(), ioe);
+        }
+    }
+}

Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoPluginProperties.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoPluginProperties.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoPluginProperties.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoPluginProperties.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoPluginUtils.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoPluginUtils.java?view=diff&rev=558562&r1=558561&r2=558562
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoPluginUtils.java (original)
+++ geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoPluginUtils.java Sun Jul 22 15:11:13 2007
@@ -17,15 +17,27 @@
 package org.apache.geronimo.netbeans;
 
 import java.io.File;
+import java.io.IOException;
+import java.net.ServerSocket;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.SwingUtilities;
+import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceCreationException;
+import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
+import org.openide.DialogDisplayer;
+import org.openide.NotifyDescriptor;
+import org.openide.util.NbBundle;
 
 /**
  * @version $Rev$ $Date$
  */
 public class GeronimoPluginUtils {
 
+    private static final Logger logger = Logger.getLogger(GeronimoPluginUtils.class.getName());
+
     private static List<String> serverRequirements = new LinkedList<String>();
     static {
         serverRequirements.add("bin");
@@ -73,5 +85,52 @@
             }
         }
         return true;
+    }
+
+    public static InstanceProperties getInstanceProperties(String uri) {
+        return getInstanceProperties(uri, null, null, null);
+    }
+
+    public static InstanceProperties getInstanceProperties(String url, String user, String password, String name) {
+        InstanceProperties instanceProperties = InstanceProperties.getInstanceProperties(url);
+        // FIXME: Might it ever happen that instanceProperties, user, password, name are all null?
+        if (instanceProperties == null) {
+            try {
+                instanceProperties = InstanceProperties.createInstanceProperties(url, user, password, name);
+            } catch (InstanceCreationException ice) {
+                // it must not happen
+                // it's thrown only when instance with same url is already registered, but it's just been checked
+                String msg = NbBundle.getMessage(GeronimoPluginUtils.class, "MSG_ExceptionThrownButShouldHaveNot", ice.getClass().getName(), ice.getLocalizedMessage());
+                logger.log(Level.WARNING, msg, ice);
+            }
+        }
+        return instanceProperties;
+    }
+
+    public static boolean isPortFree(int port) {
+        ServerSocket soc = null;
+        try {
+            soc = new ServerSocket(port);
+        } catch (IOException ioe) {
+            return false;
+        } finally {
+            if (soc != null) {
+                try {
+                    soc.close();
+                } catch (IOException ignored) {
+                }
+            }
+        }
+        return true;
+    }
+
+    public static void showInformation(final String msg, final String title) {
+        SwingUtilities.invokeLater(new Runnable() {
+            public void run() {
+                NotifyDescriptor d = new NotifyDescriptor.Message(msg, NotifyDescriptor.INFORMATION_MESSAGE);
+                d.setTitle(title);
+                DialogDisplayer.getDefault().notify(d);
+            }
+        });
     }
 }

Modified: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoStartServer.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoStartServer.java?view=diff&rev=558562&r1=558561&r2=558562
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoStartServer.java (original)
+++ geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoStartServer.java Sun Jul 22 15:11:13 2007
@@ -16,26 +16,61 @@
  */
 package org.apache.geronimo.netbeans;
 
+import java.io.File;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.enterprise.deploy.shared.StateType;
+import javax.enterprise.deploy.spi.DeploymentManager;
 import javax.enterprise.deploy.spi.Target;
 import javax.enterprise.deploy.spi.status.ProgressObject;
+import org.apache.geronimo.netbeans.status.GeronimoProgressObject;
+import org.apache.geronimo.netbeans.util.GeronimoTailer;
+import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
 import org.netbeans.modules.j2ee.deployment.plugins.api.ServerDebugInfo;
 import org.netbeans.modules.j2ee.deployment.plugins.spi.StartServer;
+import org.openide.execution.NbProcessDescriptor;
+import org.openide.util.NbBundle;
+import org.openide.util.RequestProcessor;
+import org.openide.util.Utilities;
 
 /**
  * @version $Rev$ $Date$
  */
 public class GeronimoStartServer extends StartServer {
 
+    enum ACTION_STATUS {
+        SUCCESS, FAILURE, UNKNOWN
+    }
+
+    private GeronimoDeploymentManager dm;
+
+    public GeronimoStartServer(DeploymentManager dm) {
+        if (!(dm instanceof GeronimoDeploymentManager)) {
+            String msg = NbBundle.getMessage(GeronimoStartServer.class, "MSG_UnknownDeploymentManagerType", dm);
+            throw new IllegalArgumentException(msg);
+        }
+        this.dm = (GeronimoDeploymentManager) dm;
+    }
+
     public boolean isAlsoTargetServer(Target target) {
-        return false;
+        return true;
     }
 
     public boolean supportsStartDeploymentManager() {
-        return false;
+        return true;
     }
 
     public ProgressObject startDeploymentManager() {
-        return null;
+        GeronimoProgressObject progressObject = new GeronimoProgressObject(this);
+
+        String serverName = dm.getInstanceProperties().getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
+        String msg = NbBundle.getMessage(GeronimoStartServer.class, "MSG_StartServerInProgress", serverName);
+
+        progressObject.changeState(StateType.RUNNING, msg);
+
+        RequestProcessor.getDefault().post(new GeronimoStartRunnable(progressObject), 0, Thread.NORM_PRIORITY);
+
+        return progressObject;
     }
 
     public ProgressObject stopDeploymentManager() {
@@ -70,4 +105,137 @@
         return null;
     }
 
+    private class GeronimoStartRunnable implements Runnable {
+
+        private static final String STARTUP_SH = "/bin/geronimo.sh";
+        private static final String STARTUP_BAT = "/bin/geronimo.bat";
+
+        /**
+         * How long the thread will wait till the server has started up
+         */
+        private static final int TIMEOUT = 900000;
+
+        /**
+         * How long the thread will wait before doing its stuff again
+         */
+        private static final int DELAY = 5000;
+
+        private final Logger logger = Logger.getLogger(GeronimoStartRunnable.class.getName());
+
+        private GeronimoProgressObject progressObject;
+
+        public GeronimoStartRunnable(GeronimoProgressObject progressObject) {
+            this.progressObject = progressObject;
+        }
+
+        public void run() {
+            InstanceProperties ip = dm.getInstanceProperties();
+
+            if (!checkPorts(ip)) {
+                return;
+            }
+
+            final long startTime = System.currentTimeMillis();
+
+            Process serverProcess = createProcess(ip);
+            if (serverProcess == null) {
+                return;
+            }
+
+            // dm.getInstanceProperties().getProperty(InstanceProperties.DISPLAY_NAME_ATTR)
+            final String uri = dm.getInstanceProperties().getProperty(InstanceProperties.URL_ATTR);
+            GeronimoTailer tailer = new GeronimoTailer(serverProcess.getInputStream(), uri);
+            tailer.run();
+
+            String serverName = dm.getInstanceProperties().getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
+
+            while (System.currentTimeMillis() - startTime < TIMEOUT) {
+                try {
+                    serverProcess.exitValue(); // it throws exception when the subprocess finished; that's how we know it's started up
+                    try {
+                        Thread.sleep(DELAY);
+                    } catch (InterruptedException e) {
+                    }
+                } catch (IllegalThreadStateException itse) {
+                    fireStateChange(StateType.COMPLETED, NbBundle.getMessage(GeronimoStartServer.class, "MSG_ServerStarted", serverName));
+                    return;
+                }
+            }
+            fireStateChange(StateType.FAILED, NbBundle.getMessage(GeronimoStartServer.class, "MSG_StartServerTimeout"));
+        }
+
+        private boolean checkPorts(final InstanceProperties ip) {
+
+            try {
+                String serverName = ip.getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
+
+                String httpPortStr = ip.getProperty(InstanceProperties.HTTP_PORT_NUMBER);
+                int httpPort = new Integer(httpPortStr).intValue();
+                if (!GeronimoPluginUtils.isPortFree(httpPort)) {
+                    String msg = NbBundle.getMessage(GeronimoStartServer.class, "MSG_HttpPortInUse", serverName, httpPort);
+                    progressObject.changeState(StateType.FAILED, msg);
+                    return false;
+                }
+
+                String rmiPortStr = ip.getProperty(GeronimoPluginProperties.RMI_PORT_NUMBER);
+                int rmiPort = new Integer(rmiPortStr).intValue();
+                if (!GeronimoPluginUtils.isPortFree(rmiPort)) {
+                    String msg = NbBundle.getMessage(GeronimoStartServer.class, "MSG_RmiPortInUse", serverName, rmiPort);
+                    progressObject.changeState(StateType.FAILED, msg);
+                    return false;
+                }
+            } catch (NumberFormatException ignored) {
+                // continue and let server to report the problem
+            }
+            return true;
+        }
+
+        private Process createProcess(InstanceProperties ip) {
+
+            NbProcessDescriptor pd = createProcessDescriptor(ip);
+            if (pd == null) {
+                return null;
+            }
+
+            //String[] envp = createEnvironment(ip);
+            String[] envp = null;
+
+            try {
+                return pd.exec(null, envp, true, null);
+            } catch (java.io.IOException ioe) {
+                logger.log(Level.INFO, ioe.getLocalizedMessage(), ioe);
+
+                final String serverLocation = ip.getProperty(GeronimoPluginProperties.PROPERTY_SERVER_DIR);
+                final String serverRunFileName = serverLocation + (Utilities.isWindows() ? STARTUP_BAT : STARTUP_SH);
+
+                String serverName = ip.getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
+
+                String msg = NbBundle.getMessage(GeronimoStartServer.class, "MSG_ProcessExecutionFailed", serverName, serverRunFileName);
+                progressObject.changeState(StateType.FAILED, msg);
+
+                return null;
+            }
+        }
+
+        private NbProcessDescriptor createProcessDescriptor(InstanceProperties ip) {
+
+            final String serverLocation = ip.getProperty(GeronimoPluginProperties.PROPERTY_SERVER_DIR);
+            final String serverRunFileName = serverLocation + (Utilities.isWindows() ? STARTUP_BAT : STARTUP_SH);
+            if (!new File(serverRunFileName).exists()) {
+                final String serverName = ip.getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
+                String msg = NbBundle.getMessage(GeronimoStartServer.class, "MSG_StartupScriptNotFound", serverName, serverRunFileName);
+                progressObject.changeState(StateType.FAILED, msg);
+                return null;
+            }
+            String args = "run -vv";
+            return new NbProcessDescriptor(serverRunFileName, args);
+        }
+
+        private void fireStateChange(StateType stateType, String messageKey, String... msgParam) {
+            InstanceProperties ip = dm.getInstanceProperties();
+            final String serverName = ip.getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
+            String msg = NbBundle.getMessage(GeronimoStartServer.class, messageKey, serverName, msgParam);
+            progressObject.changeState(stateType, msg);
+        }
+    }
 }

Added: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/Bundle.properties
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/Bundle.properties?view=auto&rev=558562
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/Bundle.properties (added)
+++ geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/Bundle.properties Sun Jul 22 15:11:13 2007
@@ -0,0 +1,20 @@
+#=====================================================================
+#  Licensed to the Apache Software Foundation (ASF) under one or more
+#  contributor license agreements.  See the NOTICE file distributed with
+#  this work for additional information regarding copyright ownership.
+#  The ASF licenses this file to You under the Apache License, Version 2.0
+#  (the "License"); you may not use this file except in compliance with
+#  the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#=====================================================================
+#
+# $Rev$ $Date$
+#
+MSG_OperationNotSupported=Operation not supported

Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/Bundle.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/Bundle.properties
------------------------------------------------------------------------------
    svn:executable = *

Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/Bundle.properties
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/Bundle.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/GeronimoDeploymentStatus.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/GeronimoDeploymentStatus.java?view=auto&rev=558562
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/GeronimoDeploymentStatus.java (added)
+++ geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/GeronimoDeploymentStatus.java Sun Jul 22 15:11:13 2007
@@ -0,0 +1,70 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.netbeans.status;
+
+import javax.enterprise.deploy.shared.ActionType;
+import javax.enterprise.deploy.shared.CommandType;
+import javax.enterprise.deploy.shared.StateType;
+import javax.enterprise.deploy.spi.status.DeploymentStatus;
+
+/**
+ * The DeploymentStatus interface provides information about the progress status of a deployment action.
+ *
+ * @version $Rev$ $Date$
+ */
+public class GeronimoDeploymentStatus implements DeploymentStatus {
+
+    private ActionType action;
+    private CommandType command;
+    private StateType state;
+    private String message;
+
+    public GeronimoDeploymentStatus(ActionType action, CommandType command, StateType state, String message) {
+        this.action = action;
+        this.command = command;
+        this.state = state;
+        this.message = message;
+    }
+    
+    public boolean isCompleted() {
+        return StateType.COMPLETED == state;
+    }
+
+    public boolean isFailed() {
+        return StateType.FAILED == state;
+    }
+
+    public boolean isRunning() {
+        return StateType.RUNNING == state;
+    }
+
+    public StateType getState() {
+        return this.state;
+    }
+
+    public CommandType getCommand() {
+        return this.command;
+    }
+
+    public ActionType getAction() {
+        return this.action;
+    }
+
+    public String getMessage() {
+        return this.message;
+    }
+}

Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/GeronimoDeploymentStatus.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/GeronimoDeploymentStatus.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/GeronimoDeploymentStatus.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/GeronimoDeploymentStatus.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/GeronimoProgressObject.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/GeronimoProgressObject.java?view=auto&rev=558562
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/GeronimoProgressObject.java (added)
+++ geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/GeronimoProgressObject.java Sun Jul 22 15:11:13 2007
@@ -0,0 +1,111 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.netbeans.status;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+import javax.enterprise.deploy.shared.ActionType;
+import javax.enterprise.deploy.shared.CommandType;
+import javax.enterprise.deploy.shared.StateType;
+import javax.enterprise.deploy.spi.TargetModuleID;
+import javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException;
+import javax.enterprise.deploy.spi.status.ClientConfiguration;
+import javax.enterprise.deploy.spi.status.DeploymentStatus;
+import javax.enterprise.deploy.spi.status.ProgressEvent;
+import javax.enterprise.deploy.spi.status.ProgressListener;
+import javax.enterprise.deploy.spi.status.ProgressObject;
+import org.openide.util.NbBundle;
+
+/**
+ * The ProgressObject interface tracks and reports the progress of the deployment activities, distribute, start, stop, undeploy.
+ *
+ * @version $Rev$ $Date$
+ */
+public class GeronimoProgressObject implements ProgressObject {
+
+    private Object source;
+
+    private DeploymentStatus deploymentStatus;
+
+    private List<ProgressListener> listeners = new Vector<ProgressListener>();
+
+    public GeronimoProgressObject(Object source) {
+        this.source = source;
+    }
+
+    public void changeState(StateType state, String message) {
+        fireProgressEvent(new GeronimoDeploymentStatus(ActionType.EXECUTE, CommandType.START, state, message));
+    }
+
+    private void fireProgressEvent(DeploymentStatus deploymentStatus) {
+        ProgressEvent evt = new ProgressEvent(source, null, deploymentStatus);
+
+        this.deploymentStatus = deploymentStatus;
+
+        Iterator<ProgressListener> iterator = null;
+        synchronized (this) {
+            if (listeners != null) {
+                iterator = new ArrayList<ProgressListener>(listeners).iterator();
+            }
+        }
+        if (iterator != null) {
+            while (iterator.hasNext()) {
+                iterator.next().handleProgressEvent(evt);
+            }
+        }
+    }
+
+    public DeploymentStatus getDeploymentStatus() {
+        return deploymentStatus;
+    }
+
+    public TargetModuleID[] getResultTargetModuleIDs() {
+        return new TargetModuleID[0];
+    }
+
+    public ClientConfiguration getClientConfiguration(TargetModuleID targetModuleId) {
+        return null;
+    }
+
+    public boolean isCancelSupported() {
+        return false;
+    }
+
+    public void cancel() throws OperationUnsupportedException {
+        String msg = NbBundle.getMessage(GeronimoProgressObject.class, "MSG_OperationNotSupported");
+        throw new UnsupportedOperationException(msg);
+    }
+
+    public boolean isStopSupported() {
+        return false;
+    }
+
+    public void stop() throws OperationUnsupportedException {
+        String msg = NbBundle.getMessage(GeronimoProgressObject.class, "MSG_OperationNotSupported");
+        throw new UnsupportedOperationException(msg);
+    }
+
+    public void addProgressListener(ProgressListener progressListener) {
+        listeners.add(progressListener);
+    }
+
+    public void removeProgressListener(ProgressListener progressListener) {
+        listeners.remove(progressListener);
+    }
+}

Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/GeronimoProgressObject.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/GeronimoProgressObject.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/GeronimoProgressObject.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/GeronimoProgressObject.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/util/GeronimoTailer.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/util/GeronimoTailer.java?view=auto&rev=558562
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/util/GeronimoTailer.java (added)
+++ geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/util/GeronimoTailer.java Sun Jul 22 15:11:13 2007
@@ -0,0 +1,97 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.netbeans.util;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.netbeans.modules.j2ee.deployment.plugins.api.UISupport;
+import org.openide.windows.InputOutput;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class GeronimoTailer extends Thread {
+
+    private static final Logger logger = Logger.getLogger(GeronimoTailer.class.getName());
+    /**
+     * Input stream to be sent to a console referenced by io
+     */
+    private InputStream inputStream;
+
+    /**
+     * Console window in/out
+     */
+    private InputOutput io;
+
+    /**
+     * Delay between checking for file content changes
+     */
+    private static final int delay = 1000;
+
+    public GeronimoTailer(InputStream inputStream, String uri) {
+        super();
+        this.inputStream = inputStream;
+        io = UISupport.getServerIO(uri);
+        if (io == null) {
+            return; // null if there is no registered server instance with the given url.
+        }
+        try {
+            // Clear the output pane
+            io.getOut().reset();
+        } catch (IOException ioe) {
+        }
+        // Ensure this pane is visible.
+        io.select();
+    }
+
+    /**
+     * Do the tailing
+     */
+    @Override
+    public void run() {
+        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
+        try {
+            String line;
+            while (!io.isClosed()) {
+                while (reader.ready()) {
+                    line = reader.readLine();
+                    if (line != null) {
+                        io.getOut().println(line);
+                        io.getOut().flush();
+                    }
+                }
+                try {
+                    Thread.sleep(delay);
+                } catch (InterruptedException e) {
+                    // do nothing
+                }
+            }
+        } catch (IOException ioe) {
+            logger.log(Level.WARNING, ioe.getLocalizedMessage(), ioe);
+        } finally {
+            try {
+                inputStream.close();
+            } catch (IOException ioe) {
+                logger.log(Level.WARNING, ioe.getLocalizedMessage(), ioe);
+            }
+        }
+    }
+}

Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/util/GeronimoTailer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/util/GeronimoTailer.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/util/GeronimoTailer.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/util/GeronimoTailer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/wizard/GeronimoServerLocationPanel.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/wizard/GeronimoServerLocationPanel.java?view=diff&rev=558562&r1=558561&r2=558562
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/wizard/GeronimoServerLocationPanel.java (original)
+++ geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/wizard/GeronimoServerLocationPanel.java Sun Jul 22 15:11:13 2007
@@ -37,6 +37,7 @@
 import javax.swing.event.ChangeListener;
 import javax.swing.filechooser.FileFilter;
 import org.apache.geronimo.netbeans.GeronimoInstantiatingIterator;
+import org.apache.geronimo.netbeans.GeronimoPluginProperties;
 import org.apache.geronimo.netbeans.GeronimoPluginUtils;
 import org.openide.WizardDescriptor;
 import org.openide.util.HelpCtx;
@@ -85,7 +86,7 @@
 
         setName(steps[selectedIndex]);
 
-        init();
+        initVisuals();
     }
 
     public Component getComponent() {
@@ -108,13 +109,18 @@
     public boolean isValid() {
         wizardDescriptor.putProperty(PROP_ERROR_MESSAGE, null);
 
-        File serverLocation = new File(locationField.getText());
+        String serverLocation = locationField.getText();
+        
+        File serverLocationFile = new File(locationField.getText());
 
-        if (!GeronimoPluginUtils.isValidServerLocation(serverLocation)) {
+        if (!GeronimoPluginUtils.isValidServerLocation(serverLocationFile)) {
             String msg = NbBundle.getMessage(GeronimoServerLocationPanel.class, "ERR_InvalidServerLocation");
             wizardDescriptor.putProperty(PROP_ERROR_MESSAGE, msg);
             return false;
         }
+        GeronimoPluginProperties.getInstance().setInstallLocation(serverLocation);
+        GeronimoPluginProperties.getInstance().saveProperties();
+        instantiatingIterator.setInstallLocation(serverLocation);
         return true;
     }
 
@@ -142,7 +148,7 @@
     /**
      * Initializes the panel
      */
-    private void init() {
+    private void initVisuals() {
         final JLabel locationLabel = new JLabel();
         final JButton locationBrowseButton = new JButton();
         final JPanel formattingPanel = new JPanel();



Mime
View raw message