protected void registerIndexAndTypes(InternalIndexClient indexClient, InternalTypeClient... typeClients) {
//We are in a different thread, therefore we cannot rely on the current shell context but we need to create a new one
Context context = Context.enter();
try {
//register index
NativeJavaObject indexNativeJavaObject = new RhinoCustomNativeJavaObject(shellNativeClient.getParentScope(), indexClient, InternalIndexClient.class);
indexNativeJavaObject.setPrototype(context.newObject(shellNativeClient.getParentScope()));
if (typeClients != null) {
//register types
for (InternalTypeClient typeClient : typeClients) {
NativeJavaObject typeNativeJavaObject = new RhinoCustomNativeJavaObject(shellNativeClient.getParentScope(), typeClient, InternalTypeClient.class);
ScriptableObject.putProperty(indexNativeJavaObject, typeClient.typeName(), typeNativeJavaObject);
}
}
logger.trace("Adding index {} to shell native client", indexClient.indexName());