|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.ceryle.wiki.plugin.assertion.AssertionHandlerImpl
public class AssertionHandlerImpl
As a per-WikiEngine class, AssertionHandlers create Assertions, and
receive and process AssertionEvents fired by AssertionPlugins. Methods
of this class perform any necessary update processes to the registry.
Note that the listener is enabled not by default; it must be enabled
by calling setListenerEnabled(boolean).
AssertionHandler#getAssertion(String,Term,Predicate,Term,boolean)
method in this handler (and those that aren't will be ignored by the rest
of the processing machinery), as methods in this class keep duplicate
wiki syntax declarations from repeatedly creating the same Assertion.
What we actually do is somewhat of a combination, and we avoid having to
encapsulate the session. When the end-edit event for a page editing session
shows up we check all the Assertions for that page and see if any are older
than the threshold set by the value of ASSERTION_LIFESPAN. This is
a long value representing the number of milliseconds before an Assertion is
considered "old" and likely to be from a previous editing session. This
really only has to be the maximum amount of time between the first and last
Assertion events occurring for a given page scan. The default value is a
conservative 10,000 (10 sec).
We've concentrated our efforts on getting the post-harvest processing in order, such that the WikiMapManager may handle changes to the wiki that aren't yet supported in the AssertionHandlerImpl (such as assertion additions, changes, deletions). At some point in the future there might be some time to go back and get this functionality to work in the pre-harvest world, but it's not really a priority — the real functionality is meant to happen post-harvest, once the Topic Map is made available.
The AssertionHandler provides a registry of Assertions in order to keep
from recreating them repeatedly, and also to catalog the entire set
initially. Once they have been harvested by the
WikiMapManager and the handler has
had its listener and registry disabled, it stops storing in its registry
and simply responds with a newly-created Assertion on each request.
WikiEvent,
WikiPageEvent,
WikiEventListener,
Assertion,
AssertionEvent| Field Summary | |
|---|---|
static long |
ASSERTION_LIFESPAN
The value of the assertion lifespan in milliseconds. |
protected static org.apache.log4j.Logger |
log
|
protected WikiEngine |
m_engine
|
protected WikiEventListener |
m_listener
|
protected ReferenceInfoProvider |
m_refip
|
static String |
templateName
The name of the wiki page describing assertion templates. |
| Fields inherited from interface org.ceryle.wiki.plugin.assertion.AssertionHandler |
|---|
SYNCHRONIZED, UNSYNCHRONIZED |
| Constructor Summary | |
|---|---|
protected |
AssertionHandlerImpl(WikiEngine engine)
Create an AssertionHandler for the provided WikiEngine. |
| Method Summary | |
|---|---|
protected void |
clearRegistry()
Clear the registry and page cache. |
Assertion |
createAssertion(String pagename,
Term subject,
Predicate predicate,
Property property)
Creates and returns a new property Assertion provided its parameters. |
Assertion |
createAssertion(String pagename,
Term subject,
Predicate predicate,
Term object,
boolean isTemplate)
Creates and returns a new Assertion provided its parameters. |
protected void |
disableRegistry()
Disables further use of the registry and page cache. |
Assertion |
getAssertion(String pagename,
String subject,
String predicate,
String object)
Queries the set of existing Assertions for an Assertion matching the provided Subject, Predicate and Object. |
Assertion |
getAssertion(String pagename,
Term subject,
Predicate predicate,
Property property,
boolean create)
Returns an Assertion having the wiki page name, Predicate and Property. |
Assertion |
getAssertion(String pagename,
Term subject,
Predicate predicate,
Term object,
boolean isTemplate,
boolean create)
Returns an Assertion from the registry having the same page name, Predicate and Terms if it has already been registered, null if it is not in the registry or was not added. |
Collection |
getAssertions()
Returns a Collection containing all the Assertions in the registry. |
Collection |
getAssertions(Collection assertions,
String pagename,
String subject,
String predicate,
String object,
int templateMode,
int logicMode)
Returns the Collection of all Assertions matching any of the optional parameters: pagename, subject, predicate, and/or object as Strings. |
WikiEngine |
getEngine()
Returns the WikiEngine associated with this AssertionHandler. |
protected Assertion |
getFromRegistry(String signature)
Returns true if the cache contains the Assertion indicated by the provided signature. |
ReferenceInfoProvider |
getReferenceInfoProvider()
Returns the ReferenceInfoProvider associated with this AssertionHandler. |
boolean |
hasAssertion(String pagename,
String subject,
String predicate,
String object)
Returns true if an Assertion equivalent to one created with the provided subject, predicate, and object is contained in the registry. |
boolean |
isListenerEnabled()
Returns the enabled state of this AssertionHandler's WikiEventListener. |
protected boolean |
isSynchronizing()
|
boolean |
removeAssertion(Assertion assertion)
Returns true if the Assertion was removed from the registry. |
protected boolean |
removeFromPageCache(String pagename)
|
void |
setListenerEnabled(boolean enable)
Enables or disables this AssertionHandler's WikiEventListener so that it tracks or no longer tracks changes to the wiki. |
protected void |
setRegistryIsChanging(boolean changing)
|
protected void |
setSynchronizing(boolean sync)
|
void |
synchronize(String pagename,
ActionListener listener)
Checks to see that the map of plugin-to-page for the entire wiki is up to date, and if not, fires up an AssertionCrawler thread to handle it. |
String |
toXHTML(WikiContext context,
Assertion assertion)
Format the assertion into XHTML output suitable for display on a web page. |
protected void |
updateCacheForPage(String pagename)
Update the WikiPage's internally-stored attribute containing its Assertions, and add the page to the internal cache. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static org.apache.log4j.Logger log
public static long ASSERTION_LIFESPAN
public static String templateName
protected WikiEventListener m_listener
protected WikiEngine m_engine
protected ReferenceInfoProvider m_refip
| Constructor Detail |
|---|
protected AssertionHandlerImpl(WikiEngine engine)
engine - the WikiEngine backing the event handling.| Method Detail |
|---|
public void synchronize(String pagename,
ActionListener listener)
This is an AssertionHandler API method.
Note: If the listener is disabled, this method does nothing.
synchronize in interface AssertionHandlerpagename - the optional name of the wiki page that fired
the event triggering synchronization, used to
check for page-specific changes.listener - the optional listener may be used to receive
notification (via an ActionEvent fired by the
AssertionCrawler)
that the synchronization process has finished.public WikiEngine getEngine()
This is an AssertionHandler API method.
getEngine in interface AssertionHandlerpublic ReferenceInfoProvider getReferenceInfoProvider()
This is an AssertionHandler API method.
getReferenceInfoProvider in interface AssertionHandlerpublic void setListenerEnabled(boolean enable)
The listener is created upon class instantiation, and removed from the WikiEventManager and destroyed when this method is called with a parameter value of false.
This is an AssertionHandler API method.
setListenerEnabled in interface AssertionHandlerpublic boolean isListenerEnabled()
This is an AssertionHandler API method.
isListenerEnabled in interface AssertionHandler
public Collection getAssertions()
throws AssertionException
This is an AssertionHandler API method.
getAssertions in interface AssertionHandlerAssertionException - if an error occurs while creating the Collection of assertions.
public Assertion getAssertion(String pagename,
Term subject,
Predicate predicate,
Term object,
boolean isTemplate,
boolean create)
throws AssertionException
Note: This is the only way to add an Assertion to the registry; there is no addAssertion() method. This keeps any Assertions not created by the AssertionHandler from entering into the system.
This is an AssertionHandler API method.
getAssertion in interface AssertionHandlerpagename - the wiki page name source of the Assertionsubject - the subject Term of the Assertionpredicate - the Predicate of the Assertionobject - the subject Term of the AssertionisTemplate - when true, queries for an assertion templatecreate - when true, permits creation of Assertion to fulfill a match
AssertionException - if an error occurs while creating the new Assertion
public Assertion getAssertion(String pagename,
Term subject,
Predicate predicate,
Property property,
boolean create)
throws AssertionException
Note: This is the only way to add a property Assertion to the registry; there is no addAssertion() method. This keeps any Assertions not created by the AssertionHandler from entering into the system.
This is an AssertionHandler API method.
getAssertion in interface AssertionHandlerpagename - the wiki page name source of the Assertionsubject - the subject Term of the Assertionpredicate - the property assignment Predicate (or property name) of the Assertionproperty - the property value of the Assertioncreate - when true, permits creation of Assertion to fulfill a match
AssertionException - if an error occurs while creating the new Assertion
public Collection getAssertions(Collection assertions,
String pagename,
String subject,
String predicate,
String object,
int templateMode,
int logicMode)
throws AssertionException
NOTE: Despite a similar signature (the difference being the type of content in
the Collection) to the method in WikiMapManager,
this is not an API method and queries the existing, unharvested AssertionHandlerImpl,
returning Assertions rather than Associations as in the WikiMapManager.
See AssertionQuery for a description of
the permitted values for the template and logical mode. Null values are ignored.
assertions - the beginning Collection of Assertions to query; if
null, the entire collection is queriedpagename - the name of the wiki page where the assertion was madesubject - the WikiName identifier for the subject of the querypredicate - the WikiName identifier for the predicate of the queryobject - the WikiName identifier for the object of the querytemplateMode - assertions or templates or both, as
org.ceryle.tm.assertion.AssertionQueryExecutor#TEMPLATES_EXCLUDE,
org.ceryle.tm.assertion.AssertionQueryExecutor#TEMPLATES_ONLY,
or org.ceryle.tm.assertion.AssertionQueryExecutor#TEMPLATES_INCLUDE.logicMode - the query is done as
org.ceryle.tm.assertion.AssertionQueryExecutor#LOGICAL_ALL,
org.ceryle.tm.assertion.AssertionQueryExecutor#LOGICAL_AND,
or org.ceryle.tm.assertion.AssertionQueryExecutor#LOGICAL_OR.
IllegalStateException - if this method is called prior to creation of the TopicMap
AssertionException
public Assertion getAssertion(String pagename,
String subject,
String predicate,
String object)
throws AssertionException
Returns null if unable to locate a matching Assertion. The pagename parameter is optional; it is only used as an additional query filter if provided.
This is an AssertionHandler API method.
getAssertion in interface AssertionHandlerpagename - the wiki page name source of the Assertionsubject - the wiki page name of the Assertion's subjectpredicate - the wiki page name of the Assertion's predicateobject - the wiki page name of the Assertion's object
AssertionException
public boolean hasAssertion(String pagename,
String subject,
String predicate,
String object)
This is an AssertionHandler API method.
hasAssertion in interface AssertionHandlerpagename - the wiki page source of the Assertionsubject - the wiki page name of the Assertion's subjectpredicate - the wiki page name of the Assertion's predicateobject - the wiki page name of the Assertion's object
public boolean removeAssertion(Assertion assertion)
This is an AssertionHandler API method.
removeAssertion in interface AssertionHandlerassertion - the Assertion to be removed.
public String toXHTML(WikiContext context,
Assertion assertion)
throws AssertionException
Assertion.toXHTML(WikiContext,Assertion).
The Terms are displayed square-bracketed; the Predicate not.
This is an AssertionHandler API method.
toXHTML in interface AssertionHandlercontext - optional; if supplied, used to provide link markup.assertion - the Assertion to be displayed.
AssertionException
public Assertion createAssertion(String pagename,
Term subject,
Predicate predicate,
Term object,
boolean isTemplate)
throws AssertionException
NOTE: while this is a public method by virtue of it being part of the API, it should not be called directly since creation of Assertions is meant to be handled internal to the process.
createAssertion in interface AssertionHandlerpagename - the wiki page source of the Assertionsubject - the subject Term of the Assertionpredicate - the Predicate of the Assertionobject - the subject Term of the AssertionisTemplate - if true, the assertion is created as an assertion template.
AssertionException - if unable to create the new Assertion.to create an assertion or assertion template,
to create a property assertion
public Assertion createAssertion(String pagename,
Term subject,
Predicate predicate,
Property property)
throws AssertionException
NOTE: while this is a public method by virtue of it being part of the API, it should not be called directly since creation of Assertions is meant to be handled internal to the process.
createAssertion in interface AssertionHandlerpagename - the wiki page source of the Assertionsubject - the subject Term of the Assertionpredicate - the Predicate of the Assertionproperty - the Property being asserted.
AssertionException - if unable to create the new Assertion.to create an assertion or assertion templateprotected void clearRegistry()
protected void disableRegistry()
protected void setRegistryIsChanging(boolean changing)
protected void setSynchronizing(boolean sync)
protected boolean isSynchronizing()
protected Assertion getFromRegistry(String signature)
signature - The signature of the Assertion to match.
protected void updateCacheForPage(String pagename)
Note: If the listener is disabled, this method does nothing.
protected boolean removeFromPageCache(String pagename)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||