Package com.iizix.prop
Class PropFactory
java.lang.Object
com.iizix.prop.PropFactory
This class handles definitions of available properties, available as predefined or plug-in classes extending the
GProp
class. Processing of these properties classes is handled in different ways for the client, server and editor. The client has functionality towards Swing, the server for storing the properties in XML files, and the editor provides developer-functions for Eclipse.- Author:
- Christopher Mindus
Field Summary
Constructor Summary
ConstructorDescriptionPropFactory
(int programType) Constructs the property factory with the default class loader.PropFactory
(int programType, ClassLoader classLoader) Constructs the property factory.Method Summary
Modifier and TypeMethodDescriptioncreateClientClassNameMap
(boolean jsClient) Creates the map used to replace server/editor class names with client ones.Creates a Document from a property container.Creates the map used to replace class names for communication between the editor and the server.GProp
<?> createProp
(String tag, Atom atom) Creates a generic property with the specified tag name and atom.createPropertyManager
(int application, Map<String, String> classNameMapper) Creates a Property Manager for the application type.protected URL
Maps a file name into a File object in the class path.IPluginDescriptor<?>[]
Gets a list of the loaded Server plug-in descriptors.getLoadedPlugins
(String names) Gets a list of the loaded Server plug-in descriptors.int
getPropClass
(String className) Gets the property class from a class name.boolean
isPlugInRegistered
(String name) Registers a plug-in.void
Loads the "schema/base-properties.xml" file using the "schema/property-definition-1.0.xsd" schema.GProp
<?> loadPropTree
(GProp<?> parent, Element element) Creates the GProp tree from an Element.loadPropTree
(PropMgr propertyManager, File file, boolean setPropMgrToProps) Loads a property tree from an XML file.loadPropTree
(PropMgr propertyManager, String fileName, InputStream in, boolean setPropMgrToProps) Loads a property tree from an XML file.loadPropTree
(PropMgr propertyManager, Document document, boolean setPropMgrToProps) Loads a property tree from an XML document.static void
processQueryDesignerProps
(PropReference ref, GEvent event) Requests processing of the method by the Designer factory interface, done when thePropReference
gets theGEvent.PROP_QUERY_DESIGNER_PROPS
event.void
registerPlugIn
(String name, URL url, ClassLoader classLoader, IPluginDescriptor<?> serverPluginDescriptor) Registers a plug-in.static void
setDesignerInterface
(IPropFactory designerInterface) Assigns the Designer factory interface.
Field Details
CLIENT
public static final int CLIENTThe application type: CLIENT = 0.- See Also:
SERVER
public static final int SERVERThe application type: SERVER = 1.- See Also:
EDITOR
public static final int EDITORThe application type: EDITOR = 2.- See Also:
Constructor Details
PropFactory
public PropFactory(int programType) Constructs the property factory with the default class loader.- Parameters:
programType
- Value indicating what program type is running, CLIENT, SERVER or EDITOR.
PropFactory
Constructs the property factory.- Parameters:
programType
- Value indicating what program type is running, CLIENT, SERVER or EDITOR.classLoader
- The class loader.
Method Details
getProgramType
public int getProgramType()getPropClass
Gets the property class from a class name.- Parameters:
className
- The class name.- Returns:
- The class, or null for not found.
getFile
Maps a file name into a File object in the class path.- Parameters:
fn
- The file name.- Returns:
- null if not resolved.
loadPropDefinitions
Loads the "schema/base-properties.xml" file using the "schema/property-definition-1.0.xsd" schema.- Throws:
IOException
- for load errors.
loadPropTree
public PropCnr loadPropTree(PropMgr propertyManager, File file, boolean setPropMgrToProps) throws IOException, PropException Loads a property tree from an XML file.- Parameters:
propertyManager
- The PropertyManager instance.file
- The file to load.setPropMgrToProps
- Flag to initialize the property manager to the properties.- Returns:
- the property container.
- Throws:
IOException
- for file errors.PropException
- for property errors.
loadPropTree
public PropCnr loadPropTree(PropMgr propertyManager, String fileName, InputStream in, boolean setPropMgrToProps) throws IOException, PropException Loads a property tree from an XML file.- Parameters:
propertyManager
- The PropertyManager instance.fileName
- The file name for logging and error messages/logging.in
- The input stream.setPropMgrToProps
- Flag to initialize the property manager to the properties.- Returns:
- the property container.
- Throws:
IOException
- for file errors.PropException
- for property errors.
loadPropTree
public PropCnr loadPropTree(PropMgr propertyManager, Document document, boolean setPropMgrToProps) throws IOException, PropException Loads a property tree from an XML document.- Parameters:
propertyManager
- the PropertyManager instance.document
- the Document.- Returns:
- the property container.
- Throws:
IOException
- for file errors.PropException
- for property errors.
loadPropTree
Creates the GProp tree from an Element.- Parameters:
parent
- the parent property.element
- the Element for the tree.- Returns:
- the property container.
- Throws:
PropException
- for property errors.
createClientClassNameMap
Creates the map used to replace server/editor class names with client ones.- Parameters:
jsClient
- The JavaScript client flag.- Returns:
- Map the map of names.
createEditorServerClassNameMap
Creates the map used to replace class names for communication between the editor and the server.- Returns:
- Map the map of names.
createDocument
Creates a Document from a property container.Note: this only work for the Editor, an InternalError is thrown otherwise!
- Parameters:
pc
- The property container.- Returns:
- The Document created.
- Throws:
IllegalStateException
- If the factory does not match the run mode, i.e. Designer or Server (Client is not allowed).
isPlugInRegistered
Registers a plug-in. A plug-in has an XML file that has the same format as the product-internal base definitions.- Parameters:
name
- The plug-in name.
registerPlugIn
public void registerPlugIn(String name, URL url, ClassLoader classLoader, IPluginDescriptor<?> serverPluginDescriptor) throws IOException Registers a plug-in. A plug-in has an XML file that has the same format as the product-internal base definitions.- Parameters:
name
- The plug-in name.url
- The file of the XML properties file for the plug-in.classLoader
- Additional class loader if not null.serverPluginDescriptor
- The Server plug-in descriptor, can be null only for "com.iizigo" plug-in name.- Throws:
IOException
- for load errors.
getLoadedPlugins
Gets a list of the loaded Server plug-in descriptors.- Returns:
- The list of plug-in descriptors.
getLoadedPlugins
Gets a list of the loaded Server plug-in descriptors.- Parameters:
names
- The plug-in name, e.g. "com.iizigo.db,com.iizigo.term,com.iizigo.ws".- Returns:
- The list of plug-in descriptors.
- Throws:
IOException
- If a plug-in is not loaded. This exception is thrown in order to have the same exception as the exception thrown in thecom.iizix.server.IAppLoader
interface.
createPropertyManager
Creates a Property Manager for the application type.- Parameters:
application
- The application type, EDITOR, SERVER or CLIENT.classNameMapper
- A class name mapper array, may be null for none.- Returns:
- An initialized Property Manager.
createProp
Creates a generic property with the specified tag name and atom.This method will throw an InternalError if the calling process is not the Editor.
This method will throw an NullPointerException if the tag name is not found.
- Parameters:
tag
- The tag name in the property definition XML file.atom
- The atom for the property.
setDesignerInterface
Assigns the Designer factory interface.Note: this can only be done in the Designer ONCE.
processQueryDesignerProps
Requests processing of the method by the Designer factory interface, done when thePropReference
gets theGEvent.PROP_QUERY_DESIGNER_PROPS
event.- Parameters:
ref
- The property reference instance.event
- The event.