blob: 52fb38b373362047f21ca01eaf14c0df4ba2ca3e [file] [log] [blame]
Francesco Furfarid1072b52006-05-03 07:44:48 +00001/*
2 * Copyright 2006 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18package org.apache.felix.upnp.sample.binaryLight;
19
20import java.util.Dictionary;
21
22import org.osgi.framework.BundleActivator;
23import org.osgi.framework.BundleContext;
24import org.osgi.framework.ServiceRegistration;
25import org.osgi.service.upnp.UPnPDevice;
26
27
28/*
29* @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
30*/
31
32public class Activator implements BundleActivator {
33
34 static BundleContext context;
35 private ServiceRegistration serviceRegistration;
36 private LightDevice light;
37
38 /**
39 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
40 */
41 public void start(BundleContext context) throws Exception {
42 Activator.context = context;
43 doServiceRegistration();
44 }
45
46 private void doServiceRegistration() {
47 light = new LightDevice(context);
48 Dictionary dict = light.getDescriptions(null);
49
50 serviceRegistration = context.registerService(
51 UPnPDevice.class.getName(),
52 light,
53 dict
54 );
55 }
56
57 /**
58 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
59 */
60 public void stop(BundleContext context) throws Exception {
61 serviceRegistration.unregister();
62 light.close();
63 }
64}