org.nlogo.api
Interface ExtensionManager

All Known Implementing Classes:
ExtensionManager

public interface ExtensionManager

ExtensionManager provides some methods that can be used in runOnce


Method Summary
 void addToLibraryPath(Object classManager, String directory)
           
 boolean anyExtensionsLoaded()
          Returns true if any extensions have been imported in the current model, false otherwise.
 String dumpExtensionPrimitives()
           
 String dumpExtensions()
           
 void finishFullCompilation()
          Instructs any extensions which haven't been re-imported during the current compile to shut down.
 List<String> getExtensionNames()
           
 File getFile(String path)
           
 List<String> getJarPaths()
           
 String getSource(String filename)
           
 void importExtension(String jarPath, ErrorSource errors)
          Loads the extension contained in the jar at jarPath.
 ExtensionObject readExtensionObject(String extname, String typeName, String value)
           
 Object readFromString(String src)
           
 Primitive replaceIdentifier(String name)
          Returns the identifier "name" by its imported implementation, if any, or null, if not.
 void reset()
          Instructs any loaded extensions to unload.
 String resolvePath(String path)
           
 String resolvePathAsURL(String path)
           
 Object retrieveObject()
          Returns the stored object.
 void startFullCompilation()
          During compilation, we reach the extensions [ ... ] block.
 void storeObject(Object obj)
          Stores an object for the extension that can be retrieved in runOnce if the extension is loaded again.
 

Method Detail

storeObject

void storeObject(Object obj)
Stores an object for the extension that can be retrieved in runOnce if the extension is loaded again. This is useful if the extension has initialization it needs to perform that should only happen once, even if the extension is loaded multiple times.

Parameters:
obj - the object to be stored

retrieveObject

Object retrieveObject()
Returns the stored object.

Returns:
the stored object

readExtensionObject

ExtensionObject readExtensionObject(String extname,
                                    String typeName,
                                    String value)
                                    throws CompilerException
Throws:
CompilerException

readFromString

Object readFromString(String src)
                      throws CompilerException
Throws:
CompilerException

reset

void reset()
Instructs any loaded extensions to unload. Should be called previous to a new model load.


startFullCompilation

void startFullCompilation()
During compilation, we reach the extensions [ ... ] block. When that happens, the compiler tells the ExtensionManager that it needs to forget what extensions are in the extensions [ ... ] block, by calling this method. The compiler will then call the importExtension method for each extension in the block. Among other things, this lets the ExtensionManager know each extension that is "live", or currently in the block, so that its primitives are available for use elsewhere in the model.


finishFullCompilation

void finishFullCompilation()
Instructs any extensions which haven't been re-imported during the current compile to shut down. Should be called during each full re-compile.


anyExtensionsLoaded

boolean anyExtensionsLoaded()
Returns true if any extensions have been imported in the current model, false otherwise.


replaceIdentifier

Primitive replaceIdentifier(String name)
Returns the identifier "name" by its imported implementation, if any, or null, if not.


importExtension

void importExtension(String jarPath,
                     ErrorSource errors)
                     throws CompilerException
Loads the extension contained in the jar at jarPath.

Parameters:
jarPath - the path to the extension jar. May be relative to the current model directory.
errors - the ErrorSource to use when a CompilerException needs to be thrown.
Throws:
CompilerException

resolvePath

String resolvePath(String path)

resolvePathAsURL

String resolvePathAsURL(String path)

dumpExtensions

String dumpExtensions()

dumpExtensionPrimitives

String dumpExtensionPrimitives()

getSource

String getSource(String filename)
                 throws IOException
Throws:
IOException

addToLibraryPath

void addToLibraryPath(Object classManager,
                      String directory)

getFile

File getFile(String path)
             throws ExtensionException
Throws:
ExtensionException

getJarPaths

List<String> getJarPaths()

getExtensionNames

List<String> getExtensionNames()