Skip to content

Instantly share code, notes, and snippets.

@tgmweb
Created July 27, 2015 18:31
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 tgmweb/c12151bc4f68746733d5 to your computer and use it in GitHub Desktop.
Save tgmweb/c12151bc4f68746733d5 to your computer and use it in GitHub Desktop.
/*
** SearchService.cfc
*/
component {
public string function getSearchResults(string query) {
return "I just searched for #arguments.query#";
}
}
/*
** SearchServiceCustom.cfc
** initially not mapped anywhere...
*/
component {
// inject a third party search widget
property name="javaSearchService" inject="java:searchObjectThingyForExample";
public string function getSearchResults(string query) {
return javaSearchService.search(query);
}
}
/*
** WireboxConfig
*/
map("search.SearchService").to("models.SearchService").asSingleton();
/*
** handler
*/
component {
property name="search" inject="search.SearchService";
public void function doSearch() {
event.renderData(data=search.getSearchResults(rc.query),type="text";
}
}
/*
** Now Iwant to map map("search.SearchService") to a different service.
** so in an interceptor I have....
*/
component {
function afterConfigurationLoad() {
wirebox.getBinder().map("search.SearchService").to("models.SearchServiceCustom").asSingleton();
}
}
// but when I then hit my handler, and it executes the new search service, I get:
// variable "javaSearchService" does not exist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment