use of lucee.runtime.component.Property in project Lucee by lucee.
the class ComponentImpl method _getProperties.
private static void _getProperties(ComponentImpl c, Map<String, Property> props, boolean onlyPeristent, boolean includeBaseProperties, boolean preferBaseProperties, boolean inheritedMappedSuperClassOnly) {
// collect with filter
if (c.properties.properties != null) {
Property p;
Iterator<Entry<String, Property>> it = c.properties.properties.entrySet().iterator();
while (it.hasNext()) {
p = it.next().getValue();
if (!onlyPeristent || p.isPeristent()) {
if (!preferBaseProperties || !props.containsKey(p.getName().toLowerCase())) {
props.put(p.getName().toLowerCase(), p);
}
}
}
}
// MZ: Moved to the bottom to allow base properties to override inherited versions
if (includeBaseProperties && c.base != null) {
if (!inheritedMappedSuperClassOnly || (c.base.properties.meta != null && Caster.toBooleanValue(c.base.properties.meta.get(KeyConstants._mappedSuperClass, Boolean.FALSE), false))) {
_getProperties(c.base, props, onlyPeristent, includeBaseProperties, preferBaseProperties, inheritedMappedSuperClassOnly);
}
}
}
use of lucee.runtime.component.Property in project Lucee by lucee.
the class XMLConverter method _serializeComponent.
/**
* serialize a Component
* @param component Component to serialize
* @param done
* @return serialized component
* @throws ConverterException
*/
private String _serializeComponent(Component component, Map<Object, String> done) throws ConverterException {
StringBuilder sb = new StringBuilder();
Component ca;
component = new ComponentSpecificAccess(Component.ACCESS_PRIVATE, ca = component);
boolean isPeristent = ca.isPersistent();
deep++;
Object member;
Iterator<Key> it = component.keyIterator();
Collection.Key key;
while (it.hasNext()) {
key = it.next();
member = component.get(key, null);
if (member instanceof UDF)
continue;
sb.append(goIn() + "<var scope=\"this\" name=" + del + key.toString() + del + ">");
sb.append(_serialize(member, done));
sb.append(goIn() + "</var>");
}
Property p;
Boolean remotingFetch;
Struct props = ignoreRemotingFetch ? null : ComponentUtil.getPropertiesAsStruct(ca, false);
ComponentScope scope = ca.getComponentScope();
it = scope.keyIterator();
while (it.hasNext()) {
key = Caster.toKey(it.next(), null);
if (!ignoreRemotingFetch) {
p = (Property) props.get(key, null);
if (p != null) {
remotingFetch = Caster.toBoolean(p.getDynamicAttributes().get(REMOTING_FETCH, null), null);
if (remotingFetch == null) {
if (isPeristent && ORMUtil.isRelated(p))
continue;
} else if (!remotingFetch.booleanValue())
continue;
}
}
member = scope.get(key, null);
if (member instanceof UDF || key.equals(KeyConstants._this))
continue;
sb.append(goIn() + "<var scope=\"variables\" name=" + del + key.toString() + del + ">");
sb.append(_serialize(member, done));
sb.append(goIn() + "</var>");
}
deep--;
try {
// return goIn()+"<struct>"+sb+"</struct>";
return goIn() + "<component md5=\"" + ComponentUtil.md5(component) + "\" name=\"" + component.getAbsName() + "\">" + sb + "</component>";
} catch (Exception e) {
throw toConverterException(e);
}
}
use of lucee.runtime.component.Property in project Lucee by lucee.
the class ComponentUtil method getPropertiesAsStruct.
public static Struct getPropertiesAsStruct(Component c, boolean onlyPersistent) {
Property[] props = c.getProperties(onlyPersistent);
Struct sct = new StructImpl();
if (props != null)
for (int i = 0; i < props.length; i++) {
sct.setEL(KeyImpl.getInstance(props[i].getName()), props[i]);
}
return sct;
}
use of lucee.runtime.component.Property 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.component.Property in project Lucee by lucee.
the class ComponentImpl method initProperties.
private void initProperties() throws PageException {
top.properties.properties = new LinkedHashMap<String, Property>();
// MappedSuperClass
if (isPersistent() && !isBasePeristent() && top.base != null && top.base.properties.properties != null && top.base.properties.meta != null) {
boolean msc = Caster.toBooleanValue(top.base.properties.meta.get(KeyConstants._mappedSuperClass, Boolean.FALSE), false);
if (msc) {
Property p;
Iterator<Entry<String, Property>> it = top.base.properties.properties.entrySet().iterator();
while (it.hasNext()) {
p = it.next().getValue();
if (p.isPeristent()) {
setProperty(p);
}
}
}
}
}
Aggregations