diff --git a/cnf/central.maven b/cnf/central.maven index af8a5fb..4b46206 100644 --- a/cnf/central.maven +++ b/cnf/central.maven @@ -183,4 +183,9 @@ org.jline:jline-builtins:3.22.0 org.jline:jline-reader:3.22.0 org.jline:jline-console:3.22.0 org.jline:jline-terminal:3.22.0 -org.eclipse.parsson:jakarta.json:1.1.2 +org.eclipse.parsson:jakarta.json:1.1.2# + +# +biz.aQute:biz.aQute.trace.gui:1.9.0 +biz.aQute:biz.aQute.trace.runpath:1.9.0 +biz.aQute:biz.aQute.trace.tester:1.9.0 diff --git a/org.gecko.playground.tracing.fragment/.classpath b/org.gecko.playground.tracing.fragment/.classpath new file mode 100644 index 0000000..a52eb82 --- /dev/null +++ b/org.gecko.playground.tracing.fragment/.classpath @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/org.gecko.playground.tracing.fragment/.settings/org.eclipse.jdt.core.prefs b/org.gecko.playground.tracing.fragment/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..d4540a5 --- /dev/null +++ b/org.gecko.playground.tracing.fragment/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,10 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/org.gecko.playground.tracing.fragment/README.MD b/org.gecko.playground.tracing.fragment/README.MD new file mode 100644 index 0000000..5578721 --- /dev/null +++ b/org.gecko.playground.tracing.fragment/README.MD @@ -0,0 +1,32 @@ +# aQute Tracing System Fragment + +[Github](https://github.com/aQute-os/biz.aQute.osgi.util/tree/master/biz.aQute.trace) +[Maven](https://repo1.maven.org/maven2/biz/aQute/biz.aQute.trace.runpath/) + +This is a small tool that creates metrics for typical startup and teardown methods: + +* Activator#start +* Activator#stop +* Component#activate +* Component#deactivate + +This is an example how to repackage it and making it a framework fragment + +## The Framework Fragment + +The *org.gecko.playground.tracing.fragment* be placed in the application. This is a Framework fragment. This means a fragment for the system bundle. +Its activator should be called as well. So with this the tracer is started very early. + +It is important to know, that this fragment does not import foreign packages, except `org.osgi.framework`. It is also not allowed to export something. + + +## Gogo Commands + +Further, to get some Gogo commands, the bundle *biz.aQute.trace.gui* can also be placed in the application (startlevel is unimportant here) you can then use the commands: + +* *tracer* - show table of the measurements in the console +* *dump (html | json | text)* - create a currensponding dump in the console + +E.g. the HTML dump creates a HTML page with all results. + +The *bndrun* shows, how to start it. \ No newline at end of file diff --git a/org.gecko.playground.tracing.fragment/bnd.bnd b/org.gecko.playground.tracing.fragment/bnd.bnd new file mode 100644 index 0000000..62743b0 --- /dev/null +++ b/org.gecko.playground.tracing.fragment/bnd.bnd @@ -0,0 +1,16 @@ +Fragment-Host: system.bundle +Bundle-Activator: biz.aQute.trace.runpath.impl.Activator + +-buildpath: \ + biz.aQute.trace.runpath,\ + aQute.libg + +-conditionalpackage: \ + javassist.*,\ + biz.*,\ + aQute.* + +Import-Package: \ + sun.*;'resolution:'=optional,\ + jdk.*;'resolution:'=optional,\ + * \ No newline at end of file diff --git a/org.gecko.playground.tracing.fragment/launch.bndrun b/org.gecko.playground.tracing.fragment/launch.bndrun new file mode 100644 index 0000000..e0a382d --- /dev/null +++ b/org.gecko.playground.tracing.fragment/launch.bndrun @@ -0,0 +1,37 @@ +-runfw: org.eclipse.osgi;version=3.13 +-runee: JavaSE-17 +-runprovidedcapabilities: ${native_capability} + +-resolve.effective: active + +-runproperties: \ + osgi.console.enable.builtin=false,\ + osgi.console= + +-runpath=biz.aQute.trace.runpath + +-runrequires: \ + bnd.identity;id='org.gecko.playground.tracing.fragment',\ + bnd.identity;id='org.gecko.playground.tracing',\ + bnd.identity;id='org.apache.felix.gogo.runtime',\ + bnd.identity;id='org.apache.felix.gogo.command',\ + bnd.identity;id='biz.aQute.trace.gui' + +#-runbundles+: \ + # biz.aQute.trace.runpath;startlevel=1,\ + # *;startlevel=4 +-runbundles: \ + aQute.libg;version='[6.4.0,6.4.1)',\ + org.apache.felix.scr;version='[2.2.6,2.2.7)',\ + org.osgi.service.component;version='[1.5.1,1.5.2)',\ + org.osgi.util.function;version='[1.2.0,1.2.1)',\ + org.osgi.util.promise;version='[1.3.0,1.3.1)',\ + slf4j.api;version='[1.7.30,1.7.31)',\ + slf4j.simple;version='[1.7.30,1.7.31)',\ + biz.aQute.trace.gui;version='[1.9.0,1.9.1)',\ + org.gecko.playground.tracing;version=snapshot,\ + org.apache.felix.gogo.command;version='[1.1.2,1.1.3)',\ + org.apache.felix.gogo.runtime;version='[1.1.6,1.1.7)',\ + org.apache.felix.gogo.shell;version='[1.1.4,1.1.5)',\ + org.apache.felix.inventory;version='[1.0.6,1.0.7)',\ + org.gecko.playground.tracing.fragment;version=snapshot \ No newline at end of file diff --git a/org.gecko.playground.tracing/.classpath b/org.gecko.playground.tracing/.classpath new file mode 100644 index 0000000..a52eb82 --- /dev/null +++ b/org.gecko.playground.tracing/.classpath @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/org.gecko.playground.tracing/.settings/org.eclipse.core.resources.prefs b/org.gecko.playground.tracing/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..9c75668 --- /dev/null +++ b/org.gecko.playground.tracing/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 +encoding/bnd.bnd=UTF-8 diff --git a/org.gecko.playground.tracing/.settings/org.eclipse.jdt.core.prefs b/org.gecko.playground.tracing/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..d4540a5 --- /dev/null +++ b/org.gecko.playground.tracing/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,10 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/org.gecko.playground.tracing/README.MD b/org.gecko.playground.tracing/README.MD new file mode 100644 index 0000000..d0d7246 --- /dev/null +++ b/org.gecko.playground.tracing/README.MD @@ -0,0 +1,31 @@ +# aQute Tracing + +[Github](https://github.com/aQute-os/biz.aQute.osgi.util/tree/master/biz.aQute.trace) +[Maven](https://repo1.maven.org/maven2/biz/aQute/biz.aQute.trace.runpath/) + +This is a small tool that creates metrics for typical startup and teardown methods: + +* Activator#start +* Activator#stop +* Component#activate +* Component#deactivate + +## In bndtools + +Just follow the instruction on Github. + +## Non bnd-Environment + +In non-bnd environment there is the *org.gecko.playground.tracing.fragement*. It should be placed in the application. This is a Framework frageent, means a fragment for the system bundle. +Its activator should be called as well. + +Refer to that project + +## Gogo Commands + +Further, to get some Gogo commands, the bundle *biz.aQute.trace.gui* can also be placed in the application (startlevel is unimportant here) you can then use the commands: + +* *tracer* - show table of the measurements in the console +* *dump (html | json | text)* - create a currensponding dump in the console + +E.g. the HTML dump creates a HTML page with all results. \ No newline at end of file diff --git a/org.gecko.playground.tracing/bnd.bnd b/org.gecko.playground.tracing/bnd.bnd new file mode 100644 index 0000000..151ff29 --- /dev/null +++ b/org.gecko.playground.tracing/bnd.bnd @@ -0,0 +1 @@ +-buildpath: org.osgi.util.promise;version=latest \ No newline at end of file diff --git a/org.gecko.playground.tracing/launch.bndrun b/org.gecko.playground.tracing/launch.bndrun new file mode 100644 index 0000000..07cd379 --- /dev/null +++ b/org.gecko.playground.tracing/launch.bndrun @@ -0,0 +1,36 @@ +-runfw: org.eclipse.osgi;version=3.13 +-runee: JavaSE-17 +-runprovidedcapabilities: ${native_capability} + +-resolve.effective: active + +-runproperties: \ + osgi.console.enable.builtin=false,\ + osgi.console= + +-runpath=biz.aQute.trace.runpath + +-runrequires: \ + bnd.identity;id='org.gecko.playground.tracing',\ + bnd.identity;id='org.apache.felix.gogo.runtime',\ + bnd.identity;id='org.apache.felix.gogo.command',\ + bnd.identity;id='biz.aQute.trace.runpath',\ + bnd.identity;id='biz.aQute.trace.gui' + +#-runbundles+: \ + # biz.aQute.trace.runpath;startlevel=1,\ + # *;startlevel=4 +-runbundles: \ + aQute.libg;version='[6.4.0,6.4.1)',\ + org.apache.felix.scr;version='[2.2.6,2.2.7)',\ + org.osgi.service.component;version='[1.5.1,1.5.2)',\ + org.osgi.util.function;version='[1.2.0,1.2.1)',\ + org.osgi.util.promise;version='[1.3.0,1.3.1)',\ + slf4j.api;version='[1.7.30,1.7.31)',\ + slf4j.simple;version='[1.7.30,1.7.31)',\ + biz.aQute.trace.gui;version='[1.9.0,1.9.1)',\ + org.gecko.playground.tracing;version=snapshot,\ + org.apache.felix.gogo.command;version='[1.1.2,1.1.3)',\ + org.apache.felix.gogo.runtime;version='[1.1.6,1.1.7)',\ + org.apache.felix.gogo.shell;version='[1.1.4,1.1.5)',\ + org.apache.felix.inventory;version='[1.0.6,1.0.7)' \ No newline at end of file diff --git a/org.gecko.playground.tracing/src/org/gecko/playground/tracing/LongActivationComponent.java b/org.gecko.playground.tracing/src/org/gecko/playground/tracing/LongActivationComponent.java new file mode 100644 index 0000000..d53dbaf --- /dev/null +++ b/org.gecko.playground.tracing/src/org/gecko/playground/tracing/LongActivationComponent.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2012 - 2023 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.tracing; + +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; + +/** + * + * @author mark + * @since 05.09.2023 + */ +@Component +public class LongActivationComponent { + + @Activate + public void activate() { + try { + System.out.println("Activate long ..."); + Thread.sleep(750); + System.out.println("Activated long"); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Deactivate + public void deactivate() { + try { + System.out.println("De-activate long ..."); + Thread.sleep(350); + System.out.println("De-activated long"); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/org.gecko.playground.tracing/src/org/gecko/playground/tracing/LongPromiseActivationComponent.java b/org.gecko.playground.tracing/src/org/gecko/playground/tracing/LongPromiseActivationComponent.java new file mode 100644 index 0000000..dcfd3b2 --- /dev/null +++ b/org.gecko.playground.tracing/src/org/gecko/playground/tracing/LongPromiseActivationComponent.java @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2012 - 2023 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.tracing; + +import java.util.concurrent.Executors; + +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.util.promise.PromiseFactory; + +/** + * + * @author mark + * @since 05.09.2023 + */ +@Component +public class LongPromiseActivationComponent { + + private final PromiseFactory pf = new PromiseFactory(Executors.newCachedThreadPool()); + + @Activate + public void activate() { + pf.submit(()->{ + System.out.println("Activate long promise ..."); + Thread.sleep(750); + return null; + }).onResolve(()->System.out.println("Activated long promise")); + } + + @Deactivate + public void deactivate() { + pf.submit(()->{ + System.out.println("De-activate long promise ..."); + Thread.sleep(350); + return null; + }).onResolve(()->System.out.println("De-activated long promise")); + } + +} diff --git a/org.gecko.playground.tracing/src/org/gecko/playground/tracing/NotSoLongActivationComponent.java b/org.gecko.playground.tracing/src/org/gecko/playground/tracing/NotSoLongActivationComponent.java new file mode 100644 index 0000000..bc7a051 --- /dev/null +++ b/org.gecko.playground.tracing/src/org/gecko/playground/tracing/NotSoLongActivationComponent.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2012 - 2023 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.tracing; + +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; + +/** + * + * @author mark + * @since 05.09.2023 + */ +@Component +public class NotSoLongActivationComponent { + + @Activate + public void activate() { + try { + System.out.println("Activate not so long ..."); + Thread.sleep(150); + System.out.println("Activated not so long"); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Deactivate + public void deactivate() { + try { + System.out.println("De-activate not so long ..."); + Thread.sleep(150); + System.out.println("De-activated not so long"); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/org.gecko.playground.tracing/src/org/gecko/playground/tracing/QuickActivationComponent.java b/org.gecko.playground.tracing/src/org/gecko/playground/tracing/QuickActivationComponent.java new file mode 100644 index 0000000..aedd9d6 --- /dev/null +++ b/org.gecko.playground.tracing/src/org/gecko/playground/tracing/QuickActivationComponent.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2012 - 2023 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.tracing; + +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; + +/** + * + * @author mark + * @since 05.09.2023 + */ +@Component +public class QuickActivationComponent { + + @Activate + public void activate() { + try { + System.out.println("Activate Quick ..."); + Thread.sleep(15); + System.out.println("Activated Quick"); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Deactivate + public void deactivate() { + try { + System.out.println("De-activate Quick ..."); + Thread.sleep(15); + System.out.println("De-activated Quick"); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +}