The development flow using the Object Control Facility is as follows.
Create each object from subclasses of Java Object.
Define a subclass of JFCObjectLoaderManager, and register the objects.
By calling the add method in JFCObjectLoaderManager, register each object. The object names specified for each object using the add method must be unique among the object names.
After adding all objects created in step 2, manage and control the objects.
First, by calling the getObject method, get a reference to the object. If the object creation timing is specified as DELAYED_CREATION, realizeObject method should be called beforehand.
Second, appropriate operation can be performed on the object.
And last, to remove the object from the memory, the releaseObject method is called. Whether the memory of the object is freed or not depends on the release timing of the object.
For example, the ObjectManager class is defined as subclass of JFCObjectLoaderManager class, and the SubButton class is defined as subclass of java.awt.Button class. The following code shows the usage of the object.
//The subclass of JFCObjectLoaderManager public class SubObjectManager extends JFCObjectLoaderManager { public SubObjectManager() { this.add("Button1", "SubButton", JFCObjectLoader.DELAYED_CREATION, JFCObjectLoader.TEMPORARY_INSTANCE); //add arguments are described below //1st argument specifies he object name. //2nd argument specifies the created object class name. //3rd argument specifies the object creation timing. // For the above example, the object is created when the realizeObject method is called. // Refer to "Creation Timing List" below for other creation timings. //4th argument specifies the object release timing. // For the above example, the object is released when the releaseObject method is called. // Refer to "Release Timing List" below for other release timings. //Other objects can be registered in the same way as above. this.add(......); .... } } |
Timing | Class Variable to specify | Description |
---|---|---|
at Initialization | JFCObjectLoader.INIT_CREATION | Create the object immediately when add method is called. |
when realizeObject is called | JFCObjectLoader.DELAYED_CREATION | Create the object when the realizeObject method is called. |
Asynchronously at Initialization | JFCObjectLoader.BACKGROUND_CREATION | Create the object when the add method is called, using a separate thread from the application or applet. |
Timing | Class Variable to specify | Description |
---|---|---|
when releaseObject is called | JFCObjectLoader.TEMPORARY_INSTANCE | The object is released from memory when the releaseObject method is called. |
Buffered when releaseObject is called | JFCObjectLoader.BUFFERED_INSTANCE | The object is held in a memory buffer when the releaseObject method is called. When the number of objects held in the memory buffer exceeds the limit of buffered objects set in JFCObjectLoaderManager, the oldest object is released from memory. |
at Application/Applet termination | JFCObjectLoader.PERMANENT_INSTANCE | The object is held in memory until the JFCObjectLoaderManager (or subclass of JFCObjectLoaderManager) managing the object is released from memory. |
Note
The applications or applets using Object Control Facility may use the setURLs or addURL method of JFCObjectLoader to specify the location of the object class, so that the object class can be loaded via the network at the time of object creation as if the object class is loaded locally. Note that in the case of applet, due to the security restriction, only the host from which the applet has been downloaded is trusted. The same restriction is applied when using setURLs or addURL in a applet. For the case of application, you can use setURLs and addURL as you wish.