protected Object execute(final Job job, final String curQueue, final Object instance) throws Exception {
        if (instance instanceof WorkerAware) {
            ((WorkerAware) instance).setWorker(this);
        }
        this.listenerDelegate.fireEvent(JOB_EXECUTE, this, curQueue, job, instance, null, null);
        final Object result;
        if (instance instanceof Callable) {
            result = ((Callable<?>) instance).call(); // The job is executing!
        } else if (instance instanceof Runnable) {
            ((Runnable) instance).run(); // The job is executing!
            result = null;
        } else { // Should never happen since we're testing the class earlier
            throw new ClassCastException(
                    "Instance must be a Runnable or a Callable: " + instance.getClass().getName() + " - " + instance);
        }
        return result;
    }
protected Object execute ( final Job job , final String curQueue , final Object instance ) throws Exception { if ( instance instanceof WorkerAware ) { ( ( WorkerAware ) instance ) . setWorker ( this ) ; } this . listenerDelegate . fireEvent ( JOB_EXECUTE , this , curQueue , job , instance , null , null ) ; final Object result ; if ( instance instanceof Callable ) { result = ( ( Callable < ? > ) instance ) . call ( ) ; } else if ( instance instanceof Runnable ) { ( ( Runnable ) instance ) . run ( ) ; result = null ; } else { throw new ClassCastException ( "Instance must be a Runnable or a Callable: " + instance . getClass ( ) . getName ( ) + " - " + instance ) ; } return result ; }
Executes the given job.

@param job the job to execute
@param curQueue the queue the job came from
@param instance the materialized job
@throws Exception if the instance is a {@link Callable} and throws an exception
@return result of the execution