Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. I am doing this within a Factory class' `getInstance()` method, reading the fully-qualified name of a class from a properties file and creating an instance of that class.
  2.  
  3. ```java
  4. static IAuthenticationManager getInstance() throws Exception{
  5. if (instance == null){
  6. instance = new AuthenticationManagerFactory();
  7. }
  8.  
  9. String type = props.getProperty(AUTH_MANAGER_TYPE);
  10. Class<?> c = Class.forName(type);
  11. return (IAuthenticationManager) c.getDeclaredMethod("getInstance").invoke(null);
  12. }
  13. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement