use of org.jumpmind.extension.IExtensionPoint in project symmetric-ds by JumpMind.
the class ExtensionService method registerExtension.
protected void registerExtension(Extension extension) {
if (extension.getExtensionText() != null) {
if (extension.getExtensionType().equalsIgnoreCase(Extension.EXTENSION_TYPE_JAVA)) {
try {
Object ext = SimpleClassCompiler.getInstance().getCompiledClass(extension.getExtensionText());
registerExtension(extension.getExtensionId(), (IExtensionPoint) ext);
} catch (Exception e) {
log.error("Error while compiling Java extension " + extension.getExtensionId(), e);
}
} else if (extension.getExtensionType().equalsIgnoreCase(Extension.EXTENSION_TYPE_BSH)) {
try {
Interpreter interpreter = new Interpreter();
interpreter.eval(extension.getExtensionText());
Object ext = interpreter.getInterface(Class.forName(extension.getInterfaceName()));
registerExtension(extension.getExtensionId(), (IExtensionPoint) ext);
} catch (EvalError e) {
log.error("Error while parsing BSH extension " + extension.getExtensionId(), e);
} catch (ClassNotFoundException e) {
log.error("Interface class not found for BSH extension " + extension.getExtensionId(), e);
}
} else {
log.error("Skipping extension " + extension.getExtensionId() + ", unknown extension type " + extension.getExtensionType());
}
}
}
use of org.jumpmind.extension.IExtensionPoint in project symmetric-ds by JumpMind.
the class ExtensionService method refresh.
public synchronized void refresh() {
extensionsByClassByName = new HashMap<Class, Map<String, IExtensionPoint>>();
extensionMetaData = new ArrayList<ExtensionPointMetaData>();
for (Class extensionClass : staticExtensionsByClassByName.keySet()) {
Map<String, IExtensionPoint> byNameMap = staticExtensionsByClassByName.get(extensionClass);
for (String name : byNameMap.keySet()) {
IExtensionPoint ext = byNameMap.get(name);
getExtensionsByNameMap(extensionClass).put(name, ext);
addExtensionPointMetaData(ext, name, extensionClass, true);
}
}
String prefix = parameterService.getString(ParameterConstants.RUNTIME_CONFIG_TABLE_PREFIX);
if (platform.getTableFromCache(TableConstants.getTableName(prefix, TableConstants.SYM_EXTENSION), false) != null) {
List<Extension> extensionList = sqlTemplate.query(getSql("selectEnabled"), new ExtensionRowMapper(), parameterService.getNodeGroupId());
log.info("Found {} extension points from the database that will be registered", extensionList.size());
for (Extension extension : extensionList) {
registerExtension(extension);
}
}
}
Aggregations