Class C2Helper

java.lang.Object
org.refcodes.archetype.C2Helper

public class C2Helper extends Object
The C2Helper provides means to manage launching and connecting to a C2 server.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    Builder to build C2Helper instances.
  • Constructor Summary

    Constructors
    Constructor
    Description
    C2Helper(String aInstanceAlias, Class<?> aResourceLocator, boolean isVerbose, boolean isForce, org.refcodes.logger.RuntimeLogger aLogger)
    Instantiates a new C2 helper.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates builder to build C2Helper.
    void
    deleteLockFile(boolean isVerbose)
    Manually deletes the lockfile in case an orphaned lockfile is in the way.
    Returns the instance alias assigned to this C2Helper instance.
    Gets the lock file name.
    org.refcodes.properties.Properties
    readLockFile(boolean isVerbose)
    Reads the lockfile and returns its content as a Properties instance.
    void
    writeLockFile(org.refcodes.properties.Properties aProperties, boolean isVerbose)
    Writes the lockfile with the content of the provided Properties instance.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • C2Helper

      public C2Helper(String aInstanceAlias, Class<?> aResourceLocator, boolean isVerbose, boolean isForce, org.refcodes.logger.RuntimeLogger aLogger) throws IOException
      Instantiates a new C2 helper.
      Parameters:
      aInstanceAlias - The alias identifying the invoking application's instance.
      aResourceLocator - The application's Class which to use when loading resources (of the according module) by invoking Class.getResourceAsStream(String).
      isVerbose - True to be more verbose.
      isForce - the is force
      aLogger - The application's logger.
      Throws:
      IOException - thrown in I/O problems occurred building the C2Helper.
  • Method Details

    • getLockFileName

      public String getLockFileName()
      Gets the lock file name.
      Returns:
      the lock file name
    • deleteLockFile

      public void deleteLockFile(boolean isVerbose) throws IOException
      Manually deletes the lockfile in case an orphaned lockfile is in the way.
      Parameters:
      isVerbose - Be more verbose.
      Throws:
      IOException - in case there were I/O problems reading the lock file.
    • readLockFile

      public org.refcodes.properties.Properties readLockFile(boolean isVerbose) throws IOException, ParseException
      Reads the lockfile and returns its content as a Properties instance. The properties in the lockfiles are expected to be in TOML notation (as of TomlProperties).
      Parameters:
      isVerbose - Be more verbose.
      Returns:
      The lockfile's Properties.
      Throws:
      IOException - in case there were I/O problems reading the lock file.
      ParseException - thrown in case parsing the lockfile's properties failed.
    • writeLockFile

      public void writeLockFile(org.refcodes.properties.Properties aProperties, boolean isVerbose) throws IOException
      Writes the lockfile with the content of the provided Properties instance. The properties in the lockfiles are being written in TOML notation (as of TomlProperties).
      Parameters:
      aProperties - The lockfile's Properties.
      isVerbose - Be more verbose.
      Throws:
      IOException - in case there were I/O problems reading the file.
    • getInstanceAlias

      public String getInstanceAlias()
      Returns the instance alias assigned to this C2Helper instance.
      Returns:
      the according instance alias.
    • builder

      public static C2Helper.Builder builder()
      Creates builder to build C2Helper.
      Returns:
      created builder