Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.39 KB | None | 0 0
  1.     public synchronized <T> T get(Class<T> cls) {
  2.         Object service = this.registry.get( cls.getName() );
  3.         if (cls.isInstance( service )) {
  4.             return (T) service;
  5.         }
  6.         try {
  7.             return (T) Class.forName( service.getClass().getCanonicalName() ).newInstance();
  8.         } catch (Exception e) {
  9.             throw new RuntimeException( e );
  10.         }
  11.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement