Class Resource

  • Direct Known Subclasses:
    ComponentResource, CustomResource

    @ParametersAreNonnullByDefault
    public abstract class Resource
    extends java.lang.Object
    Resource represents a class whose CRUD operations are implemented by a provider plugin.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Resource​(java.lang.String type, java.lang.String name, boolean custom, ResourceArgs args, ResourceOptions options)  
      protected Resource​(java.lang.String type, java.lang.String name, boolean custom, ResourceArgs args, ResourceOptions options, boolean remote, boolean dependency)
      Creates and registers a new resource object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Set<Resource> getChildResources()
      The child resources of this resource.
      java.lang.String getResourceName()
      The name assigned to the resource at construction.
      java.lang.String getResourceType()
      The type assigned to the resource at construction.
      Output<java.lang.String> getUrn()
      Urn is the stable logical URN used to distinctly address a resource, both before and after deployments.
      protected java.util.Optional<java.util.concurrent.CompletableFuture<Output<java.lang.String>>> idFuture()
      Lazy Initialization method called at the beginning of the constructor.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • childResources

        protected final java.util.Set<Resource> childResources
      • remote

        protected final boolean remote
    • Constructor Detail

      • Resource

        protected Resource​(java.lang.String type,
                           java.lang.String name,
                           boolean custom,
                           ResourceArgs args,
                           ResourceOptions options,
                           boolean remote,
                           boolean dependency)
        Creates and registers a new resource object. The "type" is the fully qualified type token and "name" is the "name" part to of a stable and globally unique URN for the object, "dependsOn" is an optional list of other resources that this resource depends on, controlling the order in which we perform resource operations.
        Parameters:
        type - the type of the resource
        name - the unique name of the resource
        custom - true to indicate that this is a custom resource, managed by a plugin
        args - the arguments to use to populate the new resource
        options - a bag of options that control this resource's behavior
        remote - true if this is a remote component resource
        dependency - true if this is a synthetic resource used internally for dependency tracking
    • Method Detail

      • idFuture

        protected java.util.Optional<java.util.concurrent.CompletableFuture<Output<java.lang.String>>> idFuture()
        Lazy Initialization method called at the beginning of the constructor. Resources with the id field must override this method.
      • getResourceType

        public java.lang.String getResourceType()
        The type assigned to the resource at construction.
      • getResourceName

        public java.lang.String getResourceName()
        The name assigned to the resource at construction.
      • getChildResources

        public java.util.Set<Resource> getChildResources()
        The child resources of this resource. We use these (only from a @see ComponentResource) to allow code to "dependOn" a @see ComponentResource and have that effectively mean that it is depending on all the @see ComponentResource children of that component.

        Important! We only walk through @see ComponentResources. They're the only resources that serve as an aggregation of other primitive (i.e.custom) resources. While a custom resource can be a parent of other resources, we don't want to ever depend on those child resource. If we do, it's simple to end up in a situation where we end up depending on a child resource that has a data cycle dependency due to the data passed into it. This would be pretty nonsensical as there is zero need for a custom resource to ever need to reference the urn of a component resource. So it's acceptable if that sort of pattern failed in practice.

      • getUrn

        public Output<java.lang.String> getUrn()
        Urn is the stable logical URN used to distinctly address a resource, both before and after deployments.