Class TraversalStrategies.GlobalCache

    • Constructor Detail

      • GlobalCache

        public GlobalCache()
    • Method Detail

      • registerStrategies

        public static void registerStrategies​(Class graphOrGraphComputerClass,
                                              TraversalStrategies traversalStrategies)
        Register a set of strategies for a particular graph or graph computer class. This is typically done by the graph or graph computer class itself when it is loaded. Strategy names should be globally unique and are added to the GLOBAL_REGISTRY such that duplicates will overwrite the previous registration.

        Warning: A strategy denied with denyStrategy(Class) is not added to the registry. Denial overrides registration, but does not prevent the strategy from being included in the graph or graph computer's cached strategy set.

      • registerStrategy

        public static void registerStrategy​(Class<? extends TraversalStrategy> clazz)
        Registers a strategy by its simple name, but does not cache an instance of it. Choose this method if you don't want the strategy to be included as part of the default strategy set, but do want it available to be looked up by name.

        Warning: A strategy denied with denyStrategy(Class) is not added to the registry. Denial overrides this registration.

      • unregisterStrategy

        public static void unregisterStrategy​(Class<? extends TraversalStrategy> clazz)
        Unregisters a strategy by its simple name. If the strategy is not in the registry then it cannot be referenced by name, which means that it cannot be removed from execution using {GraphTraversalSource.withoutStrategies(Class[])}.

        This operation can be reversed by a later registration. Use denyStrategy(Class) only when a strategy must remain excluded from the registry for the lifetime of this cache.

      • denyStrategy

        public static void denyStrategy​(Class<? extends TraversalStrategy> clazz)
        Unregisters and permanently denies a strategy from being added to the registry. Subsequent calls to registerStrategy(Class) and registerStrategies(Class, TraversalStrategies) do not add the denied strategy to the registry. Denial does not remove the strategy from graph or graph computer strategy sets held in this cache, or otherwise prevent it from being used explicitly.

        Warning: This operation is intended only for graph system providers and deployment operators that must prohibit a strategy from the global registry. The denial cannot be reversed for the lifetime of this cache. Use unregisterStrategy(Class) when the strategy should only be removed from the registry and may be registered again later.

      • getRegisteredStrategyClass

        public static Optional<? extends Class<? extends TraversalStrategy>> getRegisteredStrategyClass​(String strategyName)
        Looks up a strategy by its simple name.
      • getRegisteredStrategyClassByFullName

        public static Optional<? extends Class<? extends TraversalStrategy>> getRegisteredStrategyClassByFullName​(String className)
        Looks up a strategy by the fully qualified class name that a serialized traversal carries, without loading the named class. Serializers use this when they resolve a strategy name that arrived as bytes, so that the only strategies they can construct are those registered in advance by trusted code, by way of registerStrategies(Class, TraversalStrategies) or registerStrategy(Class).

        A name only resolves when it is the Class.getName() of the class registered under its simple name, so an unregistered class that shares a simple name with a registered one does not resolve.