felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pierre De Rop (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FELIX-4853) Create a new ServiceDependency that sets the TCCL to the incoming servicereference bundle's classloader before invoking callbaks
Date Fri, 17 Apr 2015 08:31:58 GMT

    [ https://issues.apache.org/jira/browse/FELIX-4853?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14499469#comment-14499469
] 

Pierre De Rop commented on FELIX-4853:
--------------------------------------

you're welcome Carlos;

By the way, the latest version of DM is now packaged in the top level "r2" release and the
DM 3.2.0 version is now old and deprecated.
You can download the "all-in-one" archive from the download page [1], and the new documentation
can be found from [2]
it requires BndTools if you want to build it and there are many samples codes that can be
executed directly under eclipse/BndTools; see "Sample code" section in [3].
In the source distribution, you will find a sample code about aspects [4], or [5] is the same
example using annotation style.

[1] http://mirror.reverse.net/pub/apache//felix/org.apache.felix.dependencymanager-r2-src.zip
[2] http://felix.apache.org/documentation/subprojects/apache-felix-dependency-manager.html
[3] http://felix.apache.org/documentation/subprojects/apache-felix-dependency-manager/guides/whatsnew.html
[4] http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/api/
[5] http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/annot/

> Create a new ServiceDependency that sets the TCCL to the incoming servicereference bundle's
classloader before invoking callbaks
> --------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: FELIX-4853
>                 URL: https://issues.apache.org/jira/browse/FELIX-4853
>             Project: Felix
>          Issue Type: New Feature
>          Components: Dependency Manager
>    Affects Versions: dependencymanager-3.2.0
>            Reporter: Carlos Sierra
>
> The invoke method would go like this:
> {code:title=TCCLServiceDependencyImpl.java|borderStyle=solid}
>         @Override
> 	@SuppressWarnings("rawtypes")
> 	public void invoke(
> 		Object[] callbackInstances, DependencyService dependencyService,
>                 ServiceReference reference, Object service, String name) {
> 		Bundle bundle = reference.getBundle();
> 		BundleWiring bundleWiring = bundle.adapt(BundleWiring.class);
> 		ClassLoader bundleClassLoader = bundleWiring.getClassLoader();
> 		Thread currentThread = Thread.currentThread();
> 		ClassLoader contextClassLoader = currentThread.getContextClassLoader();
> 		currentThread.setContextClassLoader(bundleClassLoader);
> 		try {
> 			super.invoke(
> 				callbackInstances, dependencyService, reference, service, name);
> 		}
> 		finally {
> 			currentThread.setContextClassLoader(contextClassLoader);
> 		}
> 	}
> {code}
> If you think this is useful I can provide a patch. Which version and which repo should
I use for it?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message