Exemplo n.º 1
0
 /** Return the default Tomcat Java endorsed directory. */
 public File getJavaEndorsedDir() {
   if (TomcatVersion.TOMCAT_60 == tm.getTomcatVersion()
       || TomcatVersion.TOMCAT_70 == tm.getTomcatVersion()) {
     return new File(getCatalinaHome(), "endorsed"); // NOI18N
   } else {
     return new File(getCatalinaHome(), "common/endorsed"); // NOI18N
   }
 }
Exemplo n.º 2
0
 /** Returns the folder where the HTTP Monitor jar files should be placed */
 public File getMonitorLibFolder() {
   if (tm.isBundledTomcat()) {
     return new File(baseDir, "nblib"); // NOI18N
   }
   return tm.isTomcat60() || tm.isTomcat70()
       ? new File(homeDir, "lib") // NOI18N
       : new File(homeDir, "common/lib"); // NOI18N
 }
Exemplo n.º 3
0
 /**
  * Unique instance identifier used to differentiate different Tomcat instances in a human-readable
  * form, unlike InstanceProperties.URL_ATTR.
  */
 private String getInstanceID() {
   String name = ip.getProperty(PROP_INSTANCE_ID);
   if (name != null) {
     return name;
   }
   // generate unique tomcat instance identifier (e.g. tomcat55, tomcat55_1, ...
   // for Tomcat 5.5.x and tomcat50, tomcat50_1... for Tomcat 5.0.x)
   String prefix;
   String serverID;
   switch (tm.getTomcatVersion()) {
     case TOMCAT_70:
       prefix = "tomcat70"; // NIO18N
       serverID = TomcatFactory.SERVER_ID_70;
       break;
     case TOMCAT_60:
       prefix = "tomcat60"; // NIO18N
       serverID = TomcatFactory.SERVER_ID_60;
       break;
     case TOMCAT_55:
       prefix = "tomcat55"; // NIO18N
       serverID = TomcatFactory.SERVER_ID_55;
       break;
     case TOMCAT_50:
     default:
       prefix = "tomcat50"; // NIO18N
       serverID = TomcatFactory.SERVER_ID_50;
   }
   String[] instanceURLs = Deployment.getDefault().getInstancesOfServer(serverID);
   for (int i = 0; name == null; i++) {
     if (i == 0) {
       name = prefix;
     } else {
       name = prefix + "_" + i; // NOI18N
     }
     for (String url : instanceURLs) {
       if (!tm.getUri().equals(url)) {
         InstanceProperties ip = InstanceProperties.getInstanceProperties(url);
         if (ip != null) {
           String anotherName = ip.getProperty(PROP_INSTANCE_ID);
           if (name.equals(anotherName)) {
             name = null;
             break;
           }
         }
       }
     }
   }
   ip.setProperty(PROP_INSTANCE_ID, name);
   return name;
 }
Exemplo n.º 4
0
  public List /*<URL>*/ getClasses() {
    String[] nbFilter =
        new String[] {
          "httpmonitor",
          "schema2beans",
          /*
           * The following two jars contains eclipse JDT parser. We have to
           * exclude it to not to clash with our jsp parser. See issue #115529.
           */
          "jasper-compiler-jdt",
          "jasper-jdt"
        };

    String[] implFilter = new String[] {"-impl.jar"};

    // tomcat libs
    List retValue = listUrls(new File(homeDir, tm.libFolder()), nbFilter); // NOI18N

    if (tm.isTomcat60()) {
      try {
        retValue.add(new File(homeDir, "bin/tomcat-juli.jar").toURI().toURL()); // NOI18N
      } catch (MalformedURLException e) {
        LOGGER.log(Level.WARNING, "$CATALINA_HOME/bin/tomcat-juli.jar not found", e); // NOI18N
      }
    }

    // wsit
    retValue.addAll(listUrls(new File(homeDir, "common/endorsed"), implFilter)); // NOI18N
    retValue.addAll(listUrls(new File(homeDir, "shared/lib"), implFilter)); // NOI18N

    // jwsdp libs
    retValue.addAll(listUrls(new File(homeDir, "jaxws/lib"), implFilter)); // NOI18N
    retValue.addAll(listUrls(new File(homeDir, "jaxb/lib"), implFilter)); // NOI18N
    retValue.addAll(listUrls(new File(homeDir, "jwsdp-shared/lib"), implFilter)); // NOI18N
    retValue.addAll(listUrls(new File(homeDir, "jaxp/lib"), implFilter)); // NOI18N
    retValue.addAll(listUrls(new File(homeDir, "jaxrpc/lib"), implFilter)); // NOI18N
    retValue.addAll(listUrls(new File(homeDir, "jaxr/lib"), implFilter)); // NOI18N
    retValue.addAll(listUrls(new File(homeDir, "saaj/lib"), implFilter)); // NOI18N
    retValue.addAll(listUrls(new File(homeDir, "sjsxp/lib"), implFilter)); // NOI18N

    // other
    retValue.addAll(listUrls(new File(homeDir, "jstl/lib"), implFilter)); // NOI18N
    retValue.addAll(listUrls(new File(baseDir, "shared/lib"), nbFilter)); // NOI18N
    return retValue;
  }
Exemplo n.º 5
0
 public int getShutdownPort() {
   String val = ip.getProperty(PROP_SHUTDOWN);
   if (val != null) {
     try {
       int port = Integer.parseInt(val);
       if (port >= 0 && port <= 65535) {
         return port;
       }
     } catch (NumberFormatException nfe) {
       Logger.getLogger(TomcatProperties.class.getName()).log(Level.INFO, null, nfe);
     }
   }
   return tm.isBundledTomcat() ? DEF_VALUE_BUNDLED_SHUTDOWN_PORT : DEF_VALUE_SHUTDOWN_PORT;
 }
