ice.storm
Class DefaultFactory

java.lang.Object
  extended byice.storm.DefaultFactory
All Implemented Interfaces:
PilotFactory, ScripterFactory, URLClassLoaderFactory

public class DefaultFactory
extends Object
implements PilotFactory, URLClassLoaderFactory

This is a factory for loading of pilots. It is the heart of Storm. Note that it caches all information about previously loaded pilots. This cache can freed from time to time. The cached information includes mapping between contentTypes and pilots (classname, location). actual binary class data. NOTE that the DefaultFactory only hardcodes info about essential pilots and scripters. Factories extending DefaultFactory should load info from files, current dir etc.

DefaultFactory also provides API for adding/removing mappings between mime-type and pilots as well as mappings between ascript names and scripters


Constructor Summary
DefaultFactory()
           
 
Method Summary
 void addPilotInfo(PilotInfo pi)
           
 void addScripterInfo(ScripterInfo s)
           
 Pilot createPilot(ContentLoader l)
          Create a pilot to display the content that is being loaded by the ContentLoader.
 Pilot createPilot(String contentType)
          Create a pilot for a given content type.
 Scripter createScripter(String scriptName)
          Create an interpreter for procesing commands in scripting language called scriptName
 ClassLoader createURLClassLoader(URL[] urls)
           
protected  String extractContentType(ContentLoader l)
           
 Enumeration getAllPilotInfos()
          Get a enumeration of all PilotInfos that describe all (so far) known pilots.
 Enumeration getAllScripterInfos()
          Get a enumeration of all ScripterInfos describing all (so far) known scripters
 ScripterInfo getScripterInfo(String name)
           
 boolean isContentTypeSupported(Pilot pilot, ContentLoader l, String contentType)
          Check whether the specified pilot can display the data of a given content type or that is going to be loaded by the ContentLoader.
protected  void loadDefaultResources()
           
 void removePilotInfo(PilotInfo pi)
           
 void removeScripterInfo(ScripterInfo s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultFactory

public DefaultFactory()
Method Detail

addPilotInfo

public void addPilotInfo(PilotInfo pi)

removePilotInfo

public void removePilotInfo(PilotInfo pi)

addScripterInfo

public void addScripterInfo(ScripterInfo s)

removeScripterInfo

public void removeScripterInfo(ScripterInfo s)

getAllPilotInfos

public Enumeration getAllPilotInfos()
Description copied from interface: PilotFactory
Get a enumeration of all PilotInfos that describe all (so far) known pilots.

Specified by:
getAllPilotInfos in interface PilotFactory
Returns:
Enumeration of PilotInfo objects

getAllScripterInfos

public Enumeration getAllScripterInfos()
Description copied from interface: PilotFactory
Get a enumeration of all ScripterInfos describing all (so far) known scripters

Specified by:
getAllScripterInfos in interface PilotFactory
Returns:
Enumeration of ScriptInfo objects

createScripter

public Scripter createScripter(String scriptName)
Description copied from interface: PilotFactory
Create an interpreter for procesing commands in scripting language called scriptName

Specified by:
createScripter in interface PilotFactory
Parameters:
scriptName - name of the scripting language
Returns:
an instance of Scripter object

getScripterInfo

public ScripterInfo getScripterInfo(String name)
Specified by:
getScripterInfo in interface PilotFactory

createPilot

public Pilot createPilot(String contentType)
Description copied from interface: PilotFactory
Create a pilot for a given content type. This will use existing mappings between contentType and pilots.

Specified by:
createPilot in interface PilotFactory
Parameters:
contentType - content type of the data
Returns:
a Pilot that can display the data of this content type

createPilot

public Pilot createPilot(ContentLoader l)
Description copied from interface: PilotFactory
Create a pilot to display the content that is being loaded by the ContentLoader.

Specified by:
createPilot in interface PilotFactory
Parameters:
l - ContentLoader that is doing the loading of the data
Returns:
a Pilot that can display this content

isContentTypeSupported

public boolean isContentTypeSupported(Pilot pilot,
                                      ContentLoader l,
                                      String contentType)
Description copied from interface: PilotFactory
Check whether the specified pilot can display the data of a given content type or that is going to be loaded by the ContentLoader.

Specified by:
isContentTypeSupported in interface PilotFactory
Parameters:
pilot - Pilot that is being checked
l - ContentLoader that is doing the loading of the data
contentType - contentType of the data. If this value is specified it overrides the contentType that is determined by the loader.
Returns:
true if the pilot can display the data

createURLClassLoader

public ClassLoader createURLClassLoader(URL[] urls)
Specified by:
createURLClassLoader in interface URLClassLoaderFactory

loadDefaultResources

protected void loadDefaultResources()

extractContentType

protected String extractContentType(ContentLoader l)