powered by Jive Software

Changing the ProviderManager

The current (1.4.1) code has ProviderManager that is all statics. This manager uses a particular mechanism for discovering providers and extensions. Unfortunately, that mechanism is not quite what we are after. There does not appear to be an easy way of replacing the ProviderManager.

Did I miss something?

What we have done in the mean time is change ProviderManager to be a singleton based structure and then implemented a subclass which does our work. All references (there were not many) where changed to be something like

ProviderManager.getDefault().

rather than

ProviderManager.

At startup we simply create our own ProviderManager and stuff it in the ProviderManager using a oneshot method.

ProviderManager.setDefault()

Thoughts, comments?

Jeff

p.s., how can I retain the indentation of my posts. The forums seem to delete all leading spaces.

Hey Jeff,

What is it that you need to do with ProviderManager? ProviderManager will try to look for providers and extensions automatically when initialized but you can also add new IQ providers and extension providers programmatically.

Regards,

– Gato

I am doing this in Eclipse. Eclipse is a dynamic environment where function can appear (and disappear) during a session. Eclipse also uses a component model where each “plugin” gets its own classpath.

In my system the provider manager dynamically discovers and installs (e.g., downloads from some remote server) components to handle new messaging content.

Example: I took the MUC related code out of Smack and put it in a separate plugin. This plugin is on a remote server. When running a Smack session someone invites me to a MUC. The first MUC related message triggers the provider manager to go looking for a provider. It does not have one installed so it goes out to the world (think web service or some such) to find one. When it does, it downloads it and installs it and uses it to handle the MUC messages.

So the long and short of it is that I need to provide my own ProviderManager. Since the class is all statics and everyone knows the name, I can’'t.

Jeff

Hey Jeff,

I think that you may do the following and still reuse the ProviderManager. When you load a new plugin you can register the new IQ and extension providers. Or when you go out to the world looking for a provider and if you find one you can try registering the located provider.

Does that make sense to you? We may need to add support for removing providers which is a feature that we currently don’'t have.

Regards,

– Gato

I believe the challenge I had was in hooking the provider lookup. I had to hook getIQProvider and getExtensionProvider in my subclass of ProviderManager to essentially do the super call and then if that failed to do my dynamic discovery and install.

I agree that if the user manually installed a plugin with new providers I could add them programatically but do you see another place I could inject myself in the handling of a new packet type and supply my own provider?

Thanks

Jeff

I don’'t know much about Eclipse. But being a dynamic environment I would expect to provide some notification events or some way to hook up some custom code that may be executed when a plugin is loaded and unloaded. Maybe you can check this idea out in the eclipse forums.

Another approach would be to change the ClassLoader that you are using but this idea I don’'t like it much. Otherwise, I think that you will have to change the way ProviderManager is working.

Regards,

– Gato