Class BatchLinkableResource

  • All Implemented Interfaces:
    org.eclipse.emf.common.notify.Notifier, org.eclipse.emf.ecore.resource.Resource, org.eclipse.emf.ecore.resource.Resource.Internal, org.eclipse.xtext.common.types.xtext.JvmMemberInitializableResource, org.eclipse.xtext.resource.IBatchLinkableResource, org.eclipse.xtext.resource.ISynchronizable<BatchLinkableResource>

    public class BatchLinkableResource
    extends org.eclipse.xtext.resource.DerivedStateAwareResource
    implements org.eclipse.xtext.resource.ISynchronizable<BatchLinkableResource>, org.eclipse.xtext.resource.IBatchLinkableResource, org.eclipse.xtext.common.types.xtext.JvmMemberInitializableResource
    A specialized EMF resource that is capable of resolving proxies in batch mode. That is, on getEObject(String), the BatchLinkingService is used to resolve a chunk of proxies.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.eclipse.xtext.linking.lazy.LazyLinkingResource

        org.eclipse.xtext.linking.lazy.LazyLinkingResource.CyclicLinkingException, org.eclipse.xtext.linking.lazy.LazyLinkingResource.DiagnosticMessageContext
      • Nested classes/interfaces inherited from class org.eclipse.emf.ecore.resource.impl.ResourceImpl

        org.eclipse.emf.ecore.resource.impl.ResourceImpl.ContentsEList<E extends java.lang.Object & org.eclipse.emf.ecore.EObject>, org.eclipse.emf.ecore.resource.impl.ResourceImpl.ModificationTrackingAdapter
      • Nested classes/interfaces inherited from class org.eclipse.emf.common.notify.impl.BasicNotifierImpl

        org.eclipse.emf.common.notify.impl.BasicNotifierImpl.EAdapterList<E extends java.lang.Object & org.eclipse.emf.common.notify.Adapter>, org.eclipse.emf.common.notify.impl.BasicNotifierImpl.EObservableAdapterList, org.eclipse.emf.common.notify.impl.BasicNotifierImpl.EScannableAdapterList
      • Nested classes/interfaces inherited from interface org.eclipse.emf.ecore.resource.Resource

        org.eclipse.emf.ecore.resource.Resource.Diagnostic, org.eclipse.emf.ecore.resource.Resource.Factory, org.eclipse.emf.ecore.resource.Resource.Internal, org.eclipse.emf.ecore.resource.Resource.IOWrappedException
    • Field Summary

      • Fields inherited from class org.eclipse.xtext.resource.DerivedStateAwareResource

        fullyInitialized, isInitializing
      • Fields inherited from class org.eclipse.xtext.resource.persistence.StorageAwareResource

        UNRESOLVABLE_FRAGMENT
      • Fields inherited from class org.eclipse.xtext.linking.lazy.LazyLinkingResource

        CYCLIC_LINKING_DECTECTION_COUNTER_LIMIT, cyclicLinkingDectectionCounterLimit, resolving, UNRESOLVEABLE_PROXIES_KEY
      • Fields inherited from class org.eclipse.xtext.resource.XtextResource

        isUpdating, operationCanceledManager, OPTION_ENCODING, OPTION_FORMAT, OPTION_RESOLVE_ALL, OPTION_SERIALIZATION_OPTIONS
      • Fields inherited from class org.eclipse.emf.ecore.resource.impl.ResourceImpl

        contents, defaultDeleteOptions, defaultLoadOptions, defaultSaveOptions, errors, intrinsicIDToEObjectMap, isLoaded, isLoading, isModified, modificationTrackingAdapter, resourceSet, timeStamp, unloadingContents, uri, warnings
      • Fields inherited from class org.eclipse.emf.common.notify.impl.NotifierImpl

        eAdapters, EDELIVER, eFlags, ELAST_NOTIFIER_FLAG
      • Fields inherited from interface org.eclipse.emf.ecore.resource.Resource

        OPTION_CIPHER, OPTION_LINE_DELIMITER, OPTION_LINE_DELIMITER_UNSPECIFIED, OPTION_SAVE_ONLY_IF_CHANGED, OPTION_SAVE_ONLY_IF_CHANGED_FILE_BUFFER, OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER, OPTION_ZIP, RESOURCE__CONTENTS, RESOURCE__ERRORS, RESOURCE__IS_LOADED, RESOURCE__IS_MODIFIED, RESOURCE__IS_TRACKING_MODIFICATION, RESOURCE__RESOURCE_SET, RESOURCE__TIME_STAMP, RESOURCE__URI, RESOURCE__WARNINGS
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addJvmMemberInitializer​(java.lang.Runnable runnable)
      Register runnables to be executed when the members of types in this resource are initialized.
      protected void doDiscardDerivedState()  
      void ensureJvmMembersInitialized()
      Executes any Runnables added through addJvmMemberInitializer(Runnable)
      <Result> Result execute​(org.eclipse.xtext.util.concurrent.IUnitOfWork<Result,​? super BatchLinkableResource> unit)
      org.eclipse.emf.common.util.EList<org.eclipse.emf.ecore.EObject> getContents()
      org.eclipse.emf.ecore.EObject getEObject​(java.lang.String uriFragment)
      Delegates to the BatchLinkingService if the requested reference is linkeable in batch mode.
      java.lang.Object getLock()
      Returns the lock of the owning ResourceSet, if it exposes such a lock.
      protected org.eclipse.emf.ecore.EObject handleCyclicResolution​(org.eclipse.xtext.util.Triple<org.eclipse.emf.ecore.EObject,​org.eclipse.emf.ecore.EReference,​org.eclipse.xtext.nodemodel.INode> triple)  
      boolean hasJvmMemberInitializers()  
      boolean isInitializingJvmMembers()  
      void linkBatched​(org.eclipse.xtext.util.CancelIndicator monitor)  
      void resolveLazyCrossReferences​(org.eclipse.xtext.util.CancelIndicator monitor)
      Delegates to the BatchLinkingService to resolve all references.
      • Methods inherited from class org.eclipse.xtext.resource.DerivedStateAwareResource

        clearInternalState, discardDerivedState, doGetContents, doUnload, getEObjectForURIFragmentRootSegment, getUnloadingContents, getURIFragmentRootSegment, installDerivedState, isFullyInitialized, isInitializing, setDerivedStateComputer, setFullyInitialized, updateInternalState, updateInternalState
      • Methods inherited from class org.eclipse.xtext.resource.persistence.StorageAwareResource

        getPortableURIs, getResourceDescription, getResourceStorageFacade, getUnresolvableURIFragments, isLoadedFromStorage, load, loadFromStorage, setIsLoadedFromStorage, setResourceDescription
      • Methods inherited from class org.eclipse.xtext.linking.lazy.LazyLinkingResource

        addLazyProxyInformation, clearLazyProxyInformation, createAndAddDiagnostic, createAndAddDiagnostic, createDiagnostic, createDiagnosticMessage, createDiagnosticMessageContext, doLinking, doLoad, doResolveLazyCrossReference, getDiagnosticList, getDiagnosticMessageProvider, getEncoder, getEObject, getLazyProxyInformation, getLazyProxyInformation, getLinkingHelper, getLinkingService, getReferences, hasLazyProxyInformation, isEagerLinking, isPotentialLazyCrossReference, isUnresolveableProxyCacheable, markUnresolvable, removeDiagnostic, removeLazyProxyInformation, resolveLazyCrossReference, setDiagnosticMessageProvider, setEagerLinking, setEncoder, setLinkingHelper, setLinkingService
      • Methods inherited from class org.eclipse.xtext.resource.XtextResource

        addSyntaxDiagnostic, addSyntaxErrors, basicGetEObject, clearCache, clearErrorsAndWarnings, createReader, doSave, getCache, getConcreteSyntaxValidator, getEncoding, getEntryPoint, getFragmentProvider, getLanguageName, getLinker, getModificationStamp, getParser, getParseResult, getResourceServiceProvider, getSerializer, getUnloader, getURIFragment, isValidationDisabled, reattachModificationTracker, relink, reparse, setCache, setEncodingFromOptions, setEntryPoint, setFragmentProvider, setInjectedParser, setLanguageName, setLinker, setModificationStamp, setParser, setParseResult, setResourceServiceProvider, setSerializer, setUnloader, setValidationDisabled, unload, update, validateConcreteSyntax
      • Methods inherited from class org.eclipse.emf.ecore.resource.impl.ResourceImpl

        addModificationTrackingAdapters, attached, attachedHelper, basicSetResourceSet, createModificationTrackingAdapter, delete, detached, detachedHelper, getAllContents, getAllProperContents, getAllProperContents, getDefaultURIConverter, getEObject, getEObjectByID, getErrors, getIDForEObject, getIntrinsicIDToEObjectMap, getResourceSet, getTimeStamp, getURI, getURIConverter, getWarnings, handleLoadResponse, handleSaveResponse, isAttachedDetachedHelperRequired, isContentZipEntry, isLoaded, isLoading, isModified, isTrackingModification, load, mergeMaps, newContentZipEntry, removeModificationTrackingAdapters, save, save, saveOnlyIfChangedWithFileBuffer, saveOnlyIfChangedWithMemoryBuffer, setIntrinsicIDToEObjectMap, setLoaded, setModified, setTimeStamp, setTrackingModification, setURI, supportIDRelativeURIFragmentPaths, toKeyString, toString, unload, unloaded, useZip
      • Methods inherited from class org.eclipse.emf.common.notify.impl.NotifierImpl

        eAdapters, eBasicAdapters, eDeliver, eSetDeliver
      • Methods inherited from class org.eclipse.emf.common.notify.impl.BasicNotifierImpl

        eBasicAdapterArray, eBasicHasAdapters, eNotificationRequired, eNotify
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface org.eclipse.emf.common.notify.Notifier

        eAdapters, eDeliver, eNotify, eSetDeliver
    • Constructor Detail

      • BatchLinkableResource

        public BatchLinkableResource()
    • Method Detail

      • getLock

        public java.lang.Object getLock()
        Returns the lock of the owning ResourceSet, if it exposes such a lock. Otherwise this resource itself is used as the lock context.
        Specified by:
        getLock in interface org.eclipse.xtext.resource.ISynchronizable<BatchLinkableResource>
      • execute

        public <Result> Result execute​(org.eclipse.xtext.util.concurrent.IUnitOfWork<Result,​? super BatchLinkableResource> unit)
                                throws java.lang.Exception
        Specified by:
        execute in interface org.eclipse.xtext.resource.ISynchronizable<BatchLinkableResource>
        Throws:
        java.lang.Exception
        Since:
        2.4
      • getEObject

        public org.eclipse.emf.ecore.EObject getEObject​(java.lang.String uriFragment)
        Delegates to the BatchLinkingService if the requested reference is linkeable in batch mode. Implementation detail: This specialization of getEObject synchronizes on the lock which is exposed by the synchronizable resource rather than on the resource directly. This guards against reentrant resolution from different threads that could block each other. Usually one would want to lock only in the BatchLinkingService but we could have intermixed lazy cross reference and vanilla EMF cross references which again could lead to a dead lock.
        Specified by:
        getEObject in interface org.eclipse.emf.ecore.resource.Resource
        Overrides:
        getEObject in class org.eclipse.xtext.resource.persistence.StorageAwareResource
      • getContents

        public org.eclipse.emf.common.util.EList<org.eclipse.emf.ecore.EObject> getContents()

        Implementation detail: Overridden to use the shared lock.

        Specified by:
        getContents in interface org.eclipse.emf.ecore.resource.Resource
        Overrides:
        getContents in class org.eclipse.xtext.resource.DerivedStateAwareResource
      • resolveLazyCrossReferences

        public void resolveLazyCrossReferences​(org.eclipse.xtext.util.CancelIndicator monitor)
        Delegates to the BatchLinkingService to resolve all references. The linking service is responsible to lock the resource or resource set.
        Overrides:
        resolveLazyCrossReferences in class org.eclipse.xtext.linking.lazy.LazyLinkingResource
      • handleCyclicResolution

        protected org.eclipse.emf.ecore.EObject handleCyclicResolution​(org.eclipse.xtext.util.Triple<org.eclipse.emf.ecore.EObject,​org.eclipse.emf.ecore.EReference,​org.eclipse.xtext.nodemodel.INode> triple)
                                                                throws java.lang.AssertionError
        Overrides:
        handleCyclicResolution in class org.eclipse.xtext.linking.lazy.LazyLinkingResource
        Throws:
        java.lang.AssertionError
      • linkBatched

        public void linkBatched​(org.eclipse.xtext.util.CancelIndicator monitor)
        Specified by:
        linkBatched in interface org.eclipse.xtext.resource.IBatchLinkableResource
      • ensureJvmMembersInitialized

        public void ensureJvmMembersInitialized()
        Executes any Runnables added through addJvmMemberInitializer(Runnable)
        Specified by:
        ensureJvmMembersInitialized in interface org.eclipse.xtext.common.types.xtext.JvmMemberInitializableResource
        Since:
        2.8
        Noreference:
        This method is not intended to be referenced by clients.
      • isInitializingJvmMembers

        public boolean isInitializingJvmMembers()
        Specified by:
        isInitializingJvmMembers in interface org.eclipse.xtext.common.types.xtext.JvmMemberInitializableResource
      • doDiscardDerivedState

        protected void doDiscardDerivedState()
        Overrides:
        doDiscardDerivedState in class org.eclipse.xtext.resource.DerivedStateAwareResource
      • addJvmMemberInitializer

        public void addJvmMemberInitializer​(java.lang.Runnable runnable)
        Register runnables to be executed when the members of types in this resource are initialized.
        Specified by:
        addJvmMemberInitializer in interface org.eclipse.xtext.common.types.xtext.JvmMemberInitializableResource
        Since:
        2.8
        Noreference:
        This method is not intended to be referenced by clients.
      • hasJvmMemberInitializers

        public boolean hasJvmMemberInitializers()
        Specified by:
        hasJvmMemberInitializers in interface org.eclipse.xtext.common.types.xtext.JvmMemberInitializableResource