Skip to content

Commit

Permalink
Use meaningful variable names, refactor comment to function
Browse files Browse the repository at this point in the history
  • Loading branch information
matthias-ronge committed Jun 17, 2024
1 parent 9a6d2d0 commit 215469c
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions Kitodo/src/main/java/org/kitodo/production/KitodoProduction.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,29 @@ public class KitodoProduction implements ServletContextListener, HttpSessionList
private static final Logger logger = LogManager.getLogger(KitodoProduction.class);
private static CompletableFuture<KitodoProduction> instance = new CompletableFuture<>();
private ServletContext context;
private Optional<Manifest> manifest = Optional.empty();
private Optional<Manifest> manifest;
private KitodoVersion version = new KitodoVersion();
private ActiveMQDirector activeMQDirector;

@Override
public void contextInitialized(ServletContextEvent sce) {
// Retrieve Manifest file as Stream
context = sce.getServletContext();
try (InputStream rs = context.getResourceAsStream("/META-INF/MANIFEST.MF")) {
// Use Manifest to setup version information
if (Objects.nonNull(rs)) {
Manifest m = new Manifest(rs);
manifest = Optional.of(m);
version.setupFromManifest(m);
public void contextInitialized(ServletContextEvent event) {
context = event.getServletContext();
manifest = retrieveManifestFileAsStream(context);
manifest.ifPresent(version::setupFromManifest);
instance.complete(this);
startActiveMQ();
}

private static final Optional<Manifest> retrieveManifestFileAsStream(ServletContext context) {
try (InputStream manifestResource = context.getResourceAsStream("/META-INF/MANIFEST.MF")) {
if (Objects.nonNull(manifestResource)) {
return Optional.of(new Manifest(manifestResource));
}
} catch (IOException e) {
logger.error(e.getMessage(), e);
context.log(e.getMessage());
}
instance.complete(this);
startActiveMQ();
return Optional.empty();
}

/**
Expand Down

0 comments on commit 215469c

Please sign in to comment.