You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by re...@apache.org on 2001/02/12 06:55:46 UTC
cvs commit: jakarta-slide/src/share/org/apache/slide/common AbstractServiceBase.java AbstractService.java AbstractSimpleService.java AbstractXAService.java Domain.java Namespace.java Service.java
remm 01/02/11 21:55:46
Modified: src/share/org/apache/slide/common AbstractService.java
AbstractSimpleService.java AbstractXAService.java
Domain.java Namespace.java Service.java
Added: src/share/org/apache/slide/common AbstractServiceBase.java
Log:
- Add a new AbstractServiceBase class which is used to prevend code
duplication between AbstractService, AbstractSimpleService and
AbstractXAService.
- Allow associating a logger for each namespace.
- Add a Service.getLogger() call which will return the logger which is associated
with the current namespace.
- The logging policy of some of the exceptions will be modified.
Revision Changes Path
1.2 +6 -118 jakarta-slide/src/share/org/apache/slide/common/AbstractService.java
Index: AbstractService.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/AbstractService.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractService.java 2001/01/20 20:05:00 1.1
+++ AbstractService.java 2001/02/12 05:55:45 1.2
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/AbstractService.java,v 1.1 2001/01/20 20:05:00 remm Exp $
- * $Revision: 1.1 $
- * $Date: 2001/01/20 20:05:00 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/AbstractService.java,v 1.2 2001/02/12 05:55:45 remm Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/02/12 05:55:45 $
*
* ====================================================================
*
@@ -77,9 +77,10 @@
*
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
* @author Juergen Pill
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
-public abstract class AbstractService implements Service {
+public abstract class AbstractService extends AbstractServiceBase
+ implements Service {
// -------------------------------------------------------------- Constants
@@ -97,119 +98,6 @@
* Current transaction context.
*/
protected Hashtable currentContexts = new Hashtable();
-
-
- /**
- * Namespace.
- */
- protected Namespace namespace;
-
-
- // -------------------------------------------------------- Service Methods
-
-
- /**
- * Namespace setter.
- */
- public void setNamespace(Namespace namespace) {
- this.namespace = namespace;
- }
-
-
- /**
- * Initializes the service with a set of parameters. Those could be :
- * <li>User name, login info
- * <li>Host name on which to connect
- * <li>Remote port
- * <li>JDBC driver whoich is to be used :-)
- * <li>Anything else ...
- *
- * @param parameters Hashtable containing the parameters' names
- * and associated values
- * @exception ServiceParameterErrorException Incorrect service parameter
- * @exception ServiceParameterMissingException Service parameter missing
- */
- public abstract void setParameters(Hashtable parameters)
- throws ServiceParameterErrorException,
- ServiceParameterMissingException;
-
-
- /**
- * Connects to the underlying data source (if any is needed).
- *
- * @exception ServiceConnectionFailedException Connection failed
- */
- public abstract void connect()
- throws ServiceConnectionFailedException;
-
-
- /**
- * Disconnects from the underlying data source.
- *
- * @exception ServiceDisconnectionFailedException Disconnection failed
- */
- public abstract void disconnect()
- throws ServiceDisconnectionFailedException;
-
-
- /**
- * Initializes service.
- *
- * @param token Namespace access token, needed if the service needs to
- * access objects or data within the namespace during its initialization
- * @exception ServiceInitializationFailedException May throw an exception
- * if the service has already been initialized before
- */
- public void initialize(NamespaceAccessToken token)
- throws ServiceInitializationFailedException {
- }
-
-
- /**
- * Deletes service underlying data source, if possible (and meaningful).
- *
- * @exception ServiceResetFailedException Reset failed
- */
- public abstract void reset()
- throws ServiceResetFailedException;
-
-
- /**
- * This function tells whether or not the service is connected.
- *
- * @return boolean true if we are connected
- * @exception ServiceAccessException Service access error
- */
- public abstract boolean isConnected()
- throws ServiceAccessException;
-
-
- /**
- * Connects to the service, if we were not previously connected.
- *
- * @return boolean true if we were not already connected
- * @exception ServiceAccessException Unspecified service access error
- * @exception ServiceConnectionFailedException Connection failed
- */
- public boolean connectIfNeeded()
- throws ServiceConnectionFailedException, ServiceAccessException {
- boolean result = !isConnected();
- if (result) {
- connect();
- }
- return result;
- }
-
-
- /**
- * Indicates whether or not the objects managed by this service should be
- * cached. Caching is enabled by default.
- *
- * @return boolean True if results should be cached
- */
- public boolean cacheResults() {
- return true;
- }
// ----------------------------------------------------- XAResource Mathods
1.2 +6 -118 jakarta-slide/src/share/org/apache/slide/common/AbstractSimpleService.java
Index: AbstractSimpleService.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/AbstractSimpleService.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractSimpleService.java 2001/01/20 20:05:00 1.1
+++ AbstractSimpleService.java 2001/02/12 05:55:46 1.2
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/AbstractSimpleService.java,v 1.1 2001/01/20 20:05:00 remm Exp $
- * $Revision: 1.1 $
- * $Date: 2001/01/20 20:05:00 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/AbstractSimpleService.java,v 1.2 2001/02/12 05:55:46 remm Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/02/12 05:55:46 $
*
* ====================================================================
*
@@ -76,9 +76,10 @@
* transaction context.
*
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
-public abstract class AbstractSimpleService implements Service {
+public abstract class AbstractSimpleService extends AbstractServiceBase
+ implements Service {
// -------------------------------------------------------------- Constants
@@ -105,12 +106,6 @@
/**
- * Namespace.
- */
- protected Namespace namespace;
-
-
- /**
* Transaction timeout.
*/
protected int transactionTimeout =
@@ -121,113 +116,6 @@
* Rollback only.
*/
protected boolean rollbackOnly = false;
-
-
- // -------------------------------------------------------- Service Methods
-
-
- /**
- * Namespace setter.
- */
- public void setNamespace(Namespace namespace) {
- this.namespace = namespace;
- }
-
-
- /**
- * Initializes the service with a set of parameters. Those could be :
- * <li>User name, login info
- * <li>Host name on which to connect
- * <li>Remote port
- * <li>JDBC driver whoich is to be used :-)
- * <li>Anything else ...
- *
- * @param parameters Hashtable containing the parameters' names
- * and associated values
- * @exception ServiceParameterErrorException Incorrect service parameter
- * @exception ServiceParameterMissingException Service parameter missing
- */
- public abstract void setParameters(Hashtable parameters)
- throws ServiceParameterErrorException,
- ServiceParameterMissingException;
-
-
- /**
- * Connects to the underlying data source (if any is needed).
- *
- * @exception ServiceConnectionFailedException Connection failed
- */
- public abstract void connect()
- throws ServiceConnectionFailedException;
-
-
- /**
- * Disconnects from the underlying data source.
- *
- * @exception ServiceDisconnectionFailedException Disconnection failed
- */
- public abstract void disconnect()
- throws ServiceDisconnectionFailedException;
-
-
- /**
- * Initializes service.
- *
- * @param token Namespace access token, needed if the service needs to
- * access objects or data within the namespace during its initialization
- * @exception ServiceInitializationFailedException May throw an exception
- * if the service has already been initialized before
- */
- public void initialize(NamespaceAccessToken token)
- throws ServiceInitializationFailedException {
- }
-
-
- /**
- * Deletes service underlying data source, if possible (and meaningful).
- *
- * @exception ServiceResetFailedException Reset failed
- */
- public abstract void reset()
- throws ServiceResetFailedException;
-
-
- /**
- * This function tells whether or not the service is connected.
- *
- * @return boolean true if we are connected
- * @exception ServiceAccessException Service access error
- */
- public abstract boolean isConnected()
- throws ServiceAccessException;
-
-
- /**
- * Connects to the service, if we were not previously connected.
- *
- * @return boolean true if we were not already connected
- * @exception ServiceAccessException Unspecified service access error
- * @exception ServiceConnectionFailedException Connection failed
- */
- public boolean connectIfNeeded()
- throws ServiceConnectionFailedException, ServiceAccessException {
- boolean result = !isConnected();
- if (result) {
- connect();
- }
- return result;
- }
-
-
- /**
- * Indicates whether or not the objects managed by this service should be
- * cached. Caching is enabled by default.
- *
- * @return boolean True if results should be cached
- */
- public boolean cacheResults() {
- return true;
- }
// ----------------------------------------------------- XAResource Mathods
1.2 +6 -118 jakarta-slide/src/share/org/apache/slide/common/AbstractXAService.java
Index: AbstractXAService.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/AbstractXAService.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractXAService.java 2001/01/20 20:05:00 1.1
+++ AbstractXAService.java 2001/02/12 05:55:46 1.2
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/AbstractXAService.java,v 1.1 2001/01/20 20:05:00 remm Exp $
- * $Revision: 1.1 $
- * $Date: 2001/01/20 20:05:00 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/AbstractXAService.java,v 1.2 2001/02/12 05:55:46 remm Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/02/12 05:55:46 $
*
* ====================================================================
*
@@ -79,128 +79,16 @@
* manager).
*
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
-public abstract class AbstractXAService implements Service {
+public abstract class AbstractXAService extends AbstractServiceBase
+ implements Service {
// -------------------------------------------------------------- Constants
// ----------------------------------------------------- Instance Variables
-
-
- /**
- * Namespace.
- */
- protected Namespace namespace;
-
-
- // -------------------------------------------------------- Service Methods
-
-
- /**
- * Namespace setter.
- */
- public void setNamespace(Namespace namespace) {
- this.namespace = namespace;
- }
-
-
- /**
- * Initializes the service with a set of parameters. Those could be :
- * <li>User name, login info
- * <li>Host name on which to connect
- * <li>Remote port
- * <li>JDBC driver whoich is to be used :-)
- * <li>Anything else ...
- *
- * @param parameters Hashtable containing the parameters' names
- * and associated values
- * @exception ServiceParameterErrorException Incorrect service parameter
- * @exception ServiceParameterMissingException Service parameter missing
- */
- public abstract void setParameters(Hashtable parameters)
- throws ServiceParameterErrorException,
- ServiceParameterMissingException;
-
-
- /**
- * Connects to the underlying data source (if any is needed).
- *
- * @exception ServiceConnectionFailedException Connection failed
- */
- public abstract void connect()
- throws ServiceConnectionFailedException;
-
-
- /**
- * Disconnects from the underlying data source.
- *
- * @exception ServiceDisconnectionFailedException Disconnection failed
- */
- public abstract void disconnect()
- throws ServiceDisconnectionFailedException;
-
-
- /**
- * Initializes service.
- *
- * @param token Namespace access token, needed if the service needs to
- * access objects or data within the namespace during its initialization
- * @exception ServiceInitializationFailedException May throw an exception
- * if the service has already been initialized before
- */
- public void initialize(NamespaceAccessToken token)
- throws ServiceInitializationFailedException {
- }
-
-
- /**
- * Deletes service underlying data source, if possible (and meaningful).
- *
- * @exception ServiceResetFailedException Reset failed
- */
- public abstract void reset()
- throws ServiceResetFailedException;
-
-
- /**
- * This function tells whether or not the service is connected.
- *
- * @return boolean true if we are connected
- * @exception ServiceAccessException Service access error
- */
- public abstract boolean isConnected()
- throws ServiceAccessException;
-
-
- /**
- * Connects to the service, if we were not previously connected.
- *
- * @return boolean true if we were not already connected
- * @exception ServiceAccessException Unspecified service access error
- * @exception ServiceConnectionFailedException Connection failed
- */
- public boolean connectIfNeeded()
- throws ServiceConnectionFailedException, ServiceAccessException {
- boolean result = !isConnected();
- if (result) {
- connect();
- }
- return result;
- }
-
-
- /**
- * Indicates whether or not the objects managed by this service should be
- * cached. Caching is enabled by default.
- *
- * @return boolean True if results should be cached
- */
- public boolean cacheResults() {
- return true;
- }
// ----------------------------------------------------- XAResource Mathods
1.17 +39 -17 jakarta-slide/src/share/org/apache/slide/common/Domain.java
Index: Domain.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/Domain.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- Domain.java 2001/01/25 09:17:27 1.16
+++ Domain.java 2001/02/12 05:55:46 1.17
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/Domain.java,v 1.16 2001/01/25 09:17:27 juergen Exp $
- * $Revision: 1.16 $
- * $Date: 2001/01/25 09:17:27 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/Domain.java,v 1.17 2001/02/12 05:55:46 remm Exp $
+ * $Revision: 1.17 $
+ * $Date: 2001/02/12 05:55:46 $
*
* ====================================================================
*
@@ -88,7 +88,7 @@
* For now, does not implement access control on Namespaces.
*
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
- * @version $Revision: 1.16 $
+ * @version $Revision: 1.17 $
*/
public final class Domain {
@@ -198,25 +198,23 @@
*/
public static void init(Configuration configuration) {
- String loggerClass = configuration.getAttribute("logger",
- "org.apache.slide.util.logger.SimpleLogger");
-
-
+ String loggerClass = configuration.getAttribute
+ ("logger", "org.apache.slide.util.logger.SimpleLogger");
if (isInitialized())
return;
if (logger == null) {
try {
- logger = (Logger)(Class.forName(loggerClass).newInstance());
- logger.setLoggerLevel(configuration.getAttributeAsInt("logger-level",
- Logger.INFO));
- }
- catch (Exception e) {
- e.printStackTrace();
- throw new DomainInitializationFailedError("Logger Problem: " + e.toString());
- }
-
+ logger = (Logger) (Class.forName(loggerClass).newInstance());
+ logger.setLoggerLevel(configuration.getAttributeAsInt
+ ("logger-level", Logger.INFO));
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new DomainInitializationFailedError
+ ("Logger Problem: " + e.toString());
+ }
+
}
info("Initializing Domain");
@@ -396,6 +394,16 @@
/**
+ * Get the Domain logger.
+ *
+ * @return The domain logger
+ */
+ static Logger getLogger() {
+ return Domain.logger;
+ }
+
+
+ /**
* Default initialization of the domain.
*/
static void selfInit() {
@@ -475,11 +483,25 @@
e.printStackTrace();
}
+ String loggerClass = configuration.getAttribute
+ ("logger", "org.apache.slide.util.logger.SimpleLogger");
+
+ Logger namespaceLogger = null;
+ try {
+ namespaceLogger =
+ (Logger) (Class.forName(loggerClass).newInstance());
+ namespaceLogger.setLoggerLevel(configuration.getAttributeAsInt
+ ("logger-level", Logger.INFO));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
Configuration namespaceDefinition =
configuration.getConfiguration("definition");
Namespace namespace = new Namespace();
namespace.setName(configuration.getAttribute("name"));
+ namespace.setLogger(namespaceLogger);
namespace.loadDefinition(namespaceDefinition);
addNamespace(namespace);
1.20 +27 -4 jakarta-slide/src/share/org/apache/slide/common/Namespace.java
Index: Namespace.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/Namespace.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- Namespace.java 2001/02/03 20:20:50 1.19
+++ Namespace.java 2001/02/12 05:55:46 1.20
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/Namespace.java,v 1.19 2001/02/03 20:20:50 remm Exp $
- * $Revision: 1.19 $
- * $Date: 2001/02/03 20:20:50 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/Namespace.java,v 1.20 2001/02/12 05:55:46 remm Exp $
+ * $Revision: 1.20 $
+ * $Date: 2001/02/12 05:55:46 $
*
* ====================================================================
*
@@ -87,12 +87,13 @@
import org.apache.slide.authenticate.CredentialsToken;
import org.apache.slide.util.conf.Configuration;
import org.apache.slide.util.conf.ConfigurationException;
+import org.apache.slide.util.logger.Logger;
/**
* Namespace class.
*
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
- * @version $Revision: 1.19 $
+ * @version $Revision: 1.20 $
*/
public final class Namespace {
@@ -159,6 +160,12 @@
new SlideTransactionManager();
+ /**
+ * Logger.
+ */
+ private Logger logger;
+
+
// ------------------------------------------------------------ Constructor
@@ -211,6 +218,22 @@
*/
public TransactionManager getTransactionManager() {
return transactionManager;
+ }
+
+
+ /**
+ * Return the current logger.
+ */
+ public Logger getLogger() {
+ return logger;
+ }
+
+
+ /**
+ * Set the logger used by this namespace.
+ */
+ void setLogger(Logger logger) {
+ this.logger = logger;
}
1.6 +15 -4 jakarta-slide/src/share/org/apache/slide/common/Service.java
Index: Service.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/Service.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Service.java 2001/01/10 18:49:34 1.5
+++ Service.java 2001/02/12 05:55:46 1.6
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/Service.java,v 1.5 2001/01/10 18:49:34 remm Exp $
- * $Revision: 1.5 $
- * $Date: 2001/01/10 18:49:34 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/Service.java,v 1.6 2001/02/12 05:55:46 remm Exp $
+ * $Revision: 1.6 $
+ * $Date: 2001/02/12 05:55:46 $
*
* ====================================================================
*
@@ -66,12 +66,13 @@
import java.util.Hashtable;
import java.util.Enumeration;
import javax.transaction.xa.XAResource;
+import org.apache.slide.util.logger.Logger;
/**
* Slide Service interface.
*
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
*/
public interface Service
extends XAResource {
@@ -176,5 +177,15 @@
* @return boolean True if results should be cached
*/
boolean cacheResults();
+
+
+ /**
+ * Get logger associated with the service.
+ *
+ * @return The logger if one has been set for the associated namespace,
+ * or the Domain logger otherwise
+ */
+ Logger getLogger();
+
}
1.1 jakarta-slide/src/share/org/apache/slide/common/AbstractServiceBase.java
Index: AbstractServiceBase.java
===================================================================
/*
* $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/AbstractServiceBase.java,v 1.1 2001/02/12 05:55:46 remm Exp $
* $Revision: 1.1 $
* $Date: 2001/02/12 05:55:46 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.slide.common;
import java.util.Hashtable;
import java.util.Enumeration;
import java.util.Vector;
import org.apache.slide.util.logger.Logger;
/**
* Slide Service abstract implementation.
*
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
* @version $Revision: 1.1 $
*/
public abstract class AbstractServiceBase implements Service {
// -------------------------------------------------------------- Constants
// ----------------------------------------------------- Instance Variables
/**
* Namespace.
*/
protected Namespace namespace;
// -------------------------------------------------------- Service Methods
/**
* Namespace setter.
*/
public void setNamespace(Namespace namespace) {
this.namespace = namespace;
}
/**
* Logger accessor.
*/
public Logger getLogger() {
Logger logger = this.namespace.getLogger();
if (logger == null)
logger = Domain.getLogger();
return logger;
}
/**
* Initializes the service with a set of parameters. Those could be :
* <li>User name, login info
* <li>Host name on which to connect
* <li>Remote port
* <li>JDBC driver whoich is to be used :-)
* <li>Anything else ...
*
* @param parameters Hashtable containing the parameters' names
* and associated values
* @exception ServiceParameterErrorException Incorrect service parameter
* @exception ServiceParameterMissingException Service parameter missing
*/
public abstract void setParameters(Hashtable parameters)
throws ServiceParameterErrorException,
ServiceParameterMissingException;
/**
* Connects to the underlying data source (if any is needed).
*
* @exception ServiceConnectionFailedException Connection failed
*/
public abstract void connect()
throws ServiceConnectionFailedException;
/**
* Disconnects from the underlying data source.
*
* @exception ServiceDisconnectionFailedException Disconnection failed
*/
public abstract void disconnect()
throws ServiceDisconnectionFailedException;
/**
* Initializes service.
*
* @param token Namespace access token, needed if the service needs to
* access objects or data within the namespace during its initialization
* @exception ServiceInitializationFailedException May throw an exception
* if the service has already been initialized before
*/
public void initialize(NamespaceAccessToken token)
throws ServiceInitializationFailedException {
}
/**
* Deletes service underlying data source, if possible (and meaningful).
*
* @exception ServiceResetFailedException Reset failed
*/
public abstract void reset()
throws ServiceResetFailedException;
/**
* This function tells whether or not the service is connected.
*
* @return boolean true if we are connected
* @exception ServiceAccessException Service access error
*/
public abstract boolean isConnected()
throws ServiceAccessException;
/**
* Connects to the service, if we were not previously connected.
*
* @return boolean true if we were not already connected
* @exception ServiceAccessException Unspecified service access error
* @exception ServiceConnectionFailedException Connection failed
*/
public boolean connectIfNeeded()
throws ServiceConnectionFailedException, ServiceAccessException {
boolean result = !isConnected();
if (result) {
connect();
}
return result;
}
/**
* Indicates whether or not the objects managed by this service should be
* cached. Caching is enabled by default.
*
* @return boolean True if results should be cached
*/
public boolean cacheResults() {
return true;
}
// ----------------------------------------------------- XAResource Mathods
}