| 1 | <cfscript>
|
|---|
| 2 | //// @ Author Qasim Rasheed (qasimrasheed@gmail.com)
|
|---|
| 3 | // Original idea taken by COldSpring lexicon by Nathan Strutz.
|
|---|
| 4 | // Gets an item from ColdSpring
|
|---|
| 5 | // usage:
|
|---|
| 6 | // 1. add the lexicon declaration to your circuit file:
|
|---|
| 7 | // <circuit xmlns:cs="coldspring/">
|
|---|
| 8 | // 2. use the verb in a fuseaction:
|
|---|
| 9 | // <cs:get bean="GenericCollection" returnvariable="variables.myCollection"/>
|
|---|
| 10 | // <cs:get bean="GenericCollection" returnvariable="variables.myCollection" coldspringfactory="servicefactory"/>
|
|---|
| 11 | // <cs:get beanDefinition="GenericCollection" returnvariable="variables.myBeanDefinition" coldspringfactory="servicefactory"/>
|
|---|
| 12 | //
|
|---|
| 13 | if (fb_.verbInfo.executionMode is "start") {
|
|---|
| 14 | // construct returnvariable
|
|---|
| 15 | if (structKeyExists(fb_.verbInfo.attributes,"returnvariable")) {
|
|---|
| 16 | fb_.returnvariable = fb_.verbInfo.attributes.returnvariable & " = ";
|
|---|
| 17 | } else {
|
|---|
| 18 | fb_.returnvariable = "";
|
|---|
| 19 | }
|
|---|
| 20 |
|
|---|
| 21 | // coldspringfactory is optional:
|
|---|
| 22 | fb_.coldspringfactory = 'servicefactory';
|
|---|
| 23 | if (structKeyExists(fb_.verbInfo.attributes,"coldspringfactory")) {
|
|---|
| 24 | fb_.coldspringfactory = fb_.verbInfo.attributes.coldspringfactory;
|
|---|
| 25 | }
|
|---|
| 26 | //
|
|---|
| 27 |
|
|---|
| 28 | if (structKeyExists(fb_.verbInfo.attributes,"bean")) {
|
|---|
| 29 | fb_appendLine('<cfset #fb_.returnvariable#myFusebox.getApplication().getApplicationData().#fb_.coldspringfactory#.getBean(beanName="#fb_.verbInfo.attributes.bean#")/> ');
|
|---|
| 30 | } else if (structKeyExists(fb_.verbInfo.attributes,"beanDefinition")) {
|
|---|
| 31 | fb_appendLine('<cfset #fb_.returnvariable#myFusebox.getApplication().getApplicationData().#fb_.coldspringfactory#.getBeanDefinition(beanName="#fb_.verbInfo.attributes.bean#")/> ');
|
|---|
| 32 | } else {
|
|---|
| 33 | // bean or beanDefinition is required
|
|---|
| 34 | fb_throw("fusebox.badGrammar.requiredAttributeMissing",
|
|---|
| 35 | "Required attribute is missing",
|
|---|
| 36 | "The attribute 'bean' or 'beanDefinition' is required, for a 'get' verb in fuseaction #fb_.verbInfo.circuit#.#fb_.verbInfo.fuseaction#.");
|
|---|
| 37 | }
|
|---|
| 38 | //
|
|---|
| 39 | } else {
|
|---|
| 40 | //
|
|---|
| 41 | // end mode - do nothing
|
|---|
| 42 | }
|
|---|
| 43 | </cfscript> |
|---|