blob: feabdd11b39c4d99f4a48286350cf76dfc9c2ae5 [file] [log] [blame]
Carsten Ziegeler395a7822013-01-28 19:01:22 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17package org.apache.felix.status.impl;
18
19import java.util.Dictionary;
20import java.util.Hashtable;
21
22import org.apache.felix.status.StatusPrinterManager;
23import org.apache.felix.status.impl.webconsole.WebConsoleAdapter;
24import org.osgi.framework.BundleActivator;
25import org.osgi.framework.BundleContext;
26import org.osgi.framework.Constants;
27import org.osgi.framework.ServiceRegistration;
28
29/**
30 * Activate bridges and register manager.
31 */
32public class Activator implements BundleActivator {
33
34 private StatusPrinterManagerImpl printerManager;
35
36 private ServiceRegistration managerRegistration;
37
38 private WebConsoleAdapter webAdapter;
39
40 /**
41 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
42 */
43 public void start(final BundleContext context) throws Exception {
44 this.webAdapter = new WebConsoleAdapter(context);
45 this.printerManager = new StatusPrinterManagerImpl(context);
46 final Dictionary<String, Object> props = new Hashtable<String, Object>();
47 props.put(Constants.SERVICE_DESCRIPTION, "Apache Felix Status Printer Manager");
48 props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
49 this.managerRegistration = context.registerService(
50 StatusPrinterManager.class.getName(),
51 this.printerManager, props);
Carsten Ziegelere21a0472013-01-29 17:42:46 +000052}
Carsten Ziegeler395a7822013-01-28 19:01:22 +000053
54 /**
55 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
56 */
57 public void stop(final BundleContext context) throws Exception {
58 if( this.managerRegistration != null ) {
59 this.managerRegistration.unregister();
60 this.managerRegistration = null;
61 }
62 if ( this.printerManager != null ) {
63 this.printerManager.dispose();
64 this.printerManager = null;
65 }
66 if ( this.webAdapter != null ) {
67 this.webAdapter.dispose();
68 this.webAdapter = null;
69 }
70 }
71
72}