Commit 5b55d091 authored by helene ortiz's avatar helene ortiz
Browse files

Modifications for 0-crash version

parent ffc64272
...@@ -28,6 +28,7 @@ import java.util.Set; ...@@ -28,6 +28,7 @@ import java.util.Set;
import fr.ill.ics.bridge.listeners.ServerConfigurationChangeListener; import fr.ill.ics.bridge.listeners.ServerConfigurationChangeListener;
import fr.ill.ics.nscclient.notification.DataNotificationClient; import fr.ill.ics.nscclient.notification.DataNotificationClient;
import fr.ill.ics.nscclient.servant.CorbaControllerManager; import fr.ill.ics.nscclient.servant.CorbaControllerManager;
import fr.ill.ics.util.exception.ControllerNotFoundException;
...@@ -71,7 +72,7 @@ public abstract class ControllerManager { ...@@ -71,7 +72,7 @@ public abstract class ControllerManager {
public abstract Set getStartedControllers(); public abstract Set getStartedControllers();
public abstract Controller getController(String controllerName); public abstract Controller getController(String controllerName);
public abstract Controller cloneController(String controllerName); public abstract Controller cloneController(String controllerName) throws ControllerNotFoundException;
public abstract void removeController(String controllerName); public abstract void removeController(String controllerName);
public abstract String getFamily(String controllerName); public abstract String getFamily(String controllerName);
......
...@@ -80,14 +80,14 @@ public class CorbaControllerManager extends ControllerManager implements ServerC ...@@ -80,14 +80,14 @@ public class CorbaControllerManager extends ControllerManager implements ServerC
return null; return null;
} }
public CorbaController cloneController(String controllerName) { public CorbaController cloneController(String controllerName) throws ControllerNotFoundException {
ClientServantDescriptor descriptor = ServantDatabase.getInstance().getControllerDescriptor(controllerName); ClientServantDescriptor descriptor = ServantDatabase.getInstance().getControllerDescriptor(controllerName);
if (descriptor != null) { if (descriptor != null) {
CorbaController controller = servantManager.cloneController(descriptor); CorbaController controller = servantManager.cloneController(descriptor);
return controller; return controller;
} }
ControllerNotFoundException cnfe = new ControllerNotFoundException(controllerName, "", getClass().getCanonicalName(), "cloneController"); ControllerNotFoundException cnfe = new ControllerNotFoundException(controllerName, "", getClass().getCanonicalName(), "cloneController");
return null; throw cnfe;
} }
public void removeController(String controllerName) { public void removeController(String controllerName) {
......
...@@ -39,6 +39,7 @@ import java.util.logging.Level; ...@@ -39,6 +39,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import fr.ill.ics.util.exception.ConfigurationException; import fr.ill.ics.util.exception.ConfigurationException;
import fr.ill.ics.util.exception.ParticularWidgetNotFoundException;
import fr.ill.ics.util.exception.PropertyNotFoundException; import fr.ill.ics.util.exception.PropertyNotFoundException;
/** /**
...@@ -483,13 +484,22 @@ public class ConfigManager { ...@@ -483,13 +484,22 @@ public class ConfigManager {
if (configurationException instanceof PropertyNotFoundException) { if (configurationException instanceof PropertyNotFoundException) {
PropertyNotFoundException pnfe = (PropertyNotFoundException)configurationException; PropertyNotFoundException pnfe = (PropertyNotFoundException)configurationException;
if (pnfe.getControllerType().equals(controllerType) && pnfe.getControllerName().equals(controllerName)) { if (pnfe.getControllerName().equals(controllerName)) {
if (set == null) { if (set == null) {
set = new HashSet<ConfigurationException>(); set = new HashSet<ConfigurationException>();
} }
set.add(pnfe); set.add(pnfe);
} }
} else if (configurationException instanceof ParticularWidgetNotFoundException) {
ParticularWidgetNotFoundException pwnfe = (ParticularWidgetNotFoundException)configurationException;
if (pwnfe.getControllerName().equals(controllerName)) {
if (set == null) {
set = new HashSet<ConfigurationException>();
}
set.add(configurationException);
}
} else if (configurationException instanceof ConfigurationException) { } else if (configurationException instanceof ConfigurationException) {
if (configurationException.getControllerType().equals(controllerType)) { if (configurationException.getControllerType().equals(controllerType)) {
if (set == null) { if (set == null) {
......
...@@ -29,7 +29,7 @@ public class ControllerNotFoundException extends ConfigurationException { ...@@ -29,7 +29,7 @@ public class ControllerNotFoundException extends ConfigurationException {
private final static String DEFAULT_MESSAGE = ConfigManager.getInstance().getString("controllerNotFoundExceptionMessage"); private final static String DEFAULT_MESSAGE = ConfigManager.getInstance().getString("controllerNotFoundExceptionMessage");
private String controllerName; private String controllerName;
public ControllerNotFoundException(String controllerName, String controllerType, String className, String methodName) { public ControllerNotFoundException(String controllerName, String controllerType, String className, String methodName) {
super(DEFAULT_MESSAGE, controllerType, null, className, methodName); super(DEFAULT_MESSAGE, controllerType, null, className, methodName);
this.controllerName = controllerName; this.controllerName = controllerName;
...@@ -39,8 +39,8 @@ public class ControllerNotFoundException extends ConfigurationException { ...@@ -39,8 +39,8 @@ public class ControllerNotFoundException extends ConfigurationException {
private String getControllerName() { private String getControllerName() {
return controllerName; return controllerName;
} }
public boolean equals(Object object) { public boolean equals(Object object) {
if (this == object) { if (this == object) {
return true; return true;
...@@ -49,29 +49,31 @@ public class ControllerNotFoundException extends ConfigurationException { ...@@ -49,29 +49,31 @@ public class ControllerNotFoundException extends ConfigurationException {
return false; return false;
} }
ControllerNotFoundException controllerNotFoundException = (ControllerNotFoundException)object; ControllerNotFoundException controllerNotFoundException = (ControllerNotFoundException)object;
if (this.controllerName.equals(controllerNotFoundException.getControllerName())) { if (this.controllerName.equals(controllerNotFoundException.getControllerName())) {
if (this.controllerName != null) { if (this.controllerName != null) {
return (this.controllerName.equals(controllerNotFoundException.getControllerName())); return (this.controllerName.equals(controllerNotFoundException.getControllerName()));
} }
return (this.controllerType.equals(controllerNotFoundException.getControllerType())); if (this.controllerType != null) {
return (this.controllerType.equals(controllerNotFoundException.getControllerType()));
}
} }
return false; return false;
} }
public int hashCode() { public int hashCode() {
return (this.getMessage() + this.getControllerName() + this.getControllerType()).hashCode(); return (this.getMessage() + this.getControllerName() + this.getControllerType()).hashCode();
} }
protected void addToConfigManager() { protected void addToConfigManager() {
// Already called in constructor => must not do anything // Already called in constructor => must not do anything
} }
public String toString() { public String toString() {
return getMessage() + controllerName + (controllerType == null ? "" : " (controller type: " + controllerType +")") + "\n" + getClassName() + ".." + getMethodName(); return getMessage() + controllerName + (controllerType == null ? "" : " (controller type: " + controllerType +")") + "\n" + getClassName() + ".." + getMethodName();
} }
public String format() { public String format() {
return getMessage() + " " + controllerName; return getMessage() + " " + controllerName;
} }
......
/*
* 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.util.exception;
import fr.ill.ics.util.ConfigManager;
/**
*
* @author ortizh
*
*/
public class ParticularWidgetNotFoundException extends ConfigurationException {
private final static String DEFAULT_MESSAGE = ConfigManager.getInstance().getString("particularWidgetNotFoundExceptionMessage");
private String controllerName;
private String widgetKey;
public ParticularWidgetNotFoundException(String widgetKey, String controllerType, String controllerName, String className, String methodName) {
super(DEFAULT_MESSAGE, controllerType, null, className, methodName);
this.widgetKey = widgetKey;
this.controllerName = controllerName;
ConfigManager.getInstance().addConfigurationException(this);
}
public String getControllerName() {
return controllerName;
}
public void setControllerName(String controllerName) {
this.controllerName = controllerName;
}
public String getWidgetKey() {
return widgetKey;
}
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (!(object instanceof ParticularWidgetNotFoundException)) {
return false;
}
ParticularWidgetNotFoundException particularWidgetNotFoundException = (ParticularWidgetNotFoundException)object;
if (this.widgetKey.equals(particularWidgetNotFoundException.getWidgetKey())) {
if (this.controllerName != null) {
return (this.controllerName.equals(particularWidgetNotFoundException.getControllerName()));
}
return (this.controllerType.equals(particularWidgetNotFoundException.getControllerType()));
}
return false;
}
public int hashCode() {
return (this.getMessage() + this.getWidgetKey() + this.getControllerName() + this.getControllerType()).hashCode();
}
public String toString() {
return getMessage() + widgetKey + (controllerName == null ? "" : " (controller name: " + controllerName +")") + (controllerType == null ? "" : " (controller type: " + controllerType +")") + "\n" + getClassName() + ".." + getMethodName();
}
public String format() {
return getMessage() + " " + widgetKey;
}
protected void addToConfigManager() {
// Already called in constructor => must not do anything
}
}
...@@ -41,7 +41,6 @@ public class PropertyNotFoundException extends ConfigurationException { ...@@ -41,7 +41,6 @@ public class PropertyNotFoundException extends ConfigurationException {
super(DEFAULT_MESSAGE, controllerType, null, className, methodName); super(DEFAULT_MESSAGE, controllerType, null, className, methodName);
this.propertyName = propertyName; this.propertyName = propertyName;
this.controllerName = controllerName; this.controllerName = controllerName;
this.controllerType = controllerType;
ConfigManager.getInstance().addConfigurationException(this); ConfigManager.getInstance().addConfigurationException(this);
} }
......
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