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

Martin Zdila commented on FELIX-2197:
-------------------------------------

Sorry for typo, classLoaderCreated is correct.

I don't know all the details, but this patch enabled our application to run 
under Terracotta (that modifies the bytecode on class load). I believe it could 
be written better or maybe there is other way to make Felix run under 
Terracotta without any modification to Felix. Or maybe even Terracotta itself 
could be patched to not to require this class loader registration - but I don't 
know the Therracotta reason nor internals. If I haven't decided finally not to 
use Terracotta, then I would try to find this out.

Also, Equinox has this classloader hook proprietary feature among others. I am 
not the fan of proprietary extensions, but if there is no other way... In any 
case, I don't really need it now, but maybe somebody will switch from Felix to 
Equinox just for this reason.

> Please implement something like Equinox's 
> org.eclipse.osgi.baseadaptor.hooks.ClassLoadingHook
> ---------------------------------------------------------------------------------------------
>
>                 Key: FELIX-2197
>                 URL: https://issues.apache.org/jira/browse/FELIX-2197
>             Project: Felix
>          Issue Type: New Feature
>          Components: Framework
>    Affects Versions: felix-2.0.4
>         Environment: irrelevant
>            Reporter: Martin Zdila
>         Attachments: framework.patch
>
>
> Please implement something like Equinox's 
> org.eclipse.osgi.baseadaptor.hooks.ClassLoadingHook. We need it for running 
> Felix under Terracotta (there is HOWTO for Equinox: 
> http://www.terracotta.org/confluence/display/wiki/Run+with+Eclipse+Equinox). 
> We patched the Felix Framework for the workaround. The patch is attached. We 
> use it like this:
> ...
> import org.apache.felix.framework.ClassLoaderHook;
> import org.apache.felix.framework.Felix;
> import com.tc.object.bytecode.hook.impl.ClassProcessorHelper;
> import com.tc.object.loaders.NamedClassLoader;
> ...
>       final Properties properties = new Properties();
> ...
>       properties.put("classLoaderHook", new ClassLoaderHook() {
>               @Override
>               public void classLoaderCreared(final ClassLoader classLoader) {
>                       if (classLoader instanceof NamedClassLoader) {
>                               ((NamedClassLoader) 
> classLoader).__tc_setClassLoaderName(classLoader.toString());
>                               
> ClassProcessorHelper.registerGlobalLoader((NamedClassLoader) classLoader, 
> null);
>                       }
>               }
>       });
>               
>       return new Felix(properties);
> ...
> Thanks in advance.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to