<%@ page session="false" import="java.io.File, java.io.IOException, java.net.URL, java.net.JarURLConnection, java.sql.Connection, java.sql.ResultSet, java.sql.Statement, java.util.Properties, java.util.Iterator, java.util.SortedSet, java.util.TreeSet, javax.naming.Context, javax.naming.InitialContext, javax.sql.DataSource, org.apache.juddi.registry.RegistryServlet, org.apache.juddi.registry.RegistryEngine" %> <% /* * Copyright 2002,2004 The Apache Software Foundation. * * Licensed 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. */ %> <%! /** * Look for the named class in the classpath * * @param name of the class to lookup * @return the location of the named class * @throws IOException */ String lookupClass(String className) throws IOException { // load the class (if it exists) Class clazz = null; try { clazz = Class.forName(className); if (clazz == null) return null; } catch (ClassNotFoundException e) { return null; } // class was found, now get it's URL URL url = null; try { url = clazz.getProtectionDomain().getCodeSource().getLocation(); if (url == null) return ""; } catch(Throwable t) { return ""; } // got the classes URL, now determine it's location String location = getLocation(url); if (location == null) return ""; else return location; } /** * Look for the named resource or properties file. * * @param resourceName * @return true if the file was found */ String lookupResource(String resourceName) { URL url = null; ClassLoader classLoader = null; classLoader = this.getClass().getClassLoader(); if (classLoader != null) { url = classLoader.getResource(resourceName); if (url != null) { return getLocation(url); } } else { classLoader = System.class.getClassLoader(); if (classLoader != null) { url = classLoader.getResource(resourceName); if (url != null) { return getLocation(url); } } } return null; } /** * Determine the location of the Java class. * * @param clazz * @return the file path to the jar file or class * file where the class was located. */ String getLocation(URL url) { try { String location = url.toString(); if (location.startsWith("jar:file:/")) { File file = new File(url.getFile()); return file.getPath().substring(6); } else if (location.startsWith("jar")) { url = ((JarURLConnection)url.openConnection()).getJarFileURL(); return url.toString(); } else if (location.startsWith("file")) { File file = new File(url.getFile()); return file.getAbsolutePath(); } else { return url.toString(); } } catch (Throwable t) { return null; } } %> jUDDI Happiness Page

jUDDI

Happy jUDDI!

jUDDI Version Information

jUDDI Version: <%= org.apache.juddi.util.Release.getRegistryVersion() %>
UDDI Version:  <%= org.apache.juddi.util.Release.getUDDIVersion() %>

jUDDI Dependencies: Class Files & Libraries

<%
     //creates the schema if not there
    RegistryEngine registry = RegistryServlet.getRegistry();
    registry.init();
    String[] classArray = {
      "org.apache.juddi.IRegistry",
      "org.apache.commons.logging.Log",
      "org.apache.log4j.Layout",
      "javax.xml.soap.SOAPMessage",
      "javax.xml.rpc.Service",
      "com.ibm.wsdl.factory.WSDLFactoryImpl",
      "javax.xml.parsers.SAXParserFactory"
    };
    
    for (int i=0; iLooking for: "+classArray[i]+"
"); String result = lookupClass(classArray[i]); if (result == null) { out.write("-Not Found
"); } else if (result.length() == 0) { out.write("+Found in an unknown location
"); } else { out.write("+Found in: "+ result +"
"); } } %>

jUDDI Dependencies: Resource & Properties Files

<%
    String[] resourceArray = {
      //"log4j.xml"
    };
    
    for (int i=0; iLooking for: "+resourceArray[i]+"
"); String result = lookupResource(resourceArray[i]); if (result == null) { out.write("-Not Found
"); } else if (result.length() == 0) { out.write("+Found in an unknown location
"); } else { out.write("+Found in: "+ result +"
"); } } %>

jUDDI DataSource Validation

<%
  String dsname = null;
  Context ctx = null;
  DataSource ds = null;
  Connection conn = null;
  String sql = "SELECT COUNT(*) FROM PUBLISHER";
  
  try
  {
    dsname = request.getParameter("dsname");
    if ((dsname == null) || (dsname.trim().length() == 0))
      dsname = "java:comp/env/jdbc/juddiDB";
    
    ctx = new InitialContext();
    if (ctx == null )
      throw new Exception("No Context");
  
    out.print("");
    out.print("+ Got a JNDI Context!");
    out.println("");
  }
  catch(Exception ex)
  {
    out.print("");
    out.print("- No JNDI Context ("+ex.getMessage()+")");
    out.println("");
  }

  try
  {
    ds = (DataSource)ctx.lookup(dsname);
    if (ds == null)
      throw new Exception("No Context");

    out.print("");
    out.print("+ Got a JDBC DataSource (dsname="+dsname+")");
    out.println("");
  }
  catch(Exception ex)
  {
    out.print("");
    out.print("- No '"+dsname+"' DataSource Located("+ex.getMessage()+")");
    out.println("");
  }
  
  try
  {
    conn = ds.getConnection();
    if (conn == null)
    throw new Exception("No Connection (conn=null)");  

    out.print("");
    out.print("+ Got a JDBC Connection!");
    out.println("");
  }
  catch(Exception ex)
  {
    out.print("");
    out.print("- DB connection was not acquired. ("+ex.getMessage()+")");
    out.println("");
  }
  
  try
  {
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery(sql);

    out.print("");
    out.print("+ "+sql+" = ");
    if (rs.next())
      out.print(rs.getString(1));
    out.println("");

    conn.close();
  }
  catch (Exception ex)
  {
    out.print("");
    out.print("- "+sql+" failed ("+ex.getMessage()+")");
    out.println("");
  }
%>

System Properties

<%
  try
  {
    Properties sysProps = System.getProperties();
    SortedSet sortedProperties = new TreeSet(sysProps.keySet()); 
    for (Iterator keys = sortedProperties.iterator(); keys.hasNext();)
    {
      String key = (String)keys.next();
      out.println(""+key + ": " + sysProps.getProperty(key));
    }
  }
  catch(Exception e)
  {
    e.printStackTrace();
  }
%>

Platform: <%= getServletConfig().getServletContext().getServerInfo() %>