1. binder to convert java object2document document2object.
Here is my test case class, we can covert them very easily.
package com.sillycat.easyhunter.plugin.solr;
DocumentObjectBinder binder = new DocumentObjectBinder();
User user = new User();
user.setId(222);
user.setName("JavaBean");
user.setLike(new String[] { "music", "book", "sport" });
user.setAddress("guangdong");
System.out.println(doc);
// User ->> SolrInputDocument
System.out.println(binder.toSolrInputDocument(user));
// SolrDocument ->> User
System.out.println(binder.getBean(User.class, doc));
SolrDocumentList list = new SolrDocumentList();
list.add(doc);
list.add(doc);
//SolrDocumentList ->> List
System.out.println(binder.getBeans(User.class, list));
}
SolrDocumentList list = response.getResults();
for (int i = 0; i < list.size(); i++) {
println (list.get(i));
}
} catch (SolrServerException e) {
e.printStackTrace();
}
println 'done'
}
}
error message:
java.lang.ExceptionInInitializerError
Caused by: java.lang.RuntimeException: No suitable ClassLoader found for grab
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
solution:
No, I did not solve this problem.
At last, we can run the function as 'Groovy Script' and 'Java Application'.
I will check this some other day, if I really need groovy in my architect.