org.apache.avalon.examples.jdbcdatasource
Class DefaultHelloDBService

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.apache.avalon.examples.jdbcdatasource.DefaultHelloDBService
All Implemented Interfaces:
Component, Configurable, Disposable, HelloDBService, Initializable, LogEnabled, Serviceable

public class DefaultHelloDBService
extends AbstractLogEnabled
implements HelloDBService, Serviceable, Configurable, Initializable, Disposable

This example application creates a conmponent which makes use of a JdbcDataSource to connect to a Hypersonic SQL database. It then adds a row to a table that it creates displaying a list of all the rows in the table. Note, this code ignores exceptions to keep the code simple.

Since:
4.1
Version:
CVS $Revision: 1.4 $ $Date: 2004/02/28 11:47:28 $
Author:
Avalon Development Team

Field Summary
 
Fields inherited from interface org.apache.avalon.examples.jdbcdatasource.HelloDBService
ROLE
 
Constructor Summary
DefaultHelloDBService()
          Instantiate a DefaultHelloDBService
 
Method Summary
 void addRow(java.lang.String title)
          Adds a single row to the database.
 void configure(Configuration configuration)
          Called by the Container to configure the component.
 void deleteRows()
          Ask the component to delete all rows in the database.
 void dispose()
          Called by the Container to dispose the component.
 void initialize()
          Called by the Container to initialize the component.
 void logRows()
          Ask the component to log all of the rows in the database to the logger with the info log level.
 void service(ServiceManager manager)
          Called by the Container to tell the component which ComponentManager is controlling it.
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultHelloDBService

public DefaultHelloDBService()
Instantiate a DefaultHelloDBService

Method Detail

addRow

public void addRow(java.lang.String title)
Adds a single row to the database.

Specified by:
addRow in interface HelloDBService
Parameters:
title - The row title

deleteRows

public void deleteRows()
Ask the component to delete all rows in the database.

Specified by:
deleteRows in interface HelloDBService

logRows

public void logRows()
Ask the component to log all of the rows in the database to the logger with the info log level.

Specified by:
logRows in interface HelloDBService

service

public void service(ServiceManager manager)
             throws ServiceException
Called by the Container to tell the component which ComponentManager is controlling it.

Specified by:
service in interface Serviceable
Parameters:
manager - which curently owns the component.
Throws:
ServiceException - if an error occurs

configure

public void configure(Configuration configuration)
               throws ConfigurationException
Called by the Container to configure the component.

Specified by:
configure in interface Configurable
Parameters:
configuration - configuration info used to setup the component.
Throws:
ConfigurationException - if there are any problems with the configuration.

initialize

public void initialize()
                throws java.lang.Exception
Called by the Container to initialize the component.

Specified by:
initialize in interface Initializable
Throws:
java.lang.Exception - if there were any problems durring initialization.

dispose

public void dispose()
Called by the Container to dispose the component.

Specified by:
dispose in interface Disposable


Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.