...

/

Sever and Client Configuration Properties

Sever and Client Configuration Properties

Show the gRPC server and client configuration properties.

Server configuration properties

Server configuration properties include settings such as the port on which the gRPC server will listen for incoming requests, the path of the destination directory on the server, the security configuration (like SSL certificates), and other server-specific parameters. These properties are necessary for the proper functioning of the gRPC server. To define the server configuration, we will create a file config.properties in the src/main/resources package. For now, we will define two properties to set the destination directory on the server as DESTINATION_DIRECTORY_ON_SERVER and the temporary write path as TEMP_WRITE_PATH. We will add more properties to this file when we enable authentication.

Press + to interact
DESTINATION_DIRECTORY_ON_SERVER=/Users/IdeaProjects/grpc-ftp-project/destOnServer/
TEMP_WRITE_PATH=/Users/IdeaProjects/grpc-ftp-project/destOnServer/tmp

The settings above show that the application is in the directory grpc-ftp-project. We will create a folder destOnServer in that package to store incoming files. The temporary write path points to a tmp folder inside the destOnServer folder.

The paths should be specific to your local application setup.

When the client sends a file, it is first copied to a temporary write path and moved to the destination directory only after the file transfer has been successfully completed.

Loading server configuration

To read the configuration properties, we will create a class named ServerConfiguration in the utils package inside src/main/java/io/datajek/ftpservice in the ftp-serivce project.

The ServerConfiguration class is responsible for reading and providing access to configuration properties related to the server. It contains the logic of reading the config.properties configuration file created above and provides getter methods to access specific configuration values. The class defines two private members as shown:

Press + to interact
public class ServerConfiguration {
private static final Logger logger = LogManager.getLogger(ServerConfiguration.class);
private Properties properties;
}

A line-by-line explanation of the code is as follows:

  1. The class defines a Logger from Log4j named logger. This logger is used for logging error messages or any issues encountered during configuration file reading.

  2. The class has ...