use of lucee.runtime.type.ArrayImpl in project Lucee by lucee.
the class SimpleQuery method getMetaDataSimple.
@Override
public synchronized lucee.runtime.type.Array getMetaDataSimple() {
lucee.runtime.type.Array cols = new ArrayImpl();
SimpleQueryColumn sqc;
Struct column;
Iterator<SimpleQueryColumn> it = columns.values().iterator();
while (it.hasNext()) {
sqc = it.next();
column = new StructImpl();
column.setEL(KeyConstants._name, sqc.getKey());
column.setEL("isCaseSensitive", Boolean.FALSE);
column.setEL("typeName", sqc.getTypeAsString());
cols.appendEL(column);
}
return cols;
}
use of lucee.runtime.type.ArrayImpl in project Lucee by lucee.
the class CFMLFactoryImpl method getInfo.
public Array getInfo() {
Array info = new ArrayImpl();
// synchronized (runningPcs) {
// int len=runningPcs.size();
Iterator<PageContextImpl> it = runningPcs.values().iterator();
PageContextImpl pc;
Struct data, sctThread, scopes;
Thread thread;
Entry<Integer, PageContextImpl> e;
ConfigWebImpl cw;
while (it.hasNext()) {
pc = it.next();
cw = (ConfigWebImpl) pc.getConfig();
data = new StructImpl();
sctThread = new StructImpl();
scopes = new StructImpl();
data.setEL("thread", sctThread);
data.setEL("scopes", scopes);
if (pc.isGatewayContext())
continue;
thread = pc.getThread();
if (thread == Thread.currentThread())
continue;
thread = pc.getThread();
if (thread == Thread.currentThread())
continue;
data.setEL("startTime", new DateTimeImpl(pc.getStartTime(), false));
data.setEL("endTime", new DateTimeImpl(pc.getStartTime() + pc.getRequestTimeout(), false));
data.setEL(KeyConstants._timeout, new Double(pc.getRequestTimeout()));
// thread
sctThread.setEL(KeyConstants._name, thread.getName());
sctThread.setEL("priority", Caster.toDouble(thread.getPriority()));
data.setEL("TagContext", PageExceptionImpl.getTagContext(pc.getConfig(), thread.getStackTrace()));
data.setEL("urlToken", pc.getURLToken());
try {
if (pc.getConfig().debug())
data.setEL("debugger", pc.getDebugger().getDebuggingData(pc));
} catch (PageException e2) {
}
try {
data.setEL(KeyConstants._id, Hash.call(pc, pc.getId() + ":" + pc.getStartTime()));
} catch (PageException e1) {
}
data.setEL(KeyConstants._hash, cw.getHash());
data.setEL("contextId", cw.getIdentification().getId());
data.setEL(KeyConstants._label, cw.getLabel());
data.setEL("requestId", pc.getId());
// Scopes
scopes.setEL(KeyConstants._name, pc.getApplicationContext().getName());
try {
scopes.setEL(KeyConstants._application, pc.applicationScope());
} catch (PageException pe) {
}
try {
scopes.setEL(KeyConstants._session, pc.sessionScope());
} catch (PageException pe) {
}
try {
scopes.setEL(KeyConstants._client, pc.clientScope());
} catch (PageException pe) {
}
scopes.setEL(KeyConstants._cookie, pc.cookieScope());
scopes.setEL(KeyConstants._variables, pc.variablesScope());
if (!(pc.localScope() instanceof LocalNotSupportedScope)) {
scopes.setEL(KeyConstants._local, pc.localScope());
scopes.setEL(KeyConstants._arguments, pc.argumentsScope());
}
scopes.setEL(KeyConstants._cgi, pc.cgiScope());
scopes.setEL(KeyConstants._form, pc.formScope());
scopes.setEL(KeyConstants._url, pc.urlScope());
scopes.setEL(KeyConstants._request, pc.requestScope());
info.appendEL(data);
}
return info;
// }
}
use of lucee.runtime.type.ArrayImpl in project Lucee by lucee.
the class ComponentImpl method getMetaData.
protected static Struct getMetaData(int access, PageContext pc, ComponentImpl comp, boolean ignoreCache) throws PageException {
// Cache
final Page page = MetadataUtil.getPageWhenMetaDataStillValid(pc, comp, ignoreCache);
if (page != null && page.metaData != null && page.metaData.get() != null) {
return page.metaData.get();
}
long creationTime = System.currentTimeMillis();
StructImpl sct = new StructImpl();
// fill udfs
metaUDFs(pc, comp, sct, access);
// meta
if (comp.properties.meta != null)
StructUtil.copy(comp.properties.meta, sct, true);
String hint = comp.properties.hint;
String displayname = comp.properties.dspName;
if (!StringUtil.isEmpty(hint))
sct.set(KeyConstants._hint, hint);
if (!StringUtil.isEmpty(displayname))
sct.set(KeyConstants._displayname, displayname);
sct.set(KeyConstants._persistent, comp.properties.persistent);
sct.set(KeyConstants._hashCode, comp.hashCode());
sct.set(KeyConstants._accessors, comp.properties.accessors);
sct.set(KeyConstants._synchronized, comp.properties._synchronized);
if (comp.properties.output != null)
sct.set(KeyConstants._output, comp.properties.output);
// extends
Struct ex = null;
if (comp.base != null)
ex = getMetaData(access, pc, comp.base, true);
if (ex != null)
sct.set(KeyConstants._extends, ex);
// implements
if (comp.absFin != null) {
Set<String> set = ListUtil.listToSet(comp.properties.implement, ",", true);
if (comp.absFin.hasInterfaces()) {
Iterator<InterfaceImpl> it = comp.absFin.getInterfaceIt();
Struct imp = new StructImpl();
InterfaceImpl inter;
while (it.hasNext()) {
inter = it.next();
if (!set.contains(inter.getCallPath()))
continue;
imp.setEL(KeyImpl.init(inter.getCallPath()), inter.getMetaData(pc, true));
}
sct.set(KeyConstants._implements, imp);
}
}
// PageSource
PageSource ps = comp.pageSource;
sct.set(KeyConstants._fullname, ps.getComponentName());
sct.set(KeyConstants._name, ps.getComponentName());
sct.set(KeyConstants._path, ps.getDisplayPath());
sct.set(KeyConstants._type, "component");
int dialect = comp.getPageSource().getDialect();
boolean supressWSBeforeArg = dialect != CFMLEngine.DIALECT_CFML || pc.getConfig().getSuppressWSBeforeArg();
Class<?> skeleton = comp.getJavaAccessClass(pc, new RefBooleanImpl(false), ((ConfigImpl) pc.getConfig()).getExecutionLogEnabled(), false, false, supressWSBeforeArg);
if (skeleton != null)
sct.set(KeyConstants._skeleton, skeleton);
HttpServletRequest req = pc.getHttpServletRequest();
try {
// MUST better impl !!!
String path = ContractPath.call(pc, ps.getDisplayPath());
sct.set("remoteAddress", "" + new URL(req.getScheme(), req.getServerName(), req.getServerPort(), req.getContextPath() + path + "?wsdl"));
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
// Properties
if (comp.properties.properties != null) {
ArrayImpl parr = new ArrayImpl();
Property p;
Iterator<Entry<String, Property>> pit = comp.properties.properties.entrySet().iterator();
while (pit.hasNext()) {
p = pit.next().getValue();
parr.append(p.getMetaData());
}
parr.sortIt(new ArrayOfStructComparator(KeyConstants._name));
sct.set(KeyConstants._properties, parr);
}
if (page != null)
page.metaData = new MetaDataSoftReference<Struct>(sct, creationTime);
return sct;
}
use of lucee.runtime.type.ArrayImpl in project Lucee by lucee.
the class Props method callCFCMetaData.
private void callCFCMetaData(PageContext pc, Component cfc, int format) throws IOException, PageException, ConverterException {
ComponentSpecificAccess cw = new ComponentSpecificAccess(Component.ACCESS_REMOTE, cfc);
ComponentScope scope = cw.getComponentScope();
Struct udfs = new StructImpl(), sctUDF, sctArg;
Array arrArg;
Iterator<Object> it = scope.valueIterator();
Object v;
UDF udf;
FunctionArgument[] args;
while (it.hasNext()) {
v = it.next();
// UDF
if (v instanceof UDF) {
udf = (UDF) v;
sctUDF = new StructImpl();
arrArg = new ArrayImpl();
udfs.setEL(udf.getFunctionName(), sctUDF);
args = udf.getFunctionArguments();
for (int i = 0; i < args.length; i++) {
sctArg = new StructImpl();
arrArg.appendEL(sctArg);
sctArg.setEL(KeyConstants._name, args[i].getName().getString());
sctArg.setEL(KeyConstants._type, args[i].getTypeAsString());
sctArg.setEL(KeyConstants._required, args[i].isRequired());
if (!StringUtil.isEmpty(args[i].getHint()))
sctArg.setEL(KeyConstants._hint, args[i].getHint());
}
sctUDF.set(KeyConstants._arguments, arrArg);
sctUDF.set(KeyConstants._returntype, udf.getReturnTypeAsString());
}
}
Struct rtn = new StructImpl();
rtn.set(KeyConstants._functions, udfs);
rtn.set(ACCEPT_ARG_COLL_FORMATS, "cfml,json");
InputStream is;
Charset cs = null;
// WDDX
if (UDF.RETURN_FORMAT_WDDX == format) {
WDDXConverter converter = new WDDXConverter(pc.getTimeZone(), false, false);
converter.setTimeZone(pc.getTimeZone());
String str = converter.serialize(rtn);
cs = getCharset(pc);
is = new ByteArrayInputStream(str.getBytes(cs));
} else // JSON
if (UDF.RETURN_FORMAT_JSON == format) {
boolean byColumn = false;
cs = getCharset(pc);
JSONConverter converter = new JSONConverter(false, cs);
String str = converter.serialize(pc, rtn, byColumn);
is = new ByteArrayInputStream(str.getBytes(cs));
} else // CFML
if (UDF.RETURN_FORMAT_SERIALIZE == format) {
ScriptConverter converter = new ScriptConverter(false);
String str = converter.serialize(rtn);
cs = getCharset(pc);
is = new ByteArrayInputStream(str.getBytes(cs));
} else // XML
if (UDF.RETURN_FORMAT_XML == format) {
XMLConverter converter = new XMLConverter(pc.getTimeZone(), false);
converter.setTimeZone(pc.getTimeZone());
String str = converter.serialize(rtn);
cs = getCharset(pc);
is = new ByteArrayInputStream(str.getBytes(cs));
} else // Plain
if (UDF.RETURN_FORMAT_PLAIN == format) {
String str = Caster.toString(rtn);
cs = getCharset(pc);
is = new ByteArrayInputStream(str.getBytes(cs));
} else // Java
if (UDF.RETURN_FORMAT_JAVA == format) {
byte[] bytes = JavaConverter.serializeAsBinary(rtn);
is = new ByteArrayInputStream(bytes);
} else
throw new IOException("invalid format defintion:" + format);
OutputStream os = null;
try {
os = pc.getResponseStream();
setFormat(pc.getHttpServletResponse(), format, cs);
IOUtil.copy(is, os, false, false);
} finally {
IOUtil.flushEL(os);
IOUtil.closeEL(os);
((PageContextImpl) pc).getRootOut().setClosed(true);
}
}
use of lucee.runtime.type.ArrayImpl in project Lucee by lucee.
the class WDDXConverter method _deserializeArray.
/**
* Desirialize a Struct Object
*
* @param el
* Struct Object as XML Element
* @return Struct Object
* @throws ConverterException
*/
private Array _deserializeArray(Element el) throws ConverterException {
Array array = new ArrayImpl();
NodeList list = el.getChildNodes();
int len = list.getLength();
for (int i = 0; i < len; i++) {
Node node = list.item(i);
if (node instanceof Element)
try {
array.append(_deserialize((Element) node));
} catch (PageException e) {
throw toConverterException(e);
}
}
return array;
}
Aggregations