Created
July 27, 2015 18:31
-
-
Save tgmweb/c12151bc4f68746733d5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
** 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