"framework principal" pattern
TRANSCRIPT
“Framework Principal" patternPhilippe Rabier - twitter.com/prabierSophiacom
@prabier
Follow me!
Why this presentation?
• What is a Framework Principal?
• Starter class automatically instantiated, very early
• Used to initialize your stuffs
• Independent from the Application
• @see ERXFrameworkPrincipal
What is the goal?
Resource optimization!
Feedback from You ’N Push
Sandbox environment
1 application
Back Office FTP Server Web Services
Job SchedulerIn-App
Purchase Service
Push Notification
Service
Production environment
Back Office FTP Server Web Services
Job SchedulerIn-App
Purchase Service
Push Notification
Service
4 applications
How to do that?
Not rocket science!
• Make your FP runnable. Change the build.properties like this: principalClass=ca.wowodc.pascal.util.MyFrameworkPrincipal
• Create an empty Wonder application
• Add the frameworks to the classpath
• Choose a rule for your properties file names like Properties.staging or Properties.production
• Set your properties
• Set the appropriate user name in the WOMonitor configuration
• …et voilà!
The Recipe
Skeleton of a FP public static boolean serviceMustRun()
{ return ERXProperties.booleanForKeyWithDefault("myServiceToLaunch", false); }
public void finishInitialization() { if (serviceMustRun() ) { // your code ... } }
public boolean isServiceRunning() { return a condition; }
Skeleton of a Properties file
#Launch first servicefirstServiceToLaunch=true
#second service is not runningsecondServiceToLaunch=false
WOMonitor configs
The application will look for Properties.production file
The application will look for Properties.sandbox file
2 Strategies
• Only one application
• user name is different for each application
• ex: Properties.scheduler, Properties.backoffice, …
• Several specialized applications
• user name is the same for every app like Properties.production
• applications are different: scheduler.woa, backoffice.woa, …
Do you know?
• ERRest can be configured in a FP (set up the request handler, the routes, …)
• D2W applications could be defined in a FP (the ERXNavigationManager loads all navigationMenu.plist in any frameworks, the rules can be anywhere, …).
@prabier
Follow me!
Q&A“Framework Principal" pattern