Get file Constant from Properties?

Is it possible to get a constant form of java properties file? I am trying to develop my application to set a flag in the basic properties file, which determines whether the application uses a development or production configuration file.

Most applications work fine, but Ive hit a bit of a brick wall with the database table displayed in entity classes. I am using DB Dynamo, so the class itself requires annotations as follows:

@DynamoDBTable(tableName = "table_name")
public class EmailTemplates {
...

The value of tableName should be constant, and I am trying to use the following to extract the value from the properties file and pass it to the table name;

@DynamoDBTable(tableName = DynamoTable.TABLE_NAME)
public class EmailTemplates {
...

DynamoTable Class:

public final class DynamoTable {

    public static final String TABLE_NAME = ResourceBundle.getBundle(ResourceBundle.getBundle("ProjectStage").getString("ProjectStage")).getString("EmailTemplates");

}

, , . (.. "AStringValue" ), , .

NB. , , . , .

+3
2

, .

javac , ( ).

, .

, , (, , ).

+6

DynamoDBMapper , DynamoDBMapperConfig , , , .

, dynamoDB.

private DynamoDBMapperConfig getEnvironmentConfig(DymanoTable tableEntity, String environment)
{
    DynamoDBTable annotation = (DynamoDBTable) tableEntity.getClass().getAnnotation(DynamoDBTable.class);
    DynamoDBMapperConfig.TableNameOverride tableNameOverride = new DynamoDBMapperConfig.TableNameOverride(environment + annotation.tableName());
    return new DynamoDBMapperConfig(tableNameOverride);
}

DymnamoDBMapper...

AWSCredentials credentials = new PropertiesCredentials(
                ObjectPersistenceQueryScanExample.class.getResourceAsStream("AwsCredentials.properties"));

        client = new AmazonDynamoDBClient(credentials);
        DynamoDBMapper mapper = new DynamoDBMapper(client);

dynamoDB

public void save(DynamoTable entity)
{
    mapper.save(entity, getEnvironmentConfig(entity,"dev"));
}
+3

All Articles