大家
好,我使用 Odata4j 创建 Odata 服务并部署在 tomcat 中。当我使用芝麻数据浏览器时,我可以看到一个
带有标题的表(如果我点击 THREAD )。我的问题应该是在网络浏览器中查看相同数据的 url 是什么?我想在服务中使用它,所以想知道 url。
如果我在http://localhost:8888/OdataEx/example.svc
浏览器中输入这个,我可以看到一些 XML
<?xml version="1.0" encoding="utf-8" ?>
<service xmlns="http://www.w3.org/2007/app" xml:base="http://localhost:8888/OdataEx/example.svc/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app">
<workspace>
<atom:title>Default</atom:title>
<collection href="Threads">
<atom:title>Threads</atom:title>
</collection>
</workspace>
</service>
Java 代码生成服务是
public class ExampleProducerFactory implements ODataProducerFactory {
public ODataProducer create(Properties properties) {
InMemoryProducer producer = new InMemoryProducer("example");
// expose this jvm's thread information (Thread instances) as an entity-set called "Threads"
producer.register(Thread.class, Long.class, "Threads", new Func<Iterable<Thread>>() {
public Iterable<Thread> apply() {
ThreadGroup tg = Thread.currentThread().getThreadGroup();
while (tg.getParent() != null)
tg = tg.getParent();
Thread[] threads = new Thread[50];
int count = tg.enumerate(threads, true);
return Enumerable.create(threads).take(count);
}
}, Funcs.method(Thread.class, Long.class, "getId"));
return producer;
}
}