com.sun.jini.tool.envcheck.plugins
Class CheckCodebase

java.lang.Object
  extended by com.sun.jini.tool.envcheck.AbstractPlugin
      extended by com.sun.jini.tool.envcheck.plugins.CheckCodebase
All Implemented Interfaces:
Plugin

public class CheckCodebase
extends AbstractPlugin

Plugin which performs a variety of checks on codebase components. If not configured to perform service starter checks, the codebase is expected to be defined by the java.rmi.server.codebase system property. Otherwise, all of the codebases contained in the service descriptors of the service starter Configuration are examined (excepting SharedActivationGroupDescriptors, which do not have a codebase). First, an existence check is performed; the codebase string must be non-null and have length > 0 after white space is trimmed. Non-existence is reported as an error. Then the codebase is decomposed into tokens (URL strings). Each component in a codebase is checked for the following:

Failure of the first or last checks are displayed as errors. Failure of the other checks are displayed as warnings.


Nested Class Summary
static class CheckCodebase.GetURLTask
           
private  class CheckCodebase.URLAccessor
          A Runnable which attempts to open a URL connection.
 
Field Summary
(package private)  EnvCheck envCheck
          reference to the plugin container
 
Constructor Summary
CheckCodebase()
           
 
Method Summary
private  void checkAccessibility(URL url, String source)
          Check the accessibility of the codebase URL by opening a connection to it.
private  boolean checkExistance(String source, String codebase)
          Check for existence.
private  void checkForFQDomain(URL url, String source)
          Check for a fully qualified host name.
private  void checkForKnownHost(URL url, String source)
          Check the ability to resolve the host component of url to an InetAddress.
private  void checkForLocalHost(URL url, String source)
          Check whether the host component of url resolves to a loopback address.
private  void checkForMD5(URL url, String source)
          Check for use of an MD5 httpmd URL.
private  URL checkURL(NonActivatableServiceDescriptor d, SharedActivationGroupDescriptor g, String source, String urlToken)
          Check whether urlToken can be used to construct a URL object.
private  void doChecks(NonActivatableServiceDescriptor d, SharedActivationGroupDescriptor g, String source, String codebase)
          Perform all of the checks on codebase.
 void run(EnvCheck envCheck)
          Depending on whether service start checks are configured, either check the codebase system property or all of the ServiceDescriptors that are instanceof NonActivatableServiceDescriptor.
 
Methods inherited from class com.sun.jini.tool.envcheck.AbstractPlugin
getBundle, getString, getString, getString, getString, handleUnexpectedSubtaskReturn, isPluginOption, taskName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

envCheck

EnvCheck envCheck
reference to the plugin container

Constructor Detail

CheckCodebase

public CheckCodebase()
Method Detail

run

public void run(EnvCheck envCheck)
Depending on whether service start checks are configured, either check the codebase system property or all of the ServiceDescriptors that are instanceof NonActivatableServiceDescriptor.

Parameters:
envCheck - a reference to the driver instance.

doChecks

private void doChecks(NonActivatableServiceDescriptor d,
                      SharedActivationGroupDescriptor g,
                      String source,
                      String codebase)
Perform all of the checks on codebase.

Parameters:
source - a string describing the source of the codebase for use in report messages
codebase - the codebase to check

checkExistance

private boolean checkExistance(String source,
                               String codebase)
Check for existence. codebase must be non-null and have length > 0 after trimming whitespace.

Parameters:
source - identifies the source of the codebase
codebase - the codebase to check
Returns:
true if existence check is successful

checkURL

private URL checkURL(NonActivatableServiceDescriptor d,
                     SharedActivationGroupDescriptor g,
                     String source,
                     String urlToken)
Check whether urlToken can be used to construct a URL object. If a MalformedURLException is thrown, check whether the protocol portion of the URL is httpmd:. If so, check whether the protocol handler is installed. If not, output an appropriate message. Otherwise, just complain generally that the URL is malformed.

Parameters:
source - the source of the codebase
urlToken - the codebase component to check
Returns:
the corresponding URL object if successful, null otherwise

checkForKnownHost

private void checkForKnownHost(URL url,
                               String source)
Check the ability to resolve the host component of url to an InetAddress. If successful, this method is silent.

Parameters:
url - the URL to check
source - the source of the URL

checkForLocalHost

private void checkForLocalHost(URL url,
                               String source)
Check whether the host component of url resolves to a loopback address.

Parameters:
url - the URL to check
source - the source of the URL

checkAccessibility

private void checkAccessibility(URL url,
                                String source)
Check the accessibility of the codebase URL by opening a connection to it. This check fails if the openConnection call or subsequent getInputStream call throws an IOException, or if these calls do not complete within 5 seconds. These two failure modes result in different error messages being output.

Parameters:
url - the URL to check
source - the source of the URL

checkForFQDomain

private void checkForFQDomain(URL url,
                              String source)
Check for a fully qualified host name. To be valid, the host name must consist of at least two '.' separated tokens, and the last token must be one of the well-known top level domain names, or the last token must be a two character string which is assumed to be a country code.

Parameters:
url - the URL to check
source - the source of the URL

checkForMD5

private void checkForMD5(URL url,
                         String source)
Check for use of an MD5 httpmd URL. If the protocol of url is httpmd, then the hash function identifier is parsed from the file component of url and a string comparison is done.

Parameters:
url - the URL to check
source - the source of the URL


Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.