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);
}
}
}