Package jade.domain
Class DFDBKB
- java.lang.Object
-
- jade.domain.KBManagement.KB
-
- jade.domain.KBManagement.DBKB
-
- jade.domain.DFDBKB
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jade.domain.KBManagement.DBKB
DBKB.ConnectionWrapper, DBKB.EmptyKBIterator
-
-
Field Summary
Fields Modifier and Type Field Description protected StringDEFAULT_LONGVARCHAR_TYPEDefault data type for very long strings-
Fields inherited from class jade.domain.KBManagement.DBKB
cleanTables, driver
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcreateDFTables()Creates the proper DB tables.protected voidcreateIndices()Adds explicit indices to the database to speed up queriesprotected voidcreateTable(String name, String[] entries)Creates a new DB tableprotected voiddropDFTables()Drops all existing DB tables used by the DF.protected voiddropTable(Statement stmt, String tableName)Drops a DB table or does nothing if the table doesn't exist.protected StringgetGUID()Returns a global unique identifierprotected StringgetHashValue(Object obj)Returns an MD5 hash value for an objectprotected StringgetLongVarCharType()Returns the name of the SQL type used in the database to represent very long strings.EnumerationgetSubscriptions()Return all known subscriptions at the DFprotected voidinitConnectionWrapper(DBKB.ConnectionWrapper wrapper)Subclasses can redefine this method to provide implementation specific ConnectionWrapper initializationsprotected ObjectinsertSingle(Object name, Object fact)Insert a new DFD object.protected KBIteratoriteratorSingle(Object template)protected StringprepDBStr(String s)This method must be used when inserting text values into a DB.protected ObjectremoveSingle(Object name)Remove the DFD object corresponding to the indicated AID.protected Stringreplace(String str, String pattern, String replaceWith)Replaces all occurences of apatterninstrwithreplaceWithprotected ListsearchSingle(Object template, int maxResult)Retrieve the DFDs matching the given templatevoidsetup()Initializes all used SQL statements, the DB tables and the loggingprotected voidsubscribeSingle(Object dfd, SubscriptionResponder.Subscription s)protected booleantableExists(String name)Check whether a database table already existsprotected voidunsubscribeSingle(SubscriptionResponder.Subscription sub)-
Methods inherited from class jade.domain.KBManagement.DBKB
createDBConnection, getConnectionWrapper, insert, iterator, remove, search, subscribe, unsubscribe
-
Methods inherited from class jade.domain.KBManagement.KB
deregister, register, search, setLeaseManager, setSubscriptionResponder
-
-
-
-
Field Detail
-
DEFAULT_LONGVARCHAR_TYPE
protected String DEFAULT_LONGVARCHAR_TYPE
Default data type for very long strings
-
-
Constructor Detail
-
DFDBKB
public DFDBKB(int maxResultLimit, String drv, String url, String user, String passwd, boolean cleanTables) throws SQLExceptionConstructor- Parameters:
maxResultLimit- internal limit for the number of maximum search results.drv- database driverurl- database URLuser- database user namepasswd- database passwordcleanTables- specifies whether the KB should delete all existing tables for the DF at startup- Throws:
SQLException- an error occured while opening a connection to the database
-
-
Method Detail
-
setup
public void setup() throws SQLExceptionInitializes all used SQL statements, the DB tables and the logging- Specified by:
setupin classDBKB- Throws:
SQLException
-
initConnectionWrapper
protected void initConnectionWrapper(DBKB.ConnectionWrapper wrapper) throws SQLException
Description copied from class:DBKBSubclasses can redefine this method to provide implementation specific ConnectionWrapper initializations- Overrides:
initConnectionWrapperin classDBKB- Throws:
SQLException
-
getLongVarCharType
protected String getLongVarCharType()
Returns the name of the SQL type used in the database to represent very long strings.
-
getGUID
protected String getGUID()
Returns a global unique identifier
-
dropTable
protected void dropTable(Statement stmt, String tableName)
Drops a DB table or does nothing if the table doesn't exist.
-
dropDFTables
protected void dropDFTables() throws SQLExceptionDrops all existing DB tables used by the DF.- Throws:
SQLException
-
tableExists
protected boolean tableExists(String name)
Check whether a database table already exists- Parameters:
name- name of the table
-
createTable
protected void createTable(String name, String[] entries)
Creates a new DB table- Parameters:
name- name of the tableentries- array of column and constraint specifications- Throws:
SQLException- If the table cannot be created
-
createIndices
protected void createIndices()
Adds explicit indices to the database to speed up queries
-
createDFTables
protected void createDFTables()
Creates the proper DB tables.
-
insertSingle
protected Object insertSingle(Object name, Object fact) throws SQLException
Insert a new DFD object.- Specified by:
insertSinglein classDBKB- Returns:
- the previous DFD (if any) corresponding to the same AID
- Throws:
SQLException
-
removeSingle
protected Object removeSingle(Object name) throws SQLException
Remove the DFD object corresponding to the indicated AID.- Specified by:
removeSinglein classDBKB- Returns:
- the removed DFD (if any)
- Throws:
SQLException
-
searchSingle
protected List searchSingle(Object template, int maxResult) throws SQLException
Retrieve the DFDs matching the given template- Specified by:
searchSinglein classDBKB- Throws:
SQLException
-
iteratorSingle
protected KBIterator iteratorSingle(Object template) throws SQLException
- Specified by:
iteratorSinglein classDBKB- Throws:
SQLException
-
subscribeSingle
protected void subscribeSingle(Object dfd, SubscriptionResponder.Subscription s) throws SQLException, NotUnderstoodException
- Specified by:
subscribeSinglein classDBKB- Throws:
SQLExceptionNotUnderstoodException
-
getSubscriptions
public Enumeration getSubscriptions()
Return all known subscriptions at the DF- Specified by:
getSubscriptionsin classDBKB- Returns:
Enumerationwith instances of the classjade.proto.SubscriptionResponder&Subscription
-
unsubscribeSingle
protected void unsubscribeSingle(SubscriptionResponder.Subscription sub) throws SQLException
- Specified by:
unsubscribeSinglein classDBKB- Throws:
SQLException
-
getHashValue
protected String getHashValue(Object obj) throws Exception
Returns an MD5 hash value for an object- Parameters:
obj- Object to use for the hash value calcualtion- Returns:
- an MD5 value encoded in ISO-8859-1
- Throws:
Exception- The hash value couldn't be generated
-
prepDBStr
protected String prepDBStr(String s)
This method must be used when inserting text values into a DB. It doubles all ' and " characters If the passed parameter is null, then an empty string is returned.
-
-