de.grogra.pf.registry
Class Registry

java.lang.Object
  extended by de.grogra.pf.registry.Registry
All Implemented Interfaces:
GraphTransaction.Consumer, SharedObjectProvider, SharedObjectProvider.Binding, Transaction.Consumer, XAListener, RegistryContext, TypeLoader, TreeDiff.NodeModel, javax.swing.tree.TreeModel

public final class Registry
extends java.lang.Object
implements Transaction.Consumer, GraphTransaction.Consumer, XAListener, SharedObjectProvider, SharedObjectProvider.Binding, javax.swing.tree.TreeModel, RegistryContext, TreeDiff.NodeModel, TypeLoader

The registry consists of a tree of items. Each item has a name and can be referenced like in a file system. The path for selecting an item is similar to a unix path (i. e. /ui/commands).

Author:
nmi

Nested Class Summary
 
Nested classes/interfaces inherited from interface de.grogra.persistence.Transaction.Consumer
Transaction.Consumer.Adapter, Transaction.Consumer.Multicaster
 
Nested classes/interfaces inherited from interface de.grogra.graph.impl.GraphTransaction.Consumer
GraphTransaction.Consumer.Adapter, GraphTransaction.Consumer.Multicaster
 
Nested classes/interfaces inherited from interface de.grogra.persistence.XAListener
XAListener.WeakDelegate
 
Nested classes/interfaces inherited from interface de.grogra.persistence.SharedObjectProvider
SharedObjectProvider.Binding
 
Field Summary
static JoinedFileSystem ALL_FILE_SYSTEMS
           
static MimeType MIME_TYPE
           
static java.lang.String NAMESPACE
           
static JoinedFileSystem PLUGIN_FILE_SYSTEMS
           
static java.lang.String PROJECT_GRAPH
           
static java.lang.String REGISTRY_GRAPH
           
 
Constructor Summary
Registry(Registry parentRegistry)
           
 
Method Summary
 boolean activateItems()
           
 void addEdgeBits(Node source, Node target, int mask)
           
 void addFileSystemListener(javax.swing.event.TreeModelListener l)
           
 SONodeReference addSharedObject(java.lang.String directory, Shareable object, java.lang.String name, boolean objDescribes)
          Adds a SharedObjectNode for object to the meta-graph (see GraphManager.META_GRAPH) of the project graph (see getProjectGraph()), and creates a reference to this node in the specified directory of this registry.
 void addTreeModelListener(javax.swing.event.TreeModelListener l)
           
static int allocatePropertyId()
           
 void begin()
           
 void beginXA()
           
 java.lang.Class classForName(java.lang.String name)
           
 void commitXA(boolean activateItems)
           
static Registry create(Registry parentRegistry)
           
 void createGraphs(PersistenceConnection conn)
           
 org.xml.sax.ContentHandler createXMLReader()
           
 SAXSource createXMLSource(java.util.Collection requiredPlugins)
           
