| 1 | <!----------------------------------------------------------------------- |
|---|
| 2 | ******************************************************************************** |
|---|
| 3 | Copyright 2005-2007 ColdBox Framework by Luis Majano and Ortus Solutions, Corp |
|---|
| 4 | www.coldboxframework.com | www.luismajano.com | www.ortussolutions.com |
|---|
| 5 | ******************************************************************************** |
|---|
| 6 | Author : Luis Majano |
|---|
| 7 | Date : June 30, 2006 |
|---|
| 8 | Description : |
|---|
| 9 | I model a coldfusion datasource connection setting. |
|---|
| 10 | |
|---|
| 11 | Modification History: |
|---|
| 12 | 01/28/2007 - Added the alias property and solved the java contract with correct arg. |
|---|
| 13 | -----------------------------------------------------------------------> |
|---|
| 14 | <cfcomponent name="datasourceBean" |
|---|
| 15 | hint="I model a datasource connection setting." |
|---|
| 16 | output="false"> |
|---|
| 17 | |
|---|
| 18 | <!------------------------------------------- CONSTRUCTOR -------------------------------------------> |
|---|
| 19 | <cfscript> |
|---|
| 20 | variables.instance = structnew(); |
|---|
| 21 | instance.name = ""; |
|---|
| 22 | instance.alias = ""; |
|---|
| 23 | instance.dbtype = ""; |
|---|
| 24 | instance.username = ""; |
|---|
| 25 | instance.password = "" ; |
|---|
| 26 | </cfscript> |
|---|
| 27 | |
|---|
| 28 | <!------------------------------------------- PUBLIC -------------------------------------------> |
|---|
| 29 | |
|---|
| 30 | <!--- ************************************************************* ---> |
|---|
| 31 | |
|---|
| 32 | <cffunction name="init" access="public" output="false" hint="I build a new datasource bean." returntype="coldbox.system.beans.datasourceBean"> |
|---|
| 33 | <!--- ************************************************************* ---> |
|---|
| 34 | <cfargument name="datasourceStruct" type="struct" required="false" default="#structnew()#" hint="The structure holding the name,dbtype,username,and password variables." > |
|---|
| 35 | <!--- ************************************************************* ---> |
|---|
| 36 | <cfif not structisEmpty(arguments.datasourceStruct)> |
|---|
| 37 | <cfset setMemento(arguments.datasourceStruct)> |
|---|
| 38 | </cfif> |
|---|
| 39 | <cfreturn this > |
|---|
| 40 | </cffunction> |
|---|
| 41 | |
|---|
| 42 | <!--- ************************************************************* ---> |
|---|
| 43 | |
|---|
| 44 | <cffunction name="getMemento" access="public" returntype="any" output="false" hint="Get the memento"> |
|---|
| 45 | <cfreturn variables.instance > |
|---|
| 46 | </cffunction> |
|---|
| 47 | |
|---|
| 48 | <!--- ************************************************************* ---> |
|---|
| 49 | |
|---|
| 50 | <cffunction name="setMemento" access="public" returntype="void" output="false" hint="Set the memento"> |
|---|
| 51 | <cfargument name="memento" type="struct" required="true"> |
|---|
| 52 | <cfset variables.instance = arguments.memento> |
|---|
| 53 | </cffunction> |
|---|
| 54 | |
|---|
| 55 | <!--- ************************************************************* ---> |
|---|
| 56 | |
|---|
| 57 | <cffunction name="setname" access="public" return="void" output="false" hint="Set name of the datasource, this maps to the Coldfusion datasource name"> |
|---|
| 58 | <cfargument name="name" type="string" required="true"> |
|---|
| 59 | <cfset instance.name=arguments.name > |
|---|
| 60 | </cffunction> |
|---|
| 61 | |
|---|
| 62 | <!--- ************************************************************* ---> |
|---|
| 63 | |
|---|
| 64 | <cffunction name="getname" access="public" return="string" output="false" hint="Get the name"> |
|---|
| 65 | <cfreturn instance.name > |
|---|
| 66 | </cffunction> |
|---|
| 67 | |
|---|
| 68 | <!--- ************************************************************* ---> |
|---|
| 69 | |
|---|
| 70 | <cffunction name="setalias" access="public" return="void" output="false" hint="Set alias of the datasource, this is used for reference to the structure."> |
|---|
| 71 | <cfargument name="alias" type="string" required="true"> |
|---|
| 72 | <cfset instance.alias=arguments.alias > |
|---|
| 73 | </cffunction> |
|---|
| 74 | |
|---|
| 75 | <!--- ************************************************************* ---> |
|---|
| 76 | |
|---|
| 77 | <cffunction name="getalias" access="public" return="string" output="false" hint="Get the alias"> |
|---|
| 78 | <cfreturn instance.name > |
|---|
| 79 | </cffunction> |
|---|
| 80 | |
|---|
| 81 | <!--- ************************************************************* ---> |
|---|
| 82 | |
|---|
| 83 | <cffunction name="setDBType" access="public" return="void" output="false" hint="Set DBType"> |
|---|
| 84 | <cfargument name="dbtype" type="string" required="true"> |
|---|
| 85 | <cfset instance.dbtype=arguments.dbtype > |
|---|
| 86 | </cffunction> |
|---|
| 87 | |
|---|
| 88 | <!--- ************************************************************* ---> |
|---|
| 89 | |
|---|
| 90 | <cffunction name="getDBType" access="public" return="string" output="false" hint="Get DBType"> |
|---|
| 91 | <cfreturn instance.dbtype > |
|---|
| 92 | </cffunction> |
|---|
| 93 | |
|---|
| 94 | <!--- ************************************************************* ---> |
|---|
| 95 | |
|---|
| 96 | <cffunction name="setUsername" access="public" return="void" output="false" hint="Set Username"> |
|---|
| 97 | <cfargument name="Username" type="string" required="true"> |
|---|
| 98 | <cfset instance.Username=arguments.Username > |
|---|
| 99 | </cffunction> |
|---|
| 100 | |
|---|
| 101 | <!--- ************************************************************* ---> |
|---|
| 102 | |
|---|
| 103 | <cffunction name="getUsername" access="public" return="string" output="false" hint="Get Username"> |
|---|
| 104 | <cfreturn instance.Username > |
|---|
| 105 | </cffunction> |
|---|
| 106 | |
|---|
| 107 | <!--- ************************************************************* ---> |
|---|
| 108 | |
|---|
| 109 | <cffunction name="setPassword" access="public" return="void" output="false" hint="Set Password"> |
|---|
| 110 | <cfargument name="Password" type="string" required="true" > |
|---|
| 111 | <cfset instance.Password=arguments.Password > |
|---|
| 112 | </cffunction> |
|---|
| 113 | |
|---|
| 114 | <!--- ************************************************************* ---> |
|---|
| 115 | |
|---|
| 116 | <cffunction name="getPassword" access="public" return="string" output="false" hint="Get Password"> |
|---|
| 117 | <cfreturn instance.Password > |
|---|
| 118 | </cffunction> |
|---|
| 119 | |
|---|
| 120 | <!--- ************************************************************* ---> |
|---|
| 121 | |
|---|
| 122 | </cfcomponent> |
|---|