@Override public void delete() { // TODO: clear out all state files final State state = new StateBuilder().withConfig( (ObjectNode) myParams.get("state")).build(); if (state != null) { state.delete(); } }
/** * Sets the my params. * * @param myParams * the new my params */ public void setMyParams(final ObjectNode myParams) { this.myParams = myParams; state = new StateBuilder().withConfig((ObjectNode) myParams.get("state")).build(); WakeServiceBuilder.getServices().put(state.getId(), this); }
/** * Instantiates a new wake service. * * @param params * the params, containing at least a "state" field, with a * specific State configuration. */ public WakeService(final ObjectNode params) { myParams = params; state = new StateBuilder().withConfig( (ObjectNode) myParams.get("state")).build(); WakeServiceBuilder.getServices().put(state.getId(), this); }
/** * Instantiates a new InstantiationService. * * @param params * the params, containing at least a "state" field, with a * specific State configuration. * @param cl * the cl */ public InstantiationService(final ObjectNode params, final ClassLoader cl) { this.cl = cl; myParams = params; final State state = new StateBuilder().withConfig( (ObjectNode) myParams.get("state")).build(); stateService = state.getService(); myId = state.getId(); InstantiationServiceBuilder.getServices().put(myId, this); load(); }
/** * Load state. * * @param sc * the sc */ private void loadState(final ObjectNode sc) { if (sc != null) { final StateConfig stateConfig = new StateConfig(sc); if (agentId != null && stateConfig.getId() == null) { stateConfig.setId(agentId); } state = new StateBuilder().withConfig(stateConfig).build(); config.set("state", stateConfig); } }
/** * Load. * * @param key * the key * @return the instantiation entry */ private InstantiationEntry load(final String key) { final State innerState = new StateBuilder().withConfig( new StateConfig((ObjectNode) myParams.get("state")).put("id", key)).build(); final InstantiationEntry result = innerState.get("entry", INSTANTIATIONENTRY); if(result!=null) { result.setState(innerState); } return result; }
/** * Store. * * @param key * the key * @param val * the val */ private void store(final String key, final InstantiationEntry val) { State innerState = null; if (val != null) { innerState = val.getState(); } if (innerState == null) { innerState = new StateBuilder().withConfig( new StateConfig((ObjectNode) myParams.get("state")).put( "id", key)).build(); } if (innerState != null) { innerState.put("entry", JOM.getInstance().valueToTree(val)); } }
/** * Removes the specific state. * * @param key * the key * @param val * the val */ private void remove(final String key, final InstantiationEntry val) { State innerState = null; if (val != null) { innerState = val.getState(); } if (innerState == null) { innerState = new StateBuilder().withConfig( new StateConfig((ObjectNode) myParams.get("state")).put( "id", key)).build(); } if (innerState != null) { innerState.delete(); } }