-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Example with manual Service registration
Signed-off-by: Juergen Albert <j.albert@data-in-motion.biz>
- Loading branch information
1 parent
36587b8
commit 1a7a31e
Showing
3 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
-buildpath: \ | ||
org.gecko.playground;version=project | ||
org.gecko.playground;version=project,\ | ||
org.osgi.framework |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
org.gecko.playground.ds.simple/src/org/gecko/playground/ds/simple/activator/Activator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* Copyright (c) 2012 - 2024 Data In Motion and others. | ||
* All rights reserved. | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Data In Motion - initial API and implementation | ||
*/ | ||
package org.gecko.playground.ds.simple.activator; | ||
|
||
import java.util.Dictionary; | ||
import java.util.Hashtable; | ||
|
||
import org.gecko.playground.ds.simple.ConsoleLog; | ||
import org.gecko.playground.log.Log; | ||
import org.osgi.annotation.bundle.Header; | ||
import org.osgi.framework.BundleActivator; | ||
import org.osgi.framework.BundleContext; | ||
import org.osgi.framework.ServiceRegistration; | ||
|
||
@Header(name = "Bundle-Activator", value = "org.gecko.playground.ds.simple.activator.Activator") | ||
public class Activator implements BundleActivator { | ||
|
||
private ServiceRegistration<Log> registerService; | ||
|
||
/* | ||
* (non-Javadoc) | ||
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) | ||
*/ | ||
@Override | ||
public void start(BundleContext context) throws Exception { | ||
System.out.println("Test"); | ||
|
||
Dictionary<String, String> props = new Hashtable<>(); | ||
props.put("some prop", "via Activator" ); | ||
|
||
ConsoleLog log = new ConsoleLog("Activator"); | ||
|
||
registerService = context.registerService(Log.class, log, props); | ||
} | ||
|
||
/* | ||
* (non-Javadoc) | ||
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) | ||
*/ | ||
@Override | ||
public void stop(BundleContext context) throws Exception { | ||
registerService.unregister(); | ||
} | ||
|
||
} |