]> git.mxchange.org Git - hub.git/blob - ship-simu/application/hub/starter.php
e10f33a9721eb3adb43f1a25ab54efabc8801f39
[hub.git] / ship-simu / application / hub / starter.php
1 <?php
2 // Is there an application helper instance? We need the method main() for
3 // maining the application
4 $app = ApplicationHelper::getInstance();
5
6 // Some sanity checks
7 if ((empty($app)) || (is_null($app))) {
8         // Something went wrong!
9         ApplicationEntryPoint::app_die(sprintf("[Main:] Die Applikation <strong>%s</strong> kann nicht gestartet werden, da die Hilfsklasse <strong>%s</strong> nicht geladen ist!",
10                 $application,
11                 FrameworkConfiguration::getInstance()->readConfig("app_helper_class")
12         ));
13 } elseif (!is_object($app)) {
14         // No object!
15         ApplicationEntryPoint::app_die(sprintf("[Main:] Die Applikation <strong>%s</strong> kann nicht gestartet werden, da die &#39;app&#39; kein Objekt ist!",
16                 $application
17         ));
18 } elseif (!method_exists($app, FrameworkConfiguration::getInstance()->readConfig("entry_method"))) {
19         // Method not found!
20         ApplicationEntryPoint::app_die(sprintf("[Main:] Die Applikation <strong>%s</strong> kann nicht gestartet werden, da die Methode <strong>%s</strong> fehlt!",
21                 $application,
22                 FrameworkConfiguration::getInstance()->readConfig("entry_method")
23         ));
24 }
25
26 // Call the entry point method
27 try {
28         $eval = sprintf("%s::getInstance()->%s();",
29                 FrameworkConfiguration::getInstance()->readConfig("app_helper_class"),
30                 FrameworkConfiguration::getInstance()->readConfig("entry_method")
31         );
32         eval($eval);
33 } catch (SocketCreationException $e) {
34         // Problems while creating sockets
35         ApplicationEntryPoint::app_die(sprintf("[Main:] Das Hub konnte nicht initialisiert werden. Reason: %s, Code: %s",
36                 $e->getMessage(),
37                 $e->getHexCode()
38         ));
39 } catch (SocketSetupException $e) {
40         // Problems while setting up sockets
41         ApplicationEntryPoint::app_die(sprintf("[Main:] Das Hub konnte nicht initialisiert werden. Reason: %s, Code: %s",
42                 $e->getMessage(),
43                 $e->getHexCode()
44         ));
45 } catch (SocketBindException $e) {
46         // Problems while binding to address/port
47         ApplicationEntryPoint::app_die(sprintf("[Main:] Das Hub konnte nicht initialisiert werden. Reason: %s, Code: %s",
48                 $e->getMessage(),
49                 $e->getHexCode()
50         ));
51 } catch (SocketListeningException $e) {
52         // Problems while starting listen to the socket
53         ApplicationEntryPoint::app_die(sprintf("[Main:] Das Hub konnte nicht initialisiert werden. Reason: %s, Code: %s",
54                 $e->getMessage(),
55                 $e->getHexCode()
56         ));
57 }
58
59 // [EOF]
60 ?>