org.apache.jetspeed.services.urlmanager
Class JetspeedURLManagerService

java.lang.Object
  extended byorg.apache.turbine.services.BaseInitable
      extended byorg.apache.turbine.services.BaseService
          extended byorg.apache.turbine.services.TurbineBaseService
              extended byorg.apache.jetspeed.services.urlmanager.JetspeedURLManagerService
All Implemented Interfaces:
org.apache.turbine.services.Initable, org.apache.turbine.services.Service, URLManagerService

public class JetspeedURLManagerService
extends org.apache.turbine.services.TurbineBaseService
implements URLManagerService

This implementation of the URLManagerService is backed by a simple map persisted on disk in a properties file

Added: Support for proxies.
Example: (Set in JetspeedResources.properties)
services.URLManager.proxy.http.host=myproxy.mydomain
services.URLManager.proxy.http.port=81

Version:
$Id: JetspeedURLManagerService.java,v 1.17 2005/03/21 18:21:44 sgala Exp $
Author:
RaphaŽl Luta, Santiago Gala
See Also:
URLManagerService

Field Summary
 
Fields inherited from class org.apache.turbine.services.BaseService
configuration, name, properties, serviceBroker
 
Fields inherited from class org.apache.turbine.services.BaseInitable
initableBroker, isInitialized
 
Fields inherited from interface org.apache.jetspeed.services.urlmanager.URLManagerService
SERVICE_NAME, STATUS_ANY, STATUS_BAD, STATUS_CONTENT_ERROR, STATUS_OK, STATUS_TEMPORARY_UNAVAILABLE, STATUS_UNKNOWN, STATUS_UNREACHABLE
 
Constructor Summary
JetspeedURLManagerService()
           
 
Method Summary
 URLInfo getInfo(java.lang.String url)
          Get the information record stored in the database about an URL.
 java.lang.String getProxyHost(java.lang.String protocol)
          Return a proxy's hostname
 int getProxyPort(java.lang.String protocol)
          Return the port of a proxy
 void init()
          Late init.
 void init(javax.servlet.ServletConfig config)
          Called during Turbine.init()
 boolean isOK(java.lang.String url)
          Test whether the URL is currently believed to be OK by this repository.
 java.util.List list()
          List of the current known URLs in the repository
 java.util.List list(int status)
          List of the current known URLs in the repository which have the given status.
 void register(java.lang.String url)
          Registers a new URL record.
 void register(java.lang.String url, int status)
          Registers a new URL record.
 void register(java.lang.String url, int status, java.lang.String message)
          Registers a new URL record.
 void register(URLInfo info)
          Register or replace an URL record.
 void shutdown()
          Called during Turbine destroy().
 void unregister(java.lang.String url)
          Unregister an URL from the repository
protected  void writeEscaped(java.io.PrintWriter sink, java.lang.String element)
          Escape values when saving.
 
Methods inherited from class org.apache.turbine.services.TurbineBaseService
init, init
 
Methods inherited from class org.apache.turbine.services.BaseService
getConfiguration, getName, getProperties, getServiceBroker, setName, setServiceBroker
 
Methods inherited from class org.apache.turbine.services.BaseInitable
getInit, getInitableBroker, setInit, setInitableBroker
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.turbine.services.Service
getConfiguration, getName, getProperties, setName, setServiceBroker
 
Methods inherited from interface org.apache.turbine.services.Initable
getInit, init, setInitableBroker
 

Constructor Detail

JetspeedURLManagerService

public JetspeedURLManagerService()
Method Detail

init

public void init()
Late init. Don't return control until early init says we're done.

Specified by:
init in interface org.apache.turbine.services.Initable

init

public void init(javax.servlet.ServletConfig config)
Called during Turbine.init()

Parameters:
config - A ServletConfig.

shutdown

public void shutdown()
Called during Turbine destroy(). Persist the Manager state to disk

Specified by:
shutdown in interface org.apache.turbine.services.Initable

register

public void register(java.lang.String url)
Registers a new URL record. If the url is already registered in the system, doesn't modify the current record.

Specified by:
register in interface URLManagerService
Parameters:
url - the url to register

register

public void register(java.lang.String url,
                     int status)
Registers a new URL record. If the url is already registered in the system, updates the status of this URL info record

Specified by:
register in interface URLManagerService
Parameters:
url - the url to register
status - the status of this url

register

public void register(java.lang.String url,
                     int status,
                     java.lang.String message)
Registers a new URL record. If the url is already registered in the system, updates both the status and the message of this URL info record

Specified by:
register in interface URLManagerService
Parameters:
url - the url to register
status - the status of this url
message - a descriptive message of the status

register

public void register(URLInfo info)
Register or replace an URL record. All records are keyed to the imutable URL of URLInfo.

Specified by:
register in interface URLManagerService
Parameters:
info - the info record to store

unregister

public void unregister(java.lang.String url)
Unregister an URL from the repository

Specified by:
unregister in interface URLManagerService
Parameters:
url - the url to remove

getInfo

public URLInfo getInfo(java.lang.String url)
Get the information record stored in the database about an URL.

Specified by:
getInfo in interface URLManagerService
Parameters:
url - the url whose record is sought
Returns:
the description record found in the repository or null.

isOK

public boolean isOK(java.lang.String url)
Test whether the URL is currently believed to be OK by this repository.

Specified by:
isOK in interface URLManagerService
Parameters:
url - the url to be tested
Returns:
false is the url is known by this repository and has a status indicating an error, true otherwise.

list

public java.util.List list()
List of the current known URLs in the repository

Specified by:
list in interface URLManagerService
Returns:
a List of URL strings known to this repository

list

public java.util.List list(int status)
List of the current known URLs in the repository which have the given status.

Specified by:
list in interface URLManagerService
Parameters:
status - the status to be retrieved. May be URLManagerService.STATUS_ANY to indicate any status
Returns:
a List of URL strings known to this repository with this status

getProxyPort

public int getProxyPort(java.lang.String protocol)
Return the port of a proxy

Specified by:
getProxyPort in interface URLManagerService
Parameters:
protocol - The protocol that the proxy supports, e.g. 'http'
Returns:
The port number (1-65535), or -1 if no port was specified (= use default)

getProxyHost

public java.lang.String getProxyHost(java.lang.String protocol)
Return a proxy's hostname

Specified by:
getProxyHost in interface URLManagerService
Parameters:
protocol - The protocol that the proxy supports, e.g. 'http'
Returns:
The hostname of the proxy, or null if no proxy is specified for this protocol

writeEscaped

protected void writeEscaped(java.io.PrintWriter sink,
                            java.lang.String element)

Escape values when saving. Appends a String to a StringBuffer, escaping commas.

We assume that commas are unescaped.

Parameters:
sink - a StringBuffer to write output
element - a value to be written


Copyright © 2000-2005 Apache Software Foundation. All Rights Reserved.