fr.umlv.corosol.repository
Class JImplementationRepository

java.lang.Object
  extended by java.lang.ClassLoader
      extended by fr.umlv.corosol.repository.JImplementationRepository
All Implemented Interfaces:
JObject, JProxyFactory
Direct Known Subclasses:
DefaultJImplementationRepository

public abstract class JImplementationRepository
extends java.lang.ClassLoader
implements JProxyFactory

This class represents an implementation repository. All Corosol objects will be created via this repository.

It constains all associations between an abstract type and its implementation. A JImplementationRepository object is also used as a class loader.

Author:
Christophe Deleray

Nested Class Summary
static interface JImplementationRepository.Singleton
          This interface represents a singleton.
 
Constructor Summary
JImplementationRepository()
           
 
Method Summary
abstract  java.lang.Object create(java.lang.Class abstractType)
          Creates the object which is the implementation of the specified abstract type.
abstract  java.lang.Object create(int item)
          Creates the object which implementation is associated with the specified integer.
abstract  java.lang.Object create(java.lang.String item)
          Creates the object which implementation is associated with the specified String.
abstract  JInstruction createInstruction(int opcode)
          Creates the instruction object which the opcode is specified.
abstract  JClass createPrimitiveClass(java.lang.String descriptor)
          Creates a primitive class which descriptor is specified.
abstract  java.lang.String getCorosolProperty(java.lang.String key)
          Gets the Corosol property indicated by the specified key.
static JImplementationRepository getInstance()
          Returns the unique instance of this class initialized by reading the file defined by the corosol.properties environment variable value.
 java.lang.Object getNativeObject()
          Returns the object equivalent to this object but which belong to the underlaying Virtual Machine.
abstract  void loadProperties(java.util.Properties properties)
          Loads a set of properties (key and element pairs) from the specified property set.
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface fr.umlv.corosol.component.proxy.JProxyFactory
createProxy, createProxy
 

Constructor Detail

JImplementationRepository

public JImplementationRepository()
Method Detail

getNativeObject

public java.lang.Object getNativeObject()
Returns the object equivalent to this object but which belong to the underlaying Virtual Machine.


loadProperties

public abstract void loadProperties(java.util.Properties properties)
Loads a set of properties (key and element pairs) from the specified property set.

Parameters:
properties - a set of properties

create

public abstract java.lang.Object create(java.lang.Class abstractType)
                                 throws java.lang.IllegalArgumentException
Creates the object which is the implementation of the specified abstract type. The concrete implementation class, associated with the specified abstract type, will be found into this repository, and then it will be instantiated.

Parameters:
abstractType - an abstract type
Returns:
the implementation of the specified abstract type
Throws:
java.lang.IllegalArgumentException - if the specified type is unknown by this repository

create

public abstract java.lang.Object create(java.lang.String item)
                                 throws java.lang.IllegalArgumentException
Creates the object which implementation is associated with the specified String. The concrete implementation class, associated with the specified String item, will be found into this repository, and then it will be instantiated.

Parameters:
item - a String item associated with a concrete implementation
Returns:
the implementation desgined by the specified String item
Throws:
java.lang.IllegalArgumentException - if the specified String item is unknown by this repository

create

public abstract java.lang.Object create(int item)
                                 throws java.lang.IllegalArgumentException
Creates the object which implementation is associated with the specified integer. The concrete implementation class, associated with the specified int item, will be found into this repository, and then it will be instantiated.

Parameters:
item - a int item associated with a concrete implementation
Returns:
the implementation desgined by the specified int item
Throws:
java.lang.IllegalArgumentException - if the specified int item is unknown by this repository

createPrimitiveClass

public abstract JClass createPrimitiveClass(java.lang.String descriptor)
                                     throws java.lang.IllegalArgumentException
Creates a primitive class which descriptor is specified.

Parameters:
descriptor - a primitive class descriptor
Returns:
a JClass object representing a primitive class
Throws:
java.lang.IllegalArgumentException - if the specified descriptor is not a descriptor for a primitive class or unknown by this repository

createInstruction

public abstract JInstruction createInstruction(int opcode)
                                        throws java.lang.IllegalArgumentException
Creates the instruction object which the opcode is specified.

Parameters:
opcode - the opcode of the instruction to be created
Returns:
a new instruction object
Throws:
java.lang.IllegalArgumentException - if the specified opcode is not a valid opcodea or unknown by this repository

getCorosolProperty

public abstract java.lang.String getCorosolProperty(java.lang.String key)
Gets the Corosol property indicated by the specified key.

Parameters:
key - the name of the Corosol property
Returns:
the string value of the Corosol property, or null if there is no property with that key.

getInstance

public static JImplementationRepository getInstance()
Returns the unique instance of this class initialized by reading the file defined by the corosol.properties environment variable value.

Returns:
the unique instance of this class
Throws:
java.lang.InternalError - if an error occurs when attempting to create the repository