| Package: machii_info_sample.plugins |
| Inherits from: MachII.framework.Plugin |
| I do initialization tasks. |
| Method Summary | |
|---|---|
| public void | configure() |
| public void | handleException(EventContext eventContext, Exception exception) |
| public void | postEvent(EventContext eventContext) |
| public void | postProcess(EventContext eventContext) |
| public void | postView(EventContext eventContext) |
| public void | preEvent(EventContext eventContext) |
| public void | preProcess(EventContext eventContext) |
| public void | preView(EventContext eventContext) |
| Method Detail |
|---|
| configure |
|---|
public void configure( )
Parameters:
Code:
<cffunction name="configure" access="public" returntype="void" output="false">
<cfscript>
var pm = getAppManager().getPropertyManager();
// create a user facade and store it in properties
var userFacade = createObject("component","machii_info_sample.model.user.userFacade");
// get some constants from the xml file
var administratorEmail = pm.getProperty("administratorEmail");
var smtp_server = pm.getProperty("smtp_server");
var smtp_username = pm.getProperty("smtp_username");
var smtp_password = pm.getProperty("smtp_password");
var dbType = pm.getProperty("dbType");
var dsn = "";
// if the dsn is passed by url use that value else use the config property value
if (isDefined("url.dsn"))
dsn = url.dsn;
else
dsn = pm.getProperty("dsn");
// create a bean of application constants and store it in properties
variables.appConstants = createObject("component", "machii_info_sample.model.applicationConstantsBean").init(dsn,dbtype,administratorEmail,smtp_server,smtp_username,smtp_password);
pm.setProperty("appConstants", variables.appConstants);
pm.setProperty("userfacade",userFacade);
</cfscript>
</cffunction>
| handleException |
|---|
public void handleException( EventContext eventContext, Exception exception )
Parameters:
| EventContext eventContext |
| Exception exception |
Code:
<cffunction name="handleException" access="public" returntype="void" output="false"> <cfargument name="eventContext" type="MachII.framework.EventContext" required="true" /> <cfargument name="exception" type="MachII.util.Exception" required="true" /> <cfoutput> InitializationPlugin.handleException()<br /></cfoutput> <cfoutput>#arguments.exception.getMessage()#</cfoutput> </cffunction>
| postEvent |
|---|
public void postEvent( EventContext eventContext )
Parameters:
| EventContext eventContext |
Code:
<cffunction name="postEvent" access="public" returntype="void" output="false"> <cfargument name="eventContext" type="MachII.framework.EventContext" required="true" /> <cfoutput> SimplePlugin.postEvent()<br /></cfoutput> </cffunction>
| postProcess |
|---|
public void postProcess( EventContext eventContext )
Parameters:
| EventContext eventContext |
Code:
<cffunction name="postProcess" access="public" returntype="void" output="false"> <cfargument name="eventContext" type="MachII.framework.EventContext" required="true" /> <cfoutput> SimplePlugin.postProcess()<br /></cfoutput> </cffunction>
| postView |
|---|
public void postView( EventContext eventContext )
Parameters:
| EventContext eventContext |
Code:
<cffunction name="postView" access="public" returntype="void" output="false"> <cfargument name="eventContext" type="MachII.framework.EventContext" required="true" /> <cfoutput> SimplePlugin.postView()<br /></cfoutput> </cffunction>
| preEvent |
|---|
public void preEvent( EventContext eventContext )
Parameters:
| EventContext eventContext |
Code:
<cffunction name="preEvent" access="public" returntype="void" output="false">
<cfargument name="eventContext" type="MachII.framework.EventContext" required="true" />
<cfscript>
var event = arguments.eventContext.getCurrentEvent();
var uf = getAppManager().getPropertyManager().getProperty("userfacade");
var user = 0;
// insert the application constants in each event
event.setArg("appConstants",variables.appConstants);
//if the user doesn't have a session create it (using the facade)
if (not uf.hasUser()){
user = createObject("component","machii_info_sample.model.user.user").init();
uf.setUser(user);
}
// set the session user transfer object in the event using the facade
event.setArg("sessionUser", uf.getUser().getUserTO());
</cfscript>
</cffunction>
| preProcess |
|---|
public void preProcess( EventContext eventContext )
Parameters:
| EventContext eventContext |
Code:
<cffunction name="preProcess" access="public" returntype="void" output="false"> <cfargument name="eventContext" type="MachII.framework.EventContext" required="true" /> </cffunction>
| preView |
|---|
public void preView( EventContext eventContext )
Parameters:
| EventContext eventContext |
Code:
<cffunction name="preView" access="public" returntype="void" output="false"> <cfargument name="eventContext" type="MachII.framework.EventContext" required="true" /> <cfoutput> SimplePlugin.preView()<br /></cfoutput> </cffunction>