public StackImpl build() { return new StackImpl( id, name, description, scope, creator, tags, workspaceConfig, components, stackIcon); } }
final StackImpl stack = new StackImpl(20); //(6) Shared by the threads (new Thread("Pusher"){ //(7) Thread no. 1 public void run(){ int i = 0; for(;;){ System.out.println("Pushed: " + stack.push(i++)); } } }).start();
@Transactional(rollbackOn = {RuntimeException.class, ServerException.class}) protected void doRemove(String id) throws ServerException { final EntityManager manager = managerProvider.get(); final StackImpl stack = manager.find(StackImpl.class, id); if (stack != null) { eventService.publish(new BeforeStackRemovedEvent(new StackImpl(stack))).propagateException(); manager.remove(stack); manager.flush(); } }
@Transactional(rollbackOn = {RuntimeException.class, ServerException.class}) protected void doRemove(String id) throws ServerException { final EntityManager manager = managerProvider.get(); final StackImpl stack = manager.find(StackImpl.class, id); if (stack != null) { eventService.publish(new BeforeStackRemovedEvent(new StackImpl(stack))).propagateException(); manager.remove(stack); manager.flush(); } }
@Override @Transactional public StackImpl getById(String id) throws NotFoundException, ServerException { requireNonNull(id, "Required non-null id"); try { final StackImpl stack = managerProvider.get().find(StackImpl.class, id); if (stack == null) { throw new NotFoundException(format("Stack with id '%s' doesn't exist", id)); } return new StackImpl(stack); } catch (RuntimeException x) { throw new ServerException(x.getLocalizedMessage(), x); } }
@Override @Transactional public StackImpl getById(String id) throws NotFoundException, ServerException { requireNonNull(id, "Required non-null id"); try { final StackImpl stack = managerProvider.get().find(StackImpl.class, id); if (stack == null) { throw new NotFoundException(format("Stack with id '%s' doesn't exist", id)); } return new StackImpl(stack); } catch (RuntimeException x) { throw new ServerException(x.getLocalizedMessage(), x); } }
@Override public StackImpl update(StackImpl update) throws NotFoundException, ServerException, ConflictException { requireNonNull(update, "Required non-null update"); try { return new StackImpl(doUpdate(update)); } catch (DuplicateKeyException x) { throw new ConflictException(format("Stack with name '%s' already exists", update.getName())); } catch (RuntimeException x) { throw new ServerException(x.getLocalizedMessage(), x); } }
@Override public StackImpl update(StackImpl update) throws NotFoundException, ServerException, ConflictException { requireNonNull(update, "Required non-null update"); try { return new StackImpl(doUpdate(update)); } catch (DuplicateKeyException x) { throw new ConflictException(format("Stack with name '%s' already exists", update.getName())); } catch (RuntimeException x) { throw new ServerException(x.getLocalizedMessage(), x); } }