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)
protected  boolean migrateOnInit
          Un drapeau pour effectuer la migration au demarrage (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_MIGRATE_ON_INIT
          Un drapeau pour indiquer si on doit lancer le service au demarrage
static java.lang.String MIGRATION_MODEL_NAME
          Les noms des modèles connus
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  void detectDbVersion()
          Recupere depuis la base les états internes du service : versionTableExist dbVersion
 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_MIGRATE_ON_INIT

public static final java.lang.String MIGRATION_MIGRATE_ON_INIT
Un drapeau pour indiquer si on doit 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)


migrateOnInit

protected boolean migrateOnInit
Un drapeau pour effectuer la 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

detectDbVersion

protected void detectDbVersion()
Recupere depuis la base les états internes du service :


checkInit

protected void checkInit()


Copyright © 2004-2009 CodeLutin. All Rights Reserved.