Dear all, Please be informed that, due to an important technical maintenance, the Gitlab server (git.list.lu) will not be available on Thursday April 22nd, from 9 A.M. to 1 P.M. (Luxembourg Time Zone). Thank you for your understanding.

Commit a09afead authored by Nicolas Gilmard's avatar Nicolas Gilmard

Add modification in properties files for load adapter reflexively

parent f7dae866
......@@ -17,6 +17,9 @@ fontSize = 13
colour = BLACK
centred = false
# Adapter to load
tableAdapter = tuio
# Properties for the calibration of the object manager
#The value below is best left at or above 1024
cursorIDRemappingConstant = 1024
\ No newline at end of file
......@@ -15,7 +15,6 @@ package lu.list.itis.dkd.tui;
import lu.list.itis.dkd.tui.adapter.TangibleObject;
import lu.list.itis.dkd.tui.adapter.TuiAdapter;
import lu.list.itis.dkd.tui.adapter.TuioConcreteAdapter;
import lu.list.itis.dkd.tui.logging.EventLogger;
import lu.list.itis.dkd.tui.utility.GlobalContext;
import lu.list.itis.dkd.tui.utility.IDMapper;
......@@ -28,6 +27,7 @@ import com.google.common.base.Preconditions;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
import java.util.Properties;
import java.util.Vector;
......@@ -87,8 +87,9 @@ public abstract class TangibleApplication {
*
* @param newPropertiesFileURI
* The URI of the properties file to load.
* @throws Exception
*/
protected TangibleApplication(@Nullable String newPropertiesFileURI) {
protected TangibleApplication(@Nullable String newPropertiesFileURI) throws Exception {
if (newPropertiesFileURI != null && !newPropertiesFileURI.isEmpty()) {
propertiesFileURI = newPropertiesFileURI;
}
......@@ -104,14 +105,51 @@ public abstract class TangibleApplication {
interfaceManager = new TangibleInterfaceManager(this, logger, properties);
adapter = new TuioConcreteAdapter(interfaceManager);
try {
adapter = (TuiAdapter) Class.forName(properties.getProperty("tableAdapter")).getConstructor(TangibleInterfaceManager.class).newInstance(interfaceManager); //$NON-NLS-1$
} catch (InstantiationException e) {
logger.log(Level.SEVERE, "Cannot instantiate adapter.\n" //$NON-NLS-1$
+ "You try to instantiate an abstract class or an interface!"); //$NON-NLS-1$s
throw new Exception("Cannot instantiate adapter\n" //$NON-NLS-1$
+ "You try to instantiate an abstract class or an interface!", e); //$NON-NLS-1$
} catch (IllegalAccessException e) {
logger.log(Level.SEVERE, "The currently executing method does not have access to the definition of the constructor."); //$NON-NLS-1$
throw new IllegalAccessException("The currently executing method does not have access to the definition of the constructor."); //$NON-NLS-1$
} catch (IllegalArgumentException e) {
logger.log(Level.SEVERE, "A wrong argument has been passed to the adapter."); //$NON-NLS-1$
throw new Exception("A wrong argument has been passed to the adapter.\n+" //$NON-NLS-1$
+ "Required argument of type lu.list.itis.dkd.tui.TangibleInterfaceManager!", e); //$NON-NLS-1$
} catch (InvocationTargetException e) {
logger.log(Level.SEVERE, "An exception has been thrown in the constructor of the adapter"); //$NON-NLS-1$
throw new InvocationTargetException(e, "Une exception a été jeté dans le constructeur de l'adaptateur.\n+" //$NON-NLS-1$
+ "Check the constructor of " + properties.getProperty("tableAdapter")); //$NON-NLS-1$ //$NON-NLS-2$
} catch (NoSuchMethodException e) {
logger.log(Level.SEVERE, "The called method was not found"); //$NON-NLS-1$
throw new NoSuchMethodException("The called method was not found"); //$NON-NLS-1$
} catch (SecurityException e) {
logger.log(Level.SEVERE, "Security violation"); //$NON-NLS-1$
throw new Exception("Security violation", e); //$NON-NLS-1$
} catch (ClassNotFoundException e) {
logger.log(Level.SEVERE, "The class " + properties.getProperty("tableAdapter") + "was not found."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
throw new ClassNotFoundException("The class " + properties.getProperty("tableAdapter") + "was not found.\n" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ "Check the spelling of your adapter class name in properties file."); //$NON-NLS-1$
}
GlobalContext.setGlobalContext(adapter);
IDMapper.initialise(properties);
EventLogger.getInstance().initialise(properties);
}
/**
* Method for configuring a {@link Logger} with several properties as given by the loader
* properties file.
......
......@@ -42,7 +42,7 @@ import java.util.Vector;
* @version 2.0.1
*/
@NonNullByDefault
public class TuioConcreteAdapter extends TuiAdapter implements TuioListener {
public class TuioAdapter extends TuiAdapter implements TuioListener {
/**
* A reference to the {@link TuioClient} conveying all TUIO protocol related messages and
......@@ -61,7 +61,7 @@ public class TuioConcreteAdapter extends TuiAdapter implements TuioListener {
* @param interfaceManager
* The {@link TangibleInterfaceManager} display.
*/
public TuioConcreteAdapter(TangibleInterfaceManager interfaceManager) {
public TuioAdapter(TangibleInterfaceManager interfaceManager) {
super(interfaceManager);
}
......
......@@ -62,19 +62,11 @@ public class TangibleApplicationTest {
* Test method for
* {@link lu.list.itis.dkd.tui.TangibleApplication#TangibleApplication(java.lang.String)}.
*
* @throws SecurityException
* Thrown when a security manager is present and a discrepancy in the class loaders is
* detected or it denies access to the field.
* @throws NoSuchFieldException
* Thrown when the fields that this test wants to access do not exist.
* @throws IllegalAccessException
* Thrown when access to the field is not permitted.
* @throws IllegalArgumentException
* If the provided instance cannot give access to the field.
* @throws Exception
*/
@SuppressWarnings("javadoc")
@Test
public void testTangibleApplication() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
public void testTangibleApplication() throws Exception {
assertThat(application, is(not(nullValue())));
Field properties = TestTangibleApplication.class.getSuperclass().getDeclaredField("properties");
......@@ -187,8 +179,9 @@ public class TangibleApplicationTest {
*
* @param newPropertiesFileURI
* The URI of the properties file to load.
* @throws Exception
*/
protected TestTangibleApplication(String newPropertiesFileURI) {
protected TestTangibleApplication(String newPropertiesFileURI) throws Exception {
super(newPropertiesFileURI);
}
}
......
......@@ -40,8 +40,8 @@ import java.util.logging.Logger;
* @version 1.0.2
*/
public class TangibleInterfaceManagerTest {
private String propertiesLocation = "test_properties.properties";
private TangibleApplication application;
private String propertiesLocation = "test_properties.properties";
private TangibleApplication application;
private TangibleInterfaceManager interfaceManager;
......@@ -175,8 +175,9 @@ public class TangibleInterfaceManagerTest {
*
* @param newPropertiesFileURI
* The URI of the properties file to load.
* @throws Exception
*/
protected TestTangibleApplication(String newPropertiesFileURI) {
protected TestTangibleApplication(String newPropertiesFileURI) throws Exception {
super(newPropertiesFileURI);
}
}
......
......@@ -71,8 +71,9 @@ public class TangibleObjectTest {
*
* @param newPropertiesFileURI
* The URI of the properties file to load.
* @throws Exception
*/
protected TestTangibleApplication(String newPropertiesFileURI) {
protected TestTangibleApplication(String newPropertiesFileURI) throws Exception {
super(newPropertiesFileURI);
}
}
......
......@@ -48,13 +48,13 @@ import java.util.Properties;
import java.util.logging.Logger;
/**
* Test case for testing the {@link TuioConcreteAdapter} class.
* Test case for testing the {@link TuioAdapter} class.
*
* @author Nicolas GILMARD [nicolas.gilmard@list.lu]
* @since [1].[0]
* @version [1].[0].[1]
*/
public class TuioConcreteAdapterTest {
public class TuioAdapterTest {
private TuiAdapter tuiAdapter;
private String propertiesLocation = "test_properties.properties"; //$NON-NLS-1$
private TangibleApplication application;
......@@ -82,12 +82,12 @@ public class TuioConcreteAdapterTest {
} catch (IOException e) {
// nothing to do
}
tuiAdapter = new TuioConcreteAdapter(new TestTangibleInterfaceManager(application, null, temp));
tuiAdapter = new TuioAdapter(new TestTangibleInterfaceManager(application, null, temp));
}
/**
* Test method for
* {@link lu.list.itis.dkd.tui.adapter.TuioConcreteAdapter#TuioConcreteAdapter(lu.list.itis.dkd.tui.TangibleInterfaceManager)}
* {@link lu.list.itis.dkd.tui.adapter.TuioAdapter#TuioConcreteAdapter(lu.list.itis.dkd.tui.TangibleInterfaceManager)}
* .
*
* @throws SecurityException
......@@ -104,9 +104,9 @@ public class TuioConcreteAdapterTest {
public void testTuioConcreteAdapter() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
assertThat(tuiAdapter, is(notNullValue()));
Field interfaceManager = TuioConcreteAdapter.class.getSuperclass().getDeclaredField("interfaceManager"); //$NON-NLS-1$
Field client = TuioConcreteAdapter.class.getDeclaredField("client"); //$NON-NLS-1$
Field objectManager = TuioConcreteAdapter.class.getDeclaredField("objectManager"); //$NON-NLS-1$
Field interfaceManager = TuioAdapter.class.getSuperclass().getDeclaredField("interfaceManager"); //$NON-NLS-1$
Field client = TuioAdapter.class.getDeclaredField("client"); //$NON-NLS-1$
Field objectManager = TuioAdapter.class.getDeclaredField("objectManager"); //$NON-NLS-1$
interfaceManager.setAccessible(true);
assertThat(interfaceManager.get(tuiAdapter), is(not(nullValue())));
......@@ -132,8 +132,9 @@ public class TuioConcreteAdapterTest {
*
* @param newPropertiesFileURI
* The URI of the properties file to load.
* @throws Exception
*/
protected TestTangibleApplication(String newPropertiesFileURI) {
protected TestTangibleApplication(String newPropertiesFileURI) throws Exception {
super(newPropertiesFileURI);
}
}
......@@ -193,7 +194,7 @@ public class TuioConcreteAdapterTest {
/**
* Test method for {@link lu.list.itis.dkd.tui.adapter.TuioConcreteAdapter#getObjectManager()}
* Test method for {@link lu.list.itis.dkd.tui.adapter.TuioAdapter#getObjectManager()}
*/
@SuppressWarnings("resource")
@Test
......@@ -226,7 +227,7 @@ public class TuioConcreteAdapterTest {
/**
* Test method for
* {@link lu.list.itis.dkd.tui.adapter.TuioConcreteAdapter#setObjectManager(TangibleObjectManager)}
* {@link lu.list.itis.dkd.tui.adapter.TuioAdapter#setObjectManager(TangibleObjectManager)}
*/
@SuppressWarnings("resource")
@Test
......@@ -254,7 +255,7 @@ public class TuioConcreteAdapterTest {
}
/**
* Test method for {@link lu.list.itis.dkd.tui.adapter.TuioConcreteAdapter#getActiveCursors()}
* Test method for {@link lu.list.itis.dkd.tui.adapter.TuioAdapter#getActiveCursors()}
*/
@Test
public void testGetActiveCursors() {
......@@ -262,7 +263,7 @@ public class TuioConcreteAdapterTest {
}
/**
* Test method for {@link lu.list.itis.dkd.tui.adapter.TuioConcreteAdapter#getActiveObjects()}
* Test method for {@link lu.list.itis.dkd.tui.adapter.TuioAdapter#getActiveObjects()}
*/
@Test
public void testGetActiveObjects() {
......@@ -270,7 +271,7 @@ public class TuioConcreteAdapterTest {
}
/**
* Test method for {@link lu.list.itis.dkd.tui.adapter.TuioConcreteAdapter#getCursor(long)}
* Test method for {@link lu.list.itis.dkd.tui.adapter.TuioAdapter#getCursor(long)}
*/
@Test
public void testGetCursor() {
......@@ -285,7 +286,7 @@ public class TuioConcreteAdapterTest {
}
/**
* Test method for {@link lu.list.itis.dkd.tui.adapter.TuioConcreteAdapter#getObject(long)}
* Test method for {@link lu.list.itis.dkd.tui.adapter.TuioAdapter#getObject(long)}
*/
@Test
public void testGetObject() {
......@@ -308,7 +309,7 @@ public class TuioConcreteAdapterTest {
TuioCursor tuioCursor = new TuioCursor(1, 3, 10f, 11f);
Method convertTuioCursor = null;
try {
convertTuioCursor = TuioConcreteAdapter.class.getDeclaredMethod("convertTuioCursorToTangibleObject", new Class[] {TuioCursor.class}); //$NON-NLS-1$
convertTuioCursor = TuioAdapter.class.getDeclaredMethod("convertTuioCursorToTangibleObject", new Class[] {TuioCursor.class}); //$NON-NLS-1$
} catch (NoSuchMethodException e) {
// nothing to do
} catch (SecurityException e) {
......@@ -354,7 +355,7 @@ public class TuioConcreteAdapterTest {
Method convertTuioObject = null;
try {
convertTuioObject = TuioConcreteAdapter.class.getDeclaredMethod("convertTuioObjectToTangibleObject", new Class[] {TuioObject.class}); //$NON-NLS-1$
convertTuioObject = TuioAdapter.class.getDeclaredMethod("convertTuioObjectToTangibleObject", new Class[] {TuioObject.class}); //$NON-NLS-1$
} catch (NoSuchMethodException e) {
// nothing to do
} catch (SecurityException e) {
......@@ -392,7 +393,7 @@ public class TuioConcreteAdapterTest {
}
/**
* Test method for {@link lu.list.itis.dkd.tui.adapter.TuioConcreteAdapter#connect()}
* Test method for {@link lu.list.itis.dkd.tui.adapter.TuioAdapter#connect()}
*/
@SuppressWarnings("resource")
@Test
......@@ -418,24 +419,23 @@ public class TuioConcreteAdapterTest {
assertEquals(testManager, tuiAdapter.getObjectManager());
/** not connected */
assertEquals(false, ((TuioConcreteAdapter) tuiAdapter).client.isConnected());
assertEquals(false, ((TuioAdapter) tuiAdapter).client.isConnected());
/** connect the application */
tuiAdapter.connect();
assertEquals(true, ((TuioConcreteAdapter) tuiAdapter).client.isConnected());
assertEquals(true, ((TuioAdapter) tuiAdapter).client.isConnected());
}
/**
* Test method for {@link lu.list.itis.dkd.tui.adapter.TuioConcreteAdapter#disconnect()}
* Test method for {@link lu.list.itis.dkd.tui.adapter.TuioAdapter#disconnect()}
*/
@Test
public void testDisconnect() {
/** not connected */
assertEquals(false, ((TuioConcreteAdapter) tuiAdapter).client.isConnected());
assertEquals(false, ((TuioAdapter) tuiAdapter).client.isConnected());
}
/**
* Test method for
* {@link lu.list.itis.dkd.tui.adapter.TuioConcreteAdapter#addTuioCursor(TuioCursor)}
* Test method for {@link lu.list.itis.dkd.tui.adapter.TuioAdapter#addTuioCursor(TuioCursor)}
*/
@Test
public void testAddTuioCursor() {
......@@ -443,8 +443,7 @@ public class TuioConcreteAdapterTest {
}
/**
* Test method for
* {@link lu.list.itis.dkd.tui.adapter.TuioConcreteAdapter#addTuioObject(TuioObject)}
* Test method for {@link lu.list.itis.dkd.tui.adapter.TuioAdapter#addTuioObject(TuioObject)}
*/
@Test
public void testAddTuioObject() {
......@@ -452,7 +451,7 @@ public class TuioConcreteAdapterTest {
}
/**
* Test method for {@link lu.list.itis.dkd.tui.adapter.TuioConcreteAdapter#refresh(TuioTime)}
* Test method for {@link lu.list.itis.dkd.tui.adapter.TuioAdapter#refresh(TuioTime)}
*/
@Test
public void testRefresh() {
......@@ -460,8 +459,7 @@ public class TuioConcreteAdapterTest {
}
/**
* Test method for
* {@link lu.list.itis.dkd.tui.adapter.TuioConcreteAdapter#removeTuioCursor(TuioCursor)}
* Test method for {@link lu.list.itis.dkd.tui.adapter.TuioAdapter#removeTuioCursor(TuioCursor)}
*/
@Test
public void testRemoveTuioCursor() {
......@@ -469,8 +467,7 @@ public class TuioConcreteAdapterTest {
}
/**
* Test method for
* {@link lu.list.itis.dkd.tui.adapter.TuioConcreteAdapter#removeTuioObject(TuioObject)}
* Test method for {@link lu.list.itis.dkd.tui.adapter.TuioAdapter#removeTuioObject(TuioObject)}
*/
@Test
public void testRemoveTuioObject() {
......@@ -478,8 +475,7 @@ public class TuioConcreteAdapterTest {
}
/**
* Test method for
* {@link lu.list.itis.dkd.tui.adapter.TuioConcreteAdapter#updateTuioCursor(TuioCursor)}
* Test method for {@link lu.list.itis.dkd.tui.adapter.TuioAdapter#updateTuioCursor(TuioCursor)}
*/
@Test
public void testUpdateTuioCursor() {
......@@ -487,8 +483,7 @@ public class TuioConcreteAdapterTest {
}
/**
* Test method for
* {@link lu.list.itis.dkd.tui.adapter.TuioConcreteAdapter#updateTuioObject(TuioObject)}
* Test method for {@link lu.list.itis.dkd.tui.adapter.TuioAdapter#updateTuioObject(TuioObject)}
*/
@Test
public void testUpdateTuioObject() {
......
......@@ -32,7 +32,8 @@ fontSize = 13
colour = BLACK
centred = false
# Adapter to load
tableAdapter = tuio
#The value below is best left at or above 1024. It serves the purpose of cursor ID remapping.
......
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