Package com.iizix.prop
Class PropFactory
- java.lang.Object
- com.iizix.prop.PropFactory
public class PropFactory extends java.lang.Object
This class handles definitions of available properties, available as predefined or plug-in classes extending theGProp
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
Constructor Summary
Constructors Constructor Description PropFactory(int programType)
Constructs the property factory with the default class loader.PropFactory(int programType, java.lang.ClassLoader classLoader)
Constructs the property factory.
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.HashMap<java.lang.String,java.lang.String>
createClientClassNameMap(boolean jsClient)
Creates the map used to replace server/editor class names with client ones.org.w3c.dom.Document
createDocument(PropCnr pc)
Creates a Document from a property container.java.util.HashMap<java.lang.String,java.lang.String>
createEditorServerClassNameMap()
Creates the map used to replace class names for communication between the editor and the server.GProp<?>
createProp(java.lang.String tag, Atom atom)
Creates a generic property with the specified tag name and atom.PropMgr
createPropertyManager(int application, java.util.Map<java.lang.String,java.lang.String> classNameMapper)
Creates a Property Manager for the application type.protected java.net.URL
getFile(java.lang.String fn)
Maps a file name into a File object in the class path.IPluginDescriptor<?>[]
getLoadedPlugins()
Gets a list of the loaded Server plug-in descriptors.java.util.List<IPluginDescriptor<?>>
getLoadedPlugins(java.lang.String names)
Gets a list of the loaded Server plug-in descriptors.int
getProgramType()
java.lang.Class<? extends GProp<?>>
getPropClass(java.lang.String className)
Gets the property class from a class name.boolean
isPlugInRegistered(java.lang.String name)
Registers a plug-in.void
loadPropDefinitions()
Loads the "schema/base-properties.xml" file using the "schema/property-definition-1.0.xsd" schema.GProp<?>
loadPropTree(GProp<?> parent, org.w3c.dom.Element element)
Creates the GProp tree from an Element.PropCnr
loadPropTree(PropMgr propertyManager, java.io.File file, boolean setPropMgrToProps)
Loads a property tree from an XML file.PropCnr
loadPropTree(PropMgr propertyManager, java.lang.String fileName, java.io.InputStream in, boolean setPropMgrToProps)
Loads a property tree from an XML file.PropCnr
loadPropTree(PropMgr propertyManager, org.w3c.dom.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(java.lang.String name, java.net.URL url, java.lang.ClassLoader classLoader, IPluginDescriptor<?> serverPluginDescriptor)
Registers a plug-in.static void
setDesignerInterface(IPropFactory designerInterface)
Assigns the Designer factory interface.
Field Detail
CLIENT
public static final int CLIENT
The application type: CLIENT = 0.- See Also:
- Constant Field Values
SERVER
public static final int SERVER
The application type: SERVER = 1.- See Also:
- Constant Field Values
EDITOR
public static final int EDITOR
The application type: EDITOR = 2.- See Also:
- Constant Field Values
Constructor Detail
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
public PropFactory(int programType, java.lang.ClassLoader classLoader)
Constructs the property factory.- Parameters:
programType
- Value indicating what program type is running, CLIENT, SERVER or EDITOR.classLoader
- The class loader.
Method Detail
getProgramType
public int getProgramType()
getPropClass
public java.lang.Class<? extends GProp<?>> getPropClass(java.lang.String className)
Gets the property class from a class name.- Parameters:
className
- The class name.- Returns:
- The class, or null for not found.
getFile
protected java.net.URL getFile(java.lang.String fn)
Maps a file name into a File object in the class path.- Parameters:
fn
- The file name.- Returns:
- null if not resolved.
loadPropDefinitions
public void loadPropDefinitions() throws java.io.IOException
Loads the "schema/base-properties.xml" file using the "schema/property-definition-1.0.xsd" schema.- Throws:
java.io.IOException
- for load errors.
loadPropTree
public PropCnr loadPropTree(PropMgr propertyManager, java.io.File file, boolean setPropMgrToProps) throws java.io.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:
java.io.IOException
- for file errors.PropException
- for property errors.
loadPropTree
public PropCnr loadPropTree(PropMgr propertyManager, java.lang.String fileName, java.io.InputStream in, boolean setPropMgrToProps) throws java.io.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:
java.io.IOException
- for file errors.PropException
- for property errors.
loadPropTree
public PropCnr loadPropTree(PropMgr propertyManager, org.w3c.dom.Document document, boolean setPropMgrToProps) throws java.io.IOException, PropException
Loads a property tree from an XML document.- Parameters:
propertyManager
- the PropertyManager instance.document
- the Document.- Returns:
- the property container.
- Throws:
java.io.IOException
- for file errors.PropException
- for property errors.
loadPropTree
public GProp<?> loadPropTree(GProp<?> parent, org.w3c.dom.Element element) throws PropException
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
public java.util.HashMap<java.lang.String,java.lang.String> createClientClassNameMap(boolean jsClient)
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
public java.util.HashMap<java.lang.String,java.lang.String> createEditorServerClassNameMap()
Creates the map used to replace class names for communication between the editor and the server.- Returns:
- Map the map of names.
createDocument
public org.w3c.dom.Document createDocument(PropCnr pc)
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:
java.lang.IllegalStateException
- If the factory does not match the run mode, i.e. Designer or Server (Client is not allowed).
isPlugInRegistered
public boolean isPlugInRegistered(java.lang.String name)
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(java.lang.String name, java.net.URL url, java.lang.ClassLoader classLoader, IPluginDescriptor<?> serverPluginDescriptor) throws java.io.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:
java.io.IOException
- for load errors.
getLoadedPlugins
public IPluginDescriptor<?>[] getLoadedPlugins()
Gets a list of the loaded Server plug-in descriptors.- Returns:
- The list of plug-in descriptors.
getLoadedPlugins
public java.util.List<IPluginDescriptor<?>> getLoadedPlugins(java.lang.String names) throws java.io.IOException
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:
java.io.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
public PropMgr createPropertyManager(int application, java.util.Map<java.lang.String,java.lang.String> classNameMapper)
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
public GProp<?> createProp(java.lang.String tag, Atom atom)
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
public static void setDesignerInterface(IPropFactory designerInterface)
Assigns the Designer factory interface.Note: this can only be done in the Designer ONCE.
processQueryDesignerProps
public 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.- Parameters:
ref
- The property reference instance.event
- The event.