Hi,
Pax-Web is the way to go. Here is some sample blueprint code for
serving static html pages from Karaf. This will serve 'index.html' and
other static resources directly from your bundle. Put files under
src/main/resources in your maven project.
Cheers,
<bean id="resourceMapping"
class="org.ops4j.pax.web.extender.whiteboard.runtime.DefaultResourceMapping">
<property name="alias" value="/"/>
<property name="path" value=""/>
</bean>
<service id="resources" ref="resourceMapping"
interface="org.ops4j.pax.web.extender.whiteboard.ResourceMapping"/>
<bean id="welcomeFile"
class="org.ops4j.pax.web.extender.whiteboard.runtime.DefaultWelcomeFileMapping">
<property name="redirect" value="true"/>
<property name="welcomeFiles">
<array>
<value>index.html</value>
</array>
</property>
</bean>
<service id="welcomeFileService" ref="welcomeFile"
interface="org.ops4j.pax.web.extender.whiteboard.WelcomeFileMapping"/>
On Sun, May 5, 2013 at 1:32 PM, Achim Nierbeck <[email protected]> wrote:
> Hi,
>
> you need to make sure you're using the "WebContainer" HTTP-Service, it's the
> one provided by Pax-Web. Take also
> a look at the samples of Pax-Web[1].
>
> Another way of registering your resources might be to use the whiteboard
> mechanism.
>
> Greetings, Achim
>
> [1] -
> https://github.com/ops4j/org.ops4j.pax.web/blob/master/samples/helloworld-wc/src/main/java/org/ops4j/pax/web/samples/helloworld/wc/internal/Activator.java#L122
>
>
> 2013/5/4 Clement Jebakumar <[email protected]>
>>
>>
>> Hi,
>>
>> I have a bundle which supplies css/img folder. I tried with below code,
>> looks like jetty is not recognizing it. How to enable files in those folders
>> be served by Jetty
>>
>> ServiceReference sRef = context.getServiceReference(HttpService.class
>> .getName());
>> HttpService service = (HttpService) context.getService(sRef);
>> service.registerResources("/", "/htmls", null);
>> // service.registerResources("/js", "js", null);
>> String webDir = getClass().getClassLoader().getResource("css")
>> .toExternalForm();
>> service.registerResources("/css", webDir, null);
>> service.registerResources("/img", "/img", null);
>>
>> Files are put insider bundle. In eclipse devlopment, we have an unpack
>> option which solved the issue in Eclipse. But in karaf, i am not sure how to
>> make jetty to work with this.
>>
>>
>> Clement Jebakumar,
>>
>> 111/27 Keelamutharamman Kovil Street,
>> Tenkasi, 627 811
>> http://www.declum.com/clement.html
>>
>
>
>
> --
>
> Apache Karaf <http://karaf.apache.org/> Committer & PMC
> OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
> Project Lead
> OPS4J Pax for Vaadin <http://team.ops4j.org/wiki/display/PAXVAADIN/Home>
> Commiter & Project Lead
> blog <http://notizblog.nierbeck.de/>
--
Ioan Eugen Stan
0720 898 747