. Creates a
and binds it to the specified JNDI name.
All mapping documents are loaded as resources by the MBean.
| Method from org.hibernate.jmx.HibernateService Detail: |
SessionFactory buildSessionFactory() throws HibernateException {
log.info( "starting service at JNDI name: " + boundName );
log.info( "service properties: " + properties );
return buildConfiguration().buildSessionFactory();
}
|
public void createSchema() {
new SchemaExport( buildConfiguration() ).create(false, true);
}
|
public void dropSchema() {
new SchemaExport( buildConfiguration() ).drop(false, true);
}
|
public String getAutoCloseSessionEnabled() {
return getProperty(Environment.AUTO_CLOSE_SESSION);
}
|
public String getDatasource() {
return getProperty(Environment.DATASOURCE);
}
|
protected Map getExtraProperties() {
return properties;
}
|
public String getFlushBeforeCompletionEnabled() {
return getProperty(Environment.FLUSH_BEFORE_COMPLETION);
}
|
public String getJndiName() {
return getProperty(Environment.SESSION_FACTORY_NAME);
}
|
public String getName() {
return getProperty(Environment.SESSION_FACTORY_NAME);
}
|
public String getPassword() {
return getProperty(Environment.PASS);
}
|
public Properties getProperties() {
return buildProperties();
}
|
public String getProperty(String property) {
return properties.getProperty(property);
}
|
public String getPropertyList() {
return buildProperties().toString();
}
|
public String getTransactionManagerLookupStrategy() {
return getProperty(Environment.TRANSACTION_MANAGER_STRATEGY);
}
|
public String getTransactionStrategy() {
return getProperty(Environment.TRANSACTION_STRATEGY);
}
|
public String getUserName() {
return getProperty(Environment.USER);
}
|
public String getUserTransactionName() {
return getProperty(Environment.USER_TRANSACTION);
}
|
public void setAutoCloseSessionEnabled(String enabled) {
setProperty(Environment.AUTO_CLOSE_SESSION, enabled);
}
|
public void setDatasource(String datasource) {
setProperty(Environment.DATASOURCE, datasource);
}
|
public void setFlushBeforeCompletionEnabled(String enabled) {
setProperty(Environment.FLUSH_BEFORE_COMPLETION, enabled);
}
|
public void setJndiName(String jndiName) {
setProperty(Environment.SESSION_FACTORY_NAME, jndiName);
}
|
public void setPassword(String password) {
setProperty(Environment.PASS, password);
}
|
public void setProperty(String property,
String value) {
properties.setProperty(property, value);
}
|
public void setTransactionManagerLookupStrategy(String lkpStrategy) {
setProperty(Environment.TRANSACTION_MANAGER_STRATEGY, lkpStrategy);
}
|
public void setTransactionStrategy(String txnStrategy) {
setProperty(Environment.TRANSACTION_STRATEGY, txnStrategy);
}
|
public void setUserName(String userName) {
setProperty(Environment.USER, userName);
}
|
public void setUserTransactionName(String utName) {
setProperty(Environment.USER_TRANSACTION, utName);
}
|
public void start() throws HibernateException {
boundName = getJndiName();
try {
buildSessionFactory();
}
catch (HibernateException he) {
log.info( "Could not build SessionFactory using the MBean classpath - will try again using client classpath: " + he.getMessage() );
log.debug("Error was", he);
new SessionFactoryStub(this);
}
}
|
public void stop() {
log.info("stopping service");
try {
InitialContext context = NamingHelper.getInitialContext( buildProperties() );
( (SessionFactory) context.lookup(boundName) ).close();
//context.unbind(boundName);
}
catch (Exception e) {
log.warn("exception while stopping service", e);
}
}
|