org.nuiton.topia.migration
Class ManualMigrationEngine

java.lang.Object
  extended by org.nuiton.topia.migration.ManualMigrationEngine
All Implemented Interfaces:
java.util.EventListener, TopiaContextListener, TopiaTransactionVetoable, TopiaService, TopiaMigrationService

public class ManualMigrationEngine
extends java.lang.Object
implements TopiaMigrationService

TopiaMigrationServiceImpl.java Classe principale du projet.

Version:
$Revision: 1459 $ Last update : $Date: 2009-05-16 09:56:47 +0200 (Sat, 16 May 2009) $
Author:
tchemit

Field Summary
protected  org.nuiton.util.Version applicationVersion
          Version courante de l'application (initialise en pre-init)
protected  ManualMigrationCallback callback
          CallbackHandler list (initialise en pre-init)
protected  org.nuiton.util.Version dbVersion
          Version courante de la base (initialise en pre-init)
protected  boolean init
          Un drapeau pour savoir si le service a bien ete initialise (i.e a bien fini la methode preInit)
protected  java.lang.String mappingsDirectory
          Chemin du dossier contenant les schemas de toutes les versions (initialise en pre-init)
static java.lang.String MIGRATION_APPLICATION_VERSION
          La version de référence
static java.lang.String MIGRATION_CALLBACK
          L'unique handler a utiliser
static java.lang.String MIGRATION_MAPPING_DIRECTORY
          L'emplacement de tous les mappings
static java.lang.String MIGRATION_MODEL_NAME
          Les noms des modèles connus
static java.lang.String MIGRATION_NO_MIGRATE_ON_INIT
          Un drapeau pour indiquer si on ne doit pas lancer le service au demarrage
protected  boolean noMigrateOnInit
          Un drapeau pour ne pas effectuer de migration au demarrage (initialise en pre-init)
protected  TopiaContextImplementor rootContext
          topia root context (initialise en pre-init)
protected  org.hibernate.cfg.Configuration versionConfiguration
          Configuration hibernate ne mappant que l'entite version (initialise en pre-init)
protected  java.util.SortedSet<org.nuiton.util.Version> versions
          ensemble des versions connues par le service
protected  boolean versionTableExist
          Un drapeau pour savoir si la table version existe en base (initialise en pre-init)
 
Fields inherited from interface org.nuiton.topia.migration.TopiaMigrationService
SERVICE_NAME
 
Constructor Summary
ManualMigrationEngine()
           
 
Method Summary
 void beginTransaction(TopiaTransactionEvent event)
           
protected  void checkInit()
           
protected  org.nuiton.util.Version detectDbVersion()
          Detecte la version de la base.
protected  java.util.List<org.nuiton.util.Version> detectVersions(java.util.SortedSet<org.nuiton.util.Version> versions, org.nuiton.util.Version dbVersion, org.nuiton.util.Version applicationVersion)
          Filtre l'ensemble des versions, pour obtenir toutes les versions a migrer.
 void doMigrateSchema()
           
 java.lang.Class<?>[] getPersistenceClasses()
           
 java.lang.String getServiceName()
           
protected  java.util.SortedSet<org.nuiton.util.Version> getVersions()
          Recupere toutes les versions prises en charge par le service de migration.
 boolean migrateSchema()
           
 void postCreateSchema(TopiaContextEvent event)
           
 boolean postInit(TopiaContextImplementor context)
           
 void postRestoreSchema(TopiaContextEvent event)
           
 void postUpdateSchema(TopiaContextEvent event)
           
 void preCreateSchema(TopiaContextEvent event)
           
 boolean preInit(TopiaContextImplementor context)
           
 void preRestoreSchema(TopiaContextEvent event)
           
 void preUpdateSchema(TopiaContextEvent event)
           
 void saveVersion(org.nuiton.util.Version version)
          Enregistre la version donnee en base avec creation de la table si elle n'existe pas.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIGRATION_APPLICATION_VERSION

public static final java.lang.String MIGRATION_APPLICATION_VERSION
La version de référence

See Also:
Constant Field Values

MIGRATION_MAPPING_DIRECTORY

public static final java.lang.String MIGRATION_MAPPING_DIRECTORY
L'emplacement de tous les mappings

See Also:
Constant Field Values

MIGRATION_MODEL_NAME

public static final java.lang.String MIGRATION_MODEL_NAME
Les noms des modèles connus

See Also:
Constant Field Values

MIGRATION_CALLBACK

public static final java.lang.String MIGRATION_CALLBACK
L'unique handler a utiliser

See Also:
Constant Field Values

MIGRATION_NO_MIGRATE_ON_INIT

