/** * Insure that timer methods can be invoked for the current operation on this Context. */ private void checkState() throws IllegalStateException, NoSuchObjectLocalException { /* no more mandatory final BeanContext beanContext = ThreadContext.getThreadContext().getBeanContext(); final BaseContext context = (BaseContext) beanContext.get(EJBContext.class); context.doCheck(BaseContext.Call.timerMethod); */ if (timerData.isCancelled() && !timerData.isStopped()) { throw new NoSuchObjectLocalException("Timer has been cancelled"); } if (timerData.isExpired()) { throw new NoSuchObjectLocalException("The timer has expired"); } }
public Timer getTimer() { final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class); if (containerSystem == null) { throw new NoSuchObjectLocalException("OpenEJb container system is not running"); } final BeanContext beanContext = containerSystem.getBeanContext(deploymentId); if (beanContext == null) { throw new NoSuchObjectLocalException("Deployment info not found " + deploymentId); } final EjbTimerService timerService = beanContext.getEjbTimerService(); if (timerService == null) { throw new NoSuchObjectLocalException("Deployment no longer supports ejbTimout " + deploymentId + ". Has this ejb been redeployed?"); } final Timer timer = timerService.getTimer(id); if (timer == null) { throw new NoSuchObjectLocalException("Timer not found for ejb " + deploymentId); } return timer; }
private void isValidReference(final Method method) throws NoSuchObjectException { if (isInvalidReference) { if (interfaceType.isComponent() && interfaceType.isLocal()) { throw new NoSuchObjectLocalException("reference is invalid"); } else if (interfaceType.isComponent() || Remote.class.isAssignableFrom(method.getDeclaringClass())) { throw new NoSuchObjectException("reference is invalid"); } else { throw new NoSuchEJBException("reference is invalid for " + deploymentID); } } if (!(Object.class.equals(method.getDeclaringClass()) && method.getName().equals("finalize") && method.getExceptionTypes().length == 1 && Throwable.class.equals(method.getExceptionTypes()[0]))) { getBeanContext(); // will throw an exception if app has been undeployed. } }
@Override public void setup(TestContainer container) throws Exception { container.login("1"); container.addBean(new ConfigurationServiceStub()); container.addBean(new DataServiceBean()); container.addBean(new ConfigurationServiceStub()); container.addBean(accountManagementStub = new AccountServiceStub()); container.addBean(Mockito.mock(SubscriptionServiceLocal.class)); container.addBean(Mockito.mock(BillingServiceLocal.class)); container.addBean(new PaymentServiceStub()); container.addBean(new IdentityServiceStub()); container.addBean(tm = new TimerServiceBean()); tss = new TimerServiceStub() { @Override public Timer createTimer(Date arg0, Serializable arg1) throws IllegalArgumentException, IllegalStateException, EJBException { getTimers().add(new TimerStub(0, arg1, arg0, false) { @Override public Date getNextTimeout() throws EJBException, IllegalStateException, NoSuchObjectLocalException { return getExecDate(); } }); return null; } }; ctx = Mockito.mock(SessionContext.class); Mockito.when(ctx.getTimerService()).thenReturn(tss); tm.ctx = ctx; mgr = container.get(DataService.class); cfgs = container.get(ConfigurationServiceLocal.class); setUpDirServerStub(cfgs); }
private void initTimer(TimerType timerType, Date date) { timer = new TimerStub(0, timerType, date, false) { @Override public Date getNextTimeout() throws EJBException, IllegalStateException, NoSuchObjectLocalException { return getExecDate(); } }; timer.setInfo(timerType); }
/** * {@inheritDoc} */ @Override public boolean isGenerating() { try { if (tm != null) { tm.getNextTimeout(); } else { return false; } } catch (NoSuchObjectLocalException e) { return false; } return true; }
public long getTimeRemaining() throws IllegalStateException, NoSuchObjectLocalException { checkState(); final Date nextTimeout = timerData.getNextTimeout(); if (nextTimeout == null) { throw new NoMoreTimeoutsException("The timer has no future timeouts"); } return timerData.getTimeRemaining(); }
public Date getNextTimeout() throws IllegalStateException, NoSuchObjectLocalException { checkState(); final Date nextTimeout = timerData.getNextTimeout(); if (nextTimeout == null) { throw new NoMoreTimeoutsException("The timer has no future timeouts"); } return timerData.getNextTimeout(); }
public TimerHandle getHandle() throws IllegalStateException, NoSuchObjectLocalException { checkState(); if (!timerData.isPersistent()) { throw new IllegalStateException("can't getHandle for a non-persistent timer"); } return new TimerHandleImpl(timerData.getId(), timerData.getDeploymentId()); }
public ScheduleExpression getSchedule() throws EJBException, IllegalStateException, NoSuchObjectLocalException { checkState(); if (timerData.getType() == TimerType.Calendar) { return ((CalendarTimerData) timerData).getSchedule(); } throw new IllegalStateException("The target timer is not a calendar-based type "); }
@Override public void cancel() throws IllegalStateException, NoSuchObjectLocalException, EJBException { throw new UnsupportedOperationException(); }
@Override public TimerHandle getHandle() throws IllegalStateException, NoSuchObjectLocalException, EJBException { throw new UnsupportedOperationException(); }
@Override public Serializable getInfo() throws IllegalStateException, NoSuchObjectLocalException, EJBException { throw new UnsupportedOperationException(); }
@Override public Date getNextTimeout() throws IllegalStateException, NoSuchObjectLocalException, EJBException { throw new UnsupportedOperationException(); }
@Override public long getTimeRemaining() throws IllegalStateException, NoSuchObjectLocalException, EJBException { throw new UnsupportedOperationException(); }
@Override public ScheduleExpression getSchedule() throws IllegalStateException, NoSuchObjectLocalException, EJBException { throw new UnsupportedOperationException(); }
@Override public boolean isCalendarTimer() throws IllegalStateException, NoSuchObjectLocalException, EJBException { throw new UnsupportedOperationException(); }
@Override public boolean isPersistent() throws IllegalStateException, NoSuchObjectLocalException, EJBException { throw new UnsupportedOperationException(); }
@Override public void cancel() throws EJBException, IllegalStateException, NoSuchObjectLocalException { isCanceled = true; }
@Override public TimerHandle getHandle() throws EJBException, IllegalStateException, NoSuchObjectLocalException { return null; }
@Override public Serializable getInfo() throws EJBException, IllegalStateException, NoSuchObjectLocalException { return info; }
@Override public Date getNextTimeout() throws EJBException, IllegalStateException, NoSuchObjectLocalException { return this.execDate; }
@Override public long getTimeRemaining() throws EJBException, IllegalStateException, NoSuchObjectLocalException { return 0; }
@Override public ScheduleExpression getSchedule() throws IllegalStateException, NoSuchObjectLocalException, EJBException { return null; }
@Override public boolean isCalendarTimer() throws IllegalStateException, NoSuchObjectLocalException, EJBException { return false; }
@Override public boolean isPersistent() throws IllegalStateException, NoSuchObjectLocalException, EJBException { return false; }
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String idInstancia = (String) request.getParameter(InstanciaManager.ID_INSTANCIA); logger.debug("Mantenimiento sesion sistra - comprobando ejb de sesion de tramitacion [ID_INSTANCIA: " + idInstancia + "]"); boolean sesionActiva = false; try { // Invocamos a un metodo del ejb de sesion para mantenerlo activo request.setAttribute(InstanciaManager.ID_INSTANCIA,idInstancia); InstanciaDelegate delegate = InstanciaManager.recuperarInstancia( request ); String idPersistencia = delegate.obtenerIdPersistencia(); sesionActiva=true; logger.debug("Mantenimiento sesion sistra - ejb de sesion de tramitacion activo"); }catch(DelegateException de){ if (de.getCause().getClass().equals(NoSuchObjectLocalException.class)){ // Sesion de tramitacion finalizada: no existe EJB de sesion sesionActiva=false; logger.debug("Mantenimiento sesion sistra - ejb de sesion de tramitacion ya no existe. Sesion de tramitacion finalizada."); }else{ // Sesion de tramitacion finalizada: error desconocido sesionActiva=false; logger.debug("Mantenimiento sesion sistra - no se ha podido comprobar si el ejb de sesion de tramitacion existe.",de); } } catch( Exception exc ) { logger.debug("Mantenimiento sesion sistra - no se ha podido comprobar si el ejb de sesion de tramitacion existe.",exc); } logger.debug("Mantenimiento sesion sistra - retornando sesion tramitacion activa = " + sesionActiva); byte[] encBytes = (sesionActiva + "").getBytes( "UTF-8" ); response.reset(); response.setContentLength(encBytes.length); response.setContentType("text/plain; charset=UTF-8"); response.getOutputStream().write(encBytes); response.flushBuffer(); }