Dashboard Builder Commons 6.0.0.Beta1

org.jboss.dashboard.database
Class DataSourceFragment

java.lang.Object
  extended by org.jboss.dashboard.database.DataSourceFragment

public abstract class DataSourceFragment
extends Object

A component to be used when access to remote databases is needed. Sample usage:

new DataSourceFragment("<remoteDatasourceName>") {
 protected void fragment(Connection conn) throws Exception {
    Statement stmt = conn.createStatement();
    ...
 }}.execute();


Constructor Summary
DataSourceFragment(String dataSourceName)
          Create a DataSourceFragment to perform queries against given datasource
 
Method Summary
 void execute()
          Executes this fragment.
protected abstract  void fragment(Connection conn)
          Called when the datasource exists.
protected  DataSource getDataSource()
          Get the datasource this fragment is using
 String getDataSourceName()
           
protected  void noDataSource()
          Called instead of fragment() when the datasource is invalid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataSourceFragment

public DataSourceFragment(String dataSourceName)
Create a DataSourceFragment to perform queries against given datasource

Parameters:
dataSourceName - datasource name to use
Method Detail

getDataSource

protected DataSource getDataSource()
                            throws Exception
Get the datasource this fragment is using

Returns:
the datasource this fragment is using
Throws:
Exception

getDataSourceName

public String getDataSourceName()

execute

public void execute()
             throws Exception
Executes this fragment.

Throws:
Exception

fragment

protected abstract void fragment(Connection conn)
                          throws Exception
Called when the datasource exists. Subclasses need to overwrite it to make their own queries here. The connection must be left open. It will be closed by the fragment.

Parameters:
conn - a Connection from the datasource.
Throws:
Exception

noDataSource

protected void noDataSource()
Called instead of fragment() when the datasource is invalid. Default implementation prints an error message. Custom subclasses may generate custom error messages.


Dashboard Builder Commons 6.0.0.Beta1

Copyright © 2012-2013 JBoss by Red Hat. All Rights Reserved.