Author: ruschein
Date: 2011-01-18 09:22:42 -0800 (Tue, 18 Jan 2011)
New Revision: 23489
Modified:
core3/model-api/trunk/pom.xml
core3/model-api/trunk/src/main/java/org/cytoscape/model/CyTableRowChangeTracker.java
Log:
Self-registering tracker.
Modified: core3/model-api/trunk/pom.xml
===================================================================
--- core3/model-api/trunk/pom.xml 2011-01-18 17:21:37 UTC (rev 23488)
+++ core3/model-api/trunk/pom.xml 2011-01-18 17:22:42 UTC (rev 23489)
@@ -33,8 +33,8 @@
<directory>src/main/resources</directory>
</resource>
<!--
- | example additional resource entries, useful when building Eclipse RCP
applications
- -->
+ | example additional resource entries, useful when building Eclipse
RCP applications
+ -->
<resource>
<directory>.</directory>
<includes>
@@ -50,9 +50,9 @@
<artifactId>maven-pax-plugin</artifactId>
<version>1.4</version>
<!--
- | enable improved OSGi compilation support for the bundle
life-cycle.
- | to switch back to the standard bundle life-cycle, move this
setting
- | down to the maven-bundle-plugin section
+ | enable improved OSGi compilation support for the bundle
life-cycle.
+ | to switch back to the standard bundle life-cycle, move this
setting
+ | down to the maven-bundle-plugin section
-->
<extensions>true</extensions>
</plugin>
@@ -61,20 +61,20 @@
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.3</version>
<!--
- | the following instructions build a simple set of public/private
classes into an OSGi bundle
- -->
+ | the following instructions build a simple set of public/private
classes into an OSGi bundle
+ -->
<configuration>
<instructions>
<Bundle-SymbolicName>${bundle.symbolicName}</Bundle-SymbolicName>
<Bundle-Version>${pom.version}</Bundle-Version>
<!--
- | assume public classes are in the top package, and private
classes are under ".internal"
- -->
+ | assume public classes are in the top package, and private
classes are under ".internal"
+ -->
<Export-Package>!${bundle.namespace}.internal.*,${bundle.namespace}.*;version="${pom.version}"</Export-Package>
<Private-Package>${bundle.namespace}.internal.*</Private-Package>
<!--
- | each module can override these defaults in their osgi.bnd file
- -->
+ | each module can override these defaults in their osgi.bnd file
+ -->
<_include>-osgi.bnd</_include>
</instructions>
</configuration>
@@ -107,9 +107,9 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <version>1.8.1</version>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -119,6 +119,11 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.cytoscape</groupId>
+ <artifactId>service-util</artifactId>
+ <version>3.0.0-alpha2-SNAPSHOT</version>
+ </dependency>
</dependencies>
Modified:
core3/model-api/trunk/src/main/java/org/cytoscape/model/CyTableRowChangeTracker.java
===================================================================
---
core3/model-api/trunk/src/main/java/org/cytoscape/model/CyTableRowChangeTracker.java
2011-01-18 17:21:37 UTC (rev 23488)
+++
core3/model-api/trunk/src/main/java/org/cytoscape/model/CyTableRowChangeTracker.java
2011-01-18 17:22:42 UTC (rev 23489)
@@ -2,7 +2,9 @@
import java.util.ArrayList;
+import java.util.Dictionary;
import java.util.HashMap;
+import java.util.Hashtable;
import java.util.List;
import java.util.Map;
@@ -13,6 +15,7 @@
import org.cytoscape.model.events.RowSetChangedListener;
import org.cytoscape.model.events.RowCreatedMicroListener;
import org.cytoscape.model.events.RowSetMicroListener;
+import org.cytoscape.service.util.CyServiceRegistrar;
/** This class simplifies tracking of CyRow creation and update events for a
single CyTable. In
@@ -45,19 +48,27 @@
private final CyTable table;
private final Map<CyRow, RowSetMicroListenerProxy>
rowToListenerProxyMap;
private final CyEventHelper eventHelper;
+ private final CyServiceRegistrar serviceRegistrar;
private List<RowUpdate> rowUpdates;
private int numConcurrentUpdaters;
/** @param table the table whose row updates we're forwarding
* @param eventHelper used to set up event tracking
*/
- public CyTableRowChangeTracker(final CyTable table, final CyEventHelper
eventHelper) {
+ public CyTableRowChangeTracker(final CyTable table, final CyEventHelper
eventHelper,
+ final CyServiceRegistrar
serviceRegistrar)
+ {
this.table = table;
this.eventHelper = eventHelper;
+ this.serviceRegistrar = serviceRegistrar;
this.rowToListenerProxyMap = new HashMap<CyRow,
RowSetMicroListenerProxy>();
this.rowUpdates = new ArrayList<RowUpdate>();
this.numConcurrentUpdaters = 0;
+ final Dictionary emptyProps = new Hashtable();
+ serviceRegistrar.registerService(this,
RowSetAboutToBeChangedListener.class, emptyProps);
+ serviceRegistrar.registerService(this,
RowSetChangedListener.class, emptyProps);
+
eventHelper.addMicroListener(this,
RowCreatedMicroListener.class, table);
final List<CyRow> rows = table.getAllRows();
@@ -85,12 +96,14 @@
@Override
public final synchronized void handleEvent(final
RowSetAboutToBeChangedEvent e) {
+System.err.println("?????????????????????????? got a
RowSetAboutToBeChangedEvent event, table is matching="+(e.getTable() == table));
if (e.getTable() == table)
++numConcurrentUpdaters;
}
@Override
public final synchronized void handleEvent(final RowSetChangedEvent e) {
+System.err.println("?????????????????????????? got a RowSetChangedEvent event,
table is matching="+(e.getTable() == table));
if (e.getTable() == table) {
--numConcurrentUpdaters;
if (numConcurrentUpdaters == 0) {
@@ -117,6 +130,9 @@
eventHelper.removeMicroListener(this,
RowCreatedMicroListener.class, table);
for (final RowSetMicroListenerProxy proxy :
rowToListenerProxyMap.values())
proxy.cleanup();
+
+ serviceRegistrar.unregisterService(this,
RowSetChangedListener.class);
+ serviceRegistrar.unregisterService(this,
RowSetAboutToBeChangedListener.class);
}
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.