You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by ms...@apache.org on 2006/12/13 20:04:50 UTC
svn commit: r486799 - in
/incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi: Messages.java
OdeConfigProperties.java OdeLifeCycle.java OdeServiceUnit.java
Author: mszefler
Date: Wed Dec 13 11:04:48 2006
New Revision: 486799
URL: http://svn.apache.org/viewvc?view=rev&rev=486799
Log:
JBI NPE fix
Better support for unit test.
Minor tweaks to DB handling.
Modified:
incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/Messages.java
incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeConfigProperties.java
incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java
incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeServiceUnit.java
Modified: incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/Messages.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/Messages.java?view=diff&rev=486799&r1=486798&r2=486799
==============================================================================
--- incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/Messages.java (original)
+++ incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/Messages.java Wed Dec 13 11:04:48 2006
@@ -27,110 +27,105 @@
public class Messages extends MessageBundle {
- public String msgOdeInstallErrorCfgNotFound(File configFile) {
- return format("Error installing ODE component: config file {0} not found!",
- configFile);
- }
-
- public String msgOdeInstallErrorCfgReadError(File configFile) {
- return format(
- "Error installing ODE component: config file {0} could not be read!",
- configFile);
- }
-
- public String msgOdeInstalled(String dir) {
- return format("ODE Service Engine installed in {0}", dir);
-
- }
-
- public String msgOdeInitHibernatePropertiesNotFound(File expected) {
- return format("Hibernate configuration file \"{0}\" not found!", expected);
- }
-
- public String msgOdeUsingExternalDb(String dbDataSource) {
- return format("ODE using external DataSource \"{0}\".", dbDataSource);
- }
-
- public String msgOdeInitExternalDbFailed(String dbDataSource) {
- return format("Failed to resolved external DataSource at \"{0}\".",
- dbDataSource);
- }
-
- public String msgOdeInitHibernateErrorReadingHibernateProperties(
- File hibernatePropFile) {
- return format("Error reading Hibernate properties file \"{0}\".",
- hibernatePropFile);
- }
-
- public String msgOdeStarting() {
- return format("Starting ODE ServiceEngine.");
- }
-
- public String msgOdeStarted() {
- return format("ODE Service Engine has been started.");
- }
-
- public String msgOdeInitHibernateDialectDetectFailed() {
- return format("Error detecting database dialect; Hibernate DAO could not be started.");
- }
-
- public String msgOdeInitialized() {
- return "ODE BPEL Server Initialized.";
- }
-
- public String msgOdeDbPoolStartupFailed(String url) {
- return format("Error starting Minerva connection pool for \"{0}\".", url);
- }
-
- public String msgOdeBpelServerStartFailure() {
- return format("ODE BPEL Server failed to start.");
- }
-
- public String msgOdeProcessDeploymentFailed(File dd, String suid) {
- return format(
- "Error deploying process described by deployment descriptor \"{0}\" for service unit \"{1}\".",
- dd, suid);
- }
-
- public String msgOdeProcessUndeploymentFailed(QName pid) {
- return format(
- "Error undeploying process \"{0}\".",pid);
- }
-
- public String msgServiceUnitDeployFailed(String serviceUnitID) {
- return format("Error deploying service unit \"{0}\".", serviceUnitID);
- }
-
- public String msgServiceUnitInitFailed(String serviceUnitID) {
-
- return format("Error initializing service unit \"{0}\".", serviceUnitID);
- }
-
- public String msgServiceUnitStartFailed(String serviceUnitID) {
-
- return format("Error starting service unit \"{0}\".", serviceUnitID);
- }
-
- public String msgServiceUnitStopFailed(String serviceUnitID) {
-
- return format("Error stopping service unit \"{0}\".", serviceUnitID);
- }
-
- public String msgServiceUnitShutdownFailed(String serviceUnitID) {
- return format("Error shutting down service unit \"{0}\".", serviceUnitID);
- }
-
- public String msgOdeInitMapperClassNotFound(String messageMapper) {
- return format("Message mapper class \"{0}\" not found!", messageMapper);
- }
-
- public String msgOdeInitMapperClassLoadFailed(String messageMapper) {
- return format("Message mapper class \"{0}\" could not be loaded!", messageMapper);
- }
-
- public String msgOdeInitMapperInstantiationFailed(String messageMapper) {
- return format("Message mapper class \"{0}\" could not be instantiated!", messageMapper);
- }
+ public String msgOdeInstallErrorCfgNotFound(File configFile) {
+ return format("ODE-JBI config file {0} not found; using defaults!", configFile);
+ }
+
+ public String msgOdeInstallErrorCfgReadError(File configFile) {
+ return format("Error installing ODE component: config file {0} could not be read!", configFile);
+ }
+
+ public String msgOdeInstalled(String dir) {
+ return format("ODE Service Engine installed in {0}", dir);
+
+ }
+
+ public String msgOdeInitHibernatePropertiesNotFound(File expected) {
+ return format("Hibernate configuration file \"{0}\" not found!", expected);
+ }
+
+ public String msgOdeUsingExternalDb(String dbDataSource) {
+ return format("ODE using external DataSource \"{0}\".", dbDataSource);
+ }
+
+ public String msgOdeInitExternalDbFailed(String dbDataSource) {
+ return format("Failed to resolved external DataSource at \"{0}\".", dbDataSource);
+ }
+
+ public String msgOdeInitHibernateErrorReadingHibernateProperties(File hibernatePropFile) {
+ return format("Error reading Hibernate properties file \"{0}\".", hibernatePropFile);
+ }
+
+ public String msgOdeStarting() {
+ return format("Starting ODE ServiceEngine.");
+ }
+
+ public String msgOdeStarted() {
+ return format("ODE Service Engine has been started.");
+ }
+
+ public String msgOdeInitHibernateDialectDetectFailed() {
+ return format("Error detecting database dialect; Hibernate DAO could not be started.");
+ }
+
+ public String msgOdeInitialized() {
+ return "ODE BPEL Server Initialized.";
+ }
+
+ public String msgOdeDbPoolStartupFailed(String url) {
+ return format("Error starting Minerva connection pool for \"{0}\".", url);
+ }
+
+ public String msgOdeBpelServerStartFailure() {
+ return format("ODE BPEL Server failed to start.");
+ }
+
+ public String msgOdeProcessDeploymentFailed(File dd, String suid) {
+ return format("Error deploying process described by deployment descriptor \"{0}\" for service unit \"{1}\".",
+ dd, suid);
+ }
+
+ public String msgOdeProcessUndeploymentFailed(QName pid) {
+ return format("Error undeploying process \"{0}\".", pid);
+ }
+
+ public String msgServiceUnitDeployFailed(String serviceUnitID) {
+ return format("Error deploying service unit \"{0}\".", serviceUnitID);
+ }
+
+ public String msgServiceUnitInitFailed(String serviceUnitID) {
+
+ return format("Error initializing service unit \"{0}\".", serviceUnitID);
+ }
+
+ public String msgServiceUnitStartFailed(String serviceUnitID) {
+
+ return format("Error starting service unit \"{0}\".", serviceUnitID);
+ }
+
+ public String msgServiceUnitStopFailed(String serviceUnitID) {
+
+ return format("Error stopping service unit \"{0}\".", serviceUnitID);
+ }
+
+ public String msgServiceUnitShutdownFailed(String serviceUnitID) {
+ return format("Error shutting down service unit \"{0}\".", serviceUnitID);
+ }
+
+ public String msgOdeInitMapperClassNotFound(String messageMapper) {
+ return format("Message mapper class \"{0}\" not found!", messageMapper);
+ }
+
+ public String msgOdeInitMapperClassLoadFailed(String messageMapper) {
+ return format("Message mapper class \"{0}\" could not be loaded!", messageMapper);
+ }
+
+ public String msgOdeInitMapperInstantiationFailed(String messageMapper) {
+ return format("Message mapper class \"{0}\" could not be instantiated!", messageMapper);
+ }
+
+ public String msgOdeEmbeddedDbNotFoundUsingTemp(File dbDir, File tmpDir) {
+ return format("Embedded database directory \"{0}\" does not exist, creating temporary database in \"{1}\"!", dbDir,tmpDir);
+ }
-
}
Modified: incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeConfigProperties.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeConfigProperties.java?view=diff&rev=486799&r1=486798&r2=486799
==============================================================================
--- incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeConfigProperties.java (original)
+++ incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeConfigProperties.java Wed Dec 13 11:04:48 2006
@@ -21,6 +21,7 @@
import java.io.File;
import java.io.FileInputStream;
+import java.io.InputStream;
import java.util.Properties;
import javax.jbi.JBIException;
@@ -31,115 +32,133 @@
import org.apache.ode.jbi.msgmap.JbiWsdl11WrapperMapper;
public class OdeConfigProperties extends Properties {
- private static final long serialVersionUID = 1L;
- private static final Log __log = LogFactory.getLog(OdeConfigProperties.class);
- private static final Messages __msgs = Messages.getMessages(Messages.class);
- private static final String CONFIG_FILE_NAME = "ode-jbi.properties";
- private static final String PROP_NAMESPACE = "ode-jbi.pidNamespace";
- private static final String PROP_ALLOW_INCOMPLETE_DEPLOYMENT = "ode-jbi.allowIncompleteDeployment";
- private static final String PROP_DB_MODE = "ode-jbi.db.mode";
- private static final String PROP_DB_EXTERNAL_DS = "ode-jbi.db.ext.dataSource";
- private static final String PROP_DB_EMBEDDED_NAME = "ode-jbi.db.emb.name";
- private static final String PROP_POOL_MAX = "ode-jbi.db.pool.max";
- private static final String PROP_POOL_MIN = "ode-jbi.db.pool.min";
- private static final String PROP_MSGMAPPER = "ode-jbi.messageMapper";
- private static final String PROP_CONNECTOR_PORT = "ode-jbi.connector.registryPort";
- private static final String PROP_CONNECTOR_NAME = "ode-jbi.connector.registryName";
-
-
- private String _installDir;
-
- public OdeConfigProperties(String installRoot) {
- _installDir = installRoot;
- }
-
- public void load() throws JBIException {
- File configFile = new File(_installDir ,CONFIG_FILE_NAME);
- if (!configFile.exists()) {
- String errmsg = __msgs.msgOdeInstallErrorCfgNotFound(configFile);
- __log.error(errmsg);
- throw new JBIException(errmsg);
- }
- FileInputStream fis = null;
- try {
- fis = new FileInputStream(configFile);
- load(fis);
- } catch (Exception ex) {
- String errmsg = __msgs.msgOdeInstallErrorCfgReadError(configFile);
- __log.error(errmsg,ex);
- throw new JBIException(errmsg);
- } finally {
- if (fis != null)
- try {
- fis.close();
- } catch (Exception ex) {}
- }
-
- }
-
- /**
- * Get the namespace that should be used to generate process identifiers
- * (PIDs). The local part of the PID will be the service unit id.
- * @return
- */
- public String getPidNamespace() {
- return getProperty(PROP_NAMESPACE, null);
- }
-
- /**
- * Should the internal database be used, or are the datasources provided?
- * @return
- */
- public DatabaseMode getDbMode() {
- return DatabaseMode.valueOf(getProperty(PROP_DB_MODE, DatabaseMode.EMBEDDED.toString()).toUpperCase());
- }
-
- public String getDbDataSource() {
- return getProperty(PROP_DB_EXTERNAL_DS, "java:comp/jdbc/ode-ds");
- }
-
- public String getDbEmbeddedName(){
- return getProperty(PROP_DB_EMBEDDED_NAME, "data");
- }
-
- /**
- * Possible database modes.
- */
- public enum DatabaseMode {
- /** External data-source (managed by app server) */
- EXTERNAL,
-
- /** Internal data-source (managed by us--Minerva) */
- INTERNAL,
-
- /** Embedded database (managed by us--Minerva) */
- EMBEDDED
- }
-
- public boolean getAllowIncompleteDeployment() {
- return Boolean.valueOf(getProperty(PROP_ALLOW_INCOMPLETE_DEPLOYMENT,Boolean.FALSE.toString()));
- }
-
- /**
- * Get the mapper to use for converting message to/from NMS format.
- * @return
- */
- public String getMessageMapper() {
- return getProperty(PROP_MSGMAPPER, JbiWsdl11WrapperMapper.class.getName());
- }
- public int getPoolMaxSize() {
- return Integer.valueOf(getProperty(PROP_POOL_MAX, "10"));
- }
-
- public int getPoolMinSize() {
- return Integer.valueOf(getProperty(PROP_POOL_MIN, "1"));
- }
-
- public int getConnectorPort() {
- return Integer.valueOf(getProperty(PROP_CONNECTOR_PORT, "1099"));
- }
-
- public String getConnectorName() {
- return getProperty(PROP_CONNECTOR_NAME,"ode");
- }
+ private static final long serialVersionUID = 1L;
+
+ private static final Log __log = LogFactory.getLog(OdeConfigProperties.class);
+
+ private static final Messages __msgs = Messages.getMessages(Messages.class);
+
+ private static final String CONFIG_FILE_NAME = "ode-jbi.properties";
+
+ private static final String PROP_NAMESPACE = "ode-jbi.pidNamespace";
+
+ private static final String PROP_ALLOW_INCOMPLETE_DEPLOYMENT = "ode-jbi.allowIncompleteDeployment";
+
+ private static final String PROP_DB_MODE = "ode-jbi.db.mode";
+
+ private static final String PROP_DB_EXTERNAL_DS = "ode-jbi.db.ext.dataSource";
+
+ private static final String PROP_DB_EMBEDDED_NAME = "ode-jbi.db.emb.name";
+
+ private static final String PROP_POOL_MAX = "ode-jbi.db.pool.max";
+
+ private static final String PROP_POOL_MIN = "ode-jbi.db.pool.min";
+
+ private static final String PROP_MSGMAPPER = "ode-jbi.messageMapper";
+
+ private static final String PROP_CONNECTOR_PORT = "ode-jbi.connector.registryPort";
+
+ private static final String PROP_CONNECTOR_NAME = "ode-jbi.connector.registryName";
+
+ private String _installDir;
+
+ public OdeConfigProperties(String installRoot) {
+ _installDir = installRoot;
+ }
+
+ public void load() throws JBIException {
+ File configFile = new File(_installDir, CONFIG_FILE_NAME);
+ if (!configFile.exists()) {
+ String errmsg = __msgs.msgOdeInstallErrorCfgNotFound(configFile);
+ __log.warn(errmsg);
+ } else {
+ InputStream fis = null;
+ try {
+ fis = new FileInputStream(configFile);
+ load(fis);
+
+ } catch (Exception ex) {
+ String errmsg = __msgs.msgOdeInstallErrorCfgReadError(configFile);
+ __log.error(errmsg, ex);
+ throw new JBIException(errmsg);
+ } finally {
+ if (fis != null)
+ try {
+ fis.close();
+ } catch (Exception ex) {
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Get the namespace that should be used to generate process identifiers
+ * (PIDs). The local part of the PID will be the service unit id.
+ *
+ * @return
+ */
+ public String getPidNamespace() {
+ return getProperty(PROP_NAMESPACE, null);
+ }
+
+ /**
+ * Should the internal database be used, or are the datasources provided?
+ *
+ * @return
+ */
+ public DatabaseMode getDbMode() {
+ return DatabaseMode.valueOf(getProperty(PROP_DB_MODE, DatabaseMode.EMBEDDED.toString()).toUpperCase());
+ }
+
+ public String getDbDataSource() {
+ return getProperty(PROP_DB_EXTERNAL_DS, "java:comp/jdbc/ode-ds");
+ }
+
+ public String getDbEmbeddedName() {
+ return getProperty(PROP_DB_EMBEDDED_NAME, "data");
+ }
+
+ /**
+ * Possible database modes.
+ */
+ public enum DatabaseMode {
+ /** External data-source (managed by app server) */
+ EXTERNAL,
+
+ /** Internal data-source (managed by us--Minerva) */
+ INTERNAL,
+
+ /** Embedded database (managed by us--Minerva) */
+ EMBEDDED
+ }
+
+ public boolean getAllowIncompleteDeployment() {
+ return Boolean.valueOf(getProperty(PROP_ALLOW_INCOMPLETE_DEPLOYMENT, Boolean.FALSE.toString()));
+ }
+
+ /**
+ * Get the mapper to use for converting message to/from NMS format.
+ *
+ * @return
+ */
+ public String getMessageMapper() {
+ return getProperty(PROP_MSGMAPPER, JbiWsdl11WrapperMapper.class.getName());
+ }
+
+ public int getPoolMaxSize() {
+ return Integer.valueOf(getProperty(PROP_POOL_MAX, "10"));
+ }
+
+ public int getPoolMinSize() {
+ return Integer.valueOf(getProperty(PROP_POOL_MIN, "1"));
+ }
+
+ public int getConnectorPort() {
+ return Integer.valueOf(getProperty(PROP_CONNECTOR_PORT, "1099"));
+ }
+
+ public String getConnectorName() {
+ return getProperty(PROP_CONNECTOR_NAME, "ode");
+ }
}
Modified: incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java?view=diff&rev=486799&r1=486798&r2=486799
==============================================================================
--- incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java (original)
+++ incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java Wed Dec 13 11:04:48 2006
@@ -31,6 +31,7 @@
import org.apache.ode.daohib.bpel.BpelDAOConnectionFactoryImpl;
import org.apache.ode.jbi.msgmap.Mapper;
import org.apache.ode.store.ProcessStoreImpl;
+import org.apache.ode.utils.fs.FileUtils;
import org.apache.ode.utils.fs.TempFileManager;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.Dialect;
@@ -55,6 +56,7 @@
import java.util.HashMap;
import java.util.Properties;
import java.util.concurrent.Executors;
+import java.util.zip.ZipFile;
/**
* This class implements ComponentLifeCycle. The JBI framework will start this
@@ -63,18 +65,26 @@
public class OdeLifeCycle implements ComponentLifeCycle {
private static final String DEFAULT_HIBERNATE_DIALECT = "org.hibernate.dialect.DerbyDialect";
+
private static final Messages __msgs = Messages.getMessages(Messages.class);
+
private static final Log __log = LogFactory.getLog(OdeLifeCycle.class);
private OdeSUManager _suManager = null;
+
private boolean _initSuccess = false;
+
private OdeContext _ode;
+
private Receiver _receiver;
+
private boolean _started;
+
private boolean _needDerbyShutdown;
+
private String _derbyUrl;
+
private BpelServerConnector _connector;
- private String _dbType;
ServiceUnitManager getSUManager() {
return _suManager;
@@ -94,9 +104,8 @@
_ode.setContext(context);
_ode._consumer = new OdeConsumer(_ode);
-
- TempFileManager.setWorkingDirectory(new File(_ode.getContext()
- .getWorkspaceRoot()));
+ if (_ode.getContext().getWorkspaceRoot() != null)
+ TempFileManager.setWorkingDirectory(new File(_ode.getContext().getWorkspaceRoot()));
__log.debug("Loading properties.");
initProperties();
@@ -128,7 +137,7 @@
}
}
- private void initMappers() throws JBIException {
+ private void initMappers() throws JBIException {
Class mapperClass;
try {
mapperClass = Class.forName(_ode._config.getMessageMapper());
@@ -152,17 +161,17 @@
private void initDataSource() throws JBIException {
switch (_ode._config.getDbMode()) {
- case EXTERNAL:
- initExternalDb();
- break;
- case EMBEDDED:
- initEmbeddedDb();
- break;
- case INTERNAL:
- initInternalDb();
- break;
- default:
- break;
+ case EXTERNAL:
+ initExternalDb();
+ break;
+ case EMBEDDED:
+ initEmbeddedDb();
+ break;
+ case INTERNAL:
+ initInternalDb();
+ break;
+ default:
+ break;
}
}
@@ -172,8 +181,8 @@
__log.info(__msgs.msgOdeUsingExternalDb(_ode._config.getDbDataSource()));
} catch (Exception ex) {
String msg = __msgs.msgOdeInitExternalDbFailed(_ode._config.getDbDataSource());
- __log.error(msg,ex);
- throw new JBIException(msg,ex);
+ __log.error(msg, ex);
+ throw new JBIException(msg, ex);
}
}
@@ -187,9 +196,15 @@
private void initEmbeddedDb() throws JBIException {
__log.info("Using DataSource Derby");
- String url =
- "jdbc:derby:" + _ode.getContext().getInstallRoot() + "/"
- + _ode._config.getDbEmbeddedName();
+ File dbDir = new File(_ode.getContext().getInstallRoot() + "/" + _ode._config.getDbEmbeddedName());
+
+ if (!dbDir.exists()) {
+ File tmpDir = new File(TempFileManager.getTemporaryDirectory("odeEmbeddedDb"), "data");
+ __log.warn(__msgs.msgOdeEmbeddedDbNotFoundUsingTemp(dbDir, tmpDir));
+ dbDir = tmpDir;
+ }
+
+ String url = "jdbc:derby:" + _ode.getContext().getInstallRoot() + "/" + _ode._config.getDbEmbeddedName();
__log.debug("creating Minerva pool for " + url);
@@ -197,8 +212,7 @@
minervaPool.setTransactionManager(_ode.getTransactionManager());
minervaPool.getConnectionFactory().setConnectionURL(url);
minervaPool.getConnectionFactory().setUserName("sa");
- minervaPool.getConnectionFactory().setDriver(
- org.apache.derby.jdbc.EmbeddedDriver.class.getName());
+ minervaPool.getConnectionFactory().setDriver(org.apache.derby.jdbc.EmbeddedDriver.class.getName());
minervaPool.getPoolParams().maxSize = _ode._config.getPoolMaxSize();
minervaPool.getPoolParams().minSize = _ode._config.getPoolMinSize();
@@ -209,8 +223,8 @@
minervaPool.start();
} catch (Exception ex) {
String errmsg = __msgs.msgOdeDbPoolStartupFailed(url);
- __log.error(errmsg,ex);
- throw new JBIException(errmsg,ex);
+ __log.error(errmsg, ex);
+ throw new JBIException(errmsg, ex);
}
_ode._dataSource = minervaPool.createDataSource();
@@ -220,12 +234,11 @@
/**
* Load the "ode-jbi.properties" file from the install directory.
- *
+ *
* @throws JBIException
*/
private void initProperties() throws JBIException {
- OdeConfigProperties config = new OdeConfigProperties(_ode.getContext()
- .getInstallRoot());
+ OdeConfigProperties config = new OdeConfigProperties(_ode.getContext().getInstallRoot());
config.load();
_ode._config = config;
}
@@ -244,16 +257,13 @@
_ode._scheduler = new QuartzSchedulerImpl();
_ode._scheduler.setBpelServer(_ode._server);
_ode._scheduler.setExecutorService(_ode._executorService, 20);
- _ode._scheduler.setTransactionManager((TransactionManager) _ode
- .getContext().getTransactionManager());
+ _ode._scheduler.setTransactionManager((TransactionManager) _ode.getContext().getTransactionManager());
_ode._scheduler.setDataSource(_ode._dataSource);
- if ("sqlserver".equals(_dbType)) _ode._scheduler.setSqlServer(true);
_ode._scheduler.init();
_ode._store = new ProcessStoreImpl(_ode._dataSource);
-
- _ode._server.setInMemDaoConnectionFactory(new org.apache.ode.bpel.memdao.BpelDAOConnectionFactoryImpl());
+ _ode._server.setInMemDaoConnectionFactory(new org.apache.ode.bpel.memdao.BpelDAOConnectionFactoryImpl());
_ode._server.setDaoConnectionFactory(_ode._daocf);
_ode._server.setEndpointReferenceContext(_ode._eprContext);
_ode._server.setMessageExchangeContext(_ode._mexContext);
@@ -266,19 +276,25 @@
/**
* Initialize the Hibernate data store.
- *
+ *
* @throws JBIException
*/
private void initHibernate() throws JBIException {
Properties properties = new Properties();
- properties.put(Environment.CONNECTION_PROVIDER,
- DataSourceConnectionProvider.class.getName());
- properties.put(Environment.TRANSACTION_MANAGER_STRATEGY,
- HibernateTransactionManagerLookup.class.getName());
+ properties.put(Environment.CONNECTION_PROVIDER, DataSourceConnectionProvider.class.getName());
+ properties.put(Environment.TRANSACTION_MANAGER_STRATEGY, HibernateTransactionManagerLookup.class.getName());
properties.put(Environment.SESSION_FACTORY_NAME, "jta");
- File hibernatePropFile = new File(_ode.getContext().getInstallRoot()
- + File.separatorChar + "hibernate.properties");
+ try {
+ properties.put(Environment.DIALECT, guessDialect(_ode._dataSource));
+ } catch (Exception ex) {
+ String errmsg = __msgs.msgOdeInitHibernateDialectDetectFailed();
+ __log.error(errmsg, ex);
+ throw new JBIException(errmsg, ex);
+ }
+
+ File hibernatePropFile = new File(_ode.getContext().getInstallRoot() + File.separatorChar
+ + "hibernate.properties");
if (hibernatePropFile.exists()) {
FileInputStream fis = null;
@@ -286,35 +302,15 @@
fis = new FileInputStream(hibernatePropFile);
properties.load(new BufferedInputStream(fis));
} catch (IOException e) {
- String errmsg = __msgs
- .msgOdeInitHibernateErrorReadingHibernateProperties(hibernatePropFile);
+ String errmsg = __msgs.msgOdeInitHibernateErrorReadingHibernateProperties(hibernatePropFile);
__log.error(errmsg, e);
throw new JBIException(errmsg, e);
}
} else {
- __log.info(__msgs
- .msgOdeInitHibernatePropertiesNotFound(hibernatePropFile));
+ __log.info(__msgs.msgOdeInitHibernatePropertiesNotFound(hibernatePropFile));
}
- // Guess Hibernate dialect if not specified in hibernate.properties
- if (properties.get(Environment.DIALECT) == null) {
- try {
- properties.put(Environment.DIALECT, guessDialect(_ode._dataSource));
- } catch (Exception ex) {
- String errmsg = __msgs.msgOdeInitHibernateDialectDetectFailed();
- if (__log.isDebugEnabled()) __log.error(errmsg,ex);
- else __log.error(errmsg);
- }
- }
- if (properties.get(Environment.DIALECT) != null) {
- String dialect = (String) properties.get(Environment.DIALECT);
- if (dialect.equals("org.hibernate.dialect.SQLServerDialect"))
- _dbType = "sqlserver";
- else _dbType = "other";
- }
-
- SessionManager sm = new SessionManager(properties, _ode._dataSource, _ode
- .getTransactionManager());
+ SessionManager sm = new SessionManager(properties, _ode._dataSource, _ode.getTransactionManager());
_ode._daocf = new BpelDAOConnectionFactoryImpl(sm);
}
@@ -331,12 +327,11 @@
try {
_connector.start();
} catch (Exception e) {
- __log.error("Failed to initialize JCA connector.",e);
+ __log.error("Failed to initialize JCA connector.", e);
}
}
}
-
public synchronized void start() throws JBIException {
if (_started)
return;
@@ -348,7 +343,7 @@
String errmsg = "attempt to call start() after init() failure.";
IllegalStateException ex = new IllegalStateException(errmsg);
__log.fatal(errmsg, ex);
- throw new JBIException(errmsg,ex);
+ throw new JBIException(errmsg, ex);
}
if (_ode.getChannel() == null) {
@@ -359,7 +354,7 @@
_ode._server.start();
} catch (Exception ex) {
String errmsg = __msgs.msgOdeBpelServerStartFailure();
- __log.error(errmsg,ex);
+ __log.error(errmsg, ex);
throw new JBIException(errmsg, ex);
}
@@ -411,11 +406,12 @@
/**
* Shutdown the service engine. This performs cleanup before the BPE is
- * terminated. Once this method has been called, init() must be called before
- * the transformation engine can be started again with a call to start().
- *
+ * terminated. Once this method has been called, init() must be called
+ * before the transformation engine can be started again with a call to
+ * start().
+ *
* @throws javax.jbi.JBIException
- * if the transformation engine is unable to shut down.
+ * if the transformation engine is unable to shut down.
*/
public void shutDown() throws JBIException {
ClassLoader old = Thread.currentThread().getContextClassLoader();
@@ -425,7 +421,7 @@
try {
_connector.shutdown();
} catch (Exception e) {
- __log.error("Error shutting down JCA server.",e);
+ __log.error("Error shutting down JCA server.", e);
}
_connector = null;
}
@@ -449,9 +445,9 @@
__log.debug("shutting down derby.");
EmbeddedDriver driver = new EmbeddedDriver();
try {
- driver.connect(_derbyUrl+";shutdown", new Properties());
+ driver.connect(_derbyUrl + ";shutdown=true", new Properties());
} catch (Exception ex) {
- __log.error("Error shutting down derby.", ex);
+ ; // this is fine, we expect to get a connect exception.
}
}
__log.info("Shutdown completed.");
@@ -495,15 +491,13 @@
if (metaData != null) {
String dbProductName = metaData.getDatabaseProductName();
int dbMajorVer = metaData.getDatabaseMajorVersion();
- __log.info("Using database " + dbProductName + " major version "
- + dbMajorVer);
+ __log.info("Using database " + dbProductName + " major version " + dbMajorVer);
DialectFactory.DatabaseDialectMapper mapper = (DialectFactory.DatabaseDialectMapper) HIBERNATE_DIALECTS
.get(dbProductName);
if (mapper != null) {
dialect = mapper.getDialectClass(dbMajorVer);
} else {
- Dialect hbDialect = DialectFactory.determineDialect(
- dbProductName, dbMajorVer);
+ Dialect hbDialect = DialectFactory.determineDialect(dbProductName, dbMajorVer);
if (hbDialect != null)
dialect = hbDialect.getClass().getName();
}
@@ -513,8 +507,7 @@
}
if (dialect == null) {
- __log
- .info("Cannot determine hibernate dialect for this database: using the default one.");
+ __log.info("Cannot determine hibernate dialect for this database: using the default one.");
dialect = DEFAULT_HIBERNATE_DIALECT;
}
@@ -527,9 +520,11 @@
private static final HashMap<String, DialectFactory.VersionInsensitiveMapper> HIBERNATE_DIALECTS = new HashMap<String, DialectFactory.VersionInsensitiveMapper>();
static {
- // Hibernate has a nice table that resolves the dialect from the database
+ // Hibernate has a nice table that resolves the dialect from the
+ // database
// product name,
- // but doesn't include all the drivers. So this is supplementary, and some
+ // but doesn't include all the drivers. So this is supplementary, and
+ // some
// day in the
// future they'll add more drivers and we can get rid of this.
// Drivers already recognized by Hibernate:
@@ -541,9 +536,8 @@
// Sybase SQL Server
// Informix Dynamic Server
// Oracle 8 and Oracle >8
- HIBERNATE_DIALECTS.put("Apache Derby",
- new DialectFactory.VersionInsensitiveMapper(
- "org.hibernate.dialect.DerbyDialect"));
+ HIBERNATE_DIALECTS.put("Apache Derby", new DialectFactory.VersionInsensitiveMapper(
+ "org.hibernate.dialect.DerbyDialect"));
}
}
Modified: incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeServiceUnit.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeServiceUnit.java?view=diff&rev=486799&r1=486798&r2=486799
==============================================================================
--- incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeServiceUnit.java (original)
+++ incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeServiceUnit.java Wed Dec 13 11:04:48 2006
@@ -47,7 +47,7 @@
/** Our JBI indentifier. */
private String _serviceUnitID;
- private Collection<QName> _registered;
+ private Collection<QName> _registered = new ArrayList<QName>();
/** Ctor. */