Search in sources :

Example 1 with AbstractVersion

use of com.dexels.navajo.version.AbstractVersion in project navajo by Dexels.

the class GetVersionInfo method evaluate.

@Override
public final Object evaluate() throws TMLExpressionException {
    Object o = getOperand(0);
    String packageName = o + "";
    try {
        Class<?> c = null;
        if (DispatcherFactory.getInstance().getNavajoConfig().getClassloader() == null) {
            c = Class.forName(packageName + ".Version");
        } else {
            c = Class.forName(packageName + ".Version", true, DispatcherFactory.getInstance().getNavajoConfig().getClassloader());
        }
        AbstractVersion v = (AbstractVersion) c.getDeclaredConstructor().newInstance();
        return v.toString();
    } catch (Exception e) {
        throw new TMLExpressionException(this, "Could not find version object for package: " + packageName);
    }
}
Also used : AbstractVersion(com.dexels.navajo.version.AbstractVersion) TMLExpressionException(com.dexels.navajo.expression.api.TMLExpressionException) TMLExpressionException(com.dexels.navajo.expression.api.TMLExpressionException)

Aggregations

TMLExpressionException (com.dexels.navajo.expression.api.TMLExpressionException)1 AbstractVersion (com.dexels.navajo.version.AbstractVersion)1