public synchronized void stop()

in winegrower-core/src/main/java/org/apache/winegrower/Ripener.java [537:571]


        public synchronized void stop() {
            runCallbacks(LifecycleCallbacks::beforeStop, this);
            try {
                LOGGER.info("Stopping Apache Winegrower application on {}", LocalDateTime.now());
                final Map<Long, OSGiBundleLifecycle> bundles = registry.getBundles();
                bundles.values().stream()
                        .sorted((o1, o2) -> (int) (o2.getBundle().getBundleId() - o1.getBundle().getBundleId()))
                        .forEach(OSGiBundleLifecycle::stop);
                bundles.clear();
                if (configuration.getWorkDir().exists()) {
                    try {
                        Files.walkFileTree(configuration.getWorkDir().toPath(), new SimpleFileVisitor<Path>() {
                            @Override
                            public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
                                Files.delete(file);
                                return super.visitFile(file, attrs);
                            }

                            @Override
                            public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
                                Files.delete(dir);
                                return super.postVisitDirectory(dir, exc);
                            }
                        });
                    } catch (final IOException e) {
                        LOGGER.warn("Can't delete work directory", e);
                    }
                }
                if (DefaultEventAdmin.class.isInstance(eventAdmin)) {
                    DefaultEventAdmin.class.cast(eventAdmin).close();
                }
            } finally {
                runCallbacks(LifecycleCallbacks::afterStop, this);
            }
        }