Commit 58124022 authored by yannick legoc's avatar yannick legoc

Reimplemented ServantManager with Cameo.

parent 3f754319
......@@ -193,11 +193,6 @@
<arg line="${idlFlags} ${idlCoreDir}/SessionGateway.idl" />
</exec>
<echo message="Generating ServantManager.java" />
<exec executable="idl">
<arg line="${idlFlags} ${idlCoreDir}/ServantManager.idl" />
</exec>
<echo message="Generating CommandZoneAccessor.java" />
<exec executable="idl">
<arg line="${idlFlags} ${idlCoreDir}/commandzone/CommandZoneAccessor.idl" />
......@@ -356,6 +351,11 @@
<exec executable="protoc">
<arg line="${protoFlags} ${protoDir}/DatabaseRequests.proto" />
</exec>
<echo message="Generating ServantManagerRequests.java" />
<exec executable="protoc">
<arg line="${protoFlags} ${protoDir}/ServantManagerRequests.proto" />
</exec>
</target>
</configuration>
......
......@@ -76,7 +76,7 @@ public class DataAccessor {
databaseRequester = Application.Requester.create(nomad, "database");
} catch (RequesterCreationException e) {
System.err.println("Problem to connect to the database responder");
System.err.println("Problem to connect to the database responder: " + e.getMessage());
return;
}
......
......@@ -150,13 +150,6 @@ public class LogSubscriber {
// Define the log publisher.
String logPublisherName = "log_publisher";
// Do not connect to the same application if it is simulated.
if (!serverId.equals(CommandZoneWrapper.SERVER_ID)) {
// Add the server id to the publisher name.
logPublisherName += serverId;
}
System.out.println("Trying to connect log subscriber to " + logPublisherName);
// Create the subscriber.
......
......@@ -18,14 +18,14 @@
package fr.ill.ics.nscclient.servant;
import fr.ill.ics.nscclient.servant.CorbaServantManager.LoadConfigurationFailure;
import fr.ill.ics.nscclient.sessionmanagement.ServerSessionManager;
import fr.ill.ics.nscclient.dataprovider.ServantManagerAccessor;
import fr.ill.ics.nscclient.dataprovider.ServantManagerAccessor.LoadConfigurationFailure;
public class ConfigurationManager {
private static ConfigurationManager instance = null;
private String serverId;
private CorbaServantManager servantManager;
private ServantManagerAccessor servantManagerAccessor;
public class LoadFailure extends Exception {}
......@@ -54,14 +54,15 @@ public class ConfigurationManager {
*
*/
protected void init() throws LoadFailure {
this.servantManager = ServerSessionManager.getInstance(serverId).getServantManager();
this.servantManagerAccessor = ServantManagerAccessor.getInstance(serverId);
loadWholeConfiguration();
}
public void loadWholeConfiguration() throws LoadFailure {
try {
servantManager.loadWholeConfiguration();
servantManagerAccessor.loadWholeConfiguration();
} catch (LoadConfigurationFailure e) {
throw new LoadFailure();
}
......
......@@ -33,6 +33,8 @@ import fr.ill.ics.bridge.Controller;
import fr.ill.ics.bridge.ControllerManager;
import fr.ill.ics.bridge.listeners.ServerConfigurationChangeListener;
import fr.ill.ics.nscclient.dataprovider.ServantDatabase;
import fr.ill.ics.nscclient.dataprovider.ServantManagerAccessor;
import fr.ill.ics.nscclient.dataprovider.ServantManagerAccessor.LoadConfigurationFailure;
import fr.ill.ics.nscclient.sessionmanagement.ServerSessionManager;
import fr.ill.ics.util.exception.ControllerNotFoundException;
......@@ -41,7 +43,6 @@ public class CorbaControllerManager extends ControllerManager implements ServerC
private String serverId;
private HashMap<String, LinkedHashSet<String>> visibleControllerNamesByType; // KEY=controller type VALUE=list of matching controller names
private HashMap<String, LinkedHashSet<String>> allControllerNamesByType; // KEY=controller type VALUE=list of matching controller names
private CorbaServantManager servantManager;
/**
*
......@@ -56,13 +57,16 @@ public class CorbaControllerManager extends ControllerManager implements ServerC
*
*/
protected void init() {
this.servantManager = ServerSessionManager.getInstance(serverId).getServantManager();
fillControllerNamesByTypeMaps();
}
protected void reset() {
this.servantManager = ServerSessionManager.getInstance(serverId).getServantManager();
servantManager.updateWholeConfiguration();
try {
ServantManagerAccessor.getInstance(serverId).updateWholeConfiguration();
} catch (LoadConfigurationFailure e) {
System.err.println("Unable to update the whole configuration");
}
fillControllerNamesByTypeMaps();
}
......@@ -73,7 +77,7 @@ public class CorbaControllerManager extends ControllerManager implements ServerC
public CorbaController getController(String controllerName) {
ClientServantDescriptor descriptor = ServantDatabase.getInstance().getControllerDescriptor(controllerName);
if (descriptor != null) {
CorbaController controller = servantManager.getController(descriptor);
CorbaController controller = ServantManagerAccessor.getInstance(serverId).getController(descriptor);
return controller;
}
ControllerNotFoundException cnfe = new ControllerNotFoundException(controllerName, "", getClass().getCanonicalName(), "getController");
......@@ -83,7 +87,7 @@ public class CorbaControllerManager extends ControllerManager implements ServerC
public CorbaController cloneController(String controllerName) throws ControllerNotFoundException {
ClientServantDescriptor descriptor = ServantDatabase.getInstance().getControllerDescriptor(controllerName);
if (descriptor != null) {
CorbaController controller = servantManager.cloneController(descriptor);
CorbaController controller = ServantManagerAccessor.getInstance(serverId).cloneController(descriptor);
return controller;
}
ControllerNotFoundException cnfe = new ControllerNotFoundException(controllerName, "", getClass().getCanonicalName(), "cloneController");
......@@ -93,7 +97,7 @@ public class CorbaControllerManager extends ControllerManager implements ServerC
public void removeController(String controllerName) {
ClientServantDescriptor descriptor = ServantDatabase.getInstance().getControllerDescriptor(controllerName);
if (descriptor != null) {
servantManager.removeController(descriptor);
ServantManagerAccessor.getInstance(serverId).removeController(descriptor);
}
}
......@@ -117,7 +121,7 @@ public class CorbaControllerManager extends ControllerManager implements ServerC
public HashMap<String, LinkedHashMap<String, String>> getPropertiesForGeneric() {
return servantManager.getPropertiesForGeneric();
return ServantManagerAccessor.getInstance(serverId).getPropertiesForGeneric();
}
......@@ -276,14 +280,14 @@ public class CorbaControllerManager extends ControllerManager implements ServerC
public void updateDynamicProperties(Controller controller) {
CorbaController corbaController = (CorbaController)controller;
servantManager.updateDynamicProperties(corbaController.getId());
ServantManagerAccessor.getInstance(serverId).updateDynamicProperties(corbaController.getId());
}
public void configurationChanged(int servantID, ClientEnableState enable) {
// the reload of controllers is not made here but in the CommandsSelectionPlugin
// and SettingsSelectionPlugin classes
servantManager.updateDynamicProperties(servantID);
ServantManagerAccessor.getInstance(serverId).updateDynamicProperties(servantID);
}
......@@ -295,6 +299,6 @@ public class CorbaControllerManager extends ControllerManager implements ServerC
public String getControllerNameWithRole(Controller controller, String role) {
CorbaController corbaController = (CorbaController)controller;
return servantManager.getControllerNameWithRole(corbaController.getId(), role);
return ServantManagerAccessor.getInstance(serverId).getControllerNameWithRole(corbaController.getId(), role);
}
}
\ No newline at end of file
......@@ -29,25 +29,24 @@ import java.util.TreeMap;
import fr.ill.ics.bridge.DriverManager;
import fr.ill.ics.nscclient.dataprovider.ServantDatabase;
import fr.ill.ics.nscclient.dataprovider.ServantManagerAccessor;
import fr.ill.ics.nscclient.sessionmanagement.ServerSessionManager;
public class CorbaDriverManager extends DriverManager {
private String serverId;
private CorbaServantManager servantManager;
public CorbaDriverManager(String serverId) {
this.serverId = serverId;
}
protected void init() {
this.servantManager = ServerSessionManager.getInstance(serverId).getServantManager();
}
public CorbaDriver getDriver(String driverName) {
ClientServantDescriptor descriptor = ServantDatabase.getInstance().getDriverDescriptor(driverName);
if (descriptor != null) {
CorbaDriver driver = servantManager.getDriver(descriptor);
CorbaDriver driver = ServantManagerAccessor.getInstance(serverId).getDriver(descriptor);
return driver;
}
return null;
......@@ -83,7 +82,7 @@ public class CorbaDriverManager extends DriverManager {
Map<String, Map<String, String>> allChildren = new LinkedHashMap<String, Map<String, String>>();
List<String> children = servantManager.getChildServants(descriptor.getId());
List<String> children = ServantManagerAccessor.getInstance(serverId).getChildServants(descriptor.getId());
Iterator<String> it = children.iterator();
while (it.hasNext()) {
......@@ -117,11 +116,7 @@ public class CorbaDriverManager extends DriverManager {
public void setPaused(boolean isPaused) {
servantManager.pauseSpies(isPaused);
if (!isPaused) {
servantManager.initDriversAndProtocols();
}
ServantManagerAccessor.getInstance(serverId).pauseSpies(isPaused);
}
......@@ -137,7 +132,7 @@ public class CorbaDriverManager extends DriverManager {
public void reconnectDriver(String driverName) {
CorbaDriver driver = getDriver(driverName);
if (driver != null) {
servantManager.reconnectDriver(driver.getDatabaseId(), driver.getId());
ServantManagerAccessor.getInstance(serverId).reconnectDriver(driver.getDatabaseId(), driver.getId());
}
}
......
......@@ -19,12 +19,11 @@
package fr.ill.ics.nscclient.servant;
import fr.ill.ics.bridge.ResourceManager;
import fr.ill.ics.nscclient.sessionmanagement.ServerSessionManager;
import fr.ill.ics.nscclient.dataprovider.ServantManagerAccessor;
public class CorbaResourceManager extends ResourceManager {
private String serverId;
private CorbaServantManager servantManager;
/**
*
......@@ -37,23 +36,21 @@ public class CorbaResourceManager extends ResourceManager {
*
*/
protected void init() {
this.servantManager = ServerSessionManager.getInstance(serverId).getServantManager();
}
protected void reset() {
this.servantManager = ServerSessionManager.getInstance(serverId).getServantManager();
}
public String[] getResourceFilesByExtension(String extension) {
return servantManager.getResourceFilesByExtension(extension);
return ServantManagerAccessor.getInstance(serverId).getResourceFilesByExtension(extension);
}
public byte[] getBinaryFileContent(String controllerType, String fileName) throws ResourceNotFoundException {
return servantManager.readBinaryResourceFile(controllerType, fileName);
return ServantManagerAccessor.getInstance(serverId).readBinaryResourceFile(controllerType, fileName);
}
public String getFileContent(String controllerType, String fileName) throws ResourceNotFoundException {
return servantManager.readResourceFile(controllerType, fileName);
return ServantManagerAccessor.getInstance(serverId).readResourceFile(controllerType, fileName);
/*
String fullFilePath = "/home/dpt/ortizh/tmp/" + fileName;
......@@ -82,8 +79,7 @@ public class CorbaResourceManager extends ResourceManager {
System.out.println("H.ORTIZ: call to writeResourceFile commented .................................................." + fileName);
// servantManager.writeResourceFile(controllerType, fileName, content);
//ServantManagerAccessor.getInstance(serverId).writeResourceFile(controllerType, fileName, content);
/*
......
......@@ -56,7 +56,7 @@ public class ServerInstance {
}
} else {
// Find the real instance.
String[] nomadAppNames = { "ns", "nsd", "nsv" };
String[] nomadAppNames = { "ns", "nsd", "nsg", "nsv" };
try {
for (String appName : nomadAppNames) {
nomad = server.connect(appName);
......
......@@ -24,23 +24,22 @@ import org.omg.PortableServer.POAPackage.ServantNotActive;
import org.omg.PortableServer.POAPackage.WrongAdapter;
import org.omg.PortableServer.POAPackage.WrongPolicy;
import fr.ill.ics.cameo.Application;
import fr.ill.ics.nomadserver.common.DataChangeSubscriber;
import fr.ill.ics.nomadserver.common.DataChangeSubscriberHelper;
import fr.ill.ics.nomadserver.core.SessionGateway;
import fr.ill.ics.nscclient.corbabase.CorbaORB;
import fr.ill.ics.nscclient.notification.DataChangeSubscriberImpl;
import fr.ill.ics.nscclient.servant.CorbaServantManager;
public class CorbaSessionGateway {
private CorbaServantManager servantManager;
private Application.Requester servantManagerRequester;
private SessionGateway sessionGateway;
private DataChangeSubscriberImpl dataChangeSubscriberImpl;
public CorbaSessionGateway(SessionGateway sessionGateway) {
this.sessionGateway = sessionGateway;
this.servantManager = new CorbaServantManager(sessionGateway.getServantManager());
subscribeToDataChangePublisher();
}
......@@ -54,11 +53,6 @@ public class CorbaSessionGateway {
System.err.println("unable to logout from session gateway");
}
}
public CorbaServantManager getServantManager() {
return servantManager;
}
private void subscribeToDataChangePublisher() {
try {
......
......@@ -35,11 +35,11 @@ import fr.ill.ics.nscclient.command.ScanCommandBoxAccessorProxy;
import fr.ill.ics.nscclient.commandline.CommandLineProxyImpl;
import fr.ill.ics.nscclient.condition.ConditionManagerProxy;
import fr.ill.ics.nscclient.dataprovider.DataAccessor;
import fr.ill.ics.nscclient.dataprovider.ServantManagerAccessor;
import fr.ill.ics.nscclient.log.LogSubscriber;
import fr.ill.ics.nscclient.notification.commandzone.ServerCommandZoneEventManager;
import fr.ill.ics.nscclient.servant.ConfigurationManager;
import fr.ill.ics.nscclient.servant.ConfigurationManager.LoadFailure;
import fr.ill.ics.nscclient.servant.CorbaServantManager;
import fr.ill.ics.nscclient.serverconnection.ServerInstance;
import fr.ill.ics.nscclient.survey.SurveySubcriberImpl;
......@@ -68,10 +68,9 @@ public class ServerSessionManager {
throw new ConnectionFailure();
}
// initialise DataAccessor
DataAccessor.getInstance(serverId).init();
ServantManagerAccessor.getInstance(serverId).init();
// initialise all commandzone accessors
CommandZoneAccessorProxy.getInstance(serverId).init();
CommandBoxAccessorProxy.getInstance(serverId).init();
AtomicCommandBoxAccessorProxy.getInstance(serverId).init();
......@@ -129,6 +128,7 @@ public class ServerSessionManager {
// initialise DataAccessor
DataAccessor.getInstance(serverId).init();
ServantManagerAccessor.getInstance(serverId).init();
if (currentSession != null) {
currentSession.logout();
......@@ -155,6 +155,7 @@ public class ServerSessionManager {
SurveySubcriberImpl.getInstance(serverId).unsubscribe();
DataAccessor.getInstance(serverId).reset();
ServantManagerAccessor.getInstance(serverId).reset();
currentSession.logout();
currentSession = null;
......@@ -180,9 +181,9 @@ public class ServerSessionManager {
currentSession = null;
}
}
public CorbaServantManager getServantManager() {
return currentSession.getServantManager();
public ServantManagerAccessor getServantManagerAccessor() {
return ServantManagerAccessor.getInstance(serverId);
}
public boolean isLogged() {
......
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