blob: f6d667587fe8c15c30e4deed3ba304f125dd1968 [file] [log] [blame]
Felix Meschberger8659e392009-08-19 05:46:49 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19package org.apache.felix.cm.integration.helper;
20
21
Felix Meschberger05d89e12011-11-03 23:37:10 +000022import java.util.Dictionary;
23
Felix Meschberger8659e392009-08-19 05:46:49 +000024import org.osgi.framework.BundleContext;
Guillaume Nodet34730932012-12-14 16:40:08 +000025import org.osgi.framework.Constants;
Felix Meschberger05d89e12011-11-03 23:37:10 +000026import org.osgi.framework.ServiceRegistration;
Felix Meschberger8659e392009-08-19 05:46:49 +000027import org.osgi.service.cm.ManagedService;
28
29
30public class ManagedServiceTestActivator extends BaseTestActivator
31{
32
33 public static ManagedServiceTestActivator INSTANCE;
34
Felix Meschberger05d89e12011-11-03 23:37:10 +000035 private Dictionary registrationProps;
36 private ServiceRegistration registration;
Felix Meschberger8659e392009-08-19 05:46:49 +000037
38 public void start( BundleContext context ) throws Exception
39 {
Felix Meschberger05d89e12011-11-03 23:37:10 +000040 this.registrationProps = getServiceProperties( context );
41 this.registration = context.registerService( ManagedService.class.getName(), this, this.registrationProps );
Felix Meschberger8659e392009-08-19 05:46:49 +000042 INSTANCE = this;
43 }
44
45
46 public void stop( BundleContext arg0 ) throws Exception
47 {
48 INSTANCE = null;
49 }
Felix Meschberger05d89e12011-11-03 23:37:10 +000050
51
52 public void changePid( final String newPid )
53 {
54 this.registrationProps.put( Constants.SERVICE_PID, newPid );
55 this.registration.setProperties( this.registrationProps );
56 }
Felix Meschberger8659e392009-08-19 05:46:49 +000057}