Class PersistenceFacade
- java.lang.Object
-
- org.jetbrains.mps.openapi.persistence.PersistenceFacade
-
public abstract class PersistenceFacade extends Object
Represents a singleton registry of model, model root factories, find usages and navigation participants. Also provides a bunch of methods to transform String to model refs/module refs/ node ids and vice versa.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PersistenceFacade.IncorrectModelReferenceFormatException
static class
PersistenceFacade.IncorrectNodeIdFormatException
-
Field Summary
Fields Modifier and Type Field Description protected static PersistenceFacade
INSTANCE
-
Constructor Summary
Constructors Modifier Constructor Description protected
PersistenceFacade()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract void
addFindUsagesParticipant(FindUsagesParticipant participant)
Deprecated.add/remove methods shall move to PersistenceRegistry (implementation class), instead, as components that perform registration may access PersistenceRegistry instance directly.abstract void
addNavigationParticipant(NavigationParticipant participant)
Deprecated, for removal: This API element is subject to removal in a future version.abstract String
asString(SAbstractConcept concept)
Serialize/deserialize support for concept meta-objectabstract String
asString(SLanguage language)
Serialize/deserialize support for deployed language meta-objectabstract String
asString(SModelId modelId)
Serialize counterpart forcreateModelId(String)
, persistence-ready presentation of a model identifier.abstract String
asString(SModelReference modelRef)
Serialize counterpart forcreateModelReference(String)
, persistence-ready presentation of a model referenceString
asString(SNodeId nodeId)
Serialize counterpart forcreateNodeId(String)
, persistence-ready presentation of a node identity.abstract String
asString(SNodeReference nodeRef)
Serialize counterpart forcreateNodeReference(String)
, persistence-ready presentation of a node reference.abstract String
asString(SModuleId moduleId)
abstract String
asString(SModuleReference reference)
Serialize counterpart forcreateModuleReference(String)
.abstract SAbstractConcept
createConcept(String text)
Serialize/deserialize support for concept meta-objectabstract SLanguage
createLanguage(String text)
Serialize/deserialize support for deployed language meta-objectabstract SModelId
createModelId(String text)
Creates an SModelId from a given text identifier.abstract SModelReference
createModelReference(String text)
Creates an SModelReference from a given text identifier.abstract SModelReference
createModelReference(SModuleReference module, SModelId modelId, String modelName)
Creates an SModelReference in a module with a given model id and model name.abstract SModelReference
createModelReference(SModuleReference module, SModelId modelId, SModelName modelName)
Creates an SModelReference in a module with a given model id and model name.abstract SModuleId
createModuleId(String text)
abstract SModuleReference
createModuleReference(String text)
abstract SModuleReference
createModuleReference(SModuleId moduleId, String moduleName)
abstract SNodeId
createNodeId(String text)
Creates an SNodeId from a given text identifier.abstract SNodeReference
createNodeReference(String text)
abstract ModelFactory
getDefaultModelFactory()
Deprecated.unclear contract, useModelFactoryRegistry#getDefault(DataSourceType)
+PreinstalledModelFactoryTypes.PLAIN_XML
abstract Set<FindUsagesParticipant>
getFindUsagesParticipants()
Find usages participants speed-up usages search by indexing the content.static PersistenceFacade
getInstance()
abstract ModelFactory
getModelFactory(String extension)
Deprecated.usegetModelFactory(ModelFactoryType)
insteadabstract ModelFactory
getModelFactory(DataSourceType dataSourceType)
abstract ModelFactory
getModelFactory(ModelFactoryType type)
abstract ModelRootFactory
getModelRootFactory(String type)
Retrieves the factory associated with the given typeabstract Set<NavigationParticipant>
getNavigationParticipants()
Deprecated, for removal: This API element is subject to removal in a future version.No reason to keep this in PersistenceComponent, NavigationParticipant API is cumbersome.abstract Iterable<String>
getTypeIds()
Retrieves all registered types of model roots FIXME shall rename to smth more meaningful (to reflect it's about model roots)abstract void
removeFindUsagesParticipant(FindUsagesParticipant participant)
Deprecated.seeaddFindUsagesParticipant(FindUsagesParticipant)
for reasonsabstract void
removeNavigationParticipant(NavigationParticipant participant)
Deprecated, for removal: This API element is subject to removal in a future version.abstract void
setModelIdFactory(String type, SModelIdFactory factory)
Registers the factory with the model id type, overwriting potential earlier registration.abstract void
setModelRootFactory(String type, ModelRootFactory factory)
Registers the factory with the given type, overwriting potential earlier registration.abstract void
setNodeIdFactory(String type, SNodeIdFactory factory)
Registers the factory with the node id type, overwriting potential earlier registration.
-
-
-
Field Detail
-
INSTANCE
protected static PersistenceFacade INSTANCE
-
-
Method Detail
-
getInstance
public static PersistenceFacade getInstance()
-
getTypeIds
public abstract Iterable<String> getTypeIds()
Retrieves all registered types of model roots FIXME shall rename to smth more meaningful (to reflect it's about model roots)
-
getModelRootFactory
public abstract ModelRootFactory getModelRootFactory(@NotNull String type)
Retrieves the factory associated with the given type
-
setModelRootFactory
public abstract void setModelRootFactory(@NotNull String type, @Nullable ModelRootFactory factory)
Registers the factory with the given type, overwriting potential earlier registration.- Parameters:
factory
- The factory to register,null
to clear the registration for the given type.
-
getModelFactory
@Deprecated public abstract ModelFactory getModelFactory(@Nullable String extension)
Deprecated.usegetModelFactory(ModelFactoryType)
insteadRetrieves the factory associated with the given file extension.
-
getModelFactory
@Nullable public abstract ModelFactory getModelFactory(@NotNull ModelFactoryType type)
- Returns:
- the ModelFactory which was registered last.
Use
ModelFactoryRegister
extension point in order to register a custom ModelFactory.
-
getModelFactory
@Nullable public abstract ModelFactory getModelFactory(@NotNull DataSourceType dataSourceType)
- Returns:
- the ModelFactory which was registered last and has in its
ModelFactory.getPreferredDataSourceTypes()
the dataSourceType.
-
getDefaultModelFactory
@Deprecated public abstract ModelFactory getDefaultModelFactory()
Deprecated.unclear contract, useModelFactoryRegistry#getDefault(DataSourceType)
+PreinstalledModelFactoryTypes.PLAIN_XML
Retrieves the factory for default MPS storage format (xml-based).
-
createModuleId
@NotNull public abstract SModuleId createModuleId(@NotNull String text)
- Returns:
- module identity object created from persistence text
- Throws:
IllegalArgumentException
- if the text could not be parsed- Since:
- 3.3
-
asString
@NotNull public abstract String asString(@NotNull SModuleId moduleId)
- Returns:
- textual representation of the identifier ready for persistence
- Since:
- 3.3
-
asString
public abstract String asString(@NotNull SModuleReference reference)
Serialize counterpart forcreateModuleReference(String)
.- Parameters:
reference
- module reference to serialize- Returns:
- persistence-ready presentation of a module identifier
- Since:
- 3.3
-
createModuleReference
public abstract SModuleReference createModuleReference(@NotNull String text)
-
createModuleReference
public abstract SModuleReference createModuleReference(@NotNull SModuleId moduleId, String moduleName)
- Returns:
- module identity constructed from the fragments supplied
- Since:
- 3.3
-
createModelId
public abstract SModelId createModelId(@NotNull String text)
Creates an SModelId from a given text identifier. Allows implementations to provide their own version of SModelId.- Parameters:
text
- A text that the custom implementation of SModelIdFactory could use to build its own SModelId. The text comes in the following format: "type:restInterpretedByTheConcreteTypeProvider" The actual type of the model id is followed by implementation-specific text.- Throws:
IllegalArgumentException
- if the text does not contain a parsableSModelId
.- See Also:
asString(org.jetbrains.mps.openapi.model.SModelId)
-
asString
public abstract String asString(@NotNull SModelId modelId)
Serialize counterpart forcreateModelId(String)
, persistence-ready presentation of a model identifier.- Parameters:
modelId
- model identity- Returns:
- textual representation of a model identifier ready for persistence
-
createModelReference
@NotNull public abstract SModelReference createModelReference(@NotNull String text)
Creates an SModelReference from a given text identifier.- Throws:
IllegalArgumentException
- if the text does not contain a parsableSModelReference
PersistenceFacade.IncorrectModelReferenceFormatException
- if the text does not contain a parsableSModelReference
[since 2017.3] [it is a runtime exception in order to preserve compatibility]
-
asString
public abstract String asString(@NotNull SModelReference modelRef)
Serialize counterpart forcreateModelReference(String)
, persistence-ready presentation of a model reference- Parameters:
modelRef
- model reference to serialize- Returns:
- textual representation of a model reference
-
createModelReference
public abstract SModelReference createModelReference(SModuleReference module, @NotNull SModelId modelId, @NotNull String modelName)
Creates an SModelReference in a module with a given model id and model name. PrefercreateModelReference(SModuleReference, SModelId, SModelName)
alternative that takesSModelName
.- Parameters:
module
- can be null only if modelId is globally unique (i.e. can be resolved without a module)
-
createModelReference
public abstract SModelReference createModelReference(SModuleReference module, @NotNull SModelId modelId, @NotNull SModelName modelName)
Creates an SModelReference in a module with a given model id and model name.- Parameters:
module
- can be null only if modelId is globally unique (i.e. can be resolved without a module)modelId
- identity of a model either globally or within a modulemodelName
- user-friendly name of a model- Throws:
IllegalArgumentException
- when modelId is module-relative and no module has been specified
-
setModelIdFactory
public abstract void setModelIdFactory(String type, SModelIdFactory factory)
Registers the factory with the model id type, overwriting potential earlier registration.- Parameters:
factory
- The factory to register, null to clear the registration for the given type.
-
asString
public String asString(@NotNull SNodeId nodeId)
Serialize counterpart forcreateNodeId(String)
, persistence-ready presentation of a node identity.- Parameters:
nodeId
- identity of a node, seeSNode.getNodeId()
- Returns:
- textual representation of a node identity value
- Since:
- 2018.3
-
createNodeId
@Nullable public abstract SNodeId createNodeId(@NotNull String text)
Creates an SNodeId from a given text identifier. Allows implementations to provide their own version of SNodeId.- Parameters:
text
- A text that the custom implementation of SNodeIdFactory could use to build its own SNodeId. The text comes in the following format: "type:restInterpretedByTheConcreteTypeProvider" The actual type of the node id is followed by implementation-specific text.- Throws:
IllegalArgumentException
- if the text does not contain a parsableSNodeId
.PersistenceFacade.IncorrectNodeIdFormatException
- if the text does not contain a parsable SNodeId. fixme when it returns null and when throws IAE?
-
asString
@NotNull public abstract String asString(@NotNull SNodeReference nodeRef)
Serialize counterpart forcreateNodeReference(String)
, persistence-ready presentation of a node reference.- Parameters:
nodeRef
- node reference to serialize- Returns:
- textual representation of node reference
-
createNodeReference
public abstract SNodeReference createNodeReference(@NotNull String text)
- Throws:
IllegalArgumentException
- if the model reference or node reference could not be parsedPersistenceFacade.IncorrectModelReferenceFormatException
- if the model reference could not be parsed [since 2017.3]PersistenceFacade.IncorrectNodeIdFormatException
- if the node id could not be parsed [since 2017.3]
-
setNodeIdFactory
public abstract void setNodeIdFactory(String type, SNodeIdFactory factory)
Registers the factory with the node id type, overwriting potential earlier registration.- Parameters:
factory
- The factory to register, null to clear the registration for the given type.
-
asString
public abstract String asString(@NotNull SAbstractConcept concept)
Serialize/deserialize support for concept meta-object- Since:
- 2019.2
-
createConcept
public abstract SAbstractConcept createConcept(@NotNull String text)
Serialize/deserialize support for concept meta-object- Throws:
IllegalArgumentException
- if text doesn't represent valid serialized identity of a concept- Since:
- 2019.2
-
asString
public abstract String asString(@NotNull SLanguage language)
Serialize/deserialize support for deployed language meta-object- Since:
- 2019.2
-
createLanguage
public abstract SLanguage createLanguage(@NotNull String text)
Serialize/deserialize support for deployed language meta-object- Throws:
IllegalArgumentException
- if text doesn't represent valid serialized identity of a deployed language- Since:
- 2019.2
-
getFindUsagesParticipants
public abstract Set<FindUsagesParticipant> getFindUsagesParticipants()
Find usages participants speed-up usages search by indexing the content. seeFindUsagesParticipant
-
addFindUsagesParticipant
@Deprecated public abstract void addFindUsagesParticipant(FindUsagesParticipant participant)
Deprecated.add/remove methods shall move to PersistenceRegistry (implementation class), instead, as components that perform registration may access PersistenceRegistry instance directly. I don't see a need to add/remove participants dynamically.
-
removeFindUsagesParticipant
@Deprecated public abstract void removeFindUsagesParticipant(FindUsagesParticipant participant)
Deprecated.seeaddFindUsagesParticipant(FindUsagesParticipant)
for reasons
-
getNavigationParticipants
@Deprecated(forRemoval=true) public abstract Set<NavigationParticipant> getNavigationParticipants()
Deprecated, for removal: This API element is subject to removal in a future version.No reason to keep this in PersistenceComponent, NavigationParticipant API is cumbersome. Need a replacement API.Navigation participants speed-up building Go to lists by indexing the available targets. seeNavigationParticipant
-
addNavigationParticipant
@Deprecated(forRemoval=true) public abstract void addNavigationParticipant(NavigationParticipant participant)
Deprecated, for removal: This API element is subject to removal in a future version.
-
removeNavigationParticipant
@Deprecated(forRemoval=true) public abstract void removeNavigationParticipant(NavigationParticipant participant)
Deprecated, for removal: This API element is subject to removal in a future version.
-
-