public static final java.lang.String MIGRATION_NO_MIGRATE_ON_INIT
Un drapeau pour indiquer si on ne doit pas lancer le service au demarrage

See Also:
Constant Field Values

versionConfiguration

protected org.hibernate.cfg.Configuration versionConfiguration
Configuration hibernate ne mappant que l'entite version (initialise en pre-init)


mappingsDirectory

protected java.lang.String mappingsDirectory
Chemin du dossier contenant les schemas de toutes les versions (initialise en pre-init)


versions

protected java.util.SortedSet<org.nuiton.util.Version> versions
ensemble des versions connues par le service


applicationVersion

protected org.nuiton.util.Version applicationVersion
Version courante de l'application (initialise en pre-init)


versionTableExist

protected boolean versionTableExist
Un drapeau pour savoir si la table version existe en base (initialise en pre-init)


dbVersion

protected org.nuiton.util.Version dbVersion
Version courante de la base (initialise en pre-init)


noMigrateOnInit

protected boolean noMigrateOnInit
Un drapeau pour ne pas effectuer de migration au demarrage (initialise en pre-init)


callback

protected ManualMigrationCallback callback
CallbackHandler list (initialise en pre-init)


rootContext

protected TopiaContextImplementor rootContext
topia root context (initialise en pre-init)


init

protected boolean init
Un drapeau pour savoir si le service a bien ete initialise (i.e a bien fini la methode preInit)

Constructor Detail

ManualMigrationEngine

public ManualMigrationEngine()
Method Detail

getPersistenceClasses

public java.lang.Class<?>[] getPersistenceClasses()
Specified by:
getPersistenceClasses in interface TopiaService

getServiceName

public java.lang.String getServiceName()
Specified by:
getServiceName in interface TopiaService

preInit

public boolean preInit(TopiaContextImplementor context)
Specified by:
preInit in interface TopiaService

postInit

public boolean postInit(TopiaContextImplementor context)
Specified by:
postInit in interface TopiaService

preCreateSchema

public void preCreateSchema(TopiaContextEvent event)
Specified by:
preCreateSchema in interface TopiaContextListener

preRestoreSchema

public void preRestoreSchema(TopiaContextEvent event)
Specified by:
preRestoreSchema in interface TopiaContextListener

preUpdateSchema

public void preUpdateSchema(TopiaContextEvent event)
Specified by:
preUpdateSchema in interface TopiaContextListener

postCreateSchema

public void postCreateSchema(TopiaContextEvent event)
Specified by:
postCreateSchema in interface TopiaContextListener

postUpdateSchema

public void postUpdateSchema(TopiaContextEvent event)
Specified by:
postUpdateSchema in interface TopiaContextListener

postRestoreSchema

public void postRestoreSchema(TopiaContextEvent event)
Specified by:
postRestoreSchema in interface TopiaContextListener

beginTransaction

public void beginTransaction(TopiaTransactionEvent event)
Specified by:
beginTransaction in interface TopiaTransactionVetoable

doMigrateSchema

public void doMigrateSchema()
                     throws MigrationServiceException
Throws:
MigrationServiceException

migrateSchema

public boolean migrateSchema()
                      throws MigrationServiceException
Specified by:
migrateSchema in interface TopiaMigrationService
Throws:
MigrationServiceException

saveVersion

public void saveVersion(org.nuiton.util.Version version)
Enregistre la version donnee en base avec creation de la table si elle n'existe pas.

Parameters:
version - la nouvelle version de la base

getVersions

protected java.util.SortedSet<org.nuiton.util.Version> getVersions()
                                                            throws MigrationServiceException
Recupere toutes les versions prises en charge par le service de migration.

Returns:
l'ensemble triee (par ordre croissant) de toutes les versions detectees a partir du repertoire des mappings pour le modele donne.
Throws:
MigrationServiceException - pour tout probleme

detectVersions

protected java.util.List<org.nuiton.util.Version> detectVersions(java.util.SortedSet<org.nuiton.util.Version> versions,
                                                                 org.nuiton.util.Version dbVersion,
                                                                 org.nuiton.util.Version applicationVersion)
Filtre l'ensemble des versions, pour obtenir toutes les versions a migrer.

Parameters:
versions - les versions a filtrer
dbVersion - la version actuel
applicationVersion - la version a atteindre
Returns:
la liste des versions a migrer

detectDbVersion

protected org.nuiton.util.Version detectDbVersion()
                                           throws MigrationServiceException
Detecte la version de la base. Note : si la base n'est pas versionnee, on considere alors qu'elle est en en version 0.

Returns:
la version de la base
Throws:
MigrationServiceException

checkInit

protected void checkInit()


Copyright © 2004-2009 CodeLutin. All Rights Reserved.