Commit 47c9b673 authored by Jay Jay Billings's avatar Jay Jay Billings

Addressed #347.

This commit shows how to fix all instances of busted DS services for
#347. This cases fixes it for the materials database.
Signed-off-by: default avatarJay Jay Billings <billingsjj@ornl.gov>
parent 1287e566
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" enabled="true" immediate="true" name="org.eclipse.ice.materials.ui">
<implementation class="org.eclipse.ice.materials.ui.MaterialsDatabaseServiceHolder"/>
<reference bind="set" cardinality="1..1" interface="org.eclipse.ice.materials.IMaterialsDatabase" name="IMaterialsDatabase" policy="static"/>
<reference bind="set" cardinality="1..1" interface="org.eclipse.ice.materials.IMaterialsDatabase" name="IMaterialsDatabase" policy="dynamic"/>
</scr:component>
......@@ -48,7 +48,8 @@ public class EditMaterialsDatabaseHandler extends AbstractHandler {
// Open the editor
try {
IMaterialsDatabase database = MaterialsDatabaseServiceHolder.get();
MaterialsDatabaseServiceHolder serviceHolder = new MaterialsDatabaseServiceHolder();
IMaterialsDatabase database = serviceHolder.get();
IEditorInput input = new MaterialsDatabaseEditorInput(database);
page.openEditor(input, MaterialsDatabaseEditor.ID);
} catch (PartInitException e) {
......
......@@ -20,7 +20,8 @@ import org.slf4j.LoggerFactory;
/**
* This is a simple class that catches the active Materials Database service and
* holds the reference for the Materials UI. It is a singleton.
* holds the reference for the Materials UI. It is a singleton, which is not
* ideal but in this instance convenient.
*
* This class has no tests because it is a simple bean.
*
......@@ -46,7 +47,7 @@ public class MaterialsDatabaseServiceHolder {
* @param database
* The database service
*/
public static void set(IMaterialsDatabase database) {
public void set(IMaterialsDatabase database) {
materialsDB = database;
logger.info("MaterialsDatabaseServiceHolder Message: "
+ "Service Handle Received!");
......@@ -57,7 +58,7 @@ public class MaterialsDatabaseServiceHolder {
*
* @return The database service
*/
public static IMaterialsDatabase get() {
public IMaterialsDatabase get() {
return materialsDB;
}
......
......@@ -44,8 +44,9 @@ public class MaterialsDatabaseTester extends AbstractSWTTester {
// Don't create a shell or bot for these tests.
// Switch the IMaterialsDatabase service to the test database.
realDatabase = MaterialsDatabaseServiceHolder.get();
MaterialsDatabaseServiceHolder.set(new FakeMaterialsDatabase());
MaterialsDatabaseServiceHolder serviceHolder = new MaterialsDatabaseServiceHolder();
realDatabase = serviceHolder.get();
serviceHolder.set(new FakeMaterialsDatabase());
}
......@@ -417,7 +418,8 @@ public class MaterialsDatabaseTester extends AbstractSWTTester {
*/
@Override
public void afterAllTests() {
MaterialsDatabaseServiceHolder.set(realDatabase);
MaterialsDatabaseServiceHolder serviceHolder = new MaterialsDatabaseServiceHolder();
serviceHolder.set(realDatabase);
}
}
......
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