net.larsan.urd.impl
Class DirectoryContainer

java.lang.Object
  |
  +--net.larsan.urd.jndi.ContextBase
        |
        +--net.larsan.urd.jndi.ContextImpl
              |
              +--net.larsan.urd.impl.ContainerBase
                    |
                    +--net.larsan.urd.impl.DirectoryContainer
All Implemented Interfaces:
java.lang.Cloneable, Container, javax.naming.Context, Destroyable, javax.naming.event.EventContext

public class DirectoryContainer
extends ContainerBase

A directory container scans a directory looking for service archives.

Version:
Alpha-0.1 / 2002-10-06 21:37
Author:
Lars J. Nilsson

Field Summary
 
Fields inherited from class net.larsan.urd.impl.ContainerBase
autoStart, errorHandler, name
 
Fields inherited from class net.larsan.urd.jndi.ContextBase
ACCESS_PERMISSION, env, handler, localName, nameParser, parent, port, root, ROOT_ADDRESS, ROOT_PORT
 
Fields inherited from interface javax.naming.event.EventContext
OBJECT_SCOPE, ONELEVEL_SCOPE, SUBTREE_SCOPE
 
Fields inherited from interface javax.naming.Context
APPLET, AUTHORITATIVE, BATCHSIZE, DNS_URL, INITIAL_CONTEXT_FACTORY, LANGUAGE, OBJECT_FACTORIES, PROVIDER_URL, REFERRAL, SECURITY_AUTHENTICATION, SECURITY_CREDENTIALS, SECURITY_PRINCIPAL, SECURITY_PROTOCOL, STATE_FACTORIES, URL_PKG_PREFIXES
 
Constructor Summary
DirectoryContainer(java.io.File root, ContextBase context, java.lang.String localName)
          Create directory.
 
Method Summary
 void destroy()
          Destroy container.
 void doAutoStarts()
          Attempt to start all autostart services.
protected  void firstScan(ErrorHandler errorHandler)
          Scan directory for services a register them with super class
 java.lang.String getContainerID()
          Get container id.
 long getRescanInterval()
          Get the interval in milliseconds between directory rescans.
 java.io.File getSourceFile()
          Get file source.
 java.net.URL getSourceURL()
          Get file source.
 void init(DefaultErrorHandler errorHandler)
          Initiate directory.
 void setParameters(Parameters params)
          Set parameter object for this container.
 void setRescanInterval(long millis)
          Set the interval in milliseconds between directory rescans.
 void setSourceURL(java.lang.String source)
          Set source URL for this container.
 
Methods inherited from class net.larsan.urd.impl.ContainerBase
autoStart, findServiceID, getAutoStart, getByIdImpl, getByURLImpl, info, list, removeServiceImpl, setAutoStart, setServiceImpl, start, stop
 
Methods inherited from class net.larsan.urd.jndi.ContextImpl
bind, clone, close, composeName, createSubcontext, destroySubcontext, getNameParser, hashCode, list, listBindings, lookup, lookupLink, rebind, rename, toString, unbind
 
Methods inherited from class net.larsan.urd.jndi.ContextBase
addNamingListener, addNamingListener, addToEnvironment, bind, checkAccess, composeName, createSubcontext, destroySubcontext, findRootContext, getEnvironment, getEventHandler, getNameInNamespace, getNameParser, getParent, list, listBindings, lookup, lookupLink, objectAdded, objectRemoved, objectRenamed, rebind, removeFromEnvironment, removeNamingListener, rename, setHandler, targetMustExist, unbind
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DirectoryContainer

public DirectoryContainer(java.io.File root,
                          ContextBase context,
                          java.lang.String localName)
                   throws java.io.IOException
Create directory. The root argument is the directory from which this container source URL is resolved (installation root).

Parameters:
root - Installation root directory
context - Server context, must not be null
Throws:
java.io.IOException - Ihe the root folder does not exist
Method Detail

init

public void init(DefaultErrorHandler errorHandler)
          throws ContainerException
Initiate directory. This throws a container exception if there's an IO error when scanning for or reading archives.

Overrides:
init in class ContainerBase
Parameters:
errorHandler - Error handler for exceptions
Throws:
ContainerException - If an IO error occurs

doAutoStarts

public void doAutoStarts()
Attempt to start all autostart services. If the container is marked as auto-start all service auto-start by default if not explicitly saying 'false'

Specified by:
doAutoStarts in interface Container
Overrides:
doAutoStarts in class ContainerBase

getSourceURL

public java.net.URL getSourceURL()
Get file source. This returns a full path to the directory source as a URL.

Returns:
The container source URL, or null if not set

getSourceFile

public java.io.File getSourceFile()
Get file source.

Returns:
The container file source, or null if not set

getRescanInterval

public long getRescanInterval()
Get the interval in milliseconds between directory rescans. Returns -1 is the rescanning is disabled.


setRescanInterval

public void setRescanInterval(long millis)
Set the interval in milliseconds between directory rescans. Set to -1 to disable rescanning. Note that this must be set before the directory is initiated and cannot be changed dynamicly.


setParameters

public void setParameters(Parameters params)
Set parameter object for this container.

Parameters:
params - Parameters object

setSourceURL

public void setSourceURL(java.lang.String source)
                  throws ContainerException
Set source URL for this container. This will attempt to resolve the given path relative to the root of the container.

Parameters:
source - Source URL, must not be null
Throws:
ContainerException - If the source URL is not found

getContainerID

public java.lang.String getContainerID()
Get container id.

Specified by:
getContainerID in class ContainerBase
Returns:
The container id

destroy

public void destroy()
Destroy container.

Specified by:
destroy in interface Destroyable
Overrides:
destroy in class ContainerBase

firstScan

protected void firstScan(ErrorHandler errorHandler)
                  throws ContainerException
Scan directory for services a register them with super class

ContainerException