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);
}
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);
}
}
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);
}
Aggregations