ERXFrameworkPrincipal Class Reference

Inherited by Ajax, ERAttachmentPrincipal, BTBusinessLogic, ERCaching, ERCoreBusinessLogic, ERDirectToRest, ERDirectToWeb, ERXExtensions, GCGoogleChart, ERIndexing, ERIUI, ERJavaMail, EROpenID, ERPlot, ERPrototypes, ERSelenium, ERTaggablePrincipal, and ERMoviesLogic.

Collaboration diagram for ERXFrameworkPrincipal:

Collaboration graph
[legend]

List of all members.

Classes

class  Observer

Public Member Functions

void didFinishInitialization ()
 ERXFrameworkPrincipal ()
abstract void finishInitialization ()
static< T extends
ERXFrameworkPrincipal > T 
sharedInstance (Class< T > c)
String toString ()

Static Public Member Functions

static void setUpFrameworkPrincipalClass (Class c)

Protected Member Functions

void initialize ()

Protected Attributes

final Logger log = Logger.getLogger(getClass())

Static Protected Attributes

static final NSMutableDictionary initializedFrameworks = new NSMutableDictionary()
static final NSMutableArray launchingFrameworks = new NSMutableArray()

Static Private Attributes

static Observer observer


Detailed Description

Designated starter class for frameworks, adds support for dependency management.
Allows you to disregard your framework order in the class path (at least where startup is concerned, if you override actual classes you still need to take care.)

The initialize() method will be called directly after your principal is instantiated.
The finishInitialization() method will be called when the app finishes startup but before it will begin to process requests.

If you define

public static Class[] REQUIRES = Class[] {...}
all the classes (which must be assignable from this class) will get loaded before your principal.

NOTE: try to avoid putting code in static initializers. These may lead to unpredictable behaviour when launching. Use one of the methods above to do what you need to do.

Here is an example:


 public class ExampleFrameworkPrincipal extends ERXFrameworkPrincipal {

     public static final Logger log = Logger.getLogger(ExampleFrameworkPrincipal.class);

     protected static ExampleFrameworkPrincipal sharedInstance;

     public final static Class REQUIRES[] = new Class[] {ERXExtensions.class, ERDirectToWeb.class, ERJavaMail.class};

     // Registers the class as the framework principal
     static {
         setUpFrameworkPrincipalClass(ExampleFrameworkPrincipal.class);
     }

     public static ExampleFrameworkPrincipal sharedInstance() {
         if (sharedInstance == null) {
             sharedInstance = (ExampleFrameworkPrincipal)sharedInstance(ExampleFrameworkPrincipal.class);
         }
         return sharedInstance;
     }

     public void initialize() {
         // code during startup
     }

     public void finishInitialization() {
         // Initialized shared data
     }
 }

Constructor & Destructor Documentation


Member Function Documentation

void didFinishInitialization (  ) 

Overridden by subclasses to finalize framework initialization.

Reimplemented in BTBusinessLogic.

abstract void finishInitialization (  )  [pure virtual]

void initialize (  )  [protected]

Called directly after the contructor.

Reimplemented in ERXExtensions.

static void setUpFrameworkPrincipalClass ( Class  c  )  [static]

Sets up a given framework principal class to recieve notification when it is safe for the framework to be initialized.

Parameters:
c principal class

static<T extends ERXFrameworkPrincipal> T sharedInstance ( Class< T >  c  ) 

Gets the shared framework principal instance for a given class.

Parameters:
c principal class for a given framework
Returns:
framework principal initializer

String toString (  ) 


Member Data Documentation

holds the mapping between framework principals classes and ERXFrameworkPrincipal objects

final NSMutableArray launchingFrameworks = new NSMutableArray() [static, protected]

final Logger log = Logger.getLogger(getClass()) [protected]

Observer observer [static, private]


The documentation for this class was generated from the following file:

Generated on Sat May 26 06:43:01 2012 for Project Wonder by  doxygen 1.5.8