Skip to content

Instantly share code, notes, and snippets.

@ahwinemman
Created June 1, 2020 03:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahwinemman/5fb7d0aed2eba63ee484c4812cc1315f to your computer and use it in GitHub Desktop.
Save ahwinemman/5fb7d0aed2eba63ee484c4812cc1315f to your computer and use it in GitHub Desktop.
package com.javaee.injectprops;
import com.javaee.injectprops.annotations.StringProperty;
import javax.annotation.PostConstruct;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.inject.Inject;
import java.util.logging.Logger;
@Singleton
@Startup
public class MainClass {
@Inject
@StringProperty(value = "base_url")
private String baseUrl;
@Inject
@StringProperty(value = "username")
private String username;
@Inject
@StringProperty(value = "password")
private String password;
private static final Logger LOGGER = Logger.getLogger(MainClass.class.getName());
@PostConstruct
public void logPropertyValues() {
LOGGER.info("The value of the baseUrl is : " + baseUrl);
LOGGER.info("The value of the username is : " + username);
LOGGER.info("The value of the password is : " + password);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment