I'm still unable to utilize com.mathworks.matlab.types.Struct, but I figured out how to do what I wanted with com.mathworks.toolbox.javabuilder.MWStructArray using the fromMap static method:
try {
Context theContext = new InitialContext();
Map<String,Object> contextMap = new HashMap<String,Object>();
NamingEnumeration<Binding> list = theContext.listBindings("java:comp/env");
while (list.hasMoreElements()) {
Binding binding = list.next();
contextMap.put(binding.getName(),binding.getObject());
}
fContextStruct = MWStructArray.fromMap(contextMap);
Object[] result = new Object[1];
result = fTestStruct.testStruct(1, fContextStruct);
} catch (NamingException e) {
log.error("Naming error reading context");
} catch (Exception e) {
log.error("Other error: " + e.getMessage());
}
}
This takes the environment variables defined in META-INF/context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Environment name="simtime"
value="4"
type="java.lang.Double"/>
<Environment name="xlabel"
value="Time (min)"
type="java.lang.String"/>
</Context>
and creates a structure:
context =
struct with fields:
simtime: 4
xlabel: "Time (min)"
Note that the only dependency needed is javabuilder