Exemplo n.º 6
0
  public int getDebugPort() {
    String val = ip.getProperty(PROP_DEBUG_PORT);

    if (val != null) {
      try {
        return Integer.parseInt(val);
      } catch (NumberFormatException nfe) {
        Logger.getLogger(TomcatProperties.class.getName()).log(Level.INFO, null, nfe);
      }
    }

    if (tm.isBundledTomcat()) {
      return DEF_VALUE_DEBUG_PORT_BUNDLED;
    } else {
      return DEF_VALUE_DEBUG_PORT;
    }
  }
Exemplo n.º 7
0
 public void setJavadocs(List /*<URL>*/ path) {
   ip.setProperty(PROP_JAVADOCS, CustomizerSupport.buildPath(path));
   tm.getTomcatPlatform().notifyLibrariesChanged();
 }
Exemplo n.º 8
0
 public void setSources(List /*<URL>*/ path) {
   ip.setProperty(PROP_SOURCES, CustomizerSupport.buildPath(path));
   tm.getTomcatPlatform().notifyLibrariesChanged();
 }
Exemplo n.º 9
0
 /** Returns the lib directory where for example the JDBC drivers should be deployed. */
 public File getLibsDir() {
   String libsDir = tm.isTomcat50() || tm.isTomcat55() ? "common/lib" : "lib"; // NOI18N
   return new File(getCatalinaHome(), libsDir);
 }
Exemplo n.º 10
0
  /** Creates a new instance of TomcatProperties */
  public TomcatProperties(TomcatManager tm) throws IllegalArgumentException {
    this.tm = tm;
    this.ip = tm.getInstanceProperties();
    String catalinaHome = null;
    String catalinaBase = null;
    String uri = ip.getProperty(PROP_URL); // NOI18N
    final String home = "home="; // NOI18N
    final String base = ":base="; // NOI18N
    final String uriString = "http://"; // NOI18N
    int uriOffset = uri.indexOf(uriString);
    int homeOffset = uri.indexOf(home) + home.length();
    int baseOffset = uri.indexOf(base, homeOffset);
    if (homeOffset >= home.length()) {
      int homeEnd = baseOffset > 0 ? baseOffset : (uriOffset > 0 ? uriOffset - 1 : uri.length());
      int baseEnd = uriOffset > 0 ? uriOffset - 1 : uri.length();
      catalinaHome = uri.substring(homeOffset, homeEnd);
      if (baseOffset > 0) {
        catalinaBase = uri.substring(baseOffset + base.length(), baseEnd);
      }
      // Bundled Tomcat home and base dirs can be specified as attributes
      // specified in BUNDLED_TOMCAT_SETTING file. Tomcat manager URL can
      // then look like "tomcat:home=$bundled_home:base=$bundled_base" and
      // therefore remains valid even if Tomcat version changes. (issue# 40659)
      if (catalinaHome.length() > 0 && catalinaHome.charAt(0) == '$') {
        FileObject fo = FileUtil.getConfigFile(BUNDLED_TOMCAT_SETTING);
        if (fo != null) {
          catalinaHome = fo.getAttribute(catalinaHome.substring(1)).toString();
          if (catalinaBase != null && catalinaBase.length() > 0 && catalinaBase.charAt(0) == '$') {
            catalinaBase = fo.getAttribute(catalinaBase.substring(1)).toString();
          }
        }
      }
    }
    if (catalinaHome == null) {
      throw new IllegalArgumentException("CATALINA_HOME must not be null."); // NOI18N
    }
    homeDir = new File(catalinaHome);
    if (!homeDir.isAbsolute()) {
      InstalledFileLocator ifl = InstalledFileLocator.getDefault();
      homeDir = ifl.locate(catalinaHome, null, false);
    }
    if (!homeDir.exists()) {
      throw new IllegalArgumentException("CATALINA_HOME directory does not exist."); // NOI18N
    }
    if (catalinaBase != null) {
      baseDir = new File(catalinaBase);
      if (!baseDir.isAbsolute()) {
        InstalledFileLocator ifl = InstalledFileLocator.getDefault();
        baseDir = ifl.locate(catalinaBase, null, false);
        if (baseDir == null) {
          baseDir = new File(System.getProperty("netbeans.user"), catalinaBase); // NOI18N
        }
      }
    }

    //        //parse the old format for backward compatibility
    //        if (uriOffset > 0) {
    //            String theUri = uri.substring (uriOffset + uriString.length ());
    //            int portIndex = theUri.indexOf (':');
    //            String host = theUri.substring (0, portIndex - 1);
    //            setHost (host);
    //            //System.out.println("host:"+host);
    //            int portEnd = theUri.indexOf ('/');
    //            portEnd = portEnd > 0 ? portEnd : theUri.length ();
    //            String port = theUri.substring (portIndex, portEnd - 1);
    //            //System.out.println("port:"+port);
    //            try {
    //                setServerPort (Integer.valueOf (port));
    //            } catch (NumberFormatException nef) {
    //                org.openide.ErrorManager.getDefault ().log (nef.getLocalizedMessage ());
    //            }
    //        }
    ip.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent evt) {
            String name = evt.getPropertyName();
            if (PROP_SERVER_PORT.equals(name)
                || PROP_USERNAME.equals(name)
                || PROP_PASSWORD.equals(name)) {
              // update Ant deployment properties file if it exists
              try {
                storeAntDeploymentProperties(getAntDeploymentPropertiesFile(), false);
              } catch (IOException ioe) {
                Logger.getLogger(TomcatProperties.class.getName()).log(Level.INFO, null, ioe);
              }
            }
          }
        });
  }