use of lucee.commons.lang.types.RefBoolean in project Lucee by lucee.
the class CFMLEngineImpl method loadJSPFactory.
private CFMLFactoryImpl loadJSPFactory(ConfigServerImpl configServer, ServletConfig sg, int countExistingContextes) throws ServletException {
try {
if (XMLConfigWebFactory.LOG)
SystemOut.printDate("load Context");
// Load Config
RefBoolean isCustomSetting = new RefBooleanImpl();
Resource configDir = getConfigDirectory(sg, configServer, countExistingContextes, isCustomSetting);
if (XMLConfigWebFactory.LOG)
SystemOut.printDate("got context directory");
CFMLFactoryImpl factory = new CFMLFactoryImpl(this, sg);
if (XMLConfigWebFactory.LOG)
SystemOut.printDate("init factory");
ConfigWebImpl config = XMLConfigWebFactory.newInstance(this, factory, configServer, configDir, isCustomSetting.toBooleanValue(), sg);
if (XMLConfigWebFactory.LOG)
SystemOut.printDate("loaded config");
factory.setConfig(config);
return factory;
} catch (Exception e) {
ServletException se = new ServletException(e.getMessage());
se.setStackTrace(e.getStackTrace());
throw se;
}
}
use of lucee.commons.lang.types.RefBoolean in project Lucee by lucee.
the class PageContextImpl method initApplicationContext.
/**
* @return return value of method "onApplicationStart" or true
* @throws PageException
*/
public boolean initApplicationContext(ApplicationListener listener) throws PageException {
boolean initSession = false;
// AppListenerSupport listener = (AppListenerSupport) config.get ApplicationListener();
KeyLock<String> lock = config.getContextLock();
String name = StringUtil.emptyIfNull(applicationContext.getName());
String token = name + ":" + getCFID();
Lock tokenLock = lock.lock(token, getRequestTimeout());
// print.o("outer-lock :"+token);
try {
// check session before executing any code
initSession = applicationContext.isSetSessionManagement() && listener.hasOnSessionStart(this) && !scopeContext.hasExistingSessionScope(this);
// init application
Lock nameLock = lock.lock(name, getRequestTimeout());
// print.o("inner-lock :"+token);
try {
RefBoolean isNew = new RefBooleanImpl(false);
// this is needed that the application scope is initilized
application = scopeContext.getApplicationScope(this, isNew);
if (isNew.toBooleanValue()) {
try {
if (!listener.onApplicationStart(this)) {
scopeContext.removeApplicationScope(this);
return false;
}
} catch (PageException pe) {
scopeContext.removeApplicationScope(this);
throw pe;
}
}
} finally {
// print.o("inner-unlock:"+token);
lock.unlock(nameLock);
}
// init session
if (initSession) {
// this is needed that the session scope is initilized
scopeContext.getSessionScope(this, DUMMY_BOOL);
listener.onSessionStart(this);
}
} finally {
// print.o("outer-unlock:"+token);
lock.unlock(tokenLock);
}
return true;
}
use of lucee.commons.lang.types.RefBoolean in project Lucee by lucee.
the class CFMLTransformer method attribute.
/**
* Liest ein einzelnes Atribut eines tag ein (nicht NONAME).
* <br />
* EBNF:<br />
* <code>attribute-name spaces "=" spaces attribute-value;</code>
* @param tag Definition des Tag das dieses Attribut enthaelt.
* @param args Container zum Speichern einzelner Attribute Namen zum nachtraeglichen Prufen gegen die Tag-Lib.
* @return Element Attribute Element.
* @throws TemplateException
*/
private static Attribute attribute(TagData data, TagLibTag tag, ArrayList<String> args, RefBoolean allowDefaultValue) throws TemplateException {
Expression value = null;
// Name
StringBuffer sbType = new StringBuffer();
RefBoolean dynamic = new RefBooleanImpl(false);
boolean isDefaultValue = false;
boolean[] parseExpression = new boolean[2];
parseExpression[0] = true;
parseExpression[1] = false;
String name = attributeName(data.srcCode, dynamic, args, tag, sbType, parseExpression, allowDefaultValue.toBooleanValue());
// mixed in a noname attribute
if (StringUtil.isEmpty(name)) {
allowDefaultValue.setValue(false);
TagLibTagAttr attr = tag.getDefaultAttribute();
if (attr == null)
throw new TemplateException(data.srcCode, "Invalid Identifier.");
name = attr.getName();
sbType.append(attr.getType());
isDefaultValue = true;
}
comment(data.srcCode, true);
if (isDefaultValue || data.srcCode.forwardIfCurrent('=')) {
comment(data.srcCode, true);
// Value
value = attributeValue(data, tag, sbType.toString(), parseExpression[0], false, data.factory.createLitString(""));
} else // default value boolean true
{
TagLibTagAttr attr = tag.getAttribute(name);
if (attr != null)
value = attr.getUndefinedValue(data.factory);
else
value = tag.getAttributeUndefinedValue(data.factory);
if (sbType.toString().length() > 0) {
value = CastOther.toExpression(value, sbType.toString());
}
}
comment(data.srcCode, true);
return new Attribute(dynamic.toBooleanValue(), name, value, sbType.toString());
}
use of lucee.commons.lang.types.RefBoolean in project Lucee by lucee.
the class ModernAppListener method _onRequest.
protected void _onRequest(PageContext pc, PageSource requestedPage, PageSource appPS, RequestListener rl) throws PageException {
PageContextImpl pci = (PageContextImpl) pc;
pci.setAppListenerType(ApplicationListener.TYPE_MODERN);
if (appPS != null) {
String callPath = appPS.getComponentName();
Component app = ComponentLoader.loadComponent(pci, appPS, callPath, false, false);
// init
ModernApplicationContext appContext = initApplicationContext(pci, app);
apps.put(appContext.getName(), app);
if (!pci.initApplicationContext(this))
return;
if (rl != null) {
requestedPage = rl.execute(pc, requestedPage);
if (requestedPage == null)
return;
}
String targetPage = requestedPage.getRealpathWithVirtual();
RefBoolean goon = new RefBooleanImpl(true);
// onRequestStart
if (app.contains(pc, ON_REQUEST_START)) {
try {
Object rtn = call(app, pci, ON_REQUEST_START, new Object[] { targetPage }, false);
if (!Caster.toBooleanValue(rtn, true))
return;
} catch (PageException pe) {
pe = handlePageException(pci, app, pe, requestedPage, targetPage, goon);
if (pe != null)
throw pe;
}
}
// onRequest
if (goon.toBooleanValue()) {
boolean isComp = isComponent(pc, requestedPage);
Object method;
if (isComp && app.contains(pc, ON_CFCREQUEST) && (method = pc.urlFormScope().get(KeyConstants._method, null)) != null) {
Struct url = (Struct) Duplicator.duplicate(pc.urlFormScope(), true);
url.removeEL(KeyConstants._fieldnames);
url.removeEL(KeyConstants._method);
Object args = url.get(KeyConstants._argumentCollection, null);
// url returnFormat
Object oReturnFormat = url.removeEL(KeyConstants._returnFormat);
int urlReturnFormat = -1;
if (oReturnFormat != null)
urlReturnFormat = UDFUtil.toReturnFormat(Caster.toString(oReturnFormat, null), -1);
// request header accept
List<MimeType> accept = ReqRspUtil.getAccept(pc);
int headerReturnFormat = MimeType.toFormat(accept, -1, -1);
Object queryFormat = url.removeEL(KeyConstants._queryFormat);
if (args == null) {
args = pc.getHttpServletRequest().getAttribute("argumentCollection");
}
if (args instanceof String) {
args = new JSONExpressionInterpreter().interpret(pc, (String) args);
}
if (args != null) {
if (Decision.isCastableToStruct(args)) {
Struct sct = Caster.toStruct(args, false);
// Key[] keys = url.keys();
Iterator<Entry<Key, Object>> it = url.entryIterator();
Entry<Key, Object> e;
while (it.hasNext()) {
e = it.next();
sct.setEL(e.getKey(), e.getValue());
}
args = sct;
} else if (Decision.isCastableToArray(args)) {
args = Caster.toArray(args);
} else {
Array arr = new ArrayImpl();
arr.appendEL(args);
args = arr;
}
} else
args = url;
Object rtn = call(app, pci, ON_CFCREQUEST, new Object[] { requestedPage.getComponentName(), method, args }, true);
if (rtn != null) {
if (pc.getHttpServletRequest().getHeader("AMF-Forward") != null) {
pc.variablesScope().setEL("AMF-Forward", rtn);
// ThreadLocalWDDXResult.set(rtn);
} else {
try {
ComponentPageImpl.writeToResponseStream(pc, app, method.toString(), urlReturnFormat, headerReturnFormat, queryFormat, rtn);
} catch (Exception e) {
throw Caster.toPageException(e);
}
}
}
} else {
// TODO impl die nicht so generisch ist
try {
if (!isComp && app.contains(pc, ON_REQUEST))
call(app, pci, ON_REQUEST, new Object[] { targetPage }, false);
else
pci._doInclude(new PageSource[] { requestedPage }, false, null);
} catch (PageException pe) {
pe = handlePageException(pci, app, pe, requestedPage, targetPage, goon);
if (pe != null)
throw pe;
}
}
}
// onRequestEnd
if (goon.toBooleanValue() && app.contains(pc, ON_REQUEST_END)) {
try {
call(app, pci, ON_REQUEST_END, new Object[] { targetPage }, false);
} catch (PageException pe) {
pe = handlePageException(pci, app, pe, requestedPage, targetPage, goon);
if (pe != null)
throw pe;
}
}
} else {
apps.put(pc.getApplicationContext().getName(), null);
if (rl != null) {
requestedPage = rl.execute(pc, requestedPage);
if (requestedPage == null)
return;
}
pci._doInclude(new PageSource[] { requestedPage }, false, null);
}
}
use of lucee.commons.lang.types.RefBoolean in project Lucee by lucee.
the class ComponentHandler method setupService.
/**
* handle all the work necessary set
* up the "proxy" RPC service surrounding it as the MessageContext's
* active service.
*/
protected void setupService(MessageContext msgContext) throws Exception {
RefBoolean isnew = new RefBooleanImpl(false);
Component cfc = (Component) msgContext.getProperty(Constants.COMPONENT);
Class clazz = cfc.getJavaAccessClass(ThreadLocalPageContext.get(), isnew, false, true, true, true);
String clazzName = clazz.getName();
ClassLoader classLoader = clazz.getClassLoader();
Pair pair;
SOAPService rpc = null;
if (!isnew.toBooleanValue() && (pair = (Pair) soapServices.get(clazzName)) != null) {
if (classLoader == pair.classloader)
rpc = pair.rpc;
}
// else classLoader = clazz.getClassLoader();
// print.out("cl:"+classLoader);
msgContext.setClassLoader(classLoader);
if (rpc == null) {
rpc = new SOAPService(new RPCProvider());
rpc.setName(clazzName);
rpc.setOption(JavaProvider.OPTION_CLASSNAME, clazzName);
rpc.setEngine(msgContext.getAxisEngine());
rpc.setOption(JavaProvider.OPTION_ALLOWEDMETHODS, "*");
rpc.setOption(JavaProvider.OPTION_SCOPE, Scope.REQUEST.getName());
rpc.getInitializedServiceDesc(msgContext);
soapServices.put(clazzName, new Pair(classLoader, rpc));
}
rpc.setEngine(msgContext.getAxisEngine());
// ??
rpc.init();
msgContext.setService(rpc);
}
Aggregations