VSensorLoader extends Thread { public void stopLoading ( ) { this.isActive = false; this.interrupt ( ); for ( String configFile : Mappings.getAllKnownFileName ( ) ) { VirtualSensor sensorInstance = Mappings.getVSensorInstanceByFileName ( configFile ); removeAllVSResources ( sensorInstance ); logger.info( "Removing the resources associated with : " + sensorInstance.getConfig ( ).getFileName ( ) + " [done]." ); } try { Main.getWindowStorage().shutdown( ); Iterator<VSensorConfig> iter = Mappings.getAllVSensorConfigs(); while (iter.hasNext()) { Main.getStorage(iter.next()).shutdown(); } } catch ( SQLException e ) { logger.error(e.getMessage(),e); } } VSensorLoader();  VSensorLoader( String pluginsPath ); void addVSensorStateChangeListener(VSensorStateChangeListener listener); void removeVSensorStateChangeListener(VSensorStateChangeListener listener); boolean fireVSensorLoading(VSensorConfig config); boolean fireVSensorUnLoading(VSensorConfig config); static VSensorLoader getInstance(String path); void startLoading(); void run( ); synchronized void loadVirtualSensor(String vsConfigurationFileContent, String fileName); static String getVSConfigurationFilePath(String fileName); synchronized void loadPlugin(); synchronized boolean loadPlugin(String fileFilterName); boolean isVirtualSensorValid(VSensorConfig configuration); void removeAllVSResources( VirtualSensor pool ); void releaseStreamSource(StreamSource streamSource); static Modifications getUpdateStatus(String virtualSensorsPath); static Modifications getUpdateStatus(String virtualSensorsPath, String filterFileName); boolean createInputStreams( VirtualSensor pool ); AbstractWrapper createWrapper(AddressBean addressBean); boolean prepareStreamSource( VSensorConfig vsensorConfig,InputStream inputStream , StreamSource streamSource  ); boolean prepareStreamSource( StreamSource streamSource ,DataField[] outputformat, AbstractWrapper wrapper ); void stopLoading( ); static final String VSENSOR_POOL; static final String STREAM_SOURCE; static final String INPUT_STREAM; }
@Test public void testStopLoading() throws IOException { VSensorConfig sensorConfig = new VSensorConfig(); sensorConfig.setName("test"); File someFile = File.createTempFile("bla", ".xml"); sensorConfig.setMainClass("ch.epfl.gsn.vsensor.BridgeVirtualSensor"); sensorConfig.setFileName(someFile.getAbsolutePath()); VirtualSensor pool = new VirtualSensor(sensorConfig); InputStream is = new InputStream(); is.setInputStreamName("t1"); is.setQuery("select * from my-stream1"); StreamSource ss1 = new StreamSource().setAlias("my-stream1").setAddressing(new AddressBean[] {new AddressBean("mock-test")}).setSqlQuery("select * from wrapper").setRawHistorySize("2").setInputStream(is); ss1.setSamplingRate(1); assertTrue(ss1.validate()); is.setSources(ss1); assertTrue(is.validate()); sensorConfig.setInputStreams(is); assertTrue(sensorConfig.validate()); }