I've created the following class with the main
method, which creates new instance of Application
and instances of ApplicationModel
, ApplicationView
and ApplicationController
for this particular Application
.
public class Application
{
// Variables
private ApplicationSettings settings;
private ApplicationModel model;
private ApplicationView view;
private ApplicationController controller;
// Constructor
public Application()
{
settings = new ApplicationSettings();
model = new ApplicationModel();
view = new ApplicationView(model);
controller = new ApplicationController();
}
// Main method
public static void main(String[] args)
{
Application application = new Application();
}
// Getters for settings, model, view, controller for instance of Application
}
I know, that there will always be only one unique instance of Application
.
And I want to get this particular instance in my ApplicationModel
, ApplicationView
and ApplicationController
classes.
How is it possible?
Application _app
should be static, if it is referenced from static method. Please, correct it, as I'm not sure. :) – Theoretician