static public ResourceAdaptorEntityInfo toResourceAdaptorEntityInfo(String name, ResourceAdaptorEntityState state) throws ManagementConsoleException { String strState = ""; if (state.isActive()) strState = ResourceAdaptorEntityInfo.ACTIVE; else if (state.isInactive()) strState = ResourceAdaptorEntityInfo.INACTIVE; else if (state.isStopping()) strState = ResourceAdaptorEntityInfo.STOPPING; return new ResourceAdaptorEntityInfo(name, strState); }
public String[] getResourceAdaptorEntities(ResourceAdaptorEntityState state) throws NullPointerException, ManagementException { if (state == null) throw new NullPointerException("null entity state"); Iterator resourceAdaptorEntityIterator = resourceAdaptorEntities .values().iterator(); ArrayList resultEntityNamesArrayList = new ArrayList(); while (resourceAdaptorEntityIterator.hasNext()) { ResourceAdaptorEntity resourceAdaptorEntity = (ResourceAdaptorEntity) resourceAdaptorEntityIterator .next(); if (resourceAdaptorEntity.getState().equals(state)) resultEntityNamesArrayList.add(resourceAdaptorEntity.getName()); } String[] resultEntityNames = new String[resultEntityNamesArrayList .size()]; resultEntityNames = (String[]) resultEntityNamesArrayList .toArray(resultEntityNames); return resultEntityNames; }
public void setAsText( String state ) { if(state.equalsIgnoreCase(ResourceAdaptorEntityState.ACTIVE.toString())) super.setValue(ResourceAdaptorEntityState.ACTIVE); else if(state.equalsIgnoreCase(ResourceAdaptorEntityState.ACTIVE_STRING)) super.setValue(ResourceAdaptorEntityState.ACTIVE); else if(state.equalsIgnoreCase(ResourceAdaptorEntityState.INACTIVE.toString())) super.setValue(ResourceAdaptorEntityState.INACTIVE); else if(state.equalsIgnoreCase(ResourceAdaptorEntityState.INACTIVE_STRING)) super.setValue(ResourceAdaptorEntityState.INACTIVE); else if(state.equalsIgnoreCase(ResourceAdaptorEntityState.STOPPING.toString())) super.setValue(ResourceAdaptorEntityState.STOPPING); else if(state.equalsIgnoreCase(ResourceAdaptorEntityState.STOPPING_STRING)) super.setValue(ResourceAdaptorEntityState.STOPPING); else throw new IllegalArgumentException("Bad Service State " + state); }
public void allActivitiesEnded() { logger.info("All activities ended for ra entity "+name); if (timerTask != null) { timerTask = null; } if (!this.state.isInactive()) { if (object.getState() == ResourceAdaptorObjectState.STOPPING) { try { object.raInactive(); } catch (Throwable t) { logger.error("Got exception invoking raInactive() for entity "+name, t); } } if (state != null && state.isStopping()) { state = ResourceAdaptorEntityState.INACTIVE; } } }
/** * Signals that the container is in STOPPING state * @throws TransactionRequiredLocalException */ public void sleeStopping() throws InvalidStateException, TransactionRequiredLocalException { if (state != null && state.isActive()) { try { object.raStopping(); } catch (Throwable t) { logger.error("Got exception from RA object",t); } scheduleAllActivitiesEnd(); } }
if (!this.state.isInactive()) { throw new InvalidStateException("entity " + name + " is in state: " + this.state);
/** * Signals that the container is in RUNNING state */ @SuppressWarnings({ "unchecked", "rawtypes" }) public void sleeRunning() throws InvalidStateException { // if entity is active then activate the ra object if (this.state.isActive()) { if (setFTContext) { setFTContext = false; if (object.isFaultTolerant()) { // set fault tolerant context, it is a ft ra try { this.ftResourceAdaptorContext = new FaultTolerantResourceAdaptorContextImpl(name,sleeContainer,(FaultTolerantResourceAdaptor) object.getResourceAdaptorObject()); object.setFaultTolerantResourceAdaptorContext(ftResourceAdaptorContext); } catch (Throwable t) { logger.error("Got exception invoking setFaultTolerantResourceAdaptorContext(...) for entity "+name, t); } } } try { object.raActive(); } catch (Throwable t) { logger.error("Got exception invoking raActive() for entity "+name, t); } } }
/** * Removes the entity, it will unconfigure and unset the ra context, the * entity object can not be reused * * @throws InvalidStateException */ public void remove() throws InvalidStateException { if (!this.state.isInactive()) { throw new InvalidStateException("entity " + name + " is in state: " + this.state); } object.raUnconfigure(); if (object.isFaultTolerant()) { object.unsetFaultTolerantResourceAdaptorContext(); ftResourceAdaptorContext.shutdown(); } object.unsetResourceAdaptorContext(); this.sleeContainer.getTraceManagement() .deregisterNotificationSource(this.getNotificationSource()); state = null; }
if (!this.state.isActive()) { throw new InvalidStateException("entity " + name + " is in state: " + this.state);
/** * * Remembers in memory active Resource Adaptors so that they can be * reactivated on start. (NOTE: the list should be persisted info according * to SLEE spec #14.6.1, #2.2.17) * */ private void rememberActiveResourceAdaptorsBeforeStop() throws Exception { HashMap<String, ResourceAdaptorEntity> map = sleeContainer .getResourceAdaptorEntities(); for (String entityName : map.keySet()) { ResourceAdaptorEntity entity = map.get(entityName); if (!entityName.equals("tck") && entity.getState().equals( ResourceAdaptorEntityState.ACTIVE)) this.activeRAEntities.add(entityName); } }
/** * * Deactivate all active resource adaptors in preparation for moving to the * STOPPED state. See SLEE #14.6.1 * */ private void stopAllResourceAdaptors() { HashMap<String, ResourceAdaptorEntity> entities = this.sleeContainer .getResourceAdaptorEntities(); Iterator<ResourceAdaptorEntity> it = entities.values().iterator(); while (it.hasNext()) { ResourceAdaptorEntity entity = it.next(); if (!entity.getName().equals("tck") && entity.getState().equals( ResourceAdaptorEntityState.ACTIVE)) try { entity.deactivate(); } catch (InvalidStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }