com.webrenderer.se
Class BrowserFactory

java.lang.Object
  extended by com.webrenderer.se.BrowserFactory

public class BrowserFactory
extends java.lang.Object

BrowserFactory is used to generate new IBrowserCanvas implementations. It follows the factory design pattern, allowing it to spawn off specific implementations. Each implementation implements IBrowserCanvas at a minimum, but probably has browser-specific interfaces as well.

If a browser is not available for the platform (for example, a certain browser not installed), then attempting to spawn such a browser will return null.


Constructor Summary
protected BrowserFactory()
          Protected constructor for BrowserFactory.
 
Method Summary
static void addFontSearchDirectory(java.io.File fontDir)
          Add a directory to the font search path.
static void destroyBrowser(IBrowserCanvas browser)
          Destroy an IBrowserCanvas instance.
static java.lang.String getHomeDirectory()
          Get the workspace directory for WebRenderer.
static java.lang.String getLibraryPath()
          Get the path from which native Mozilla libraries are loaded.
static java.lang.String getWebrendererVersion()
          Get a String identifying the version of WebRenderer Server Edition.
static void setCorecomponentsExtractOn(java.lang.String filename)
          Sets extraction of corcomponents based on a custom file within.
static boolean setHomeDirectory(java.io.File newDirectory)
          Set the workspace root directory for WebRenderer.
static boolean setHomeDirectory(java.lang.String newDirectory)
          Set the workspace root directory for WebRenderer.
static void setLibraryPath(java.io.File directory)
          Sets the path from where the Webrenderer Server Edition library files are loaded.
static void setLibraryPath(java.lang.String Path)
          Sets the path where the WebRenderer Server Edition library files are located.
static void setLicenseData(java.lang.String username, java.lang.String serial)
          Set registration/license key.
static void setMozillaPath(java.io.File directory)
           
static void setMozillaPath(java.lang.String path)
          Setting the Mozilla Path is used to change the directory that contains the webrenderer Server Edition native library and the core components.
static boolean shutdownMozilla()
          Shutdown Mozilla.
static IMozillaBrowserCanvas spawnMozilla()
          Spawns a new instance of WebRenderer Server Edition.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BrowserFactory

protected BrowserFactory()
Protected constructor for BrowserFactory. We do not want this being used by people in general, hence being protected.

Method Detail

getWebrendererVersion

public static java.lang.String getWebrendererVersion()
Get a String identifying the version of WebRenderer Server Edition.

Returns:
the platform-specific version of WebRenderer Server Edition (example: "2.2.43")

setMozillaPath

public static void setMozillaPath(java.lang.String path)
Setting the Mozilla Path is used to change the directory that contains the webrenderer Server Edition native library and the core components. The path given must contain both the webrenderer native library and the core components, and is relative to the current working directory.

You must call this before any other calls are made as they may need to load the native libraries.

Parameters:
path - relative path from current directory to libraries.

getLibraryPath

public static java.lang.String getLibraryPath()
Get the path from which native Mozilla libraries are loaded.

Returns:
the path to the native libraries (or empty string if libraries are in current working directory).

setLicenseData

public static void setLicenseData(java.lang.String username,
                                  java.lang.String serial)
Set registration/license key. Prevents a registration dialog from being shown when browsing, and unlocks features which are not available in the unregistered version. To prevent feature-locking, the license key must be set via this function before any browser instances are created.

Parameters:
username - username (up to 8 characters).
serial - registration key.

setLibraryPath

public static void setLibraryPath(java.lang.String Path)
Sets the path where the WebRenderer Server Edition library files are located.

Parameters:
Path - path from project location to the library files.
See Also:
setLibraryPath(File)

setLibraryPath

public static void setLibraryPath(java.io.File directory)
Sets the path from where the Webrenderer Server Edition library files are loaded.

Parameters:
directory - Path from project location to the library files.
See Also:
setLibraryPath(String)

setMozillaPath

public static void setMozillaPath(java.io.File directory)
Parameters:
directory -

destroyBrowser

public static void destroyBrowser(IBrowserCanvas browser)
Destroy an IBrowserCanvas instance.

Parameters:
browser - browser to destroy.

setCorecomponentsExtractOn

public static void setCorecomponentsExtractOn(java.lang.String filename)
Sets extraction of corcomponents based on a custom file within. This allows you to change the corecomponents and make sure that your version of the corecomponets extracts if it is not found.
This must be called before any other method on BrowserFactory.
A file with the given name should be added to corecomponets-xxx.zip (where xxx is the platform those corecomponets are for).

Parameters:
filename - The name of the file in the corecomponents to look for.

spawnMozilla

public static IMozillaBrowserCanvas spawnMozilla()
Spawns a new instance of WebRenderer Server Edition.


setHomeDirectory

public static boolean setHomeDirectory(java.lang.String newDirectory)
Set the workspace root directory for WebRenderer. Note, the actual directory used is a subdirectory of this, dependant on the operating system (this allows shared networked drives to be used with multiple operating systems). This function must be called before a browser is spawned, and before setLicenseData, otherwise it will have no effect.

Parameters:
newDirectory -
Returns:
true if the home directory was set OK.
See Also:
getHomeDirectory(), setLicenseData(String, String)

setHomeDirectory

public static boolean setHomeDirectory(java.io.File newDirectory)
Set the workspace root directory for WebRenderer. Note, the actual directory used is a subdirectory of this, dependant on the operating system (this allows shared networked drives to be used with multiple operating systems). This function must be called before a browser is spawned, and before setLicenseData, otherwise it will have no effect.

Parameters:
newDirectory -
Returns:
true if the home directory was set OK.
See Also:
getHomeDirectory(), setHomeDirectory( String )

addFontSearchDirectory

public static void addFontSearchDirectory(java.io.File fontDir)
Add a directory to the font search path. Any fonts in this directory will be available for the next page render.

The following fonts are supported...

Parameters:
fontDir - directory containing fonts.

getHomeDirectory

public static java.lang.String getHomeDirectory()
Get the workspace directory for WebRenderer. Note, the default is the user's home directory + com.webrenderer.server.webRendererLocation + operating system descriptor.

Returns:
The user's home directory.
See Also:
setHomeDirectory(String)

shutdownMozilla

public static boolean shutdownMozilla()
Shutdown Mozilla. This must be called after all browsers are destroyed using BrowserFactory.destroyBrowser(). Will return false if browsers are still around or if Mozilla hasn't been started yet.

Returns:
true if shutdown successfull.