Changeset 376
- Timestamp:
- 01/28/07 19:53:48 (6 years ago)
- Location:
- coldbox/trunk/src/system
- Files:
-
- 4 modified
-
beans/datasourceBean.cfc (modified) (6 diffs)
-
config/config.xsd (modified) (2 diffs)
-
plugins/XMLParser.cfc (modified) (2 diffs)
-
util/actioncontroller.cfc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
coldbox/trunk/src/system/beans/datasourceBean.cfc
r362 r376 9 9 10 10 Modification History: 11 11 01/28/2007 - Added the alias property and solved the java contract with correct arg. 12 12 -----------------------------------------------------------------------> 13 13 <cfcomponent name="datasourceBean" hint="I model a datasource connection setting." output="false"> … … 17 17 variables.instance = structnew(); 18 18 variables.instance.name = ""; 19 variables.instance.alias = ""; 19 20 variables.instance.dbtype = ""; 20 21 variables.instance.username = ""; … … 52 53 53 54 <cffunction name="setname" access="public" return="void" output="false" hint="Set name of the datasource, this maps to the Coldfusion datasource name"> 54 <cfargument name=" value" type="string">55 <cfset variables.instance.name=arguments. value >55 <cfargument name="name" type="string" required="true"> 56 <cfset variables.instance.name=arguments.name > 56 57 </cffunction> 57 58 … … 64 65 <!--- ************************************************************* ---> 65 66 67 <cffunction name="setalias" access="public" return="void" output="false" hint="Set alias of the datasource, this is used for reference to the structure."> 68 <cfargument name="alias" type="string" required="true"> 69 <cfset variables.instance.alias=arguments.alias > 70 </cffunction> 71 72 <!--- ************************************************************* ---> 73 74 <cffunction name="getalias" access="public" return="string" output="false" hint="Get the alias"> 75 <cfreturn variables.instance.name > 76 </cffunction> 77 78 <!--- ************************************************************* ---> 79 66 80 <cffunction name="setDBType" access="public" return="void" output="false" hint="Set DBType"> 67 <cfargument name=" value" type="string">68 <cfset variables.instance.dbtype=arguments. value >81 <cfargument name="dbtype" type="string" required="true"> 82 <cfset variables.instance.dbtype=arguments.dbtype > 69 83 </cffunction> 70 84 … … 78 92 79 93 <cffunction name="setUsername" access="public" return="void" output="false" hint="Set Username"> 80 <cfargument name=" value" type="string">81 <cfset variables.instance.Username=arguments. value >94 <cfargument name="Username" type="string" required="true"> 95 <cfset variables.instance.Username=arguments.Username > 82 96 </cffunction> 83 97 … … 91 105 92 106 <cffunction name="setPassword" access="public" return="void" output="false" hint="Set Password"> 93 <cfargument name=" value" type="string" >94 <cfset variables.instance.Password=arguments. value>107 <cfargument name="Password" type="string" required="true" > 108 <cfset variables.instance.Password=arguments.Password > 95 109 </cffunction> 96 110 -
coldbox/trunk/src/system/config/config.xsd
r371 r376 58 58 <xs:enumeration value="onInvalidEvent"/> 59 59 <xs:enumeration value="HandlerCaching" /> 60 <xs:enumeration value="IOCFramework" /> 61 <xs:enumeration value="IOCDefinitionFile" /> 60 62 </xs:restriction> 61 63 </xs:simpleType> … … 294 296 </xs:annotation> 295 297 <xs:complexType> 298 <xs:attribute name="alias" type="xs:string" use="required"> 299 <xs:annotation> 300 <xs:documentation>The alias of the registered datasource, for use in your application.</xs:documentation> 301 </xs:annotation> 302 </xs:attribute> 296 303 <xs:attribute name="name" type="xs:string" use="required"> 297 304 <xs:annotation> -
coldbox/trunk/src/system/plugins/XMLParser.cfc
r371 r376 29 29 01/17/2007 - fixed Bug #83, failure to set handler invocation path if / as first char 30 30 01/18/2007 - Preparing for new event registration system. 31 01/26/2007 - Datasource Alias and error checking Ticket #88, #89 31 32 -----------------------------------------------------------------------> 32 33 <cfcomponent name="XMLParser" … … 440 441 for(i=1;i lte ArrayLen(DatasourcesNodes); i=i+1){ 441 442 DSNStruct = structNew(); 442 StructInsert(DSNStruct,"Name", Trim(DatasourcesNodes[i].XMLAttributes["name"])); 443 StructInsert(DSNStruct,"DBType", Trim(DatasourcesNodes[i].XMLAttributes["dbtype"])); 444 StructInsert(DSNStruct,"Username", Trim(DatasourcesNodes[i].XMLAttributes["username"])); 445 StructInsert(DSNStruct,"Password", Trim(DatasourcesNodes[i].XMLAttributes["password"])); 443 444 //Required Entries 445 if ( not structKeyExists(DatasourcesNodes[i].XMLAttributes, "Alias") or len(Trim(DatasourcesNodes[i].XMLAttributes["Alias"])) eq 0 ) 446 throw("This datasource entry's alias cannot be blank","","Framework.plugins.XMLParser.ConfigXMLParsingException"); 447 else 448 StructInsert(DSNStruct,"Alias", Trim(DatasourcesNodes[i].XMLAttributes["Alias"])); 449 if ( not structKeyExists(DatasourcesNodes[i].XMLAttributes, "Name") or len(Trim(DatasourcesNodes[i].XMLAttributes["Name"])) eq 0 ) 450 throw("This datasource entry's name cannot be blank","","Framework.plugins.XMLParser.ConfigXMLParsingException"); 451 else 452 StructInsert(DSNStruct,"Name", Trim(DatasourcesNodes[i].XMLAttributes["Name"])); 453 454 //Optional Entries. 455 if ( structKeyExists(DatasourcesNodes[i].XMLAttributes, "dbtype") ) 456 StructInsert(DSNStruct,"DBType", Trim(DatasourcesNodes[i].XMLAttributes["dbtype"])); 457 else 458 StructInsert(DSNStruct,"DBType",""); 459 if ( structKeyExists(DatasourcesNodes[i].XMLAttributes, "Username") ) 460 StructInsert(DSNStruct,"Username", Trim(DatasourcesNodes[i].XMLAttributes["username"])); 461 else 462 StructInsert(DSNStruct,"Username",""); 463 if ( structKeyExists(DatasourcesNodes[i].XMLAttributes, "password") ) 464 StructInsert(DSNStruct,"Password", Trim(DatasourcesNodes[i].XMLAttributes["password"])); 465 else 466 StructInsert(DSNStruct,"Password",""); 467 446 468 //Insert to structure 447 if ( not structKeyExists(DatasourcesStruct,DSNStruct. name) )448 StructInsert(DatasourcesStruct, DSNStruct. name, DSNStruct);449 else 450 throw("The datasource name: #dsnStruct.name# has already been declared.","","Framework.plugins.XMLParser.ConfigXMLParsingException");469 if ( not structKeyExists(DatasourcesStruct,DSNStruct.Alias) ) 470 StructInsert(DatasourcesStruct, DSNStruct.Alias , DSNStruct); 471 else 472 throw("The datasource alias: #dsnStruct.Alias# has already been declared.","","Framework.plugins.XMLParser.ConfigXMLParsingException"); 451 473 } 452 474 } -
coldbox/trunk/src/system/util/actioncontroller.cfc
r373 r376 16 16 10/10/2006 - Mail settings updated. 17 17 12/08/2006 - Refactored. 18 01/28/2006 - Datasource Alias resolved. 18 19 -----------------------------------------------------------------------> 19 20 <cfcomponent name="actioncontroller" hint="This is the action controller cfc. Method implementations are done here for sharing between plugin and event handler controllers." output="false" extends="coldbox.system.controller"> … … 168 169 <cffunction name="getDatasource" access="public" output="false" returnType="any" hint="I will return to you a datasourceBean according to the name of the datasource you wish to get from the configstruct (config.xml)"> 169 170 <!--- ************************************************************* ---> 170 <cfargument name=" name" type="string" hint="The name of the datasource to get from the configstruct (nameproperty in the config.xml)">171 <cfargument name="alias" type="string" hint="The alias of the datasource to get from the configstruct (alias property in the config.xml)"> 171 172 <!--- ************************************************************* ---> 172 173 <cfscript> … … 177 178 } 178 179 //Try to get the correct datasource. 179 if ( structKeyExists(datasources, arguments. name) ){180 return getPlugin("beanFactory").create("coldbox.system.beans.datasourceBean").init(datasources[arguments. name]);180 if ( structKeyExists(datasources, arguments.alias) ){ 181 return getPlugin("beanFactory").create("coldbox.system.beans.datasourceBean").init(datasources[arguments.alias]); 181 182 } 182 183 else{ 183 throw("The datasource: #arguments. name# is not defined.","","Framework.actioncontroller.DatasourceNotFoundException");184 throw("The datasource: #arguments.alias# is not defined.","","Framework.actioncontroller.DatasourceNotFoundException"); 184 185 } 185 186 </cfscript>
