blob: d4ef91769e1dbbfe695b65c34b86e619e1eae9c8 [file] [log] [blame]
Felix Meschbergerefb2d082008-08-19 13:18:47 +00001/*
Richard S. Hall59aef192009-04-25 14:50:37 +00002 * 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 */
Felix Meschbergerefb2d082008-08-19 13:18:47 +000017package org.apache.felix.shell.remote;
18
Felix Meschbergerefb2d082008-08-19 13:18:47 +000019import org.osgi.framework.BundleActivator;
20import org.osgi.framework.BundleContext;
21
Felix Meschbergerefb2d082008-08-19 13:18:47 +000022/**
23 * Activator for the telnet console.
Felix Meschbergerefb2d082008-08-19 13:18:47 +000024 */
25public class Activator implements BundleActivator
26{
Richard S. Hall55900ec2009-04-25 16:57:58 +000027 private ServiceMediator m_services;
Richard S. Hall59aef192009-04-25 14:50:37 +000028 private Listener m_listener;
Felix Meschbergerefb2d082008-08-19 13:18:47 +000029
Richard S. Hall55900ec2009-04-25 16:57:58 +000030 public void start(BundleContext context) throws Exception
Felix Meschbergerefb2d082008-08-19 13:18:47 +000031 {
32 //1. Prepare mediator
Richard S. Hall55900ec2009-04-25 16:57:58 +000033 m_services = new ServiceMediator(context);
Felix Meschbergerefb2d082008-08-19 13:18:47 +000034
35 //2. Prepare the listener
Richard S. Hall55900ec2009-04-25 16:57:58 +000036 m_listener = new Listener(context, m_services);
Felix Meschbergerefb2d082008-08-19 13:18:47 +000037 }
38
Richard S. Hall55900ec2009-04-25 16:57:58 +000039 public void stop(BundleContext context) throws Exception
Felix Meschbergerefb2d082008-08-19 13:18:47 +000040 {
Richard S. Hall59aef192009-04-25 14:50:37 +000041 if (m_listener != null)
Felix Meschbergerefb2d082008-08-19 13:18:47 +000042 {
Richard S. Hall59aef192009-04-25 14:50:37 +000043 m_listener.deactivate();
44 m_listener = null;
Felix Meschbergerefb2d082008-08-19 13:18:47 +000045 }
Richard S. Hall55900ec2009-04-25 16:57:58 +000046 if (m_services != null)
Felix Meschbergerefb2d082008-08-19 13:18:47 +000047 {
Richard S. Hall55900ec2009-04-25 16:57:58 +000048 m_services.deactivate();
49 m_services = null;
Felix Meschbergerefb2d082008-08-19 13:18:47 +000050 }
51 }
Richard S. Hall59aef192009-04-25 14:50:37 +000052}