@Plugin(name="Persistence Service Plugin", id="persistence-service", description="Service that facilitates persisting data between the graphical console sessions.") public class PersistenceService extends ConsolePlugin implements ConsoleService
| Constructor and Description |
|---|
PersistenceService() |
| Modifier and Type | Method and Description |
|---|---|
void |
delete(Persistable.Descriptor descriptor)
Deletes the specified descriptor from storage.
|
Persistable |
edit(Persistable before,
String title,
Component parent)
Takes user input and returns a modified
Persistable instance. |
List<Creator> |
getFactories(String category)
Utility method that returns all registered instance creators in the specified category.
|
Creator |
getFactory(String category,
String path)
Utility method that returns an instance creator identified by category and path.
|
ArrayList<Persistable.Descriptor> |
getSavedDescriptors(String category)
Returns a list of saved descriptors in the specified category.
|
static PersistenceService |
getService() |
Persistable.Descriptor |
load(String category,
String title,
Component parent)
Lets the user select one of the saved descriptors in the specified category.
|
<T extends Persistable> |
make(Creator.Descriptor desc)
Creates a
Persistable instance. |
<T extends Persistable> |
make(Persistable.Descriptor descriptor)
Creates a
Persistable instance based on the provided descriptor. |
<T extends Persistable> |
make(Persistable.Descriptor descriptor,
String title,
Component parent,
String category)
Creates a
Persistable instance by letting the user to select one of
the available creators in the given category, and using the provided
descriptor (if any) as the starting point. |
<T extends Persistable> |
make(String category,
String path,
Object... parameters)
Creates a
Persistable instance. |
<T extends Persistable> |
make(String category,
String path,
String[] parameters)
Creates a
Persistable instance. |
void |
save(Persistable.Descriptor descriptor)
Saves the specified descriptor to disk, making it available in future console sessions.
|
void |
saveAs(Persistable.Descriptor descriptor,
String title,
Component parent)
Saves the descriptor to disk, letting the user specify path, name, and description.
|
void |
startService()
Called by the framework to start the service.
|
getConsole, getServices, initialize, propertiesChanged, restore, save, setServicesProvider, shutdown, start, stopclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitstopServicepublic void startService()
startService in interface ConsoleServicepublic static PersistenceService getService()
public <T extends Persistable> T make(Persistable.Descriptor descriptor)
Persistable instance based on the provided descriptor. No user interaction.
An instance of Persistable is constructed as follows:
Describe annotation or by being an enclosing class, and the target class has
a constructor that takes the descriptor as the only argument, that constructor is used;
Creator factory
identified by it can be found, that factory is used;
Persistable instance is created, its restore(...) method is called.T - Type of Persistable.descriptor - JavaBean that describes the Persistable type and state.Persistable, or null if it cannot be created.public <T extends Persistable> T make(String category, String path, Object... parameters)
Persistable instance. No user interaction.T - Type of Persistable.category - Persistable category.path - Path of the Creator that should be used.parameters - Parameters to be passed to the Creator.Persistable, or null if it cannot be created.public <T extends Persistable> T make(String category, String path, String[] parameters)
Persistable instance. No user interaction.T - Type of Persistable.category - Persistable category.path - Path of the Creator that should be used.parameters - Parameters to be passed to the Creator, encoded as strings.Persistable, or null if it cannot be created.public <T extends Persistable> T make(Creator.Descriptor desc)
Persistable instance. No user interaction.T - Type of Persistable.desc - Creator descriptor.Persistable, or null if it cannot be created.public <T extends Persistable> T make(Persistable.Descriptor descriptor, String title, Component parent, String category)
Persistable instance by letting the user to select one of
the available creators in the given category, and using the provided
descriptor (if any) as the starting point.
Returns null if the user cancels creation, or an instance cannot be created for any reason.T - Type of Persistable.descriptor - Descriptor to be used as a starting point.title - User-interaction dialog title, or null if the default title should be used.parent - Graphical component to be use as a parent for user-interaction dialog(s).category - Persistable category. If null, the category will be extracted from the provided descriptor.Persistable.IllegalArgumentException - if the category is not provided and cannot be inferred from the descriptor.CancellationException - if creation is canceled by the user.public void save(Persistable.Descriptor descriptor)
descriptor - Descriptor to be saved.public void saveAs(Persistable.Descriptor descriptor, String title, Component parent)
descriptor - Descriptor to be saved.title - User interaction dialog title.parent - User interaction dialog parent component, or null if the parent is the console window.public void delete(Persistable.Descriptor descriptor)
descriptor - Descriptor to be removed.public Persistable.Descriptor load(String category, String title, Component parent)
category - Persistable object category.title - User interaction dialog title.parent - User interaction dialog parent component, or null if the parent is the console window.public Persistable edit(Persistable before, String title, Component parent)
Persistable instance.
This method should be called on EDT.before - Persistable instance to edit.title - User-interaction dialog title, or null if the default title should be used.parent - Graphical component to be use as a parent for user-interaction dialog(s).this).CancellationException - If editing is canceled by the user.RuntimeException - If editing fails for any reason.public Creator getFactory(String category, String path)
category - Creator category.path - Creator path.null if no such factory is known to this service.public List<Creator> getFactories(String category)
category - Persistable object category.public ArrayList<Persistable.Descriptor> getSavedDescriptors(String category)
category - Persistable object category.Copyright © 2023 LSST. All rights reserved.