icatproject / icat.utils

Setup scripts and a few useful bits of Java code.
Other
0 stars 2 forks source link

getContainer method relies on presence of a file rather than using the provided API #15

Open stuartpullinger opened 2 years ago

stuartpullinger commented 2 years ago

The ContainerGetter.getContainer method returns an enum of either JBoss, Glassfish or UNKNOWN. It does this by checking for the presence of a particular file at a relative path. This file doesn't exist when running Payara inside the standard Payara docker image so the method returns UNKNOWN whereas it is expected to return Glassfish.

Checking for the presence of the file is clearly unreliable so perhaps we could get the container information from an api such as the getServerInfo call eg.

c.getServerInfo().toLowerCase().contains("glassfish") || c.getServerInfo().toLowerCase().contains("payara");

where c is a ServletContext. (Copied from here)

What does @ajkyffin think of this solution?

ajkyffin commented 2 years ago

Determining the application server from the ServletContext would be much better than the current method.