Search in sources :

Example 31 with ClassDefinitionImpl

use of lucee.transformer.library.ClassDefinitionImpl in project Lucee by lucee.

the class XMLConfigAdmin method updateAdminSyncClass.

public void updateAdminSyncClass(ClassDefinition cd) throws PageException {
    if (cd.getClassName() == null)
        cd = new ClassDefinitionImpl(AdminSyncNotSupported.class.getName());
    Element app = _getRootElement("application");
    setClass(app, AdminSync.class, "admin-sync-", cd);
}
Also used : ClassDefinitionImpl(lucee.transformer.library.ClassDefinitionImpl) Element(org.w3c.dom.Element)

Example 32 with ClassDefinitionImpl

use of lucee.transformer.library.ClassDefinitionImpl in project Lucee by lucee.

the class AppListenerUtil method toDataSource.

public static DataSource toDataSource(Config config, String name, Struct data, Log log) throws PageException {
    String user = Caster.toString(data.get(KeyConstants._username, null), null);
    String pass = Caster.toString(data.get(KeyConstants._password, ""), "");
    if (StringUtil.isEmpty(user)) {
        user = null;
        pass = null;
    } else {
        user = user.trim();
        pass = pass.trim();
    }
    // first check for {class:... , connectionString:...}
    Object oConnStr = data.get(CONNECTION_STRING, null);
    if (oConnStr != null) {
        String className = Caster.toString(data.get(KeyConstants._class));
        if ("com.microsoft.jdbc.sqlserver.SQLServerDriver".equals(className)) {
            className = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
        }
        ClassDefinition cd = new ClassDefinitionImpl(className, Caster.toString(data.get(KeyConstants._bundleName, null), null), Caster.toString(data.get(KeyConstants._bundleVersion, null), null), ThreadLocalPageContext.getConfig().getIdentification());
        try {
            return ApplicationDataSource.getInstance(config, name, cd, Caster.toString(oConnStr), user, pass, Caster.toBooleanValue(data.get(BLOB, null), false), Caster.toBooleanValue(data.get(CLOB, null), false), Caster.toIntValue(data.get(CONNECTION_LIMIT, null), -1), Caster.toIntValue(data.get(CONNECTION_TIMEOUT, null), 1), Caster.toLongValue(data.get(META_CACHE_TIMEOUT, null), 60000L), Caster.toTimeZone(data.get(TIMEZONE, null), null), Caster.toIntValue(data.get(ALLOW, null), DataSource.ALLOW_ALL), Caster.toBooleanValue(data.get(STORAGE, null), false), Caster.toBooleanValue(data.get(READ_ONLY, null), false), log);
        } catch (Exception cnfe) {
            throw Caster.toPageException(cnfe);
        }
    }
    // then for {type:... , host:... , ...}
    String type = Caster.toString(data.get(KeyConstants._type));
    DataSourceDefintion dbt = DBUtil.getDataSourceDefintionForType(type, null);
    if (dbt == null)
        throw new ApplicationException("no datasource type [" + type + "] found");
    try {
        return new DataSourceImpl(config, null, name, dbt.classDefinition, Caster.toString(data.get(KeyConstants._host)), dbt.connectionString, Caster.toString(data.get(DATABASE)), Caster.toIntValue(data.get(KeyConstants._port, null), -1), user, pass, Caster.toIntValue(data.get(CONNECTION_LIMIT, null), -1), Caster.toIntValue(data.get(CONNECTION_TIMEOUT, null), 1), Caster.toLongValue(data.get(META_CACHE_TIMEOUT, null), 60000L), Caster.toBooleanValue(data.get(BLOB, null), false), Caster.toBooleanValue(data.get(CLOB, null), false), DataSource.ALLOW_ALL, Caster.toStruct(data.get(KeyConstants._custom, null), null, false), Caster.toBooleanValue(data.get(READ_ONLY, null), false), true, Caster.toBooleanValue(data.get(STORAGE, null), false), Caster.toTimeZone(data.get(TIMEZONE, null), null), "", ParamSyntax.toParamSyntax(data, ParamSyntax.DEFAULT), Caster.toBooleanValue(data.get("literalTimestampWithTSOffset", null), false), Caster.toBooleanValue(data.get("alwaysSetTimeout", null), false), log);
    } catch (Exception cnfe) {
        throw Caster.toPageException(cnfe);
    }
}
Also used : ClassDefinitionImpl(lucee.transformer.library.ClassDefinitionImpl) ApplicationException(lucee.runtime.exp.ApplicationException) DataSourceDefintion(lucee.runtime.db.DBUtil.DataSourceDefintion) DataSourceImpl(lucee.runtime.db.DataSourceImpl) ClassDefinition(lucee.runtime.db.ClassDefinition) PageException(lucee.runtime.exp.PageException) ApplicationException(lucee.runtime.exp.ApplicationException)

