Server and Client Constants
Define the server and client constants to store important values.
We'll cover the following...
Constants are used to store information that does not change throughout the application’s lifecycle. We can define values or parameters related to the configuration and behavior of the server component of our application. Instead of scattering these constants throughout the codebase, they are centralized within a utility class.
Defining server constants
In the src/main/java/io/datajek/ftpservice/utils
package, we will create a utility class named ServerConstants
. This class will hold all constants used by the server. The class is shown below:
public class ServerConstants {private ServerConstants() {}static public final String DESTINATION_DIRECTORY_ON_SERVER = "DESTINATION_DIRECTORY_ON_SERVER";static public final int INSECURE_MODE_PORT = 17373;static public final String TEMP_WRITE_PATH = "TEMP_WRITE_PATH";static public final String LOCALHOST = "localhost";}
The constructor for this class in line 3 is private
to prevent instantiation because it only contains static
members.
The class defines several constant fields that represent configuration keys or values used in the server implementation. ...