My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package com.extensiblejava.hello.web;

import java.util.Dictionary;
import java.util.Hashtable;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.http.HttpContext;
import org.osgi.service.http.HttpService;
import org.ops4j.pax.web.service.WebContainer;

public final class Activator implements BundleActivator {

private ServiceReference m_httpServiceRef;

public void start( BundleContext bc ) throws Exception {

m_httpServiceRef = bc.getServiceReference( WebContainer.class.getName() );
if( m_httpServiceRef != null ) {
final WebContainer webContainer = (WebContainer) bc.getService( m_httpServiceRef );
if( webContainer != null ) {
// create a default context to share between registrations
final HttpContext httpContext = webContainer.createDefaultHttpContext();
// register the hello world servlet
final Dictionary initParams = new Hashtable();
initParams.put( "from", "HttpService" );
webContainer.registerServlet("/", new HelloWorldServlet(), initParams, httpContext);
//register JSP
webContainer.registerJsps(new String[]{ "/jsp/*" }, httpContext);
// register html pages as resources
webContainer.registerResources("/html", "/", httpContext);
}
}
}

public void stop( BundleContext bc ) throws Exception {
if( m_httpServiceRef != null ) {
bc.ungetService( m_httpServiceRef );
m_httpServiceRef = null;
}
}
}

Change log

r43 by pragkirk on Feb 2, 2009   Diff
cleaned up a bit of code
Go to: 
Project members, sign in to write a code review

Older revisions

r31 by pragkirk on Jan 27, 2009   Diff
changed to use Pax Web
r13 by pragkirk on Mar 18, 2008   Diff
Initial checkin.
All revisions of this file

File info

Size: 1712 bytes, 43 lines

File properties

svn:executable
Powered by Google Project Hosting