/** * Invokes a void callback * * @param callback the callback */ public void invokeVoid( @NotNull T callback ) throws AsynchroniousInvocationException { invokeNullable( callback ); }
public AsynchronousServiceManager( @NotNull final String description, @NotNull final GenericServiceManager delegatingManager ) { asyncCallSupport.initializeWorker( new CallbackCaller<AsyncServiceCreator<?>>() { @NotNull public String getDescription() { return description; } public Object call( @NotNull AsyncServiceCreator<?> callback ) throws Exception { return callback.execute( delegatingManager ); } } ); }
/** * Invokes an action * * @param action the action * @return the return value of the action */ @Nonnull private <R> R invoke( @Nonnull DaoAction<T, R> action ) throws AsynchroniousInvocationException { return asyncCallSupport.<R>invoke( action ); }
@Override public void shutdown() { asyncCallSupport.shutdown(); }
@Override public void run() { log.debug( "up and running" ); //noinspection InfiniteLoopStatement while ( true ) { if ( Thread.currentThread().isInterrupted() ) { log.debug( "Thread has been interrupted --> exiting" ); return; } try { log.debug( "waiting for next callback" ); T callback = support.waitForNextCallback(); log.debug( "got callback" ); Object returnValue; synchronized ( support ) { returnValue = execute( callback ); } log.debug( "executed" ); support.acknowledge( callback, returnValue ); log.debug( "acknowledged" ); } catch ( InterruptedException ignore ) { log.debug( "Thread has been interrupted --> exiting" ); return; } } }
log.debug( "invoking Nullable " + callback ); log.debug( "Is initialized: " + initialized ); if ( !isInitialized() ) { initialize();
/** * Invokes an action * * @param actionVoid the action * @throws AsynchroniousInvocationException * */ private void invokeVoid( @Nonnull VoidDaoAction<T> actionVoid ) throws AsynchroniousInvocationException { asyncCallSupport.invokeVoid( actionVoid ); }
public static void shutdownWorkerThreads() throws InterruptedException { ThreadGroup group = Thread.currentThread().getThreadGroup(); Thread[] threads = new Thread[group.activeCount()]; group.enumerate( threads ); for ( Thread thread : threads ) { if ( thread.getName().contains( NAME_PREFIX ) ) { thread.interrupt(); thread.stop(); } } verifyNoWorkerThreadsLeft(); }
@Override public void shutdown() { asyncCallSupport.shutdown(); }
@Override public void run() { log.debug( "up and running" ); //noinspection InfiniteLoopStatement while ( true ) { if ( Thread.currentThread().isInterrupted() ) { log.debug( "Thread has been interrupted --> exiting" ); return; } try { log.debug( "waiting for next callback" ); T callback = support.waitForNextCallback(); log.debug( "got callback" ); Object returnValue; synchronized ( support ) { returnValue = execute( callback ); } log.debug( "executed" ); support.acknowledge( callback, returnValue ); log.debug( "acknowledged" ); } catch ( InterruptedException ignore ) { log.debug( "Thread has been interrupted --> exiting" ); return; } } }
log.debug( "invoking Nullable " + callback ); log.debug( "Is initialized: " + initialized ); if ( !isInitialized() ) { initialize();
/** * Invokes an action * * @param actionVoid the action * @throws AsynchroniousInvocationException * */ private void invokeVoid( @NotNull VoidDaoAction<T> actionVoid ) throws AsynchroniousInvocationException { asyncCallSupport.invokeVoid( actionVoid ); }
public static void shutdownWorkerThreads() throws InterruptedException { ThreadGroup group = Thread.currentThread().getThreadGroup(); Thread[] threads = new Thread[group.activeCount()]; group.enumerate( threads ); for ( Thread thread : threads ) { if ( thread.getName().contains( NAME_PREFIX ) ) { thread.interrupt(); thread.stop(); } } verifyNoWorkerThreadsLeft(); }
/** * Invokes a void callback * * @param callback the callback */ public void invokeVoid( @Nonnull T callback ) throws AsynchroniousInvocationException { invokeNullable( callback ); }
public AsynchronousServiceManager( @Nonnull final String description, @Nonnull final GenericServiceManager delegatingManager ) { asyncCallSupport.initializeWorker( new CallbackCaller<AsyncServiceCreator<?>>() { @Override @Nonnull public String getDescription() { return description; } @Override public Object call( @Nonnull AsyncServiceCreator<?> callback ) throws Exception { return callback.execute( delegatingManager ); } } ); }
public void shutdown() { asyncCallSupport.shutdown(); }
/** * Invokes an action * * @param action the action * @return the return value of the action */ @NotNull private <R> R invoke( @NotNull DaoAction<T, R> action ) throws AsynchroniousInvocationException { return asyncCallSupport.<R>invoke( action ); }
/** * Invokes an action * * @param actionVoid the action * @throws AsynchroniousInvocationException * */ private void invokeVoid( @NotNull VoidDaoAction<T> actionVoid ) throws AsynchroniousInvocationException { asyncCallSupport.invokeVoid( actionVoid ); }
@Nullable public <R> R perform( @NotNull final ServiceCallback<T, R> callback ) { return asyncCallSupport.<R>invokeNullable( new DaoAction<T, R>() { public R execute( @NotNull GenericDao<T> dao ) { GenericService<T> service = ( GenericService<T> ) dao; return callback.perform( service ); } } ); }
public AsynchronousDaoManager( @NotNull final String description, @NotNull final GenericDaoManager delegatingManager ) { asyncCallSupport.initializeWorker( new CallbackCaller<AsyncDaoCreator<?>>() { public Object call( @NotNull AsyncDaoCreator<?> callback ) throws Exception { log.debug( "executing callback" ); return callback.execute( delegatingManager ); } @NotNull public String getDescription() { return description; } } ); }