blob: 499230dabce3301b5dae392d06d7abcab3230aaa [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.sling.testing.mock.osgi.testsvc.osgiserviceutil.activatedeactivate;
import org.apache.sling.testing.mock.osgi.testsvc.osgiserviceutil.ServiceInterface1;
import org.apache.sling.testing.mock.osgi.testsvc.osgiserviceutil.ServiceInterface2;
import org.apache.sling.testing.mock.osgi.testsvc.osgiserviceutil.ServiceInterface3;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
@Component(service = { ServiceInterface1.class, ServiceInterface2.class })
public class Service8 implements ServiceInterface1, ServiceInterface2, ServiceInterface3 {
private ServiceRegistration<ServiceInterface3> serviceRegistration;
@Activate
private void activate(BundleContext bundleContext) {
serviceRegistration = bundleContext.registerService(ServiceInterface3.class, this, null);
}
@Deactivate
private void deactivate(BundleContext bundleContext) {
serviceRegistration.unregister();
// explicitly set to null to ensure deactivate is never called twice
serviceRegistration = null;
}
}