Package jetbrains.mps.smodel.language
Class LanguageRegistry
- java.lang.Object
 - 
- jetbrains.mps.smodel.language.LanguageRegistry
 
 
- 
- All Implemented Interfaces:
 DeployListener,CoreComponent
public class LanguageRegistry extends Object implements CoreComponent, DeployListener
Preferred way to obtain instance ofLanguageRegistryis to queryComponentHost, e.g. throughjetbrains.mps.core.platform.PlatformorProject.getComponent(Class)which is aware of the MPS platform. evgeny, 3/11/11 
- 
- 
Nested Class Summary
- 
Nested classes/interfaces inherited from interface jetbrains.mps.classloading.DeployListener
DeployListener.ResourceTrackerCallback 
 - 
 
- 
Constructor Summary
Constructors Constructor Description LanguageRegistry(ClassLoaderManager loaderManager) 
- 
Method Summary
- 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait 
- 
Methods inherited from interface jetbrains.mps.classloading.DeployListener
onUnloaded 
 - 
 
 - 
 
- 
- 
Constructor Detail
- 
LanguageRegistry
public LanguageRegistry(ClassLoaderManager loaderManager)
 
 - 
 
- 
Method Detail
- 
getInstance
@Deprecated public static LanguageRegistry getInstance()
Deprecated.obtain instance throughcomponentHost#findComponent(LanguageRegistry.class)or use context-specific alternativegetInstance(SRepository). 
- 
getInstance
@NotNull public static LanguageRegistry getInstance(@NotNull SRepository repository)
IMPORTANT: usecomponentHost#findComponent(LanguageRegistry.class)whenever \ possible instead of this method. USE OF THIS METHOD IS DISCOURAGED. At the moment, there's only 1 global LanguageRegistry. However, we move slowly towards independent projects/non-global module repositories and thus would need repository-specific registries, and use of the method is the proper way to obtain registry and to think about proper context in the client code right away.- Returns:
 - collection of languages available in the given context
 
 
- 
init
public void init()
- Specified by:
 initin interfaceCoreComponent
 
- 
dispose
public void dispose()
- Specified by:
 disposein interfaceCoreComponent
 
- 
addRegistryListener
public void addRegistryListener(LanguageRegistryListener listener)
 
- 
removeRegistryListener
public void removeRegistryListener(LanguageRegistryListener listener)
 
- 
withAvailableLanguages
public void withAvailableLanguages(@NotNull Consumer<LanguageRuntime> operation)
Synchronous access to actual languages in the registry. It's guaranteed no change to the set of languages happen while this method is working. BEWARE,operationshall not perform model read/write as it might lead to dead-lock (a thread starts model write and waits for write on myRuntimeInstanceAccess, while another thread had grabbed myRuntimeInstanceAccess read lock and consumer operation trues to grab model lock).- Parameters:
 operation- invoked for each actualLanguageRuntime, minimalistic and simple.
 
- 
getAllLanguages
public Collection<SLanguage> getAllLanguages()
- Returns:
 - snapshot of languages known to the registry at the given moment. May not reflect actual state (a language might get unloaded), but as long as it's about identity objects, it's not that important to keep the collection exact.
 
 
- 
getLanguage
@Nullable public LanguageRuntime getLanguage(SLanguage language)
 
- 
getLanguage
@Nullable public LanguageRuntime getLanguage(SLanguageId id)
 
- 
getLanguage
@Nullable public LanguageRuntime getLanguage(String namespace)
 
- 
getLanguage
@Nullable public LanguageRuntime getLanguage(Language language)
 
- 
getGenerator
@Nullable @Deprecated public GeneratorRuntime getGenerator(Generator generator)
Deprecated.usegetGenerator(SModuleReference)as it'sSModuleReferencethat is generator identity.PROVISIONAL API, DO NOT USE Find respective runtime presentation of generator module FIXME shall decide whether need standalone GeneratorRegistry to supply GeneratorRuntimes FIXME or access to GeneratorRuntime through LanguageRegistry is enough. 
- 
getGenerator
@Nullable public GeneratorRuntime getGenerator(@NotNull SModuleReference generatorIdentity)
- Parameters:
 generatorIdentity- we useSModuleReferenceto identify generator, not to introduce a dedicatedSGeneratorsimilar toSLanguage
 
- 
onUnloaded
public void onUnloaded(Set<ReloadableModule> unloadedModules, @NotNull ProgressMonitor monitor)
Description copied from interface:DeployListenerContract: The class loaders of theunloadedModulesare still valid (i.e. not disposed) Modules are still deployed however the modules might be reloaded and the corresponding ModuleClassLoaders might get disposed, essentially meaning that ANY use of instances of these stale classes might triggerModuleClassLoader.ModuleClassLoaderIsDisposedException.- Specified by:
 onUnloadedin interfaceDeployListener- Parameters:
 unloadedModules- are likely to be removed from the repository after this moment- See Also:
 if for some reason you need to use the objects of the stale module classes after #unload event.
 
- 
onLoaded
public void onLoaded(Set<ReloadableModule> loadedModules, @NotNull ProgressMonitor monitor)
Description copied from interface:DeployListenerContract: The loaded modules are guaranteed to be deployed and module.getClassLoader() returns not-null. Essentially they are ready to give out classes. The modules will stay deployed until the corresponding notification in the #onUnloaded method.- Specified by:
 onLoadedin interfaceDeployListener- Parameters:
 loadedModules- are surely in the repository at this moment.- See Also:
 ReloadableModule.getStatus()
 
 - 
 
 -