Class PersistenceFacade


  • public abstract class PersistenceFacade
    extends Object
    Represents a singleton registry of model and model root factories.
    • Constructor Detail

      • PersistenceFacade

        protected PersistenceFacade()
    • Method Detail

      • 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​(String type)
        Retrieves the factory associated with the given type
      • setModelRootFactory

        public abstract void setModelRootFactory​(String type,
                                                 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.
        use ModelFactoryRegistry#getDefault(DataSourceType) see jetbrains.mps.extapi.persistence.ModelFactoryService see jetbrains.mps.extapi.persistence.datasource.DataSourceFactoryRuleService
        Retrieves the factory associated with the given file extension.
      • getDefaultModelFactory

        @Deprecated
        public abstract ModelFactory getDefaultModelFactory()
        Deprecated.
        unclear contract, use ModelFactoryRegistry#getDefault(DataSourceType) see jetbrains.mps.extapi.persistence.ModelFactoryService see jetbrains.mps.extapi.persistence.datasource.DataSourceFactoryRuleService
        Retrieves the factory for default MPS storage format (xml-based).
      • setModelFactory

        @Deprecated
        public abstract void setModelFactory​(@Nullable
                                             String extension,
                                             ModelFactory factory)
        Deprecated.
        ModelFactory notion is isolated from the location by DataSource. Use ModelFactoryRegistry#register instead. see jetbrains.mps.extapi.persistence.ModelFactoryService see jetbrains.mps.extapi.persistence.datasource.DataSourceFactoryRuleService
        Registers the factory with the file extension, overwriting the potential earlier registration.
        Parameters:
        factory - The factory to register, null to clear the registration for the given type.
      • getModelFactoryExtensions

        @Deprecated
        public abstract Set<String> getModelFactoryExtensions()
        Deprecated.
        the model factories are separated from the type of location (while file extension as a key clearly violates this idea). Thus one might to look at the jetbrains.mps.extapi.persistence.datasource.DataSourceFactoryService which can be used to register your one custom data source factories. jetbrains.mps.extapi.persistence.ModelFactoryService is an extension point to register your custom model factory implementation and associate it (if needed) with some specific data source type.
        Retrieves registered storage formats extensions.
      • asString

        @NotNull
        public abstract String asString​(@NotNull
                                        SModuleId moduleId)
        Returns:
        textual representation of the identifier ready for persistence
        Since:
        3.3
      • 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​(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 parsable SModelId.
        See Also:
        asString(org.jetbrains.mps.openapi.model.SModelId)
      • asString

        public abstract String asString​(@NotNull
                                        SModelId modelId)
        Serialize counterpart for createModelId(String), persistence-ready presentation of a model identifier.
        Parameters:
        modelId - model identity
        Returns:
        textual representation of a model identifier ready for persistence
      • createModelReference

        public abstract SModelReference createModelReference​(String text)
        Creates an SModelReference from a given text identifier.
        Throws:
        IllegalArgumentException - if the text does not contain a parsable SModelReference.
      • asString

        public abstract String asString​(@NotNull
                                        SModelReference modelRef)
        Serialize counterpart for createModelReference(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.
        Parameters:
        module - can be null only if modelId is globally unique (i.e. can be resolved without a module)
      • 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.
      • createNodeId

        public abstract SNodeId createNodeId​(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 parsable SNodeId.
      • 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.
      • 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.