Commit d8a9ff67 authored by yannick legoc's avatar yannick legoc

First introduction of Protocol buffers in the configuration loading

parent 4f324ebe
......@@ -5,5 +5,6 @@
<classpathentry kind="lib" path="lib64/avalon-framework-4.2.0.jar"/>
<classpathentry kind="lib" path="lib64/jacorb.jar"/>
<classpathentry kind="lib" path="lib64/logkit-2.0.jar"/>
<classpathentry kind="lib" path="lib64/protobuf-2.5.0.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
......@@ -19,6 +19,9 @@
<property name="clientCalculatorLibDir" value="${env.NOMADCLIENT_HOME}/lib/common/calculator" />
<property name="clientCalculatorLib64Dir" value="${env.NOMADCLIENT_HOME}/lib64/common/calculator" />
<property name="idlFlags" value="-d ${src} -sloppy_forward" />
<property name="protoFlags" value="-I${env.NOMAD_HOME}/src/common/protobuf/proto --java_out=${src}"/>
<property name="protoDir" value="${env.NOMAD_HOME}/src/common/protobuf/proto"/>
<target name="init">
<!-- Create the time stamp -->
......@@ -266,6 +269,12 @@
</exec>
</target>
<target name="proto" depends="init">
<exec executable="protoc">
<arg line="${protoFlags} ${protoDir}/ServantConfiguration.proto" />
</exec>
</target>
<target name="jar">
<echo message="Creating nomadCommandSystem.jar" />
......
......@@ -22,6 +22,7 @@ import java.util.Properties;
import fr.ill.ics.nscclient.corbabase.CorbaNamingService;
import fr.ill.ics.nscclient.corbabase.CorbaORB;
import fr.ill.ics.nscclient.servant.ConfigurationManager.LoadFailure;
import fr.ill.ics.nscclient.serverconnection.ServerConnection;
import fr.ill.ics.nscclient.sessionmanagement.CorbaSessionManager;
import fr.ill.ics.nscclient.sessionmanagement.ServerSessionManager;
......@@ -69,7 +70,10 @@ public class LoginManager {
throw new ClientAlreadyLaunchedException();
} catch (ServerSessionManager.ConnectionFailure e) {
throw new ConnectionFailure();
} catch (LoadFailure e) {
throw new ConnectionFailure();
}
}
......
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
package fr.ill.ics.nscclient.servant;
import java.io.IOException;
import fr.ill.ics.nscclient.servant.CorbaServantManager.LoadConfigurationFailure;
import fr.ill.ics.nscclient.sessionmanagement.ServerSessionManager;
public class ConfigurationManager {
private static ConfigurationManager instance = null;
private String serverId;
private CorbaServantManager servantManager;
public class LoadFailure extends Exception {}
public static ConfigurationManager getInstance() {
return instance;
}
public static void initInstance(String serverId) throws LoadFailure {
instance = new ConfigurationManager(serverId);
instance.init();
}
public static void resetInstance() {
instance = null;
}
/**
*
*/
private ConfigurationManager(String serverId) {
this.serverId = serverId;
}
/**
* @throws LoadFailure
*
*/
protected void init() throws LoadFailure {
this.servantManager = ServerSessionManager.getInstance(serverId).getServantManager();
loadWholeConfiguration();
}
public void loadWholeConfiguration() throws LoadFailure {
try {
servantManager.loadWholeConfiguration();
} catch (LoadConfigurationFailure e) {
throw new LoadFailure();
}
}
}
\ No newline at end of file
......@@ -23,11 +23,8 @@ import fr.ill.ics.nomadserver.core.Controller;
public class CorbaController extends CorbaServant {
private Controller controller;
public CorbaController(int databaseId, int servantId, Controller controller, ClientServantDescriptor descriptor) {
super(databaseId, servantId, controller, descriptor);
this.controller = controller;
}
}
\ No newline at end of file
......@@ -55,6 +55,11 @@ 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();
List controllersList = servantManager.getControllers();
......@@ -270,7 +275,7 @@ public class CorbaControllerManager extends ControllerManager implements ServerC
// reset controller information
ServantDatabase.getInstance().clearControllers();
init();
reset();
}
......
......@@ -19,19 +19,17 @@
package fr.ill.ics.nscclient.servant;
import fr.ill.ics.nomadserver.core.Driver;
import fr.ill.ics.nomadserver.core.DriverPackage.DriverMode;
public class CorbaDriver extends CorbaServant {
public enum Mode {REAL, SIMULATED, PERFECT};
private Driver driver;
private Mode mode = Mode.REAL;
private Long channel;
public CorbaDriver(int databaseId, int servantId, Driver driver, ClientServantDescriptor descriptor) {
super(databaseId, servantId, driver, descriptor);
this.driver = driver;
}
public void setChannel(long channel) {
......@@ -41,19 +39,13 @@ public class CorbaDriver extends CorbaServant {
public Long getChannel() {
return channel;
}
public void setMode(Mode mode) {
this.mode = mode;
}
public Mode getMode() {
DriverMode corbaMode = driver.getMode(getDatabaseId());
if (corbaMode == DriverMode.REAL) {
return Mode.REAL;
} else if (corbaMode == DriverMode.SIMULATED) {
return Mode.SIMULATED;
} else if (corbaMode == DriverMode.PERFECT) {
return Mode.PERFECT;
}
return Mode.REAL;
return mode;
}
}
\ No newline at end of file
......@@ -19,6 +19,7 @@
package fr.ill.ics.nscclient.sessionmanagement;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
......@@ -39,6 +40,8 @@ import fr.ill.ics.nscclient.console.DataProviderRemoteConsole;
import fr.ill.ics.nscclient.dataprovider.DataAccessor;
import fr.ill.ics.nscclient.log.LogSubcriberImpl;
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.survey.SurveySubcriberImpl;
......@@ -102,7 +105,7 @@ public class ServerSessionManager {
return instances.get(serverId);
}
public void login(boolean standAlone) throws CorbaSessionManager.ClientAlreadyLaunchedException, ConnectionFailure {
public void login(boolean standAlone) throws CorbaSessionManager.ClientAlreadyLaunchedException, ConnectionFailure, LoadFailure {
init();
......@@ -116,6 +119,8 @@ public class ServerSessionManager {
// - simulated server with no real server logged
// This is because ControllerManager and DriverManager are accessed by getInstance() without any serverId
if (serverId.equals("real") || (!serverId.equals("real") && !getInstance("real").isLogged())) {
ConfigurationManager.initInstance(serverId);
ControllerManager.initInstance(serverId);
DriverManager.initInstance(serverId);
}
......
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