Author: jm
Date: 2012-10-31 10:08:25 -0700 (Wed, 31 Oct 2012)
New Revision: 30724

Modified:
   
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/mapper/InteractionClusterMapper.java
   
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/mapper/MergedNetworkBuilder.java
Log:
References #1555: Further boot optimizations by deferring reading of mapping 
configuration file until mapping actually happens.  Shaves an extra 200ms.

Modified: 
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/mapper/InteractionClusterMapper.java
===================================================================
--- 
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/mapper/InteractionClusterMapper.java
       2012-10-31 16:45:49 UTC (rev 30723)
+++ 
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/mapper/InteractionClusterMapper.java
       2012-10-31 17:08:25 UTC (rev 30724)
@@ -19,7 +19,6 @@
 
 import org.cytoscape.model.CyEdge;
 import org.cytoscape.model.CyNetwork;
-import org.cytoscape.model.CyNode;
 import org.cytoscape.model.CyRow;
 import org.cytoscape.webservice.psicquic.miriam.Miriam;
 import org.cytoscape.webservice.psicquic.miriam.Miriam.Datatype;
@@ -61,19 +60,29 @@
        static final String TAXNOMY_NAME = "taxonomy.name";
        static final String TAXNOMY_DB = "taxonomy.db";
 
+       boolean isInitialized = false;
+       
        public InteractionClusterMapper() {
                namespaceSet = new HashSet<String>();
                this.name2ns = new HashMap<String, String>();
                this.synonym2ns = new HashMap<String, String>();
+       }
 
-               // Read resource file
-               try {
-                       parseXml();
-               } catch (Exception ex) {
-                       throw new RuntimeException("Could not read resource 
file", ex);
+       void ensureInitialized() {
+               synchronized (this) {
+                       if (isInitialized) {
+                               return;
+                       }
+                       // Read resource file
+                       try {
+                               parseXml();
+                       } catch (Exception ex) {
+                               throw new RuntimeException("Could not read 
resource file", ex);
+                       }
+                       isInitialized = true;
                }
        }
-
+       
        public void mapNodeColumn(final EncoreInteraction interaction, final 
CyRow sourceRow, final CyRow targetRow) {
 
                final Map<String, String> accsSource = 
interaction.getInteractorAccsA();

Modified: 
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/mapper/MergedNetworkBuilder.java
===================================================================
--- 
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/mapper/MergedNetworkBuilder.java
   2012-10-31 16:45:49 UTC (rev 30723)
+++ 
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/mapper/MergedNetworkBuilder.java
   2012-10-31 17:08:25 UTC (rev 30724)
@@ -6,11 +6,9 @@
 
 import java.io.IOException;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 
 import org.cytoscape.model.CyEdge;
-import org.cytoscape.model.CyIdentifiable;
 import org.cytoscape.model.CyNetwork;
 import org.cytoscape.model.CyNetworkFactory;
 import org.cytoscape.model.CyNode;
@@ -58,6 +56,7 @@
 
        private final Map<String, CyNode> process(final InteractionCluster iC, 
CyNetwork network, CyNetworkView netView,
                        final View<CyNode> hubNode) {
+               mapper.ensureInitialized();
                nodeMap = new HashMap<String, CyNode>();
                if (hubNode != null) {
                        
nodeMap.put(network.getRow(hubNode.getModel()).get(CyNetwork.NAME, 
String.class), hubNode.getModel());

-- 
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.

Reply via email to