use of lucee.transformer.bytecode.util.ASMPropertyImpl in project Lucee by lucee.
the class Axis1Client method _mapComplex.
private Class _mapComplex(PageContext pc, SymbolTable symbolTable, Config secondChanceConfig, org.apache.axis.encoding.TypeMapping tm, TypeEntry type) throws PageException {
// extension
Class ex = null;
if (type instanceof DefinedType) {
DefinedType dt = (DefinedType) type;
TypeEntry exType = dt.getComplexTypeExtensionBase(symbolTable);
if (exType != null)
ex = map(pc, symbolTable, secondChanceConfig, tm, exType);
}
Vector children = type.getContainedElements();
ArrayList<ASMPropertyImpl> properties = new ArrayList<ASMPropertyImpl>();
if (children != null) {
Iterator it = children.iterator();
ElementDecl el;
Class clazz;
TypeEntry t;
String name;
while (it.hasNext()) {
clazz = null;
el = (ElementDecl) it.next();
t = el.getType();
Vector els = t.getContainedElements();
// again handle children
if (els != null) {
clazz = mapComplex(pc, symbolTable, secondChanceConfig, tm, t);
}
name = lucee.runtime.type.util.ListUtil.last(el.getQName().getLocalPart(), '>');
if (clazz == null)
clazz = tm.getClassForQName(t.getQName());
if (clazz == null)
clazz = Object.class;
properties.add(new ASMPropertyImpl(clazz, name));
}
}
ASMProperty[] props = properties.toArray(new ASMProperty[properties.size()]);
String clientClassName = getClientClassName(type, props);
Class pojo;
if (pc == null)
pojo = ComponentUtil.getComponentPropertiesClass(secondChanceConfig, clientClassName, props, ex);
else
pojo = ComponentUtil.getClientComponentPropertiesClass(pc, clientClassName, props, ex);
TypeMappingUtil.registerBeanTypeMapping(tm, pojo, type.getQName());
return pojo;
}
use of lucee.transformer.bytecode.util.ASMPropertyImpl in project Lucee by lucee.
the class ComponentUtil method _getStructPropertiesClass.
private static Class _getStructPropertiesClass(PageContext pc, Struct sct, PhysicalClassLoader cl) throws PageException, IOException, ClassNotFoundException {
// create hash based on the keys of the struct
String hash = StructUtil.keyHash(sct);
char c = hash.charAt(0);
if (c >= '0' && c <= '9')
hash = "a" + hash;
// create class name (struct class name + hash)
String className = sct.getClass().getName() + "." + hash;
// create physcal location for the file
String real = className.replace('.', '/');
Resource classFile = cl.getDirectory().getRealResource(real.concat(".class"));
// load existing class
if (classFile.exists()) {
try {
Class clazz = cl.loadClass(className);
if (clazz != null)
return clazz;
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
}
// Properties
List<ASMProperty> props = new ArrayList<ASMProperty>();
Iterator<Entry<Key, Object>> it = sct.entryIterator();
Entry<Key, Object> e;
while (it.hasNext()) {
e = it.next();
props.add(new ASMPropertyImpl(ASMUtil.toType(e.getValue() == null ? Object.class : Object.class, /*e.getValue().getClass()*/
true), e.getKey().getString()));
}
// create file
byte[] barr = ASMUtil.createPojo(real, props.toArray(new ASMProperty[props.size()]), Object.class, new Class[] { Pojo.class }, null);
// create class file from bytecode
ResourceUtil.touch(classFile);
IOUtil.copy(new ByteArrayInputStream(barr), classFile, true);
cl = (PhysicalClassLoader) ((PageContextImpl) pc).getRPCClassLoader(true);
return cl.loadClass(className);
}
Aggregations