Commit b9c5bb54 authored by Philippe Merle's avatar Philippe Merle

- Revisited how FraSCAti closes SCA composites.

  Used CompositeManager.removeComposite() instead of TinfiDomain.close() in order to release the composite more properly.
- Revisited how FraSCAti closes itself.
  Closed all running SCA composites before closing FraSCAti.
parent c208dc88
......@@ -45,7 +45,6 @@ import org.ow2.frascati.assembly.factory.api.CompositeManager;
import org.ow2.frascati.assembly.factory.api.ProcessingContext;
import org.ow2.frascati.assembly.factory.api.ProcessingMode;
import org.ow2.frascati.component.factory.api.MembraneGeneration;
import org.ow2.frascati.tinfi.TinfiDomain;
import org.ow2.frascati.util.AbstractFractalLoggeable;
import org.ow2.frascati.util.FrascatiClassLoader;
import org.ow2.frascati.util.FrascatiException;
......@@ -394,12 +393,14 @@ public class FraSCAti
* @throws FrascatiException
*/
public final void close(Component composite) throws FrascatiException {
// Closing the SCA domain.
// Closing the SCA composite.
String compositeName = "";
try {
log.info("Closing the SCA composite '" + composite + "'.");
TinfiDomain.close(composite);
compositeName = getFractalComponentName(composite);
log.info("Closing the SCA composite '" + compositeName + "'.");
getCompositeManager().removeComposite(compositeName);
} catch (Exception exc) {
severe(new FrascatiException("Impossible to stop the SCA composite '" + composite + "'!", exc));
severe(new FrascatiException("Impossible to stop the SCA composite '" + compositeName + "'!", exc));
return;
}
}
......@@ -410,6 +411,19 @@ public class FraSCAti
* @throws FrascatiException
*/
public final void close() throws FrascatiException {
// Close all running SCA composites.
for(String compositeName : getCompositeManager().getCompositeNames()) {
// Close the FraSCAti composite after closing all other composites.
if(compositeName.equals(FRASCATI_COMPOSITE_DEFAULT_VALUE)) {
continue;
}
try {
getCompositeManager().removeComposite(compositeName);
} catch (Exception exc) {
log.warning("Can't close the SCA composite '" + compositeName + "'.");
}
}
// Closing the FraSCAti composite.
close(this.frascatiComposite);
this.frascatiComposite = null;
......
/**
* OW2 FraSCAti Assembly Factory
* Copyright (C) 2008-2012 Inria, University of Lille 1
* Copyright (C) 2008-2013 Inria, University of Lille 1
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -14,7 +14,8 @@
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* Contact: frascati@ow2.org
*
......@@ -151,14 +152,12 @@ public class AssemblyFactoryManager
* Used to share resources between composite deployed at runtime
*/
private List<ImportExportFrascatiClassLoader> exportFrascatiClassLoaders=new ArrayList<ImportExportFrascatiClassLoader>();
/**
* Map of all processingContext used to process composite (entry composite's name)
*/
private Map<String, ProcessingContext> mapOfProcessingContext=new HashMap<String, ProcessingContext>();
/**
* Map of loaded composites.
*/
......@@ -252,8 +251,7 @@ public class AssemblyFactoryManager
fcl.addParent(this.mainClassLoader);
return new ProcessingContextImpl(fcl);
}
/**
* @see org.ow2.frascati.assembly.factory.api.CompositeManager#getProcessingContext(java.lang.String)
*/
......@@ -772,7 +770,7 @@ public class AssemblyFactoryManager
throws ManagerException
{
// Retrieve component reference from its name
Component component = this.loadedComposites.get(name);
final Component component = this.loadedComposites.get(name);
if (component == null) {
severe(new ManagerException("Composite '" + name +"' does not exist"));
......@@ -787,9 +785,29 @@ public class AssemblyFactoryManager
// // Remove the processingContext from the saved processingContext
// this.mapOfProcessingContext.remove(name);
// log.info("Remove ProcessingContext realed to "+name+" comoposite");
// Stop the SCA component.
stopFractalComponent(component);
// Stop the SCA composite.
if(!name.equals("org.ow2.frascati.FraSCAti")) {
// If it is not the FraSCAti composite then just stop it.
stopFractalComponent(component);
} else {
// As a business call is inside the FraSCAti composite
// then stopping FraSCAti will block instead the current call is finished
// so this creates a deadlock.
// Stopping FraSCAti inside a new thread avoids this deadlock.
new Thread(
new Runnable() {
public void run()
{
try {
stopFractalComponent(component);
} catch(Exception exc) {
log.warning("Can't stop the FraSCAti composite!");
}
}
}
).start();
}
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment