I have an application say x which uses another Java library(say Y) as a JAR file . So y basically needs to download a file and load it into memory before any of it's methods are called at runtime by X. How do I make sure that files are downloaded and loaded before any of the methods of y are called ? Also, Y is being used in multiples apps.
Should i use akka pattern here?
y is a Java framework used to detect useragent type. y is going to use a file to detect useragent stuff which needs to be downloaded from s3 and refreshed periodically and only then this library/framework should be used to detect type of useragent from X.
For example:
X is something like :
import com.data.Extract
public class X { public static void main(String[] args) { System.out.println(Extract.getUserAgentInfo(args[0])); } } pom.xml of X(Includes dependency of Y):
<dependency> <groupId>group-y</groupId> <artifactId>extract-data</artifactId> <version>3.8.1</version> <scope>runtime</scope> </dependency> Now before X calls getuseragentinfo, Y should have already loaded files into memory to get data from.
I'm wondering if I can use WatchService or Threading here to run a separate thread to just download the file and load into memory before this jar is being used .i.e. from inside the jar.
Please advise.