Package org.lwjgl.util.applet
Class AppletLoader
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Panel
java.applet.Applet
org.lwjgl.util.applet.AppletLoader
- All Implemented Interfaces:
AppletStub
,ImageObserver
,MenuContainer
,Serializable
,Runnable
,Accessible
The AppletLoader enables deployment of LWJGL to applets in an easy and polished way. The loader will display a configurable logo and progressbar while the relevant jars (generic and native) are downloaded from a specified source.
The downloaded jars are extracted to the users temporary directory - and if enabled, cached for faster loading in future uses.
The following applet parameters are required:
- al_main - [String] Full package and class the applet to instantiate and display when loaded.
- al_jars - [String] Comma separated list of jars to download.
- al_windows - [String] Jar containing native files for windows.
- al_linux - [String] Jar containing native files for linux.
- al_mac - [String] Jar containing native files for mac.
- al_solaris - [String] Jar containing native files for solaris.
- al_freebsd - [String] Jar containing native files for freebsd.
- al_openbsd - [String] Jar containing native files for openbsd.
Additionally the following parameters can be supplied to tweak the behaviour of the AppletLoader.
- al_cache - [boolean] Whether to use cache system. Default: true.
- al_version - [int or float] Version of deployment. If this is specified, the jars will be cached and reused if the version matches. If version doesn't match all of the files are reloaded.
- al_debug - [boolean] Whether to enable debug mode. Default: false.
- al_min_jre - [String] Specify the minimum jre version that the applet requires, should be in format like 1.6.0_24 or a subset like 1.6 Default: 1.5.
- al_prepend_host - [boolean] Whether to limit caching to this domain, disable if your applet is hosted on multiple domains and needs to share the cache. Default: true.
- al_lookup_threads - [int] Specify the number of concurrent threads to use to get file information before downloading. Default: 1.
- al_windows64 - [String] If specified it will be used instead of al_windows on 64bit windows systems.
- al_windows32 - [String] If specified it will be used instead of al_windows on 32bit windows systems.
- al_linux64 - [String] If specified it will be used instead of al_linux on 64bit linux systems.
- al_linux32 - [String] If specified it will be used instead of al_linux on 32bit linux systems.
- al_mac32 - [String] If specified it will be used instead of al_mac on 64bit mac systems.
- al_mac64 - [String] If specified it will be used instead of al_mac on 32bit mac systems.
- al_macppc - [String] If specified it will be used instead of al_mac on PPC mac systems.
- boxbgcolor - [String] any String AWT color ("red", "blue", etc), RGB (0-255) or hex formated color (#RRGGBB) to use as background. Default: #ffffff.
- boxfgcolor - [String] any String AWT color ("red", "blue", etc), RGB (0-255) or hex formated color (#RRGGBB) to use as foreground. Default: #000000.
- al_logo - [String Path of of the logo resource to paint while loading.Default: "appletlogo.gif".
- al_progressbar - [String] Path of the progressbar resource to paint on top of the logo, width clipped by percentage.Default: "appletprogress.gif".
- lwjgl_arguments - [String] used to pass LWJGL parameters to LWJGL e.g. ("-Dorg.lwjgl.input.Mouse.allowNegativeMouseCoords=true -Dorg.lwjgl.util.Debug=true").
- Version:
- $Revision$
$Id$
Contributors:
- Arielsan
- Bobjob
- Dashiva
- Dr_evil
- Elias Naur
- Kevin Glass
- Matthias Mann
- Mickelukas
- NateS
- Pelle Johnsen
- Riven
- Ruben01
- Shannon Smith
- Author:
- kappaOne invalid input: '<'one.kappa@gmail.com>, Brian Matzon invalid input: '<'brian@matzon.dk>
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.applet.Applet
Applet.AccessibleApplet
Nested classes/interfaces inherited from class java.awt.Panel
Panel.AccessibleAWTPanel
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Thread
animation thread that renders our load screen while loadingprotected Color
background color of appletprotected boolean
whether to use caching system, only download files that have changedprotected boolean
whether a certificate refused error occurredprotected String[]
error message to display if user refuses to accept certificateprotected ClassLoader
classLoader used to add downloaded jars to the classpathprotected int
threads to use when fetching information of files to be downloadedprotected int
current size of extracted in bytesprotected boolean
whether we're running in debug modeprotected String[]
fatal error message to displayprotected boolean
whether a fatal error occurredprotected Color
color to write foreground inprotected int[]
Sizes of files to downloadUsed to store file names with lastModified timeprotected String[]
generic error message to display on errorprotected boolean
whether to run in headless modeprotected String[]
messages to be passed via liveconnect in headless modeprotected boolean
whether to switch applets in headless mode or wait longerprotected Thread
actual thread that does the loadingprotected Image
logo to be shown while loadingprotected Image
logo to be shown while loadingprotected Applet
applet to load after all downloads are completeprotected boolean
whether lzma is supportedprotected String[]
error message to display if minimum JRE version is not metprotected boolean
whether the minimum required JRE version is not foundprotected int
Number of native jarsprotected static boolean
have natives been loaded by another instance of this appletprotected Image
offscreen image usedprotected boolean
whether pack200 is supportedprotected boolean
set to true while painting is doneprotected int
used to calculate length of progress barprotected boolean
whether to prepend host to cache pathprotected Image
progressbar to render while loadingprotected Image
progressbar to render while loadingprotected int
state of applet loaderstatic final int
checking version of jrestatic final int
checking for already downloaded filesstatic final int
checking if any updates are available for cache filesstatic final int
determining which packages that are requiredstatic final int
donestatic final int
downloading packagesstatic final int
extracting packagesstatic final int
initializingstatic final int
initializing real appletstatic final int
stating real appletstatic final int
switching to real appletstatic final int
updating the classpathstatic final int
validating packagesprotected String
String to display as a subtaskprotected int
total size of download in bytesprotected int
total size of extracted in bytesprotected URL[]
urls of the jars to downloadFields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
appletResize
(int width, int height) Transfers the call of AppletResize from the stub to the lwjglApplet.protected static boolean
certificatesMatch
(Certificate[] certs1, Certificate[] certs2) Compare two certificate chains to see if they matchprotected void
cleanUp()
Clean up resourcesprotected boolean
compareVersion
(File versionFile, String version) This method will return true if the version stored in the file matches the supplied String version.protected void
debug_sleep
(long ms) Utility method for sleeping Will only really sleep if debug has been enabledvoid
destroy()
protected void
downloadJars
(String path) Will download the jars from the server using the list of urls in urlList, while at the same time updating progress barprotected void
extractGZip
(String in, String out) Extract GZip Fileprotected void
extractJars
(String path) Extract all jars from any lzma/gz/pack filesprotected void
extractLZMA
(String in, String out) Extract LZMA Fileprotected void
extractNatives
(String path) This method will extract all file from the native jar and extract them to the subdirectory called "natives" in the local path, will also check to see if the native jar files is signed properlyprotected void
fatalErrorOccured
(String error, Exception e) Sets the error message and print debug informationRetrieves the applet that has been loaded.protected boolean
getBooleanParameter
(String name, boolean defaultValue) Retrieves the boolean value for the parameterprotected String
This method will return the location of the cache directory.protected Color
Retrieves the colorprotected static Certificate[]
Returns the current certificate chain of the AppletLoaderprotected String
protected String
getFileName
(URL url) Get file name portion of URL.protected Image
Get Image from path providedGet Image from path providedprotected int
getIntParameter
(String name, int defaultValue) Retrieves the int value for the appletprotected void
getJarInfo
(File dir) This method will get the files sizes of the files to download.protected InputStream
getJarInputStream
(String currentFile, URLConnection urlconnection) Retrieves a jar files input stream.protected String
getJarName
(URL url) Get jar name from URL.protected String
Get path to the lwjgl cache directory.String[]
Retrieves the current message for the current status.int
Retrieves the current status of the AppletLoader and is used by liveconnect when running in headless mode.protected String
getStringParameter
(String name, String defaultValue) Retrieves the String value for the parameterboolean
imageUpdate
(Image img, int flag, int x, int y, int width, int height) When an animated gif frame is ready to be drawn the ImageObserver will call this method.void
init()
boolean
When this method is supplied with a JRE version it will compare it to the current JRE version.protected boolean
isZipValid
(File file) This method will check if a zip file is valid by running through it and checking for any corruption and CRC failuresprotected void
Reads list of jars to download and adds the urls to urlList also finds out which OS you are on and adds appropriate native jar to the urlListvoid
readHashMapFile
(File file) read the HashMap from Fileprotected Object
readObjectFile
(File file) read the object from the Fileprotected String
readStringFile
(File file) read String object from FilereplaceLast
(String original, String target, String replacement) Replaces the last occurrence of the specified target substring with the specified replacement string in a string.void
run()
9 steps 1) check jre version meets minimum requirements 2) check applet cache and decide which jars to download 3) download the jars 4) extract native files 5) validate jars for any corruption 6) save applet cache information 7) add jars to class path 8) set any lwjgl properties 9) switch to loaded appletprotected void
Parses the java_arguments list and sets lwjgl specific properties accordingly, before the launch.protected void
setState
(int state) set the state of applet loaderprotected void
sleep
(long ms) Utility method for sleepingvoid
start()
void
stop()
protected void
replace the current applet with the lwjgl applet using AppletStub and initialise and start itprotected String
Trims the passed file string based on the available capabilitiesfinal void
protected void
updateClassPath
(String path) Edits the ClassPath at runtime to include the jars that have just been downloaded and then adds the lwjgl natives folder property.protected void
validateJars
(String path) Check and validate jars which will be loaded into the classloader to make sure that they are not corrupt.protected void
writeObjectFile
(File file, Object object) write object to specified FileMethods inherited from class java.applet.Applet
getAccessibleContext, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getLocale, getParameter, getParameterInfo, isActive, isValidateRoot, newAudioClip, play, play, resize, resize, setStub, showStatus
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, reshape, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setMixingCutoutShape, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.applet.AppletStub
getAppletContext, getCodeBase, getDocumentBase, getParameter, isActive
-
Field Details
-
STATE_INIT
public static final int STATE_INITinitializing- See Also:
-
STATE_CHECK_JRE_VERSION
public static final int STATE_CHECK_JRE_VERSIONchecking version of jre- See Also:
-
STATE_DETERMINING_PACKAGES
public static final int STATE_DETERMINING_PACKAGESdetermining which packages that are required- See Also:
-
STATE_CHECKING_CACHE
public static final int STATE_CHECKING_CACHEchecking for already downloaded files- See Also:
-
STATE_CHECKING_FOR_UPDATES
public static final int STATE_CHECKING_FOR_UPDATESchecking if any updates are available for cache files- See Also:
-
STATE_DOWNLOADING
public static final int STATE_DOWNLOADINGdownloading packages- See Also:
-
STATE_EXTRACTING_PACKAGES
public static final int STATE_EXTRACTING_PACKAGESextracting packages- See Also:
-
STATE_VALIDATING_PACKAGES
public static final int STATE_VALIDATING_PACKAGESvalidating packages- See Also:
-
STATE_UPDATING_CLASSPATH
public static final int STATE_UPDATING_CLASSPATHupdating the classpath- See Also:
-
STATE_SWITCHING_APPLET
public static final int STATE_SWITCHING_APPLETswitching to real applet- See Also:
-
STATE_INITIALIZE_REAL_APPLET
public static final int STATE_INITIALIZE_REAL_APPLETinitializing real applet- See Also:
-
STATE_START_REAL_APPLET
public static final int STATE_START_REAL_APPLETstating real applet- See Also:
-
STATE_DONE
public static final int STATE_DONEdone- See Also:
-
percentage
protected volatile int percentageused to calculate length of progress bar -
totalDownloadSize
protected int totalDownloadSizetotal size of download in bytes -
currentSizeExtract
protected int currentSizeExtractcurrent size of extracted in bytes -
totalSizeExtract
protected int totalSizeExtracttotal size of extracted in bytes -
logo
logo to be shown while loading -
logoBuffer
logo to be shown while loading -
progressbar
progressbar to render while loading -
progressbarBuffer
progressbar to render while loading -
offscreen
offscreen image used -
painting
protected boolean paintingset to true while painting is done -
bgColor
background color of applet -
fgColor
color to write foreground in -
urlList
urls of the jars to download -
classLoader
classLoader used to add downloaded jars to the classpath -
loaderThread
actual thread that does the loading -
animationThread
animation thread that renders our load screen while loading -
lwjglApplet
applet to load after all downloads are complete -
debugMode
protected boolean debugModewhether we're running in debug mode -
prependHost
protected boolean prependHostwhether to prepend host to cache path -
filesLastModified
Used to store file names with lastModified time -
fileSizes
protected int[] fileSizesSizes of files to download -
nativeJarCount
protected int nativeJarCountNumber of native jars -
cacheEnabled
protected boolean cacheEnabledwhether to use caching system, only download files that have changed -
subtaskMessage
String to display as a subtask -
state
protected volatile int statestate of applet loader -
lzmaSupported
protected boolean lzmaSupportedwhether lzma is supported -
pack200Supported
protected boolean pack200Supportedwhether pack200 is supported -
headless
protected boolean headlesswhether to run in headless mode -
headlessWaiting
protected boolean headlessWaitingwhether to switch applets in headless mode or wait longer -
headlessMessage
messages to be passed via liveconnect in headless mode -
concurrentLookupThreads
protected int concurrentLookupThreadsthreads to use when fetching information of files to be downloaded -
fatalError
protected boolean fatalErrorwhether a fatal error occurred -
certificateRefused
protected boolean certificateRefusedwhether a certificate refused error occurred -
minimumJreNotFound
protected boolean minimumJreNotFoundwhether the minimum required JRE version is not found -
genericErrorMessage
generic error message to display on error -
certificateRefusedMessage
error message to display if user refuses to accept certificate -
minimumJREMessage
error message to display if minimum JRE version is not met -
errorMessage
fatal error message to display -
natives_loaded
protected static boolean natives_loadedhave natives been loaded by another instance of this applet
-
-
Constructor Details
-
AppletLoader
public AppletLoader()
-
-
Method Details
-
init
public void init() -
start
public void start() -
stop
public void stop() -
destroy
public void destroy() -
cleanUp
protected void cleanUp()Clean up resources -
getApplet
Retrieves the applet that has been loaded. Useful for liveconnect. -
getStatus
public int getStatus()Retrieves the current status of the AppletLoader and is used by liveconnect when running in headless mode. This method will return the current progress of the AppletLoader as a value from 0-100. In the case of a fatal error it will return -1. If the certificate is refused it will return -2. If the minimum jre requirement is not met will return -3. When method returns 100 the AppletLoader will sleep until the method is called again. When called again it will switch to the LWJGL Applet. This is a useful trigger to start the LWJGL applet when needed. -
getMessages
Retrieves the current message for the current status. Used by liveconnect when running in headless mode. -
appletResize
public void appletResize(int width, int height) Transfers the call of AppletResize from the stub to the lwjglApplet.- Specified by:
appletResize
in interfaceAppletStub
-
update
-
paint
-
imageUpdate
When an animated gif frame is ready to be drawn the ImageObserver will call this method. The Image frame is copied into a buffer, which is then drawn. This is done to prevent image tearing on gif animations.- Specified by:
imageUpdate
in interfaceImageObserver
- Overrides:
imageUpdate
in classComponent
-
getDescriptionForState
- Returns:
- string describing the state of the loader
-
trimExtensionByCapabilities
Trims the passed file string based on the available capabilities- Parameters:
file
- string of files to be trimmed- Returns:
- trimmed string based on capabilities of client
-
loadJarURLs
Reads list of jars to download and adds the urls to urlList also finds out which OS you are on and adds appropriate native jar to the urlList- Throws:
Exception
-
run
public void run()9 steps 1) check jre version meets minimum requirements 2) check applet cache and decide which jars to download 3) download the jars 4) extract native files 5) validate jars for any corruption 6) save applet cache information 7) add jars to class path 8) set any lwjgl properties 9) switch to loaded applet -
isMinJREVersionAvailable
When this method is supplied with a JRE version it will compare it to the current JRE version. minimum requried JRE version is set using al_min_jre parameter, if not this is not set then the value will default to version 1.5 The minimumVersion should follow a structure such as x.x.x_x Example values would include 1.6.0_10 or a subset like 1.6.0 or 1.6- Returns:
- returns true if the available version is greater or equal to the minimum version required
- Throws:
Exception
- a NumberFormatException is thrown if the string is not valid
-
compareVersion
This method will return true if the version stored in the file matches the supplied String version.- Parameters:
versionFile
- - location to file containing version informationversion
- - String version that needs to be compared- Returns:
- returns true if the version in file matches specified version
-
setLWJGLProperties
protected void setLWJGLProperties()Parses the java_arguments list and sets lwjgl specific properties accordingly, before the launch. -
getCacheDirectory
This method will return the location of the cache directory. All the applet files will be downloaded and stored here. A folder will be created inside the LWJGL cache directory from the al_title parameter. This folder will also be prepended by the host name of the codebase to avoid conflict with same named applets on other hosts.- Returns:
- path to applets cache directory
- Throws:
Exception
- if access is denied
-
getLWJGLCacheDir
Get path to the lwjgl cache directory. This location will be where the OS keeps temporary files.- Returns:
- path to the lwjgl cache directory
-
readStringFile
read String object from File- Parameters:
file
- to be read- Returns:
- the String stored in the file or null if it fails
-
readHashMapFile
read the HashMap from File- Parameters:
file
- the file to read- Returns:
- the hashmap stored in the file or an empty hashmap if it fails
-
readObjectFile
read the object from the File- Parameters:
file
- the file to read- Returns:
- the object contained in the file or null if it fails
- Throws:
Exception
- if it fails to read object from file
-
writeObjectFile
write object to specified File- Parameters:
file
- the file to write out toobject
- the contents of the file- Throws:
Exception
- if it fails to write file
-
updateClassPath
Edits the ClassPath at runtime to include the jars that have just been downloaded and then adds the lwjgl natives folder property.- Parameters:
path
- location where applet is stored- Throws:
Exception
- if it fails to add classpath
-
switchApplet
replace the current applet with the lwjgl applet using AppletStub and initialise and start it- Throws:
Exception
-
getJarInfo
This method will get the files sizes of the files to download. It wil further get the lastModified time of files and save it in a hashmap, if cache is enabled it will mark those files that have not changed since last download to not redownloaded.- Parameters:
dir
- - location to read cache file from- Throws:
Exception
- - if fails to get infomation
-
downloadJars
Will download the jars from the server using the list of urls in urlList, while at the same time updating progress bar- Parameters:
path
- location of the directory to save to- Throws:
Exception
- if download fails
-
getJarInputStream
protected InputStream getJarInputStream(String currentFile, URLConnection urlconnection) throws Exception Retrieves a jar files input stream. This method exists primarily to fix an Opera hang in getInputStream- Parameters:
urlconnection
- connection to get input stream from- Returns:
- InputStream or null if not possible
- Throws:
Exception
-
extractLZMA
Extract LZMA File- Parameters:
in
- Input path to pack fileout
- output path to resulting file- Throws:
Exception
- if any errors occur
-
extractGZip
Extract GZip File- Parameters:
in
- Input path to pack fileout
- output path to resulting file- Throws:
Exception
- if any errors occur
-
extractJars
Extract all jars from any lzma/gz/pack files- Parameters:
path
- output path- Throws:
Exception
- if any errors occur
-
extractNatives
This method will extract all file from the native jar and extract them to the subdirectory called "natives" in the local path, will also check to see if the native jar files is signed properly- Parameters:
path
- base folder containing all downloaded jars- Throws:
Exception
- if it fails to extract files
-
certificatesMatch
protected static boolean certificatesMatch(Certificate[] certs1, Certificate[] certs2) throws Exception Compare two certificate chains to see if they match- Parameters:
certs1
- first chain of certificatescerts2
- second chain of certificates- Returns:
- true if the certificate chains are the same
- Throws:
Exception
-
getCurrentCertificates
Returns the current certificate chain of the AppletLoader- Returns:
- - certificate chain of AppletLoader
- Throws:
Exception
-
validateJars
Check and validate jars which will be loaded into the classloader to make sure that they are not corrupt. This ensures corrupt files are never marked as successful downloadeds by the cache system.- Parameters:
path
- - where the jars are stored- Throws:
Exception
- if a corrupt jar is found
-
isZipValid
This method will check if a zip file is valid by running through it and checking for any corruption and CRC failures- Parameters:
file
- - zip file to test- Returns:
- boolean - runs false if the file is corrupt
-
getImage
Get Image from path provided- Parameters:
s
- location of the image- Returns:
- the Image file
-
getImage
Get Image from path provided -
getJarName
Get jar name from URL.- Parameters:
url
- Get jar file name from this url- Returns:
- file name as string
-
getFileName
Get file name portion of URL.- Parameters:
url
- Get file name from this url- Returns:
- file name as string
-
getColor
Retrieves the color- Parameters:
param
- Color to loaddefaultColor
- Default color to use if no color to load- Returns:
- Color to use
-
replaceLast
Replaces the last occurrence of the specified target substring with the specified replacement string in a string.- Parameters:
original
- - String to searchtarget
- - substring to findreplacement
- - what to replace target substring with- Returns:
- - return the modified string, if target substring not found return original string
-
getStringParameter
Retrieves the String value for the parameter- Parameters:
name
- Name of parameterdefaultValue
- default value to return if no such parameter- Returns:
- value of parameter or defaultValue
-
getBooleanParameter
Retrieves the boolean value for the parameter- Parameters:
name
- Name of parameterdefaultValue
- default value to return if no such parameter- Returns:
- value of parameter or defaultValue
-
getIntParameter
Retrieves the int value for the applet- Parameters:
name
- Name of parameterdefaultValue
- default value to return if no such parameter- Returns:
- value of parameter or defaultValue
-
fatalErrorOccured
Sets the error message and print debug information- Parameters:
error
- Error message to print
-
setState
protected void setState(int state) set the state of applet loader- Parameters:
state
- new state of applet loader
-
debug_sleep
protected void debug_sleep(long ms) Utility method for sleeping Will only really sleep if debug has been enabled- Parameters:
ms
- milliseconds to sleep
-
sleep
protected void sleep(long ms) Utility method for sleeping- Parameters:
ms
- milliseconds to sleep
-