use of lucee.runtime.exp.PageRuntimeException in project Lucee by lucee.
the class HTTPClient method toDumpData.
@Override
public DumpData toDumpData(PageContext pageContext, int maxlevel, DumpProperties dp) {
try {
Array args;
Struct sct = getMetaData(pageContext), val, a;
DumpTable cfc = new DumpTable("udf", "#66ccff", "#ccffff", "#000000"), udf, arg;
cfc.setTitle("Web Service (HTTP)");
if (dp.getMetainfo())
cfc.setComment(url.toExternalForm());
Iterator<Entry<Key, Object>> it = sct.entryIterator();
Entry<Key, Object> e;
// Loop UDFs
while (it.hasNext()) {
e = it.next();
val = Caster.toStruct(e.getValue());
// udf name
udf = new DumpTable("udf", "#66ccff", "#ccffff", "#000000");
arg = new DumpTable("udf", "#66ccff", "#ccffff", "#000000");
cfc.appendRow(1, new SimpleDumpData(e.getKey().getString()), udf);
// args
args = Caster.toArray(val.get(KeyConstants._arguments));
udf.appendRow(1, new SimpleDumpData("arguments"), arg);
arg.appendRow(7, new SimpleDumpData("name"), new SimpleDumpData("required"), new SimpleDumpData("type"));
Iterator<Object> ait = args.valueIterator();
while (ait.hasNext()) {
a = Caster.toStruct(ait.next());
arg.appendRow(0, new SimpleDumpData(Caster.toString(a.get(KeyConstants._name))), new SimpleDumpData(Caster.toString(a.get(KeyConstants._required))), new SimpleDumpData(Caster.toString(a.get(KeyConstants._type))));
}
// return type
udf.appendRow(1, new SimpleDumpData("return type"), new SimpleDumpData(Caster.toString(val.get(KeyConstants._returntype))));
/*
cfc.appendRow(new DumpRow(0,new DumpData[]{
new SimpleDumpData(arg.getDisplayName()),
new SimpleDumpData(e.getKey().getString()),
new SimpleDumpData(arg.isRequired()),
new SimpleDumpData(arg.getTypeAsString()),
def,
new SimpleDumpData(arg.getHint())}));*/
}
return cfc;
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
throw new PageRuntimeException(Caster.toPageException(t));
}
}
use of lucee.runtime.exp.PageRuntimeException in project Lucee by lucee.
the class JavaProxy method call.
public static Object call(ConfigWeb config, Component cfc, String methodName, Object... arguments) {
boolean unregister = false;
PageContext pc = null;
try {
pc = ThreadLocalPageContext.get();
// create PageContext if necessary
if (pc == null) {
pc = ThreadUtil.createPageContext(config, DevNullOutputStream.DEV_NULL_OUTPUT_STREAM, Constants.NAME, "/", "", null, null, null, null, null, true, -1);
unregister = true;
pc.addPageSource(cfc.getPageSource(), true);
}
return cfc.call(pc, methodName, arguments);
} catch (PageException pe) {
throw new PageRuntimeException(pe);
} finally {
if (unregister)
config.getFactory().releaseLuceePageContext(pc, true);
}
}
use of lucee.runtime.exp.PageRuntimeException in project Lucee by lucee.
the class GatewayEngineImpl method invokeListener.
public boolean invokeListener(String gatewayId, String method, Map data) {
// do not add this method to loade, it can be removed with Lucee 5
data = GatewayUtil.toCFML(data);
GatewayEntry entry;
try {
entry = getGatewayEntry(gatewayId);
} catch (PageException pe) {
throw new PageRuntimeException(pe);
}
String cfcPath = entry.getListenerCfcPath();
if (!StringUtil.isEmpty(cfcPath, true)) {
try {
if (!callOneWay(cfcPath, gatewayId, method, Caster.toStruct(data, null, false), false))
log(gatewayId, LOGLEVEL_ERROR, "function [" + method + "] does not exist in cfc [" + cfcPath + "]");
else
return true;
} catch (PageException e) {
log(gatewayId, LOGLEVEL_ERROR, e.getMessage(), e);
}
} else
log(gatewayId, LOGLEVEL_ERROR, "there is no listener cfc defined");
return false;
}
use of lucee.runtime.exp.PageRuntimeException in project Lucee by lucee.
the class InstrumentationFactory method getInstrumentation.
public static synchronized Instrumentation getInstrumentation(final Config config) {
final Log log = config.getLog("application");
final CFMLEngine engine = ConfigWebUtil.getEngine(config);
Instrumentation instr = _getInstrumentation(log, config);
// agent already exist
if (instr != null)
return instr;
AccessController.doPrivileged(new PrivilegedAction<Object>() {
@Override
public Object run() {
ClassLoader ccl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());
try {
JavaVendor vendor = JavaVendor.getCurrentVendor();
Resource toolsJar = null;
// When running on IBM, the attach api classes are packaged in vm.jar which is a part
// of the default vm classpath.
RefBoolean useOurOwn = new RefBooleanImpl(true);
// if (!vendor.isIBM()) {
// If we can't find the tools.jar and we're not on IBM we can't load the agent.
toolsJar = findToolsJar(config, log, useOurOwn);
if (toolsJar == null) {
return null;
}
// }
log.info("Instrumentation", "tools.jar used:" + toolsJar);
// add the attach native library
if (useOurOwn.toBooleanValue())
addAttachIfNecessary(config, log);
Class<?> vmClass = loadVMClass(toolsJar, log, vendor);
log.info("Instrumentation", "loaded VirtualMachine class:" + (vmClass == null ? "null" : vmClass.getName()));
if (vmClass == null) {
return null;
}
String agentPath = createAgentJar(log, config).getAbsolutePath();
if (agentPath == null) {
return null;
}
log.info("Instrumentation", "try to load agent (path:" + agentPath + ")");
loadAgent(config, log, agentPath, vmClass);
// log.info("Instrumentation","agent loaded (path:"+agentPath+")");
} catch (IOException ioe) {
log.log(Log.LEVEL_INFO, "Instrumentation", ioe);
} finally {
Thread.currentThread().setContextClassLoader(ccl);
}
return null;
}
});
// If the load(...) agent call was successful, this variable will no
// longer be null.
instr = _getInstrumentation(log, config);
if (instr == null) {
try {
Resource agentJar = createAgentJar(log, config);
throw new PageRuntimeException(new ApplicationException(Constants.NAME + " was not able to load a Agent dynamically! " + "You need to load one manually by adding the following to your JVM arguments [-javaagent:\"" + (agentJar) + "\"]"));
} catch (IOException ioe) {
SystemOut.printDate(ioe);
}
}
return instr;
}
use of lucee.runtime.exp.PageRuntimeException in project Lucee by lucee.
the class DatasourceResourceProvider method getOutputStream.
public synchronized OutputStream getOutputStream(ConnectionData data, int fullPathHash, int pathHash, String path, String name, boolean append) throws IOException {
Attr attr = getAttr(data, fullPathHash, path, name);
if (attr.getId() == 0) {
create(data, fullPathHash, pathHash, path, name, Attr.TYPE_FILE);
attr = getAttr(data, fullPathHash, path, name);
}
PipedInputStream pis = new PipedInputStream();
PipedOutputStream pos = new PipedOutputStream();
pis.connect(pos);
DatasourceConnection dc = null;
// Connection c=null;
try {
dc = getDatasourceConnection(data);
// Connection c = dc.getConnection();
DataWriter writer = new DataWriter(getCore(data), dc, data.getPrefix(), attr, pis, this, append);
writer.start();
return new DatasourceResourceOutputStream(writer, pos);
// core.getOutputStream(dc, name, attr, pis);
} catch (PageException e) {
throw new PageRuntimeException(e);
} finally {
removeFromCache(data, path, name);
// manager.releaseConnection(CONNECTION_ID,dc);
}
}
Aggregations