View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2012 Mort Bay Consulting Pty. Ltd.
4   //  ------------------------------------------------------------------------
5   //  All rights reserved. This program and the accompanying materials
6   //  are made available under the terms of the Eclipse Public License v1.0
7   //  and Apache License v2.0 which accompanies this distribution.
8   //
9   //      The Eclipse Public License is available at
10  //      http://www.eclipse.org/legal/epl-v10.html
11  //
12  //      The Apache License v2.0 is available at
13  //      http://www.opensource.org/licenses/apache2.0.php
14  //
15  //  You may elect to redistribute this code under either of these licenses.
16  //  ========================================================================
17  //
18  
19  package com.acme.osgi;
20  
21  import java.util.Dictionary;
22  import java.util.Hashtable;
23  
24  import org.eclipse.jetty.server.Server;
25  import org.eclipse.jetty.server.handler.ContextHandler;
26  import org.osgi.framework.Bundle;
27  import org.osgi.framework.BundleActivator;
28  import org.osgi.framework.BundleContext;
29  import org.osgi.framework.BundleException;
30  import org.osgi.framework.FrameworkUtil;
31  import org.osgi.framework.ServiceRegistration;
32  import org.osgi.util.tracker.BundleTracker;
33  
34  /**
35   * Bootstrap a ContextHandler
36   * 
37   * 
38   */
39  public class Activator implements BundleActivator
40  {
41  
42      /**
43       * 
44       * @param context
45       */
46      public void start(BundleContext context) throws Exception
47      {
48          ContextHandler ch = new ContextHandler();
49          Dictionary props = new Hashtable();
50          props.put("contextPath","/acme");
51          props.put("Jetty-ContextFilePath", "acme.xml");
52          context.registerService(ContextHandler.class.getName(),ch,props);
53      }
54  
55      /**
56       * Stop the activator.
57       * 
58       * @see
59       * org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
60       */
61      public void stop(BundleContext context) throws Exception
62      {
63      }
64  }