You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Martin Zdila (JIRA)" <ji...@apache.org> on 2010/03/12 10:59:27 UTC

[jira] Created: (FELIX-2197) Please implement something like Equinox's org.eclipse.osgi.baseadaptor.hooks.ClassLoadingHook

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;
...
		properties.put("classLoaderHook", new ClassLoaderHook() {
			@Override
			public void classLoaderCreared(final ClassLoader classLoader) {
				if (!(classLoader instanceof NamedClassLoader)) {
					return;
				}

				System.out.println(classLoader.toString());
				((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.


[jira] Updated: (FELIX-2197) Please implement something like Equinox's org.eclipse.osgi.baseadaptor.hooks.ClassLoadingHook

Posted by "Martin Zdila (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-2197?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Zdila updated FELIX-2197:
--------------------------------

    Attachment: framework.patch

the patch

> 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;
> ...
> 		properties.put("classLoaderHook", new ClassLoaderHook() {
> 			@Override
> 			public void classLoaderCreared(final ClassLoader classLoader) {
> 				if (!(classLoader instanceof NamedClassLoader)) {
> 					return;
> 				}
> 				System.out.println(classLoader.toString());
> 				((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.


[jira] Updated: (FELIX-2197) Please implement something like Equinox's org.eclipse.osgi.baseadaptor.hooks.ClassLoadingHook

Posted by "Martin Zdila (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-2197?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Zdila updated FELIX-2197:
--------------------------------

    Description: 
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.

  was:
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;
...
		properties.put("classLoaderHook", new ClassLoaderHook() {
			@Override
			public void classLoaderCreared(final ClassLoader classLoader) {
				if (!(classLoader instanceof NamedClassLoader)) {
					return;
				}

				System.out.println(classLoader.toString());
				((NamedClassLoader) classLoader).__tc_setClassLoaderName(classLoader.toString());
				ClassProcessorHelper.registerGlobalLoader((NamedClassLoader) classLoader, null);
			}
		});
		
		return new Felix(properties);
...

Thanks in advance.


slight simplification of the usecase example

> 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.


[jira] Commented: (FELIX-2197) Please implement something like Equinox's org.eclipse.osgi.baseadaptor.hooks.ClassLoadingHook

Posted by "Richard S. Hall (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-2197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12844552#action_12844552 ] 

Richard S. Hall commented on FELIX-2197:
----------------------------------------

This patch seem pretty simple. Can you tell me how you guys actually use it?

> 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;
> ...
> 		properties.put("classLoaderHook", new ClassLoaderHook() {
> 			@Override
> 			public void classLoaderCreared(final ClassLoader classLoader) {
> 				if (!(classLoader instanceof NamedClassLoader)) {
> 					return;
> 				}
> 				System.out.println(classLoader.toString());
> 				((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.


[jira] Commented: (FELIX-2197) Please implement something like Equinox's org.eclipse.osgi.baseadaptor.hooks.ClassLoadingHook

Posted by "Martin Zdila (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-2197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12844846#action_12844846 ] 

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

The usecase is in the issue description: We use Felix embedded and we pass ClassLoaderHook to Felix via its properties.

Anyway, we finally decided not to use Terracotta in out project. But the ClassLoaderHook feature for Felix would be useful for others who want to use Terracotta. Equinox has such feature (even more capable, see the link in description), so why Felix shouldn't ;-). The attached patch was only a quick solution for us and if you decide to implement it, you will probably do it better :-)

> 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;
> ...
> 		properties.put("classLoaderHook", new ClassLoaderHook() {
> 			@Override
> 			public void classLoaderCreared(final ClassLoader classLoader) {
> 				if (!(classLoader instanceof NamedClassLoader)) {
> 					return;
> 				}
> 				System.out.println(classLoader.toString());
> 				((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.


[jira] Commented: (FELIX-2197) Please implement something like Equinox's org.eclipse.osgi.baseadaptor.hooks.ClassLoadingHook

Posted by "Martin Zdila (JIRA)" <ji...@apache.org>.
    [ 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.


[jira] Commented: (FELIX-2197) Please implement something like Equinox's org.eclipse.osgi.baseadaptor.hooks.ClassLoadingHook

Posted by "Richard S. Hall (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-2197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12845360#action_12845360 ] 

Richard S. Hall commented on FELIX-2197:
----------------------------------------

Yeah, I have no doubt that some people use Equinox specifically for its proprietary extensions, but I prefer to not get into that game.

Thanks for the info about the hook. I realize that there is a general need for this and the topic has come up in CPEG, which is why I was interested in how this patched worked. If I were to extend the framework, I'd like for it to be done in a way that provided a general solution, not one specific to Terracotta. But I guess if they can use it for this purpose, then other people can too.

At any rate, we'll keep this issue around, since it represents a real need.

> 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.


[jira] Commented: (FELIX-2197) Please implement something like Equinox's org.eclipse.osgi.baseadaptor.hooks.ClassLoadingHook

Posted by "Richard S. Hall (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-2197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12844888#action_12844888 ] 

Richard S. Hall commented on FELIX-2197:
----------------------------------------

Well, why we shouldn't is because it is a containerism that adds additional API to the framework beyond the OSGi API, which then constrains us further when it comes to making future changes.

Still, I guess I wasn't clear. I was wondering what capability this patch enables. Typically, a class loader hook is need to intercept byte code definitions to rewrite them. This patch appears to simply notify someone that a class loader was created.

BTW, should that be classLoaderCreated()  rather than classLoaderCreared()?

> 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.