|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.xpn.xwiki.store.XWikiHibernateBaseStore
public class XWikiHibernateBaseStore
Created by IntelliJ IDEA. User: ludovic Date: 10 mars 2006 Time: 14:04:13 To change this template use File | Settings | File Templates.
Nested Class Summary | |
---|---|
class |
XWikiHibernateBaseStore.ConnectionMonitor
|
Field Summary | |
---|---|
private org.hibernate.cfg.Configuration |
configuration
|
private java.util.Map |
connections
|
private java.lang.String |
hibpath
|
private java.net.URL |
hiburl
|
private static org.apache.commons.logging.Log |
log
|
private int |
nbConnections
|
private org.hibernate.SessionFactory |
sessionFactory
|
Constructor Summary | |
---|---|
XWikiHibernateBaseStore(java.lang.String hibpath)
Initialize the storage engine with a specific path This is used for tests. |
|
XWikiHibernateBaseStore(XWiki xwiki,
XWikiContext context)
THis allows to initialize our storage engine. |
Method Summary | |
---|---|
private void |
addConnection(java.sql.Connection connection,
XWikiContext context)
Adding a connection to the Monitor module |
boolean |
beginTransaction(boolean withTransaction,
XWikiContext context)
Begins a transaction |
boolean |
beginTransaction(org.hibernate.SessionFactory sfactory,
boolean withTransaction,
XWikiContext context)
Begins a transaction with a specific SessionFactory |
boolean |
beginTransaction(org.hibernate.SessionFactory sfactory,
XWikiContext context)
Begins a transaction with a specific SessionFactory |
boolean |
beginTransaction(XWikiContext context)
Begins a transaction |
void |
checkHibernate(XWikiContext context)
Initializes hibernate and calls updateSchema if necessary |
void |
cleanUp(XWikiContext context)
Cleanup all sessions Used at the shutdown time |
private void |
closeSession(org.hibernate.Session session)
Closes the hibernate session |
void |
endTransaction(XWikiContext context,
boolean commit)
Ends a transaction |
void |
endTransaction(XWikiContext context,
boolean commit,
boolean withTransaction)
Ends a transaction |
org.hibernate.cfg.Configuration |
getConfiguration()
|
java.util.Collection |
getConnections()
|
java.net.URL |
getHibUrl()
Get's the hibernate config path as an URL |
int |
getNbConnections()
|
java.lang.String |
getPath()
Allows to get the current hibernate config file path |
java.lang.String[] |
getSchemaUpdateScript(org.hibernate.cfg.Configuration config,
XWikiContext context)
This function gets the schema update scripts generated by comparing the current database woth the current hibernate mapping config. |
org.hibernate.Session |
getSession(XWikiContext context)
This get's the current session. |
org.hibernate.SessionFactory |
getSessionFactory()
|
org.hibernate.Transaction |
getTransaction(XWikiContext context)
Allows to get the current transaction from the context This is set in beginTransaction |
private void |
initHibernate()
Allows to init the hibernate configuration |
protected boolean |
isVirtual(XWikiContext context)
Checks if this xwiki setup is virtual meaning if multiple wikis can be accessed using the same database pool |
protected org.hibernate.cfg.Configuration |
makeMapping(java.lang.String className,
java.lang.String custommapping1)
|
protected java.lang.String |
makeMapping(java.lang.String entityName,
java.lang.String tableName,
java.lang.String custommapping1)
|
private void |
removeConnection(java.sql.Connection connection)
Remove a connection to the Monitor module |
void |
setConfiguration(org.hibernate.cfg.Configuration configuration)
|
void |
setDatabase(org.hibernate.Session session,
XWikiContext context)
Virtual Wikis Allows to switch database connection |
void |
setHibUrl(java.net.URL hiburl)
Set the hibernate config path as an URL |
void |
setNbConnections(int nbConnections)
|
void |
setPath(java.lang.String hibpath)
Allows to set the current hibernate config file path |
void |
setSession(org.hibernate.Session session,
XWikiContext context)
Allows to set the current session in the context This is set in beginTransaction |
void |
setSessionFactory(org.hibernate.SessionFactory sessionFactory)
|
void |
setTransaction(org.hibernate.Transaction transaction,
XWikiContext context)
Allows to set the current transaction This is set in beginTransaction |
void |
shutdownHibernate(XWikiContext context)
Allows to shut down the hibernate configuration Closing all pools and connections |
void |
updateSchema(BaseClass bclass,
XWikiContext context)
Custom Mapping This function update the schema based on the dynamic custom mapping provided by the class |
void |
updateSchema(java.lang.String[] createSQL,
XWikiContext context)
Runs the update script on the current database |
void |
updateSchema(XWikiContext context)
Allows to update the schema to match the hibernate mapping |
void |
updateSchema(XWikiContext context,
boolean force)
Allows to update the schema to match the hibernate mapping |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final org.apache.commons.logging.Log log
private java.util.Map connections
private int nbConnections
private org.hibernate.SessionFactory sessionFactory
private org.hibernate.cfg.Configuration configuration
private java.lang.String hibpath
private java.net.URL hiburl
Constructor Detail |
---|
public XWikiHibernateBaseStore(XWiki xwiki, XWikiContext context)
xwiki
- context
- public XWikiHibernateBaseStore(java.lang.String hibpath)
hibpath
- Method Detail |
---|
public java.lang.String getPath()
public void setPath(java.lang.String hibpath)
hibpath
- public java.net.URL getHibUrl()
public void setHibUrl(java.net.URL hiburl)
hiburl
- private void initHibernate() throws org.hibernate.HibernateException
org.hibernate.HibernateException
public org.hibernate.Session getSession(XWikiContext context)
context
-
public void setSession(org.hibernate.Session session, XWikiContext context)
session
- context
- public org.hibernate.Transaction getTransaction(XWikiContext context)
context
-
public void setTransaction(org.hibernate.Transaction transaction, XWikiContext context)
transaction
- context
- public void shutdownHibernate(XWikiContext context) throws org.hibernate.HibernateException
context
-
org.hibernate.HibernateException
public void updateSchema(XWikiContext context) throws org.hibernate.HibernateException
context
-
org.hibernate.HibernateException
public void updateSchema(XWikiContext context, boolean force) throws org.hibernate.HibernateException
context
- force
- defines wether or not to force the update despite the xwiki.cfg settings
org.hibernate.HibernateException
public java.lang.String[] getSchemaUpdateScript(org.hibernate.cfg.Configuration config, XWikiContext context) throws org.hibernate.HibernateException
config
- context
-
org.hibernate.HibernateException
public void updateSchema(java.lang.String[] createSQL, XWikiContext context)
createSQL
- context
- public void updateSchema(BaseClass bclass, XWikiContext context) throws XWikiException
bclass
- context
-
XWikiException
public void checkHibernate(XWikiContext context) throws org.hibernate.HibernateException
context
-
org.hibernate.HibernateException
protected boolean isVirtual(XWikiContext context)
context
-
public void setDatabase(org.hibernate.Session session, XWikiContext context) throws XWikiException
session
- context
-
XWikiException
public boolean beginTransaction(XWikiContext context) throws XWikiException
context
-
XWikiException
public boolean beginTransaction(boolean withTransaction, XWikiContext context) throws XWikiException
withTransaction
- context
-
XWikiException
public boolean beginTransaction(org.hibernate.SessionFactory sfactory, XWikiContext context) throws XWikiException
sfactory
- context
-
XWikiException
public boolean beginTransaction(org.hibernate.SessionFactory sfactory, boolean withTransaction, XWikiContext context) throws org.hibernate.HibernateException, XWikiException
sfactory
- withTransaction
- context
-
org.hibernate.HibernateException
XWikiException
private void addConnection(java.sql.Connection connection, XWikiContext context)
connection
- context
- private void removeConnection(java.sql.Connection connection)
connection
- public void endTransaction(XWikiContext context, boolean commit)
context
- commit
- should we commit or notpublic void endTransaction(XWikiContext context, boolean commit, boolean withTransaction) throws org.hibernate.HibernateException
context
- commit
- should we commit or notwithTransaction
-
org.hibernate.HibernateException
private void closeSession(org.hibernate.Session session) throws org.hibernate.HibernateException
session
-
org.hibernate.HibernateException
public void cleanUp(XWikiContext context)
context
- public org.hibernate.SessionFactory getSessionFactory()
public void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
public org.hibernate.cfg.Configuration getConfiguration()
public void setConfiguration(org.hibernate.cfg.Configuration configuration)
public java.util.Collection getConnections()
public int getNbConnections()
public void setNbConnections(int nbConnections)
protected org.hibernate.cfg.Configuration makeMapping(java.lang.String className, java.lang.String custommapping1)
protected java.lang.String makeMapping(java.lang.String entityName, java.lang.String tableName, java.lang.String custommapping1)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |