Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 1 | /* |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame] | 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 | */ |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 17 | package org.apache.felix.shell.remote; |
| 18 | |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 19 | import org.osgi.framework.BundleActivator; |
| 20 | import org.osgi.framework.BundleContext; |
| 21 | |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 22 | /** |
| 23 | * Activator for the telnet console. |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 24 | */ |
| 25 | public class Activator implements BundleActivator |
| 26 | { |
Richard S. Hall | 55900ec | 2009-04-25 16:57:58 +0000 | [diff] [blame] | 27 | private ServiceMediator m_services; |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame] | 28 | private Listener m_listener; |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 29 | |
Richard S. Hall | 55900ec | 2009-04-25 16:57:58 +0000 | [diff] [blame] | 30 | public void start(BundleContext context) throws Exception |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 31 | { |
| 32 | //1. Prepare mediator |
Richard S. Hall | 55900ec | 2009-04-25 16:57:58 +0000 | [diff] [blame] | 33 | m_services = new ServiceMediator(context); |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 34 | |
| 35 | //2. Prepare the listener |
Richard S. Hall | 55900ec | 2009-04-25 16:57:58 +0000 | [diff] [blame] | 36 | m_listener = new Listener(context, m_services); |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 37 | } |
| 38 | |
Richard S. Hall | 55900ec | 2009-04-25 16:57:58 +0000 | [diff] [blame] | 39 | public void stop(BundleContext context) throws Exception |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 40 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame] | 41 | if (m_listener != null) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 42 | { |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame] | 43 | m_listener.deactivate(); |
| 44 | m_listener = null; |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 45 | } |
Richard S. Hall | 55900ec | 2009-04-25 16:57:58 +0000 | [diff] [blame] | 46 | if (m_services != null) |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 47 | { |
Richard S. Hall | 55900ec | 2009-04-25 16:57:58 +0000 | [diff] [blame] | 48 | m_services.deactivate(); |
| 49 | m_services = null; |
Felix Meschberger | efb2d08 | 2008-08-19 13:18:47 +0000 | [diff] [blame] | 50 | } |
| 51 | } |
Richard S. Hall | 59aef19 | 2009-04-25 14:50:37 +0000 | [diff] [blame] | 52 | } |