“Framework Principal" pattern
Philippe Rabier - twitter.com/prabier
Sophiacom
@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 fromYou ’N Push
Sandbox environment
1 application
Back Office FTP Server Web Services
Job Scheduler
In-App
Purchase
Service
Push
Notification
Service
Production environment
Back Office FTP Server Web Services
Job Scheduler
In-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 service
firstServiceToLaunch=true
#second service is not running
secondServiceToLaunch=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

"Framework Principal" pattern

  • 1.
    “Framework Principal" pattern PhilippeRabier - twitter.com/prabier Sophiacom
  • 2.
  • 3.
  • 4.
    •What is aFramework Principal? • Starter class automatically instantiated, very early • Used to initialize your stuffs • Independent from the Application • @see ERXFrameworkPrincipal
  • 5.
    What is thegoal? Resource optimization!
  • 6.
  • 7.
    Sandbox environment 1 application BackOffice FTP Server Web Services Job Scheduler In-App Purchase Service Push Notification Service
  • 8.
    Production environment Back OfficeFTP Server Web Services Job Scheduler In-App Purchase Service Push Notification Service 4 applications
  • 9.
    How to dothat? Not rocket science!
  • 10.
    • Make yourFP 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
  • 11.
    Skeleton of aFP public static boolean serviceMustRun() { return ERXProperties.booleanForKeyWithDefault("myServiceToLaunch", false); } public void finishInitialization() { if (serviceMustRun() ) { // your code ... } } public boolean isServiceRunning() { return a condition; }
  • 12.
    Skeleton of aProperties file #Launch first service firstServiceToLaunch=true #second service is not running secondServiceToLaunch=false
  • 13.
    WOMonitor configs The applicationwill look for Properties.production file The application will look for Properties.sandbox file
  • 14.
    2 Strategies • Onlyone 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, …
  • 15.
    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, …).
  • 16.
  • 17.