Example 33 with ClassDefinitionImpl

use of lucee.transformer.library.ClassDefinitionImpl in project Lucee by lucee.

the class ApplicationContextSupport method toClassDefinition.

public static ClassDefinition toClassDefinition(Struct sct, ClassDefinition defaultValue, boolean isAppender, boolean isLayout) {
    if (sct == null)
        return defaultValue;
    // class
    String className = Caster.toString(sct.get("class", null), null);
    if (StringUtil.isEmpty(className))
        return defaultValue;
    if (isAppender) {
        if ("console".equalsIgnoreCase(className))
            return new ClassDefinitionImpl(ConsoleAppender.class);
        if ("resource".equalsIgnoreCase(className))
            return new ClassDefinitionImpl(RollingResourceAppender.class);
        if ("datasource".equalsIgnoreCase(className))
            return new ClassDefinitionImpl(DatasourceAppender.class);
    } else if (isLayout) {
        if ("classic".equalsIgnoreCase(className))
            return new ClassDefinitionImpl(ClassicLayout.class);
        if ("html".equalsIgnoreCase(className))
            return new ClassDefinitionImpl(HTMLLayout.class);
        if ("xml".equalsIgnoreCase(className))
            return new ClassDefinitionImpl(XMLLayout.class);
        if ("pattern".equalsIgnoreCase(className))
            return new ClassDefinitionImpl(PatternLayout.class);
    }
    // name
    String name = Caster.toString(sct.get("bundlename", null), null);
    if (StringUtil.isEmpty(name))
        name = Caster.toString(sct.get("name", null), null);
    // version
    Version version = OSGiUtil.toVersion(Caster.toString(sct.get("bundleversion", null), null), null);
    if (version == null)
        version = OSGiUtil.toVersion(Caster.toString(sct.get("version", null), null), null);
    if (StringUtil.isEmpty(name))
        return new ClassDefinitionImpl(className);
    return new ClassDefinitionImpl(null, className, name, version);
}
Also used : ConsoleAppender(lucee.commons.io.log.log4j.appender.ConsoleAppender) ClassDefinitionImpl(lucee.transformer.library.ClassDefinitionImpl) RollingResourceAppender(lucee.commons.io.log.log4j.appender.RollingResourceAppender) Version(org.osgi.framework.Version) DatasourceAppender(lucee.commons.io.log.log4j.appender.DatasourceAppender)

Aggregations

ClassDefinitionImpl (lucee.transformer.library.ClassDefinitionImpl)33 ClassDefinition (lucee.runtime.db.ClassDefinition)26 Element (org.w3c.dom.Element)9 ApplicationException (lucee.runtime.exp.ApplicationException)8 PageException (lucee.runtime.exp.PageException)6 IOException (java.io.IOException)5 BundleException (org.osgi.framework.BundleException)5 MalformedURLException (java.net.MalformedURLException)4 lucee.aprint (lucee.aprint)4 ClassException (lucee.commons.lang.ClassException)4 SecurityException (lucee.runtime.exp.SecurityException)4 Struct (lucee.runtime.type.Struct)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 Entry (java.util.Map.Entry)3 DumpWriterEntry (lucee.runtime.dump.DumpWriterEntry)3 ExpressionException (lucee.runtime.exp.ExpressionException)3 GatewayEntry (lucee.runtime.gateway.GatewayEntry)3