initial: Lucee CRUD — table name from json_env (TABLE_NAME)
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<cfcomponent displayname="Application" output="true">
|
||||
|
||||
<cfset this.Name = "tfluceecrud" />
|
||||
<cfset this.applicationTimeout = createTimeSpan(0, 0, 3, 0) />
|
||||
<cfset this.sessionmanagement = "Yes" />
|
||||
<cfset this.sessiontimeout = CreateTimeSpan(0, 0, 120, 0) />
|
||||
|
||||
<cfset this.datasource = "testds" />
|
||||
<cfset getDS(this.datasource, this.datasource) />
|
||||
|
||||
<cfsetting requesttimeout="20" showdebugoutput="false" />
|
||||
|
||||
<cffunction name="OnApplicationStart" access="public" returntype="boolean">
|
||||
<cfreturn true />
|
||||
</cffunction>
|
||||
|
||||
<cffunction name="OnRequestStart" access="public" returntype="boolean">
|
||||
<cfset request.tableName = createObject("java", "java.lang.System").getEnv().get("TABLE_NAME") />
|
||||
<cfif NOT isDefined("request.tableName") OR NOT len(request.tableName)>
|
||||
<cfset request.tableName = "check_point" />
|
||||
</cfif>
|
||||
<cfreturn true />
|
||||
</cffunction>
|
||||
|
||||
<cffunction name="OnRequest" access="public" returntype="void">
|
||||
<cfargument name="template" type="string" required="true" />
|
||||
|
||||
<cfset setEncoding("FORM", "UTF-8") />
|
||||
<cfset setEncoding("URL", "UTF-8") />
|
||||
|
||||
<cfset local.basePath = getDirectoryFromPath(getCurrentTemplatePath()) />
|
||||
<cfset request.webRoot = "../" />
|
||||
<cfset request.thisPage = Replace(ReplaceNoCase(expandPath(arguments.template), local.basePath, ""), "\", "/") />
|
||||
|
||||
<cfinclude template="#arguments.template#" />
|
||||
</cffunction>
|
||||
|
||||
<cffunction name="getDS" access="private" returntype="void">
|
||||
<cfargument name="dsname" type="string" required="true" />
|
||||
<cfargument name="prefix" type="string" default="#dsname#" />
|
||||
|
||||
<cfset system = createObject("java", "java.lang.System") />
|
||||
<cfset var ds = {} />
|
||||
|
||||
<cfloop list="class,connectionString,username,password,bundleName,bundleVersion,connectionLimit,liveTimeout,validate" item="field">
|
||||
<cfset var value = system.getEnv("#arguments.prefix#_#field#") />
|
||||
<cfif isDefined("value") AND len(value)>
|
||||
<cfset structInsert(ds, field, value) />
|
||||
</cfif>
|
||||
</cfloop>
|
||||
|
||||
<cfset THIS.datasources[dsname] = ds />
|
||||
</cffunction>
|
||||
|
||||
</cfcomponent>
|
||||
Reference in New Issue
Block a user