Skip to content

Instantly share code, notes, and snippets.

@aarongreenlee
Created August 27, 2011 00:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aarongreenlee/1174783 to your computer and use it in GitHub Desktop.
Save aarongreenlee/1174783 to your computer and use it in GitHub Desktop.
ColdBox Environment Detection Interceptor that ensures proper environment
/** Ensure the proper environment regardless of domain used to construct the app **/
component {
// PUBLIC METHODS ---------------------------------------------------------------
public void function configure(){
// You don't have to put this in the application scope.
// I just like to keep it there.
application.machine
= createObject('java','java.net.InetAddress').getLocalHost().getHostName();
switch(application.machine)
{
case 'somemachine' :
local.env = "workstation"
break;
case 'some_other_machine' :
local.env = "dev"
break;
case 'machine_name_45' :
local.env = "CIServer"
break;
case 'machine_name_x' :
default:
local.env = "production"
break;
}
variables.Controller.SetSetting('Environment',local.env);
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment