Package org.eclipse.emf.cdo.server.db.evolution.phased

# Class FolderContextManager

java.lang.Object
org.eclipse.net4j.util.event.Notifier
org.eclipse.net4j.util.lifecycle.Lifecycle
org.eclipse.emf.cdo.server.db.evolution.phased.FolderContextManager

All Implemented Interfaces:
  `Context.Manager`, `org.eclipse.net4j.util.event.INotifier`, `org.eclipse.net4j.util.event.INotifier.INotifier2`, `org.eclipse.net4j.util.lifecycle.IDeactivateable`, `org.eclipse.net4j.util.lifecycle.ILifecycle`, `org.eclipse.net4j.util.lifecycle.ILifecycle.DeferrableActivation`

public class FolderContextManager extends org.eclipse.net4j.util.lifecycle.Lifecycle implements Context.Manager
A context manager that saves and loads the evolution contexts to and from a folder on disk.

The folder is determined by `PhasedModelEvolutionSupport.getEvolutionFolder()`.

Each model is saved as an individual .ecore file. The file name is derived from the model ID by encoding it to a safe file name using `IOUtil.encodeFileName(String)`. Additionally, an `evolution.properties` file is created to map the model file names to their original types and timestamps.

If the `saveNewModels` property is set to `true`, the new models are also saved to disk during evolution. The new model files have the same name as the original model files, but with a `_new` suffix before the `.ecore` extension. These extra files can be useful for debugging and verification purposes.

Since:
  4.14
Author:
  Eike Stepper
No Implement
  This package is currently considered provisional.
No Extend
  This package is currently considered provisional.
No Reference
  This package is currently considered provisional.

## Nested Class Summary

## Nested classes/interfaces inherited from class org.eclipse.net4j.util.event.Notifier

`org.eclipse.net4j.util.event.Notifier.Cancelation`

## Nested classes/interfaces inherited from interface org.eclipse.net4j.util.lifecycle.ILifecycle

`org.eclipse.net4j.util.lifecycle.ILifecycle.DeferrableActivation`

## Nested classes/interfaces inherited from interface org.eclipse.net4j.util.event.INotifier

`org.eclipse.net4j.util.event.INotifier.INotifier2`

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`FACTORY_TYPE`
The factory type of the folder context manager implementation.

### Fields inherited from class org.eclipse.net4j.util.lifecycle.Lifecycle

`USE_LABEL`

### Fields inherited from interface org.eclipse.emf.cdo.server.db.evolution.phased.Context.Manager

`PRODUCT_GROUP`

## Constructor Summary

Constructors
Constructor
Description
`FolderContextManager()`
Creates a new folder context manager.

## Method Summary

Modifier and Type
Method
Description
`Context`
`createContext()`
Creates a new context by loading the models from the database.
`PhasedModelEvolutionSupport`
`getSupport()`
Returns the model evolution support.
`boolean`
`isSaveNewModels()`
Returns whether to save the new models to disk during evolution.
`Context`
`loadContext()`
Loads the context from disk.
`protected List<Context.Model>`
`loadModelsFromDatabase(IDBStore store)`
Loads the models from the database.
`protected List<Context.Model>`
`loadModelsFromDisk(File folder)`
Loads the models from disk.
`void`
`saveContext(Context context)`
Saves the context to disk.
`protected void`
`saveModelsToDisk(File folder, Collection<Context.Model> models)`
Saves the models to disk.
`void`
`setSaveNewModels(boolean saveNewModels)`
Sets whether to save the new models to disk during evolution.
`void`
`setSupport(PhasedModelEvolutionSupport support)`
Sets the model evolution support.

### Methods inherited from class org.eclipse.net4j.util.lifecycle.Lifecycle

`activate, checkActive, checkArg, checkArg, checkInactive, checkNull, checkState, checkState, deactivate, deferredActivate, doActivate, doAfterActivate, doBeforeActivate, doBeforeDeactivate, doDeactivate, dump, getLifecycleState, isActive, isDeferredActivation, toString`

### Methods inherited from class org.eclipse.net4j.util.event.Notifier

`addListener, addUniqueListener, fireEvent, fireEvent, fireEvent, fireThrowable, firstListenerAdded, getListeners, getNotificationService, hasListener, hasListeners, lastListenerRemoved, listenerAdded, listenerRemoved, removeListener`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.eclipse.net4j.util.event.INotifier

`addListener, getListeners, hasListeners, removeListener`

## Field Details

### FACTORY_TYPE

public static final String FACTORY_TYPE
The factory type of the folder context manager implementation.

See Also:
  - Constant Field Values

## Constructor Details

### FolderContextManager

public FolderContextManager()
Creates a new folder context manager.

## Method Details

### getSupport

public PhasedModelEvolutionSupport getSupport()
Returns the model evolution support.

Specified by:
  `getSupport` in interface `Context.Manager`

### setSupport

public void setSupport(PhasedModelEvolutionSupport support)
Sets the model evolution support.

Specified by:
  `setSupport` in interface `Context.Manager`
No Reference
  This method is not intended to be called by clients.

### isSaveNewModels

public boolean isSaveNewModels()
Returns whether to save the new models to disk during evolution.

### setSaveNewModels

public void setSaveNewModels(boolean saveNewModels)
Sets whether to save the new models to disk during evolution.

### createContext

public Context createContext() throws Exception
Creates a new context by loading the models from the database.

Specified by:
  `createContext` in interface `Context.Manager`
Throws:
  `Exception`

### loadContext

public Context loadContext() throws Exception
Loads the context from disk.

Specified by:
  `loadContext` in interface `Context.Manager`
Throws:
  `Exception`

### saveContext

public void saveContext(Context context) throws Exception
Saves the context to disk.

Specified by:
  `saveContext` in interface `Context.Manager`
Throws:
  `Exception`

### loadModelsFromDatabase

protected List<Context.Model> loadModelsFromDatabase(IDBStore store) throws SQLException
Loads the models from the database.

Throws:
  `SQLException`

### loadModelsFromDisk

protected List<Context.Model> loadModelsFromDisk(File folder) throws IOException
Loads the models from disk.

Throws:
  `IOException`

### saveModelsToDisk

protected void saveModelsToDisk(File folder, Collection<Context.Model> models) throws IOException
Saves the models to disk.

Throws:
  `IOException`