public TangoConnectionImpl(final String uri, String attributeName, boolean requireEvents) throws Exception { super(uri, attributeName); createTangoHost(); this.tangoProxy = new DeviceProxy(uri); if (requireEvents) { this.tangoEvents = new TangoEventsAdapter(tangoProxy); this.listener = new ITangoChangeListener() { @Override public void change(TangoChangeEvent event) { fireTangoConnectionListeners(event); lastEvent = System.currentTimeMillis(); } }; if (attributeName != null) { tangoEvents.addTangoChangeListener(listener, attributeName, new String[0]); } else { this.attributeName = "Output"; tangoEvents.addTangoChangeListener(listener, attributeName, new String[0]); } } }
/** * Can throw tango exceptions. Once called this connection is dead. * * @throws Exeption */ public synchronized void dispose() throws Exception { super.dispose(); if (tangoEvents != null && listener != null) { tangoEvents.removeTangoChangeListener(listener, attributeName); } tangoProxy = null; tangoEvents = null; listener = null; }