Search in sources :

Example 1 with Destroy

use of org.apache.karaf.shell.api.action.lifecycle.Destroy in project karaf by apache.

the class ManagerImpl method release.

public void release(Object instance) throws Exception {
    Class<?> clazz = instance.getClass();
    if (!allowCustomServices) {
        Service reg = clazz.getAnnotation(Service.class);
        if (reg == null) {
            throw new IllegalArgumentException("Class " + clazz.getName() + " is not annotated with @Service");
        }
    }
    for (Method method : clazz.getDeclaredMethods()) {
        Destroy ann = method.getAnnotation(Destroy.class);
        if (ann != null && method.getParameterTypes().length == 0 && method.getReturnType() == void.class) {
            method.setAccessible(true);
            method.invoke(instance);
        }
    }
}
Also used : Destroy(org.apache.karaf.shell.api.action.lifecycle.Destroy) Service(org.apache.karaf.shell.api.action.lifecycle.Service) Method(java.lang.reflect.Method)

Aggregations

Method (java.lang.reflect.Method)1 Destroy (org.apache.karaf.shell.api.action.lifecycle.Destroy)1 Service (org.apache.karaf.shell.api.action.lifecycle.Service)1