MCPcopy Create free account
hub / github.com/GateNLP/gate-core / cleanup

Method cleanup

src/main/java/gate/creole/SerialController.java:257–292  ·  view source on GitHub ↗

Cleans the internal data and prepares this object to be collected

()

Source from the content-addressed store, hash-verified

255 * Cleans the internal data and prepares this object to be collected
256 */
257 @Override
258 public void cleanup() {
259 //stop listening to Creole events.
260 Gate.getCreoleRegister().removeCreoleListener(this);
261 // close all PRs in this controller, if not members of other apps.
262 if(prList != null && !prList.isEmpty()) {
263 try {
264 //get all the other controllers
265 List<Resource> allOtherControllers =
266 Gate.getCreoleRegister().getAllInstances("gate.Controller");
267 allOtherControllers.remove(this);
268 //get all the PRs in all the other controllers
269 List<Resource> prsInOtherControllers = new ArrayList<Resource>();
270 for(Resource aController : allOtherControllers){
271 prsInOtherControllers.addAll(((Controller)aController).getPRs());
272 }
273 //remove all PRs in this controller, that are not also in other
274 //controllers
275// for(Iterator prIter = getPRs().iterator(); prIter.hasNext();){
276// ProcessingResource aPr = (ProcessingResource)prIter.next();
277// if(!prsInOtherControllers.contains(aPr)){
278// prIter.remove();
279// Factory.deleteResource((Resource)aPr);
280// }
281// }
282 for(Resource aPr : new ArrayList<Resource>(getPRs())){
283 if(!prsInOtherControllers.contains(aPr)){
284 Factory.deleteResource(aPr);
285 }
286 }
287 }
288 catch(GateException e) {
289 //ignore
290 }
291 }
292 }
293
294 /**
295 * Duplicate this controller. We perform a default duplication of

Callers

nothing calls this directly

Calls 10

getCreoleRegisterMethod · 0.95
getPRsMethod · 0.95
deleteResourceMethod · 0.95
removeCreoleListenerMethod · 0.65
getAllInstancesMethod · 0.65
removeMethod · 0.65
getPRsMethod · 0.65
isEmptyMethod · 0.45
addAllMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected