use of lucee.runtime.listener.ClassicApplicationContext in project Lucee by lucee.
the class Application method doStartTag.
@Override
public int doStartTag() throws PageException {
ApplicationContext ac;
boolean initORM;
if (action == ACTION_CREATE) {
ac = new ClassicApplicationContext(pageContext.getConfig(), name, false, pageContext.getCurrentPageSource().getResourceTranslated(pageContext));
initORM = set(ac, false);
pageContext.setApplicationContext(ac);
} else {
ac = pageContext.getApplicationContext();
initORM = set(ac, true);
}
// scope cascading
if (((UndefinedImpl) pageContext.undefinedScope()).getScopeCascadingType() != ac.getScopeCascading()) {
pageContext.undefinedScope().initialize(pageContext);
}
// ORM
if (initORM)
ORMUtil.resetEngine(pageContext, false);
return SKIP_BODY;
}
use of lucee.runtime.listener.ClassicApplicationContext in project Lucee by lucee.
the class Application method set.
private boolean set(ApplicationContext ac, boolean update) throws PageException {
if (applicationTimeout != null)
ac.setApplicationTimeout(applicationTimeout);
if (sessionTimeout != null)
ac.setSessionTimeout(sessionTimeout);
if (clientTimeout != null)
ac.setClientTimeout(clientTimeout);
if (requestTimeout != null)
ac.setRequestTimeout(requestTimeout);
if (clientstorage != null) {
ac.setClientstorage(clientstorage);
}
if (sessionstorage != null) {
ac.setSessionstorage(sessionstorage);
}
if (customTagMappings != null)
ac.setCustomTagMappings(customTagMappings);
if (componentMappings != null)
ac.setComponentMappings(componentMappings);
if (mappings != null)
ac.setMappings(mappings);
if (loginstorage != Scope.SCOPE_UNDEFINED)
ac.setLoginStorage(loginstorage);
if (!StringUtil.isEmpty(datasource)) {
ac.setDefDataSource(datasource);
ac.setORMDataSource(datasource);
}
if (!StringUtil.isEmpty(defaultdatasource))
ac.setDefDataSource(defaultdatasource);
if (datasources != null) {
try {
ac.setDataSources(AppListenerUtil.toDataSources(pageContext.getConfig(), datasources, pageContext.getConfig().getLog("application")));
} catch (Exception e) {
throw Caster.toPageException(e);
}
}
if (logs != null) {
try {
ApplicationContextSupport acs = (ApplicationContextSupport) ac;
acs.setLoggers(ApplicationContextSupport.initLog(logs));
} catch (Exception e) {
throw Caster.toPageException(e);
}
}
if (mails != null) {
ApplicationContextSupport acs = (ApplicationContextSupport) ac;
try {
acs.setMailServers(AppListenerUtil.toMailServers(pageContext.getConfig(), mails, null));
} catch (Exception e) {
throw Caster.toPageException(e);
}
}
if (caches != null) {
try {
ApplicationContextSupport acs = (ApplicationContextSupport) ac;
Iterator<Entry<Key, Object>> it = caches.entryIterator();
Entry<Key, Object> e;
String name;
Struct sct;
while (it.hasNext()) {
e = it.next();
// default value by name
if (!StringUtil.isEmpty(name = Caster.toString(e.getValue(), null))) {
setDefault(ac, e.getKey(), name);
} else // cache definition
if ((sct = Caster.toStruct(e.getValue(), null)) != null) {
CacheConnection cc = ModernApplicationContext.toCacheConnection(pageContext.getConfig(), e.getKey().getString(), sct);
if (cc != null) {
name = e.getKey().getString();
acs.setCacheConnection(name, cc);
// key is a cache type
setDefault(ac, e.getKey(), name);
// default key
Key def = Caster.toKey(sct.get(KeyConstants._default, null), null);
if (def != null)
setDefault(ac, def, name);
}
}
}
} catch (Exception e) {
throw Caster.toPageException(e);
}
}
if (onmissingtemplate != null && ac instanceof ClassicApplicationContext) {
((ClassicApplicationContext) ac).setOnMissingTemplate(onmissingtemplate);
}
if (scriptrotect != null)
ac.setScriptProtect(AppListenerUtil.translateScriptProtect(scriptrotect));
if (bufferOutput != null)
ac.setBufferOutput(bufferOutput.booleanValue());
if (secureJson != null)
ac.setSecureJson(secureJson.booleanValue());
if (typeChecking != null)
ac.setTypeChecking(typeChecking.booleanValue());
if (suppress != null)
ac.setSuppressContent(suppress.booleanValue());
if (secureJsonPrefix != null)
ac.setSecureJsonPrefix(secureJsonPrefix);
if (setClientCookies != null)
ac.setSetClientCookies(setClientCookies.booleanValue());
if (setClientManagement != null)
ac.setSetClientManagement(setClientManagement.booleanValue());
if (setDomainCookies != null)
ac.setSetDomainCookies(setDomainCookies.booleanValue());
if (setSessionManagement != null)
ac.setSetSessionManagement(setSessionManagement.booleanValue());
if (localMode != -1)
ac.setLocalMode(localMode);
if (mailListener != null)
((ApplicationContextSupport) ac).setMailListener(mailListener);
if (locale != null)
ac.setLocale(locale);
if (timeZone != null)
ac.setTimeZone(timeZone);
if (webCharset != null)
ac.setWebCharset(webCharset.toCharset());
if (resourceCharset != null)
ac.setResourceCharset(resourceCharset.toCharset());
if (sessionType != -1)
ac.setSessionType(sessionType);
if (wsType != -1)
ac.setWSType(wsType);
if (triggerDataMember != null)
ac.setTriggerComponentDataMember(triggerDataMember.booleanValue());
if (compression != null)
ac.setAllowCompression(compression.booleanValue());
if (cacheFunction != null)
ac.setDefaultCacheName(Config.CACHE_TYPE_FUNCTION, cacheFunction);
if (cacheObject != null)
ac.setDefaultCacheName(Config.CACHE_TYPE_OBJECT, cacheObject);
if (cacheQuery != null)
ac.setDefaultCacheName(Config.CACHE_TYPE_QUERY, cacheQuery);
if (cacheResource != null)
ac.setDefaultCacheName(Config.CACHE_TYPE_RESOURCE, cacheResource);
if (cacheTemplate != null)
ac.setDefaultCacheName(Config.CACHE_TYPE_TEMPLATE, cacheTemplate);
if (cacheInclude != null)
ac.setDefaultCacheName(Config.CACHE_TYPE_INCLUDE, cacheInclude);
if (cacheHTTP != null)
ac.setDefaultCacheName(Config.CACHE_TYPE_HTTP, cacheHTTP);
if (cacheFile != null)
ac.setDefaultCacheName(Config.CACHE_TYPE_FILE, cacheFile);
if (cacheWebservice != null)
ac.setDefaultCacheName(Config.CACHE_TYPE_WEBSERVICE, cacheWebservice);
if (antiSamyPolicyResource != null)
((ApplicationContextSupport) ac).setAntiSamyPolicyResource(antiSamyPolicyResource);
if (sessionCookie != null) {
ApplicationContextSupport acs = (ApplicationContextSupport) ac;
acs.setSessionCookie(sessionCookie);
}
if (authCookie != null) {
ApplicationContextSupport acs = (ApplicationContextSupport) ac;
acs.setAuthCookie(authCookie);
}
if (tag != null)
ac.setTagAttributeDefaultValues(pageContext, tag);
ac.setClientCluster(clientCluster);
ac.setSessionCluster(sessionCluster);
ac.setCGIScopeReadonly(cgiReadOnly);
if (s3 != null)
ac.setS3(AppListenerUtil.toS3(s3));
// Scope cascading
if (scopeCascading != -1)
ac.setScopeCascading(scopeCascading);
// ORM
boolean initORM = false;
if (!update) {
if (ormenabled == null)
ormenabled = false;
if (ormsettings == null)
ormsettings = new StructImpl();
}
if (ormenabled != null)
ac.setORMEnabled(ormenabled);
if (ac.isORMEnabled()) {
initORM = true;
if (ormsettings != null)
AppListenerUtil.setORMConfiguration(pageContext, ac, ormsettings);
}
return initORM;
}
Aggregations