I have a utility class where I have saved the objects and other and the java classes calls this object. All the variables and methods are static here. I want to know whether it is a good practice or not. And are there any security threats to my application or not.
public class ObjectHolderUtil {
/**
* Object of the main stage of the application
*/
public static Stage mainStage;
public static HibernateSession hibernateSession;
public static String dashboard="/fxml/Dashboard.fxml"; //dashboard fxml file
public static String mainScreen="/fxml/MainScreen.fxml";
public static String addBill="/fxml/AddBill.fxml";
public static StackPane mainStackPane;
public static User user;
public static Helper helper;
public static String getMainScreen() {
return mainScreen;
}
public static void setMainScreen(String mainScreen) {
ObjectHolderUtil.mainScreen = mainScreen;
}
public static Helper getHelper() {
return helper;
}
public static void setHelper(Helper helper) {
ObjectHolderUtil.helper = helper;
}
public static User getUser() {
return user;
}
public static void setUser(User user) {
ObjectHolderUtil.user = user;
}
public static StackPane getMainStackPane() {
return mainStackPane;
}
public static void setMainStackPane(StackPane mainStackPane) {
ObjectHolderUtil.mainStackPane = mainStackPane;
}
public static Stage getMainStage() {
return mainStage;
}
public static void setMainStage(Stage mainStage) {
ObjectHolderUtil.mainStage = mainStage;
}
public static String getDashboard() {
return dashboard;
}
public static void setDashboard(String dashboard) {
ObjectHolderUtil.dashboard = dashboard;
}
public static HibernateSession getHibernateSession() {
return hibernateSession;
}
public static void setHibernateSession(HibernateSession hibernateSession) {
ObjectHolderUtil.hibernateSession = hibernateSession;
}
}
Aucun commentaire:
Enregistrer un commentaire