static Registry current()
           
 void dispose()
           
 void end()
           
 boolean equals(java.lang.Object a, java.lang.Object b)
           
 Item[] findAll(ItemCriterion c, java.lang.Object info, boolean resolve)
           
 Item findFirst(ItemCriterion c, java.lang.Object info, boolean resolve)
           
 Item findMax(ItemComparator c, java.lang.Object info, boolean resolve)
           
 void forAll(ItemCriterion c, java.lang.Object info, ItemVisitor cb, java.lang.Object cbInfo, boolean resolve)
           
 int getActivationStamp()
           
 java.lang.Object getChild(java.lang.Object parent, int index)
           
 int getChildCount(java.lang.Object parent)
           
 java.lang.ClassLoader getClassLoader()
           
 TreeDiff.DiffInfo getDiffInfo(java.lang.Object node)
           
 Item getDirectory(java.lang.String path, PluginDescriptor plugin)
          Return the item specified by its absolute path or create such an item if does not yet exist.
 java.util.Collection getFiles()
           
 FileSystem getFileSystem()
           
 java.lang.String getFileSystemName()
           
 java.lang.Object getImportAttribute(java.lang.String key)
           
 int getIndexOfChild(java.lang.Object parent, java.lang.Object child)
           
 Item getItem(java.lang.String key)
           
 java.lang.Object getLock()
           
 java.util.logging.Logger getLogger()
           
 Registry getParentRegistry()
           
 PluginDescriptor getPluginDescriptor(java.lang.String pluginId)
           
 Item getPluginDirectory()
           
 java.lang.Object getProjectFile(java.lang.String systemId)
           
 GraphManager getProjectGraph()
           
 java.lang.String getProjectName()
           
 java.lang.String getProviderName()
           
 Registry getRegistry()
          Returns the Registry which is linked with this instance.
 GraphManager getRegistryGraph()
           
 java.lang.Object getRoot()
           
 Registry getRootRegistry()
           
 Transaction getTransaction()
           
 java.lang.Object getUserProperty(int id)
           
 java.lang.Object getWriteLock()
           
 void initFileSystem(FileSystem fileSystem)
           
 void initialize()
           
 void insertComponent(PersistenceCapable o, PersistenceField field, int[] indices, Transaction.Reader reader)
           
 void invokeAfterCommit(java.lang.Runnable r)
           
 boolean isActive()
           
 boolean isLeaf(java.lang.Object node)
           
 boolean isRootRegistry()
           
 SharedObjectProvider lookup(java.lang.String name)
           
 void makePersistent(long id, ManageableType type)
           
 void makeTransient(PersistenceCapable o, ManageableType type)
           
 void readData(PersistenceCapable o, Transaction.Reader reader)
           
 ResolvableReference readReference(PersistenceInput in)
           
 void removeComponent(PersistenceCapable o, PersistenceField field, int[] indices, Transaction.Reader reader)
           
 void removeEdgeBits(Node source, Node target, int mask)
           
 void removeFileSystemListener(javax.swing.event.TreeModelListener l)
           
 void removeTreeModelListener(javax.swing.event.TreeModelListener l)
           
