Search in sources :

Example 1 with MetaDataSoftReference

use of lucee.runtime.component.MetaDataSoftReference 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;
}
Also used : ArrayOfStructComparator(lucee.runtime.type.comparator.ArrayOfStructComparator) ArrayImpl(lucee.runtime.type.ArrayImpl) URL(java.net.URL) Struct(lucee.runtime.type.Struct) HttpServletRequest(javax.servlet.http.HttpServletRequest) StructImpl(lucee.runtime.type.StructImpl) MetaDataSoftReference(lucee.runtime.component.MetaDataSoftReference) RefBooleanImpl(lucee.commons.lang.types.RefBooleanImpl) UDFGSProperty(lucee.runtime.type.UDFGSProperty) Property(lucee.runtime.component.Property)

Aggregations

URL (java.net.URL)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 RefBooleanImpl (lucee.commons.lang.types.RefBooleanImpl)1 MetaDataSoftReference (lucee.runtime.component.MetaDataSoftReference)1 Property (lucee.runtime.component.Property)1 ArrayImpl (lucee.runtime.type.ArrayImpl)1 Struct (lucee.runtime.type.Struct)1 StructImpl (lucee.runtime.type.StructImpl)1 UDFGSProperty (lucee.runtime.type.UDFGSProperty)1 ArrayOfStructComparator (lucee.runtime.type.comparator.ArrayOfStructComparator)1