SimpleInstanceManager implements the org.apache.tomcat.InstanceManager interface.
| 24 | * SimpleInstanceManager implements the org.apache.tomcat.InstanceManager interface. |
| 25 | */ |
| 26 | public class SimpleInstanceManager implements InstanceManager { |
| 27 | |
| 28 | /** |
| 29 | * Creates a new SimpleInstanceManager. |
| 30 | */ |
| 31 | public SimpleInstanceManager() { |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * {@inheritDoc} |
| 36 | */ |
| 37 | @Override |
| 38 | public Object newInstance(Class<?> clazz) throws IllegalAccessException, InvocationTargetException, NamingException, |
| 39 | InstantiationException, NoSuchMethodException { |
| 40 | return prepareInstance(clazz.getConstructor().newInstance()); |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * {@inheritDoc} |
| 45 | */ |
| 46 | @Override |
| 47 | public Object newInstance(String className) throws IllegalAccessException, InvocationTargetException, |
| 48 | NamingException, InstantiationException, ClassNotFoundException, NoSuchMethodException { |
| 49 | Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(className); |
| 50 | return prepareInstance(clazz.getConstructor().newInstance()); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * {@inheritDoc} |
| 55 | */ |
| 56 | @Override |
| 57 | public Object newInstance(String fqcn, ClassLoader classLoader) |
| 58 | throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException, |
| 59 | ClassNotFoundException, NoSuchMethodException { |
| 60 | Class<?> clazz = classLoader.loadClass(fqcn); |
| 61 | return prepareInstance(clazz.getConstructor().newInstance()); |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * {@inheritDoc} |
| 66 | */ |
| 67 | @Override |
| 68 | public void newInstance(Object o) throws IllegalAccessException, InvocationTargetException, NamingException { |
| 69 | // NO-OP |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * {@inheritDoc} |
| 74 | */ |
| 75 | @Override |
| 76 | public void destroyInstance(Object o) throws IllegalAccessException, InvocationTargetException { |
| 77 | } |
| 78 | |
| 79 | private Object prepareInstance(Object o) { |
| 80 | return o; |
| 81 | } |
| 82 | } |
nothing calls this directly
no outgoing calls
no test coverage detected