/** * The main method that creates new instances in a separate context. * * @param \AppserverIo\Psr\Application\ApplicationInterface $application The application instance to register the class loader with * @param \AppserverIo\Appserver\Core\Api\Node\ManagerNodeInterface $managerConfiguration The manager configuration * * @return void */ public static function visit(ApplicationInterface $application, ManagerNodeInterface $managerConfiguration) { // initialize the service locator $serviceLocator = new ServiceLocator(); // initialize the stackable for the data, the services and the scheduled timer tasks $data = new StackableStorage(); $services = new StackableStorage(); $tasksToExecute = new GenericStackable(); $scheduledTimers = new GenericStackable(); // initialize the timer factory $timerFactory = new TimerFactory(); $timerFactory->injectApplication($application); $timerFactory->start(); // initialize the calendar timer factory $calendarTimerFactory = new CalendarTimerFactory(); $calendarTimerFactory->injectApplication($application); $calendarTimerFactory->start(); // initialize the executor for the scheduled timer tasks $timerServiceExecutor = new TimerServiceExecutor(); $timerServiceExecutor->injectApplication($application); $timerServiceExecutor->injectTasksToExecute($tasksToExecute); $timerServiceExecutor->injectScheduledTimers($scheduledTimers); $timerServiceExecutor->start(); // initialize the service registry $serviceRegistry = new TimerServiceRegistry(); $serviceRegistry->injectData($data); $serviceRegistry->injectServices($services); $serviceRegistry->injectApplication($application); $serviceRegistry->injectTimerFactory($timerFactory); $serviceRegistry->injectServiceLocator($serviceLocator); $serviceRegistry->injectCalendarTimerFactory($calendarTimerFactory); $serviceRegistry->injectTimerServiceExecutor($timerServiceExecutor); // attach the instance $application->addManager($serviceRegistry, $managerConfiguration); }