Hello,
I want to make my own REST Server for example like the DiscoveryResource.java
in org.eclipse.smarthome.io.rest.core
. For example class I implemented the RESTResource
and created the resource.xml
. In the Eclipse SmartHome namespace the example works fine. When I copy the .java and .xml in the openHAB2 namespace and change the packagenames, it doesn’t work anymore. What am I doing wrong?
The following is my example which only works in the Eclipse SmartHome namespace:
package org.eclipse.smarthome.io.rest.core.discovery;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.eclipse.smarthome.io.rest.RESTResource;/**
@Path("myowntestpath")
public class MessageResource implements RESTResource {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String getDiscoveryServices() {
return "hi";
}}
my xml File:
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.smarthome.io.rest.core.discovery.MessageResource">
<implementation class="org.eclipse.smarthome.io.rest.core.discovery.MessageResource"/>
<service>
<provide interface="org.eclipse.smarthome.io.rest.core.discovery.MessageResource"/>
<provide interface="org.eclipse.smarthome.io.rest.RESTResource"/>
</service>
</scr:component>