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

Roy Teeuwen edited comment on GROOVY-10885 at 12/29/22 9:11 PM:
----------------------------------------------------------------

[~emilles] what would be very helpful is to at least create some API methods in 
the MetaClassRegistryImpl to make it easier to add extra methods. At this 
moment I had to copy over a lot of code from other sources, notably the 
following two methods I'd expect to have available in an API somewhere:

https://github.com/orbinson/aem-groovy-console/blob/feature/update-to-groovy-4.x/groovy/groovy-osgi/src/main/java/groovy/osgi/activator/Activator.java#L117

About the bundle loading / unloading. Loading is not really the issue, it's 
that when a bundle is unloaded, the meta methods are not removable. It is 
currently not a big issue, as long as I don't start developing my own custom 
meta extension module's, where I'd have to redeploy the jar all the time. But 
in my puristic view it would be nice to be able to do it, thats the reason for 
the question of course

https://github.com/orbinson/aem-groovy-console/blob/feature/update-to-groovy-4.x/groovy/groovy-osgi/src/main/java/groovy/osgi/activator/Activator.java#L102


was (Author: royteeuwen):
[~emilles] what would be very helpful is to at least create some API methods in 
the MetaClassRegistryImpl to make it easier to add extra methods. At this 
moment I had to copy over a lot of code from other sources, notably the 
following two methods I'd expect to have available in an API somewhere:

https://github.com/orbinson/aem-groovy-console/blob/feature/update-to-groovy-4.x/groovy/groovy-osgi/src/main/java/groovy/osgi/activator/Activator.java#L117

https://github.com/orbinson/aem-groovy-console/blob/feature/update-to-groovy-4.x/groovy/groovy-osgi/src/main/java/groovy/osgi/activator/Activator.java#L102

> Make Groovy Extensions work in an OSGi environment
> --------------------------------------------------
>
>                 Key: GROOVY-10885
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10885
>             Project: Groovy
>          Issue Type: Improvement
>          Components: groovy-runtime
>            Reporter: Roy Teeuwen
>            Priority: Major
>
> The current setup for loading in ExtensionModule's does not support groovy 
> extensions correctly in OSGi (tested in Apache Felix).
> The reason is that the 
> [MetaClassRegistryImpl|https://github.com/apache/groovy/blob/master/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java]
>  creates an 
> [ExtensionModuleScanner|https://github.com/apache/groovy/blob/master/src/main/java/org/codehaus/groovy/runtime/m12n/ExtensionModuleScanner.java],
>  which scan's the classloader for every jar file with an ExtensionModule 
> properties file. In an OSGi environment, the classloader does not have access 
> to every jar file (bundle) by default.
> I have created an example of an OSGi compatible implementation, using a 
> BundleListener to listen for the addition of a Bundle to the OSGi 
> environment, and then use this to get a ClassLoader for this Bundle to load 
> the ExtensionModule properties file of that Bundle: 
> [Activator|https://github.com/orbinson/aem-groovy-console/blob/feature/update-to-groovy-4.x/groovy/groovy-osgi/src/main/java/groovy/osgi/activator/Activator.java]
> Open questions: 
> - What to do when a Bundle gets reloaded / removed, in an OSGi environment 
> this can be done at runtime but I don't see any methods available in the 
> MetaClassRegistry / CachedClass to remove MetaMethods 
> - Where is this code best hosted? Is it ok to make a new subproject named 
> groovy-osgi that contains the code to make this work, or does Groovy not see 
> this relevant in the groovy git project?



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to