Java Doc for JDBCPersistentMap.java in  » Workflow-Engines » wfmopen-2.1.1 » de » danet » an » util » persistentmaps » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Workflow Engines » wfmopen 2.1.1 » de.danet.an.util.persistentmaps 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.util.HashMap
   de.danet.an.util.persistentmaps.JDBCPersistentMap

All known Subclasses:   de.danet.an.workflow.ejbs.core.ProcessDataStore,
JDBCPersistentMap
public class JDBCPersistentMap extends HashMap implements PersistentMap,Serializable(Code)
This class provides an implementation of de.danet.an.util.PersistentMap PersistentMap that uses JDBC to implement the persistence.

The class uses an abstract SQL table model. The table consists of a column for the map id, the entry key and two value entries.

All columns except the second value entry are of type string, with lengths as appropriate for the application. The second value field is of type BLOB (binary large object) and is used if either the value to be stored is not of type java.lang.String String or longer than a given limit. The map id enables storing of several jdbc persistent maps in a single table. It is passed as paramter to all constructors of this class. Only a single instance for a map id may be created as creating two instances may corrupt caching.

The SQL statements used to retrieve and save data are configurable. Thus any table or view may be used as a base for a jdbc persistent map.

Note that this implementation is not synchronized. If multiple threads access this map concurrently, and at least one of the threads modifies the map structurally, it must be synchronized externally. (A structural modification is any operation that adds or deletes one or more mappings; merely changing the value associated with a key that an instance already contains is not a structural modification.) This is typically accomplished by synchronizing on some object that naturally encapsulates the map. This can be done at creation time, to prevent accidental unsynchronized access to the map: JDBCPersistentMap pm = new JDBCPersistentMap(...); Map m = Collections.synchronizedMap(pm); Since only the methods defined by Map are synchronized by this mechanism, all supplemented methods (like 'load' or 'store' have to be synchronized on the map object 'm', created above, e.g.: synchronized(m) { pm.load(); // Must be in the synchronized block }

The class is serializable. Note, however, that the database connection is transient.




Constructor Summary
public  JDBCPersistentMap(DataSource dataSource, String mapId)
     Returns a new JDBC persistent map.
public  JDBCPersistentMap(DataSource dataSource, Long mapId)
     Returns a new JDBC persistent map.
public  JDBCPersistentMap(DataSource dataSource, String mapId, String dbtable)
     Returns a new JDBC persistent map.
public  JDBCPersistentMap(DataSource dataSource, Long mapId, String dbtable)
     Returns a new JDBC persistent map.

Method Summary
public  voidclear()
     Removes all mappings from this map.
public  ConnectiongetConnection()
     Returns the database connection set by JDBCPersistentMap.setConnection setConnection .
public  StringgetDeleteAllStatement()
     Returns the SQL statement used to delete all entries for this map in the database table.
public  StringgetDeleteStatement()
     Returns the SQL statement used to delete an entry for this map in the database table.
public  StringgetInsertStatement()
     Returns the SQL statement used to insert an entry for this map into the database table.
public  StringgetLoadStatement()
     Returns the SQL statement used to retrieve all entries for this map from the database table.
public  ObjectgetMapId()
     Returns the map id of this map.
public  intgetSValueMax()
     Returns the maximum length for string value in the SVALUE column of the database table.
public  StringgetUpdateStatement()
     Returns the SQL statement used to update an entry for this map in the database table.
public  booleanisModified()
     Indicates whether modifications need to be saved currently.
protected  booleanisSValue(String value)
     Verify if the string will be stored as string, not as object.
public  voidload()
     Loads the map from persistent store.
public  intmaxKeyLength()
     Retrieves the information about the maximum string length of key entries.
public  Objectput(Object key, Object value)
     Associates the specified value with the specified key in this map. The key has to have a non-null value. If the map previously contained a mapping for this key, the old value is replaced. This implementation ensures consistency between the map and the persistent store.
Parameters:
  key - key with which the specified value is to be associated.
Parameters:
  value - value to be associated with the specified key.
public  voidputAll(Map t)
     Copies all of the mappings from the specified map to this map.
public  Objectremove(Object key)
     Removes the mapping for this key from this map if present. This implementation ensures consistency between the map and the persistent store.
Parameters:
  key - key with which the specified value is to be associated.
public  voidsetConnection(Connection con)
     Sets the database connection used in JDBCPersistentMap.load load and JDBCPersistentMap.store store .
public  voidsetDataSource(DataSource dataSource)
     Set the data source for this map.
public  voidsetDeleteAllStatement(String statement)
     Sets the SQL statement used to delete all entries for this map in the database table.
public  voidsetDeleteStatement(String statement)
     Sets the SQL statement used to delete an entry for this map in the database table.
public  voidsetInsertStatement(String statement)
     Sets the SQL statement used to insert an entry for this map in the database table.
public  voidsetLoadStatement(String statement)
     Sets the SQL statement used to retrieve all entries for this map from the database table.
public  voidsetMapId(String mapId)
     Sets the map id for this map.
public  voidsetMapId(Long mapId)
     Sets the map id for this map.
public  voidsetNewMap()
     May be called after constructor or setMapId and before the first call to store() to indicate that the map is newly created.
public  voidsetSValueMax(int limit)
     Sets the maximum length for string value in the SVALUE column of the database table.
public  voidsetUpdateStatement(String statement)
     Sets the SQL statement used to update an entry for this map in the database table.
public  voidstore()
     Stores the map in persistent store.


Constructor Detail
JDBCPersistentMap
public JDBCPersistentMap(DataSource dataSource, String mapId) throws SQLException(Code)
Returns a new JDBC persistent map. The map is formed by all entries in the underlying table with the given map id. The table used by the default SQL statements is DEFAULTPERSISTENCEMAP.
Parameters:
  dataSource - the data source that will be used to obtainconnections.
Parameters:
  mapId - the map id.
throws:
  SQLException - if a database related error occurs



JDBCPersistentMap
public JDBCPersistentMap(DataSource dataSource, Long mapId) throws SQLException(Code)
Returns a new JDBC persistent map. The map is formed by all entries in the underlying table with the given map id. The table used by the default SQL statements is DEFAULTPERSISTENCEMAP.
Parameters:
  dataSource - the data source that will be used to obtainconnections.
Parameters:
  mapId - the map id.
throws:
  SQLException - if a database related error occurs



JDBCPersistentMap
public JDBCPersistentMap(DataSource dataSource, String mapId, String dbtable) throws SQLException(Code)
Returns a new JDBC persistent map. The map is formed by all entries in the underlying table with the given persistence group.
Parameters:
  dataSource - the data source that will be used to obtainconnections.
Parameters:
  mapId - the map id.
Parameters:
  dbtable - the table used in the default SQL statements.
throws:
  SQLException - if a database related error occurs



JDBCPersistentMap
public JDBCPersistentMap(DataSource dataSource, Long mapId, String dbtable) throws SQLException(Code)
Returns a new JDBC persistent map. The map is formed by all entries in the underlying table with the given persistence group.
Parameters:
  dataSource - the data source that will be used to obtainconnections.
Parameters:
  mapId - the map id.
Parameters:
  dbtable - the table used in the default SQL statements.
throws:
  SQLException - if a database related error occurs




Method Detail
clear
public void clear()(Code)
Removes all mappings from this map. This implementation ensures consistency between the map and the persistent store.



getConnection
public Connection getConnection()(Code)
Returns the database connection set by JDBCPersistentMap.setConnection setConnection . the current connection
See Also:   JDBCPersistentMap.setConnection



getDeleteAllStatement
public String getDeleteAllStatement()(Code)
Returns the SQL statement used to delete all entries for this map in the database table. the SQL statement.
See Also:   JDBCPersistentMap.setDeleteAllStatement



getDeleteStatement
public String getDeleteStatement()(Code)
Returns the SQL statement used to delete an entry for this map in the database table. the SQL statement.
See Also:   JDBCPersistentMap.setDeleteStatement



getInsertStatement
public String getInsertStatement()(Code)
Returns the SQL statement used to insert an entry for this map into the database table. the SQL statement.
See Also:   JDBCPersistentMap.setInsertStatement



getLoadStatement
public String getLoadStatement()(Code)
Returns the SQL statement used to retrieve all entries for this map from the database table. the SQL statement.
See Also:   JDBCPersistentMap.setLoadStatement



getMapId
public Object getMapId()(Code)
Returns the map id of this map. the map id.
See Also:   JDBCPersistentMap.setMapId



getSValueMax
public int getSValueMax()(Code)
Returns the maximum length for string value in the SVALUE column of the database table. the current maximum length
See Also:   JDBCPersistentMap.setSValueMax



getUpdateStatement
public String getUpdateStatement()(Code)
Returns the SQL statement used to update an entry for this map in the database table. the SQL statement.
See Also:   JDBCPersistentMap.setUpdateStatement



isModified
public boolean isModified()(Code)
Indicates whether modifications need to be saved currently. true, if there are non-saved modifications, otherwise false.



isSValue
protected boolean isSValue(String value)(Code)
Verify if the string will be stored as string, not as object.
Parameters:
  value - the string true if the string will be stored as "svalue"



load
public void load() throws IOException(Code)
Loads the map from persistent store. The map is cleared before loading.
throws:
  IOException - problems while loading the map



maxKeyLength
public int maxKeyLength() throws IOException(Code)
Retrieves the information about the maximum string length of key entries. the maximum string length of key entries
throws:
  IOException - problems while storing the map



put
public Object put(Object key, Object value)(Code)
Associates the specified value with the specified key in this map. The key has to have a non-null value. If the map previously contained a mapping for this key, the old value is replaced. This implementation ensures consistency between the map and the persistent store.
Parameters:
  key - key with which the specified value is to be associated.
Parameters:
  value - value to be associated with the specified key. previous value associated with specified key, or null if there was no mapping for key.



putAll
public void putAll(Map t)(Code)
Copies all of the mappings from the specified map to this map. These mappings will replace any mappings that this map had for any of the keys currently in the specified map. This implementation ensures consistency between the map and the persistent store.
Parameters:
  t - Mappings to be stored in this map.



remove
public Object remove(Object key)(Code)
Removes the mapping for this key from this map if present. This implementation ensures consistency between the map and the persistent store.
Parameters:
  key - key with which the specified value is to be associated. previous value associated with specified key, or null if there was no mapping for key.



setConnection
public void setConnection(Connection con) throws SQLException(Code)
Sets the database connection used in JDBCPersistentMap.load load and JDBCPersistentMap.store store . If connection is closed or changes, all prepared statements are released. If a valid connection with a different database url (compared with the previous valid connection) is set, the svalue threshold is validated if it hasn't been checked before (@see #setSValueMax).
Parameters:
  con - the Connection.
throws:
  SQLException - from the underlying JDBC calls
See Also:   JDBCPersistentMap.getConnection



setDataSource
public void setDataSource(DataSource dataSource) throws SQLException(Code)
Set the data source for this map. This must be called after deserialization. Calling this method resets the connection and must therefore be followed by a call to JDBCPersistentMap.setConnectionsetConnection .
Parameters:
  dataSource - the data source that will be used to obtainconnections.
throws:
  SQLException - if a database related error occurs



setDeleteAllStatement
public void setDeleteAllStatement(String statement)(Code)
Sets the SQL statement used to delete all entries for this map in the database table. The default is
DELETE FROM table WHERE MAPID=?
where table defaults to DEFAULTPERSISTENCEMAP and can be set by calling the JDBCPersistentMap.JDBCPersistentMap(String,String) extended constructor .

NOTE: The statement must declare semantically corresponding columns for all the restriction values described in the example above!


Parameters:
  statement - the delete statement.
See Also:   JDBCPersistentMap.getDeleteAllStatement



setDeleteStatement
public void setDeleteStatement(String statement)(Code)
Sets the SQL statement used to delete an entry for this map in the database table. The default is
DELETE FROM table WHERE MAPID=? AND ITEM=?
where table defaults to DEFAULTPERSISTENCEMAP and can be set by calling the JDBCPersistentMap.JDBCPersistentMap(String,String) extended constructor .

NOTE: The statement must declare semantically corresponding columns for all the restriction values described in the example above!


Parameters:
  statement - the delete statement.
See Also:   JDBCPersistentMap.getDeleteStatement



setInsertStatement
public void setInsertStatement(String statement)(Code)
Sets the SQL statement used to insert an entry for this map in the database table. The default is
INSERT INTO table (MAPID, ITEM, SVALUE, BVALUE) 
 VALUES (?, ?, ?, ?)
where table defaults to DEFAULTPERSISTENCEMAP and can be set by calling the JDBCPersistentMap.JDBCPersistentMap(String,String) extended constructor .

NOTE: The statement must declare semantically corresponding columns for all the values described in the example above!


Parameters:
  statement - the insert statement.
See Also:   JDBCPersistentMap.getInsertStatement



setLoadStatement
public void setLoadStatement(String statement)(Code)
Sets the SQL statement used to retrieve all entries for this map from the database table. The default is
SELECT ITEM, SVALUE, BVALUE FROM table WHERE MAPID = ?
where table defaults to DEFAULTPERSISTENCEMAP and can be set by calling the JDBCPersistentMap.JDBCPersistentMap(String,String) extended constructor .

NOTE: The statement must declare semantically corresponding columns for all the selection and restriction values described in the example above!


Parameters:
  statement - the load statement.
See Also:   JDBCPersistentMap.getLoadStatement



setMapId
public void setMapId(String mapId)(Code)
Sets the map id for this map. Clears the cached modifications as a side effect if the map id differs from the current map id.
Parameters:
  mapId - the new map id.
See Also:   JDBCPersistentMap.getMapId



setMapId
public void setMapId(Long mapId)(Code)
Sets the map id for this map. Clears the cached modifications as a side effect if the map id differs from the current map id.
Parameters:
  mapId - the new map id.
See Also:   JDBCPersistentMap.getMapId



setNewMap
public void setNewMap()(Code)
May be called after constructor or setMapId and before the first call to store() to indicate that the map is newly created. This allows the persistent map implementation to optimize the storage bahaviour.



setSValueMax
public void setSValueMax(int limit)(Code)
Sets the maximum length for string value in the SVALUE column of the database table. The default is 256. If the given length value is greater than the column length in the database scheme (a DB connection that supports column information assumed), the length value is restricted to the DB column length.
Parameters:
  limit - the maximum length for values in the SVALUEcolumn.
See Also:   JDBCPersistentMap.getSValueMax



setUpdateStatement
public void setUpdateStatement(String statement)(Code)
Sets the SQL statement used to update an entry for this map in the database table. The default is
UPDATE table SET
 SVALUE = ?, BVALUE = ? WHERE MAPID=? AND ITEM=?
where table defaults to DEFAULTPERSISTENCEMAP and can be set by calling the JDBCPersistentMap.JDBCPersistentMap(String,String) extendedconstructor .

NOTE: The statement must declare semantically corresponding columns for all the data and restriction values described in the example above! The names of the key columns in the restriction phrase have to be in the same order as above (first: map-ident, second: item-ident)


Parameters:
  statement - the update statement.
See Also:   JDBCPersistentMap.getUpdateStatement



store
public void store() throws IOException(Code)
Stores the map in persistent store. If the set has not been loaded before, all entries with the current map id are deleted from the persistent store first. Only modified (new, changed, deleted) map entries are changed in the peristent store.
throws:
  IOException - problems while storing the map



Methods inherited from java.util.HashMap
public void clear()(Code)(Java Doc)
public Object clone()(Code)(Java Doc)
public boolean containsKey(Object key)(Code)(Java Doc)
public boolean containsValue(Object value)(Code)(Java Doc)
public Set<Map.Entry<K, V>> entrySet()(Code)(Java Doc)
public V get(Object key)(Code)(Java Doc)
public boolean isEmpty()(Code)(Java Doc)
public Set<K> keySet()(Code)(Java Doc)
public V put(K key, V value)(Code)(Java Doc)
public void putAll(Map<? extends K, ? extends V> m)(Code)(Java Doc)
public V remove(Object key)(Code)(Java Doc)
public int size()(Code)(Java Doc)
public Collection<V> values()(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.