com.voytechs.jnetstream.protocol
Class ClasspathProtocolLoader

java.lang.Object
  extended by com.voytechs.jnetstream.protocol.ClasspathProtocolLoader
All Implemented Interfaces:
ProtocolLoader

public class ClasspathProtocolLoader
extends java.lang.Object
implements ProtocolLoader

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Field Summary
static java.lang.String PROTOCOL_DIR
           
 
Fields inherited from interface com.slytechs.jnetstream.protocol.ProtocolLoader
PROPERTY_JAVA_CLASS_PATH, PROPERTY_NPL_PROTOCOL_PATH
 
Constructor Summary
ClasspathProtocolLoader()
           
ClasspathProtocolLoader(ProtocolLoader parent, ProtocolRegistry registry)
           
 
Method Summary
 Protocol findLoadedProtocol(java.lang.String name)
          Will search only in the list of protocols that have been already defined in the ProtocolRegistry.
 Protocol findProtocol(java.lang.String name)
          Will search in the list of protocols that have been already defined in the ProtocolRegistry and in other places as defined by the implementation of this interface.
 ProtocolLoader getParent()
          Returns the parent ProtocolLoader.
 java.net.URL getResource(java.lang.String name)
          Method that returns a URL for the requested named resource.
 java.io.InputStream getResourceAsStream(java.lang.String name)
          Opens up an InputStream to the resource if found.
 Protocol linkProtocol(java.lang.String name)
          Links the named protocol into the runtime environment.
 Protocol loadProtocol(java.io.InputStream in, java.net.URL url)
          Loads a protocol definition from a user supplied stream.
 Protocol loadProtocol(java.lang.String name)
          Loads either the binary protocol file or invokes the compiler to compile the source protocol definition to binary form and loads it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROTOCOL_DIR

public static final java.lang.String PROTOCOL_DIR
See Also:
Constant Field Values
Constructor Detail

ClasspathProtocolLoader

public ClasspathProtocolLoader()

ClasspathProtocolLoader

public ClasspathProtocolLoader(ProtocolLoader parent,
                               ProtocolRegistry registry)
Method Detail

findProtocol

public Protocol findProtocol(java.lang.String name)
                      throws ProtocolNotFoundException
Description copied from interface: ProtocolLoader

Will search in the list of protocols that have been already defined in the ProtocolRegistry and in other places as defined by the implementation of this interface.

Specified by:
findProtocol in interface ProtocolLoader
Parameters:
name - name of the protocol to locate
Returns:
protocol if found, otherwise null
Throws:
ProtocolNotFoundException

loadProtocol

public Protocol loadProtocol(java.lang.String name)
                      throws ProtocolDeclarationException,
                             ProtocolNotFoundException,
                             java.io.IOException
Description copied from interface: ProtocolLoader
Loads either the binary protocol file or invokes the compiler to compile the source protocol definition to binary form and loads it. Does not perform link on the protocol.

Specified by:
loadProtocol in interface ProtocolLoader
Parameters:
name - name of the protocol to load
Returns:
protocol that has been fully loaded. This method never returns null.
Throws:
ProtocolDeclarationException - if the protocol binary or source files contain some kind of delaration or syntax errors
ProtocolNotFoundException - if the protocol binary and source files can not be found
java.io.IOException - any problems with physically accessing the files

linkProtocol

public Protocol linkProtocol(java.lang.String name)
                      throws ProtocolFormatException,
                             ProtocolNotFoundException,
                             ProtocolDeclarationException,
                             java.io.IOException,
                             ProtocolBindingException
Description copied from interface: ProtocolLoader
Links the named protocol into the runtime environment. This should only be done by the runtime system at an appropriate time. If done by the user too early, unresolved link exceptions may be thrown.

Specified by:
linkProtocol in interface ProtocolLoader
Parameters:
name - name of the protocol to link
Returns:
protocol that has been fully linked. This method never returns null.
Throws:
ProtocolNotFoundException - if the protocol binary and source files can not be found
ProtocolDeclarationException - if the protocol binary or source files contain some kind of delaration or syntax errors
java.io.IOException - any problems with physically accessing the files
ProtocolBindingException - Any problems during the linking process. Uresolved references, etc..
ProtocolFormatException

getParent

public ProtocolLoader getParent()
Description copied from interface: ProtocolLoader
Returns the parent ProtocolLoader.

Specified by:
getParent in interface ProtocolLoader
Returns:
Returns the parent loader or null if this is the root system loader.

getResource

public java.net.URL getResource(java.lang.String name)
Description copied from interface: ProtocolLoader
Method that returns a URL for the requested named resource.

Specified by:
getResource in interface ProtocolLoader
Parameters:
name - name of the resource (protocol declaration, image, or anything else to search for.)
Returns:
url to the resource or null if not found

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String name)
Description copied from interface: ProtocolLoader
Opens up an InputStream to the resource if found.

Specified by:
getResourceAsStream in interface ProtocolLoader
Parameters:
name - name of the resource to open
Returns:
InputStream bound to the named resource

findLoadedProtocol

public Protocol findLoadedProtocol(java.lang.String name)
Description copied from interface: ProtocolLoader

Will search only in the list of protocols that have been already defined in the ProtocolRegistry. Will not perform an extensive search for the protocol.

Specified by:
findLoadedProtocol in interface ProtocolLoader
Parameters:
name - name of the protocol to locate
Returns:
protocol if found, otherwise null

loadProtocol

public Protocol loadProtocol(java.io.InputStream in,
                             java.net.URL url)
                      throws ProtocolDeclarationException
Loads a protocol definition from a user supplied stream. The URL is required to help identify the protocol and report errors.

Specified by:
loadProtocol in interface ProtocolLoader
Parameters:
protocolNplDef -
Returns:
protocol that has been loaded with the definition from the stream. This method never returns null.
Throws:
ProtocolDeclarationException