net.sourceforge.fluxion.datapublisher.mysql.impl
Class MySQLBeanFactory

java.lang.Object
  extended by net.sourceforge.fluxion.datapublisher.sql.impl.SQLBeanFactory
      extended by net.sourceforge.fluxion.datapublisher.mysql.impl.MySQLBeanFactory
All Implemented Interfaces:
BeanFactory

@ServiceProvider
public class MySQLBeanFactory
extends SQLBeanFactory

An implementation of BeanFactory that generates beans from an SQL datasource connection.

Version:
0.2
Author:
Tony Burdett

Nested Class Summary
protected static class MySQLBeanFactory.DataType
          Contains mappings of the java datatypes to all types available in the MySQL format
 
Field Summary
 
Fields inherited from class net.sourceforge.fluxion.datapublisher.sql.impl.SQLBeanFactory
beanConfigs, connection, connectionDetails, filterTables, metaBeans, packageName, usingTableFiltering
 
Constructor Summary
MySQLBeanFactory()
           
 
Method Summary
 void acquireDatasourceConnection(java.util.Map<java.lang.String,java.lang.String> connectionDetails)
          Acquire a connection to the underlying datasource.
 boolean dbms(java.lang.String dbms)
          Determines whether a BeanFactory implementation can generate beans for the given dbms.
 void generateBeans(java.io.File sourceDirectory, java.lang.String packageName, java.util.Set<java.lang.Class> metaBeans, java.lang.String... schemas)
          Generate javabeans from sql metadata specific to the supplied connection
protected  java.lang.String getJavaType(java.lang.String sqlType)
          Get the java type that matches the given sqlType
protected  java.lang.Class getQueryGeneratorClass()
          Return the class that concrete BeanFactory implementations use to the create a query.
 void terminateDatasourceConnection()
          Close the connection to the underlying datasource.
 
Methods inherited from class net.sourceforge.fluxion.datapublisher.sql.impl.SQLBeanFactory
analyseColumns, analyseKeys, analyseTable, donotUseTableFiltering, getDatasourceConnectionParameters, getPackageName, makeExportedObjectPropertyMethods, makeImportedObjectPropertyMethods, readTableFilterFile, setType, useTableFiltering
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MySQLBeanFactory

public MySQLBeanFactory()
Method Detail

dbms

public boolean dbms(java.lang.String dbms)
Description copied from interface: BeanFactory
Determines whether a BeanFactory implementation can generate beans for the given dbms. Returns true if this is a valid dbms name for this service provider, false otherwise.

Parameters:
dbms - the name of the dbms for a service provider, e.g. "mysql"
Returns:
true if this service provider can generate beans for the given dbms

generateBeans

public void generateBeans(java.io.File sourceDirectory,
                          java.lang.String packageName,
                          java.util.Set<java.lang.Class> metaBeans,
                          java.lang.String... schemas)
                   throws BeanGenerationException
Description copied from class: SQLBeanFactory
Generate javabeans from sql metadata specific to the supplied connection

Specified by:
generateBeans in interface BeanFactory
Overrides:
generateBeans in class SQLBeanFactory
Parameters:
sourceDirectory - The location for the generated source files to be written to
packageName - the name of the package the generate beans should be placed in
metaBeans - the set of classes representing the database metadata
schemas - an array of database schema names to use in generating the beans
Throws:
BeanGenerationException - if the beans could not be generated

acquireDatasourceConnection

public void acquireDatasourceConnection(java.util.Map<java.lang.String,java.lang.String> connectionDetails)
                                 throws BeanGenerationException
Description copied from interface: BeanFactory
Acquire a connection to the underlying datasource. This map should contain parameters for databse URL, username, and password. Use getDatasourceConnectionParameters().keySet() to get the parameters that must be set. Or do a lookup on these key values to get the default values (e.g. "anonymous" is the default username). This way, those parameters which have been set can be used, whilst null fields will be ignored if possible (for example, in the case where password="" in accessing a public MySql database).

Parameters:
connectionDetails - a map containing parameters for connection to the database.
Throws:
BeanGenerationException - if the connection could not be acquired

terminateDatasourceConnection

public void terminateDatasourceConnection()
                                   throws BeanGenerationException
Description copied from interface: BeanFactory
Close the connection to the underlying datasource. Any open connection will be closed, and it is very important that implementations of this class close all connections correclty to prevent future access problems.

Throws:
BeanGenerationException - if there is a problem closing the connection

getQueryGeneratorClass

protected java.lang.Class getQueryGeneratorClass()
Description copied from class: SQLBeanFactory
Return the class that concrete BeanFactory implementations use to the create a query.

Specified by:
getQueryGeneratorClass in class SQLBeanFactory
Returns:
the corresponding QueryGeneratorClass for BeanFactory concrete implementations

getJavaType

protected java.lang.String getJavaType(java.lang.String sqlType)
                                throws BeanGenerationException
Get the java type that matches the given sqlType

Specified by:
getJavaType in class SQLBeanFactory
Parameters:
sqlType - the name fo the sqlType
Returns:
the name of the Java type
Throws:
BeanGenerationException - if the sqlType passed in is not recognized


Copyright © 2010. All Rights Reserved.