How to have list of objects accessable to all classes in Java? -
i'm writing plugin server , need create list of players can accessed several classes.
for example, there 3 classes:
events commands plugin the 'events' class have list of players online context (i cannot add together context player). need access list 3 of classes.
i unsure do, because worry class loader messing things.
i've thought of making global variable class static accessor methods players , context (thread safe) , store need in here, people global variables evil in java , should not done.
what should problem?
you create singleton class contains list classes need access, , add together singleton composite fellow member of 3 classes.
the singleton design pattern global variable in sense, in oo-friendly way should work fine , not evil.
java
No comments:
Post a Comment