Author: jm
Date: 2012-01-02 13:47:24 -0800 (Mon, 02 Jan 2012)
New Revision: 27897

Removed:
   
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/ShutdownHandler.java
Modified:
   
core3/impl/trunk/application-impl/src/main/java/org/cytoscape/application/internal/CyActivator.java
   
core3/impl/trunk/application-impl/src/main/java/org/cytoscape/application/internal/ShutdownHandler.java
Log:
Cleaned up the way shutdown happens so OSGi framework is stopped instead of 
using System.exit()


Modified: 
core3/impl/trunk/application-impl/src/main/java/org/cytoscape/application/internal/CyActivator.java
===================================================================
--- 
core3/impl/trunk/application-impl/src/main/java/org/cytoscape/application/internal/CyActivator.java
 2012-01-02 21:31:02 UTC (rev 27896)
+++ 
core3/impl/trunk/application-impl/src/main/java/org/cytoscape/application/internal/CyActivator.java
 2012-01-02 21:47:24 UTC (rev 27897)
@@ -19,6 +19,7 @@
 import org.cytoscape.property.CyProperty;
 
 
+import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 
 import org.cytoscape.service.util.AbstractCyActivator;
@@ -40,7 +41,8 @@
                CyNetworkViewManager cyNetworkViewManagerServiceRef = 
getService(bc,CyNetworkViewManager.class);
                
                CyApplicationManagerImpl cyApplicationManager = new 
CyApplicationManagerImpl(cyEventHelperServiceRef,cyNetworkManagerServiceRef,cyNetworkViewManagerServiceRef);
-               ShutdownHandler cytoscapeShutdown = new 
ShutdownHandler(cyEventHelperServiceRef);
+               Bundle rootBundle = bc.getBundle(0);
+               ShutdownHandler cytoscapeShutdown = new 
ShutdownHandler(cyEventHelperServiceRef, rootBundle);
                CyApplicationConfigurationImpl cyApplicationConfiguration = new 
CyApplicationConfigurationImpl();
                CyProperty cyApplicationCoreProperty = 
getService(bc,CyProperty.class,"(cyPropertyName=cytoscape3.props)");
                CyVersionImpl cytoscapeVersion = new 
CyVersionImpl(cyApplicationCoreProperty);

Modified: 
core3/impl/trunk/application-impl/src/main/java/org/cytoscape/application/internal/ShutdownHandler.java
===================================================================
--- 
core3/impl/trunk/application-impl/src/main/java/org/cytoscape/application/internal/ShutdownHandler.java
     2012-01-02 21:31:02 UTC (rev 27896)
+++ 
core3/impl/trunk/application-impl/src/main/java/org/cytoscape/application/internal/ShutdownHandler.java
     2012-01-02 21:47:24 UTC (rev 27897)
@@ -41,6 +41,8 @@
 import org.cytoscape.application.CyShutdown;
 import org.cytoscape.application.events.CyShutdownEvent;
 import org.cytoscape.event.CyEventHelper;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -53,17 +55,23 @@
        
        private final CyEventHelper eh;
 
-       public ShutdownHandler(CyEventHelper eh) {
+       private Bundle rootBundle;
+
+       public ShutdownHandler(CyEventHelper eh, Bundle rootBundle) {
                this.eh = eh;
+               this.rootBundle = rootBundle;
        }
 
        public void exit(int retVal) {
                CyShutdownEvent ev =  new CyShutdownEvent(ShutdownHandler.this);
                eh.fireEvent( ev );
 
-               // TODO figure out a way to do a clean shutdown of the OSGi 
container.
                if ( ev.actuallyShutdown() )
-                       System.exit(retVal);
+                       try {
+                               rootBundle.stop();
+                       } catch (BundleException e) {
+                               logger.error("Error while shutting down", e);
+                       }
                else
                        logger.info("NOT shutting down, per listener 
instruction: " + ev.abortShutdownReason() );
        }

Deleted: 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/ShutdownHandler.java
===================================================================
--- 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/ShutdownHandler.java
   2012-01-02 21:31:02 UTC (rev 27896)
+++ 
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/ShutdownHandler.java
   2012-01-02 21:47:24 UTC (rev 27897)
@@ -1,73 +0,0 @@
-
-/*
- File: ShutdownHandler.java
-
- Copyright (c) 2006, The Cytoscape Consortium (www.cytoscape.org)
-
- The Cytoscape Consortium is:
- - Institute for Systems Biology
- - University of California San Diego
- - Memorial Sloan-Kettering Cancer Center
- - Institut Pasteur
- - Agilent Technologies
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 2.1 of the License, or
- any later version.
-
- This library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
- MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
- documentation provided hereunder is on an "as is" basis, and the
- Institute for Systems Biology and the Whitehead Institute
- have no obligations to provide maintenance, support,
- updates, enhancements or modifications.  In no event shall the
- Institute for Systems Biology and the Whitehead Institute
- be liable to any party for direct, indirect, special,
- incidental or consequential damages, including lost profits, arising
- out of the use of this software and its documentation, even if the
- Institute for Systems Biology and the Whitehead Institute
- have been advised of the possibility of such damage.  See
- the GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-
-package org.cytoscape.internal;
-
-import org.cytoscape.application.CyShutdown;
-import org.cytoscape.application.events.CyShutdownEvent;
-import org.cytoscape.application.events.CyShutdownListener;
-import org.cytoscape.event.CyEventHelper;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * 
- */
-public class ShutdownHandler implements CyShutdown {
-
-       private static final Logger logger = 
LoggerFactory.getLogger(ShutdownHandler.class);
-       private final CyEventHelper eh;
-       private boolean actuallyShutdown;
-
-       public ShutdownHandler(CyEventHelper eh) {
-               this.eh = eh;
-       }
-
-       public void exit(int retVal) {
-               actuallyShutdown = true;
-               CyShutdownEvent ev =  new CyShutdownEvent(ShutdownHandler.this);
-               eh.fireEvent( ev );
-
-               // TODO figure out a way to do a clean shutdown of the OSGi 
container.
-               if ( ev.actuallyShutdown() )
-                       System.exit(retVal);
-               else
-                       logger.info("NOT shutting down, per listener 
instruction: " + ev.abortShutdownReason() );
-       }
-}

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