"framework principal" pattern

17
“Framework Principal" pattern Philippe Rabier - twitter.com/prabier Sophiacom

Upload: wo-community

Post on 19-May-2015

399 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: "Framework Principal" pattern

“Framework Principal" patternPhilippe Rabier - twitter.com/prabierSophiacom

Page 2: "Framework Principal" pattern

@prabier

Follow me!

Page 3: "Framework Principal" pattern

Why this presentation?

Page 4: "Framework Principal" pattern

• What is a Framework Principal?

• Starter class automatically instantiated, very early

• Used to initialize your stuffs

• Independent from the Application

• @see ERXFrameworkPrincipal

Page 5: "Framework Principal" pattern

What is the goal?

Resource optimization!

Page 6: "Framework Principal" pattern

Feedback from You ’N Push

Page 7: "Framework Principal" pattern

Sandbox environment

1 application

Back Office FTP Server Web Services

Job SchedulerIn-App

Purchase Service

Push Notification

Service

Page 8: "Framework Principal" pattern

Production environment

Back Office FTP Server Web Services

Job SchedulerIn-App

Purchase Service

Push Notification

Service

4 applications

Page 9: "Framework Principal" pattern

How to do that?

Not rocket science!

Page 10: "Framework Principal" pattern

• 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

Page 11: "Framework Principal" pattern

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; }

Page 12: "Framework Principal" pattern

Skeleton of a Properties file

#Launch first servicefirstServiceToLaunch=true

#second service is not runningsecondServiceToLaunch=false

Page 13: "Framework Principal" pattern

WOMonitor configs

The application will look for Properties.production file

The application will look for Properties.sandbox file

Page 14: "Framework Principal" pattern

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, …

Page 15: "Framework Principal" pattern

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, …).

Page 16: "Framework Principal" pattern

@prabier

Follow me!

Page 17: "Framework Principal" pattern

Q&A“Framework Principal" pattern