public void dispose() {
        for (Field f : this.bagFields) {
            try {
                Object value = f.get(this);
                if (value != null && value instanceof Disposable) {
                    Disposable.class.cast(value).dispose();
                }
            } catch (IllegalAccessException e) {
                System.err.println("Failed to access a resource bag!");
                e.printStackTrace(System.err);
            }
        }
    }