org.enhydra.shark.utilities
Class Loader

java.lang.Object
  extended by org.enhydra.shark.utilities.Loader

public class Loader
extends java.lang.Object

Author:
Svjetlana Milidrag TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates

Field Summary
 boolean cacheFilled
           
 
Constructor Summary
Loader()
          Loader Initializion classCache - key(full class name) name without extension) - value(class file) cacheTimestamp - key(full class name) - value(timestamp for class file in classCache)
Loader(com.lutris.util.Config config)
          Loader Initializion classCache - key(full class name) name without extension) - value(class file) cacheTimestamp - key(full class name) - value(timestamp for class file in classCache)
Loader(java.io.File propertyFile)
          Loader Initializion classCache - key(full class name) name without extension) - value(class file) cacheTimestamp - key(full class name) - value(timestamp for class file in classCache)
Loader(java.io.InputStream propertyIs)
          Loader Initializion classCache - key(full class name) name without extension) - value(class file) cacheTimestamp - key(full class name) - value(timestamp for class file in classCache)
Loader(java.util.Properties properties)
          Loader Initializion classCache - key(full class name) name without extension) - value(class file) cacheTimestamp - key(full class name) - value(timestamp for class file in classCache)
Loader(java.lang.String propertyFileName)
          Loader Initializion classCache - key(full class name) name without extension) - value(class file) cacheTimestamp - key(full class name) - value(timestamp for class file in classCache)
 
Method Summary
 void clearCaches()
           
 void fillLoaderCache()
          Method for searcing all file paths in mainRoot array calling recursive function searchingForFiles
 java.util.HashMap getClassCache()
           
 com.lutris.logging.LogChannel GetLogChannel()
           
 java.lang.String getProperty(java.lang.String key, java.lang.String defaultVal)
          Function for getting property as String
 java.lang.String[] getPropertyArray(java.lang.String key, java.lang.String[] defaultVal)
          Function for getting property as String[]
 java.util.Date getTimestamp(java.lang.String classname)
           
 boolean isCacheFilled()
           
 java.lang.Class loadClass(java.lang.String fullClassName, boolean force)
          method loadClass if mode is "lazy" creates file from the full path to file Function needToReload is called for checking of timestamp values, and existing cache data for searched class Reloading class if it's necessarily This function returns class file
 java.lang.Class[] loadPackage(java.lang.String packageId, boolean force)
           
 void runThread(int time)
          start thread
 void setLogChannel(com.lutris.logging.LogChannel newLogChannel)
          Function for set logChannel
 void setProperty(java.lang.String key, java.lang.String newVal)
          Set property as String
 void setPropertyArray(java.lang.String key, java.lang.String[] newValues)
          Set property value as String[] , and remove old values
 boolean seveProperty()
          Save property file
 void stopThread(int time)
          stop thread
 void updateCache(java.util.HashMap updateCacheTimestamp, java.util.HashMap updateClassCache, java.util.HashMap tempTimestamp)
          Update timestamp cache
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cacheFilled

public boolean cacheFilled
Constructor Detail

Loader

public Loader()
Loader Initializion classCache - key(full class name) name without extension) - value(class file) cacheTimestamp - key(full class name) - value(timestamp for class file in classCache)


Loader

public Loader(java.lang.String propertyFileName)
Loader Initializion classCache - key(full class name) name without extension) - value(class file) cacheTimestamp - key(full class name) - value(timestamp for class file in classCache)

Parameters:
propertyFileName - - properties file name

Loader

public Loader(java.io.File propertyFile)
Loader Initializion classCache - key(full class name) name without extension) - value(class file) cacheTimestamp - key(full class name) - value(timestamp for class file in classCache)

Parameters:
propertyFile - - properties file

Loader

public Loader(java.io.InputStream propertyIs)
Loader Initializion classCache - key(full class name) name without extension) - value(class file) cacheTimestamp - key(full class name) - value(timestamp for class file in classCache)

Parameters:
propertyIs - - InputStream for properties file

Loader

public Loader(java.util.Properties properties)
Loader Initializion classCache - key(full class name) name without extension) - value(class file) cacheTimestamp - key(full class name) - value(timestamp for class file in classCache)

Parameters:
properties - - properties object

Loader

public Loader(com.lutris.util.Config config)
       throws java.lang.Exception
Loader Initializion classCache - key(full class name) name without extension) - value(class file) cacheTimestamp - key(full class name) - value(timestamp for class file in classCache)

Parameters:
config - - config object
Throws:
java.lang.Exception
Method Detail

isCacheFilled

public boolean isCacheFilled()

loadClass

public java.lang.Class loadClass(java.lang.String fullClassName,
                                 boolean force)
                          throws java.lang.Exception
method loadClass if mode is "lazy" creates file from the full path to file Function needToReload is called for checking of timestamp values, and existing cache data for searched class Reloading class if it's necessarily This function returns class file

Parameters:
fullClassName - - full name of class(with package name) that should load
Returns:
- class object
Throws:
java.lang.ClassNotFoundException
java.lang.Exception

getTimestamp

public java.util.Date getTimestamp(java.lang.String classname)

loadPackage

public java.lang.Class[] loadPackage(java.lang.String packageId,
                                     boolean force)
                              throws java.lang.Exception
Throws:
java.lang.Exception

fillLoaderCache

public void fillLoaderCache()
                     throws java.lang.Exception
Method for searcing all file paths in mainRoot array calling recursive function searchingForFiles

Throws:
java.lang.Exception

getProperty

public java.lang.String getProperty(java.lang.String key,
                                    java.lang.String defaultVal)
Function for getting property as String

Parameters:
key - - key for property value in property file
defaultVal - - String default value if value for given key doesn't exist
Returns:
property as String if there is no value for given key, return value is default value

getPropertyArray

public java.lang.String[] getPropertyArray(java.lang.String key,
                                           java.lang.String[] defaultVal)
Function for getting property as String[]

Parameters:
key - - key for property value in property file
defaultVal - - String[] default value if value for given key doesn't exist
Returns:
property as String[] if there is no value for given key, return value is default value

setProperty

public void setProperty(java.lang.String key,
                        java.lang.String newVal)
Set property as String

Parameters:
key - - key for property value in property file
newVal - - String value that will be positioned in property object

setPropertyArray

public void setPropertyArray(java.lang.String key,
                             java.lang.String[] newValues)
Set property value as String[] , and remove old values

Parameters:
key - - key for property value in property file
newValues - - String[] of values that will be positioned in property object

seveProperty

public boolean seveProperty()
Save property file

Returns:
boolean value as true if property file is saved well, or false in counterpart

updateCache

public void updateCache(java.util.HashMap updateCacheTimestamp,
                        java.util.HashMap updateClassCache,
                        java.util.HashMap tempTimestamp)
Update timestamp cache


runThread

public void runThread(int time)
start thread


stopThread

public void stopThread(int time)
stop thread


GetLogChannel

public com.lutris.logging.LogChannel GetLogChannel()
Returns:
logChanal

setLogChannel

public void setLogChannel(com.lutris.logging.LogChannel newLogChannel)
Function for set logChannel

Parameters:
newLogChannel -

getClassCache

public java.util.HashMap getClassCache()

clearCaches

public void clearCaches()