I doubt that using a callback will make any difference.
Passing an object to a callback constructor is the same as passing an object to any other class's constructor. There is nothing special or CPLEX specific here. Just plain Java.
In any case, here is an (untested) code snippet that passes the expression used as objective function to a callback instance:
import ilog.cplex.*;
import ilog.concert.*;
public final class ObjToCallback {
private static final class Callback extends IloCplex.UserCutCallback {
private final double mybound;
private final IloCplex cplex;
private final IloNumExpr expr;
public Callback(double mybound, IloCplex cplex, IloNumExpr expr) {
this.mybound = mybound;
this.cplex = cplex;
this.expr = expr;
}
protected void main() throws IloException {
// Do something with expr here
if ( getValue(expr) < mybound )
add(cplex.ge(expr, mybound), IloCplex.CutManagement.UseCutFilter);
}
}
public static void main(String[] args) throws IloException {
final IloCplex cplex = new IloCplex();
try {
IloNumVar x = cplex.numVar(0, Double.POSITIVE_INFINITY, "x");
IloNumVar y = cplex.numVar(0, Double.POSITIVE_INFINITY, "y");
IloNumExpr sum = cplex.sum(x, y);
cplex.addMinimize(sum);
Callback callback = new Callback(0.0, cplex, sum);
cplex.use(callback);
}
finally {
cplex.end();
}
}
}
#CPLEXOptimizers#DecisionOptimization