static void setCurrent(RegistryContext current)
           
 void setEmptyGraph()
           
 void setField(PersistenceCapable o, PersistenceField field, int[] indices, Transaction.Reader reader)
           
 void setProjectName(java.lang.String projectName)
           
 java.lang.Object setUserProperty(int id, java.lang.Object value)
           
 void startup()
           
 void substituteFileSystem(FileSystem newfs)
           
 void transactionApplied(Transaction.Data xa, boolean rollback)
           
 Type typeForName(java.lang.String name)
           
 void valueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)
           
 void writeObject(Shareable object, PersistenceOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALL_FILE_SYSTEMS

public static final JoinedFileSystem ALL_FILE_SYSTEMS

MIME_TYPE

public static final MimeType MIME_TYPE

NAMESPACE

public static final java.lang.String NAMESPACE
See Also:
Constant Field Values

PLUGIN_FILE_SYSTEMS

public static final JoinedFileSystem PLUGIN_FILE_SYSTEMS

PROJECT_GRAPH

public static final java.lang.String PROJECT_GRAPH
See Also:
Constant Field Values

REGISTRY_GRAPH

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

Registry

public Registry(Registry parentRegistry)
Method Detail

activateItems

public final boolean activateItems()

addEdgeBits

public void addEdgeBits(Node source,
                        Node target,
                        int mask)
Specified by:
addEdgeBits in interface GraphTransaction.Consumer

addFileSystemListener

public void addFileSystemListener(javax.swing.event.TreeModelListener l)

addSharedObject

public SONodeReference addSharedObject(java.lang.String directory,
                                       Shareable object,
                                       java.lang.String name,
                                       boolean objDescribes)
Adds a SharedObjectNode for object to the meta-graph (see GraphManager.META_GRAPH) of the project graph (see getProjectGraph()), and creates a reference to this node in the specified directory of this registry. The name is chosen based on name in the same way as in Item.addUserItemWithUniqueName(Item, String).

Parameters:
directory - absolute path where to insert reference item
object - object for which references shall be created
name - base name to use
objDescribes - true iff object shall be queried for descriptions (e.g., for the icon)
Returns:
reference item to object in registry

addTreeModelListener

public void addTreeModelListener(javax.swing.event.TreeModelListener l)
Specified by:
addTreeModelListener in interface javax.swing.tree.TreeModel

allocatePropertyId

public static int allocatePropertyId()

begin

public void begin()
Specified by:
begin in interface Transaction.Consumer

beginXA

public final void beginXA()

classForName

public java.lang.Class classForName(java.lang.String name)
                             throws java.lang.ClassNotFoundException
Specified by:
classForName in interface TypeLoader
Throws:
java.lang.ClassNotFoundException

commitXA

public final void commitXA(boolean activateItems)

create

public static Registry create(Registry parentRegistry)

createGraphs

public void createGraphs(PersistenceConnection conn)

createXMLReader

public org.xml.sax.ContentHandler createXMLReader()

createXMLSource

public SAXSource createXMLSource(java.util.Collection requiredPlugins)

current

public static Registry current()

dispose

public void dispose()

end

public void end()
Specified by:
end in interface Transaction.Consumer

equals

public boolean equals(java.lang.Object a,
                      java.lang.Object b)
Specified by:
equals in interface TreeDiff.NodeModel

findAll

public Item[] findAll(ItemCriterion c,
                      java.lang.Object info,
                      boolean resolve)

findFirst

public Item findFirst(ItemCriterion c,
                      java.lang.Object info,
                      boolean resolve)

findMax

public Item findMax(ItemComparator c,
                    java.lang.Object info,
                    boolean resolve)

forAll

public void forAll(ItemCriterion c,
                   java.lang.Object info,
                   ItemVisitor cb,
                   java.lang.Object cbInfo,
                   boolean resolve)

getActivationStamp

public int getActivationStamp()

getChild

public java.lang.Object getChild(java.lang.Object parent,
                                 int index)
Specified by:
getChild in interface javax.swing.tree.TreeModel

getChildCount

public int getChildCount(java.lang.Object parent)
Specified by:
getChildCount in interface javax.swing.tree.TreeModel

getClassLoader

public java.lang.ClassLoader getClassLoader()
Specified by:
getClassLoader in interface TypeLoader

getDiffInfo

public TreeDiff.DiffInfo getDiffInfo(java.lang.Object node)
Specified by:
getDiffInfo in interface TreeDiff.NodeModel

getDirectory

public Item getDirectory(java.lang.String path,
                         PluginDescriptor plugin)
Return the item specified by its absolute path or create such an item if does not yet exist. plugin is stored as the plugin that was responsible for creating the item (only if an item was created). plugin may be null to signal that there is no responsible instance.

Parameters:
path - absolute path
plugin - descriptor of responsible plugin
Returns:
item specified by path

getFiles

public java.util.Collection getFiles()

getFileSystem

public FileSystem getFileSystem()

getFileSystemName

public final java.lang.String getFileSystemName()

getImportAttribute

public java.lang.Object getImportAttribute(java.lang.String key)

getIndexOfChild

public int getIndexOfChild(java.lang.Object parent,
                           java.lang.Object child)
Specified by:
getIndexOfChild in interface javax.swing.tree.TreeModel

getItem

public Item getItem(java.lang.String key)

getLock

public java.lang.Object getLock()

getLogger

public java.util.logging.Logger getLogger()

getParentRegistry

public Registry getParentRegistry()

getPluginDescriptor

public PluginDescriptor getPluginDescriptor(java.lang.String pluginId)

getPluginDirectory

public final Item getPluginDirectory()

getProjectFile

public final java.lang.Object getProjectFile(java.lang.String systemId)

getProjectGraph

public GraphManager getProjectGraph()

getProjectName

public java.lang.String getProjectName()

getProviderName

public java.lang.String getProviderName()
Specified by:
getProviderName in interface SharedObjectProvider

getRegistry

public Registry getRegistry()
Description copied from interface: RegistryContext
Returns the Registry which is linked with this instance.

Specified by:
getRegistry in interface RegistryContext
Returns:
the registry linked with this instance

getRegistryGraph

public GraphManager getRegistryGraph()

getRoot

public java.lang.Object getRoot()
Specified by:
getRoot in interface javax.swing.tree.TreeModel

getRootRegistry

public Registry getRootRegistry()

getTransaction

public final Transaction getTransaction()

getUserProperty

public java.lang.Object getUserProperty(int id)

getWriteLock

public java.lang.Object getWriteLock()

initFileSystem

public void initFileSystem(FileSystem fileSystem)

initialize

public void initialize()

insertComponent

public void insertComponent(PersistenceCapable o,
                            PersistenceField field,
                            int[] indices,
                            Transaction.Reader reader)
Specified by:
insertComponent in interface Transaction.Consumer

invokeAfterCommit

public final void invokeAfterCommit(java.lang.Runnable r)

isActive

public boolean isActive()

isLeaf

public boolean isLeaf(java.lang.Object node)
Specified by:
isLeaf in interface javax.swing.tree.TreeModel

isRootRegistry

public final boolean isRootRegistry()

lookup

public SharedObjectProvider lookup(java.lang.String name)
Specified by:
lookup in interface SharedObjectProvider.Binding

makePersistent

public void makePersistent(long id,
                           ManageableType type)
Specified by:
makePersistent in interface Transaction.Consumer

makeTransient

public void makeTransient(PersistenceCapable o,
                          ManageableType type)
Specified by:
makeTransient in interface Transaction.Consumer

readData

public void readData(PersistenceCapable o,
                     Transaction.Reader reader)
Specified by:
readData in interface Transaction.Consumer

readReference

public ResolvableReference readReference(PersistenceInput in)
                                  throws java.io.IOException
Specified by:
readReference in interface SharedObjectProvider
Throws:
java.io.IOException

removeComponent

public void removeComponent(PersistenceCapable o,
                            PersistenceField field,
                            int[] indices,
                            Transaction.Reader reader)
Specified by:
removeComponent in interface Transaction.Consumer

removeEdgeBits

public void removeEdgeBits(Node source,
                           Node target,
                           int mask)
Specified by:
removeEdgeBits in interface GraphTransaction.Consumer

removeFileSystemListener

public void removeFileSystemListener(javax.swing.event.TreeModelListener l)

removeTreeModelListener

public void removeTreeModelListener(javax.swing.event.TreeModelListener l)
Specified by:
removeTreeModelListener in interface javax.swing.tree.TreeModel

setCurrent

public static void setCurrent(RegistryContext current)

setEmptyGraph

public void setEmptyGraph()

setField

public void setField(PersistenceCapable o,
                     PersistenceField field,
                     int[] indices,
                     Transaction.Reader reader)
Specified by:
setField in interface Transaction.Consumer

setProjectName

public void setProjectName(java.lang.String projectName)

setUserProperty

public java.lang.Object setUserProperty(int id,
                                        java.lang.Object value)

startup

public void startup()

substituteFileSystem

public void substituteFileSystem(FileSystem newfs)
                          throws java.io.IOException
Throws:
java.io.IOException

transactionApplied

public void transactionApplied(Transaction.Data xa,
                               boolean rollback)
Specified by:
transactionApplied in interface XAListener

typeForName

public Type typeForName(java.lang.String name)
                 throws java.lang.ClassNotFoundException
Specified by:
typeForName in interface TypeLoader
Throws:
java.lang.ClassNotFoundException

valueForPathChanged

public void valueForPathChanged(javax.swing.tree.TreePath path,
                                java.lang.Object newValue)
Specified by:
valueForPathChanged in interface javax.swing.tree.TreeModel

writeObject

public void writeObject(Shareable object,
                        PersistenceOutput out)
                 throws java.io.IOException
Specified by:
writeObject in interface SharedObjectProvider
Throws:
java.io.IOException