Class DefaultComponentLocation

java.lang.Object
org.mule.runtime.dsl.api.component.config.DefaultComponentLocation
All Implemented Interfaces:
Serializable, org.mule.runtime.api.component.location.ComponentLocation

@NoExtend public class DefaultComponentLocation extends Object implements org.mule.runtime.api.component.location.ComponentLocation, Serializable
A component location describes where the component is defined in the configuration of the artifact. For instance:
  • COMPONENT_NAME - global component defined with name COMPONENT_NAME
  • FLOW_NAME/source - a source defined within a flow
  • FLOW_NAME/processors/0 - the first processor defined within a flow with name FLOW_NAME
  • FLOW_NAME/processors/4/1 - the first processors defined inside another processor which is positioned fifth within a flow with name FLOW_NAME
  • FLOW_NAME/errorHandler/0 - the first on-error within the error handler
  • FLOW_NAME/0/errorHandler/3 - the third on-error within the error handler of the first element of the flow with name FLOW_NAME
The different DefaultComponentLocation.DefaultLocationParts in FLOW_NAME/processors/1 are:
  • 'processors' as partPath and no component identifier since this part is synthetic to indicate the part of the flow referenced by the next index
  • '1' as partPath and 'mule:payload' as component identifier assuming that the second processor of the flow was a set-payload component
Since:
4.0
See Also:
  • Field Details

  • Constructor Details

    • DefaultComponentLocation

      public DefaultComponentLocation(Optional<String> name, List<DefaultComponentLocation.DefaultLocationPart> parts)
      Parameters:
      name - the name of the global element in which the specific component is located.
      parts - the set of parts to locate the component.
    • DefaultComponentLocation

      public DefaultComponentLocation(Optional<String> name, List<DefaultComponentLocation.DefaultLocationPart> parts, List<URI> importChain)
      Parameters:
      name - the name of the global element in which the specific component is located.
      parts - the set of parts to locate the component.
      importChain - a List containing an element for the location of every import tag leading to the file containing the owning component.
  • Method Details

    • from

      public static org.mule.runtime.api.component.location.ComponentLocation from(String component)
      Creates a virtual ComponentLocation for a single element, using the core namespace and using UNKNOWN as type. Only meant for situations where a real location cannot be obtained.
      Parameters:
      component - the name of the element
      Returns:
      a location for it
      Since:
      1.4.0
    • fromSingleComponent

      @Deprecated public static DefaultComponentLocation fromSingleComponent(String component)
      Deprecated.
      use from(String) instead.
      Creates a virtual ComponentLocation for a single element, using the core namespace and using UNKNOWN as type. Only meant for situations where a real location cannot be obtained.
      Parameters:
      component - the name of the element
      Returns:
      a location for it
    • getName

      public Optional<String> getName()
    • getParts

      public List<org.mule.runtime.api.component.location.LocationPart> getParts()
      Specified by:
      getParts in interface org.mule.runtime.api.component.location.ComponentLocation
    • getComponentIdentifier

      public org.mule.runtime.api.component.TypedComponentIdentifier getComponentIdentifier()
      Specified by:
      getComponentIdentifier in interface org.mule.runtime.api.component.location.ComponentLocation
    • getFileName

      public Optional<String> getFileName()
      Specified by:
      getFileName in interface org.mule.runtime.api.component.location.ComponentLocation
    • getImportChain

      public List<URI> getImportChain()
      Specified by:
      getImportChain in interface org.mule.runtime.api.component.location.ComponentLocation
    • getLineInFile

      public Optional<Integer> getLineInFile()
      Specified by:
      getLineInFile in interface org.mule.runtime.api.component.location.ComponentLocation
    • getStartColumn

      public Optional<Integer> getStartColumn()
      Specified by:
      getStartColumn in interface org.mule.runtime.api.component.location.ComponentLocation
    • getLine

      public OptionalInt getLine()
      Specified by:
      getLine in interface org.mule.runtime.api.component.location.ComponentLocation
    • getColumn

      public OptionalInt getColumn()
      Specified by:
      getColumn in interface org.mule.runtime.api.component.location.ComponentLocation
    • getLocation

      public String getLocation()
      Specified by:
      getLocation in interface org.mule.runtime.api.component.location.ComponentLocation
      Returns:
      a string representation of the DefaultComponentLocation.
    • getRootContainerName

      public String getRootContainerName()
      Specified by:
      getRootContainerName in interface org.mule.runtime.api.component.location.ComponentLocation
    • appendLocationPart

      public DefaultComponentLocation appendLocationPart(String partPath, Optional<org.mule.runtime.api.component.TypedComponentIdentifier> partIdentifier, Optional<String> fileName, OptionalInt lineInFile, OptionalInt startColumn)
      Creates a new instance of ComponentLocation adding the specified part.
      Parameters:
      partPath - the path of this part
      partIdentifier - the component identifier of the part if it's not a synthetic part
      fileName - the file name in which the component was defined
      lineInFile - the line number in which the component was defined
      startColumn - the column number in which the component was defined
      Returns:
      a new instance with the given location part appended.
      Since:
      1.3
    • appendLocationPart

      @Deprecated public DefaultComponentLocation appendLocationPart(String partPath, Optional<org.mule.runtime.api.component.TypedComponentIdentifier> partIdentifier, Optional<String> fileName, Optional<Integer> lineInFile, Optional<Integer> startColumn)
      Creates a new instance of ComponentLocation adding the specified part.
      Parameters:
      partPath - the path of this part
      partIdentifier - the component identifier of the part if it's not a synthetic part
      Returns:
      a new instance with the given location part appended.
    • appendProcessorsPart

      public DefaultComponentLocation appendProcessorsPart()
      Utility method that adds a processors part to the location. This is the part used for nested processors in configuration components.
      Returns:
      a new instance with the processors location part appended.
    • appendRoutePart

      public DefaultComponentLocation appendRoutePart()
      Utility method that adds a router part to the location. This is the part used for nested processors in configuration components.
      Returns:
      a new instance with the processors location part appended.
    • appendConnectionPart

      public DefaultComponentLocation appendConnectionPart(Optional<org.mule.runtime.api.component.TypedComponentIdentifier> partIdentifier, Optional<String> fileName, OptionalInt lineInFile, OptionalInt startColumn)
      Utility method that adds a connection part to the location. Keep in mind that this method in no way validates that the actual location is a valid one. Clients should add the required logic before calling this method to make sure that the final location corresponds to a correct element.
      Returns:
      a new instance with the connection location part appended.
    • calculateComponentIdentifier

      protected org.mule.runtime.api.component.TypedComponentIdentifier calculateComponentIdentifier(List<DefaultComponentLocation.DefaultLocationPart> parts)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object