Menu
abriraqui
  • reflexiones
  • publicaciones
  • hackership
  • experiencias
abriraqui

How to serve static content via dynamic service?

Posted on September 4, 2014September 4, 2014

Tweet

A DeepaMehta(DM) plugin can publish static resources and dynamic resources.

A DM plugin automatically publishes the Static resources (files) that are in resource/web directory. They will be published in the URI specified in bundle symbolic name in the pom.xml

A DM plugin can also publish dynamic resources created by java code, by providing a DeepaMehta RESTful service. To do so, you should define a method where you call getStaticResource to access a resource from the plugin, this method returns an Inputstream. The resources will be published in the URI obtained from the @path annotation defined in the plugin, and the resource method should be annotated with @Produces(“text/html”).

An example:


package de.example;

import de.deepamehta.core.osgi.PluginActivator;
import java.io.InputStream;
import javax.ws.rs.Path;
import javax.ws.rs.GET;
import javax.ws.rs.Produces;

@Path("/website")
public class ExamplePlugin extends PluginActivator {

@GET
@Path("/{id}")
@Produces("text/html")
public InputStream invokeExample() {
return getStaticResource("web/index.html");
}
}

©2023 abriraqui | Powered by SuperbThemes & WordPress