SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Studio
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-17-2010, 10:06 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Possible to get all implementations of a interface?

Is it possibly to get all currently available implementations of a given interface?

I am new to the interface coding and have been reading up and I was curious if it was possible for me to get a list of any classes that are currently implementing my interface? Surely there is and I am just missing it.

TIA

plucky
Reply With Quote
  #2  
Old 08-17-2010, 10:11 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Looking at Sean's interface classes it appears new ones are added to his via a property so it appears it can't be grabbed automatically if I am correct in my thinking.
Reply With Quote
  #3  
Old 08-17-2010, 11:01 AM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
What do you mean by "all currently available implementations"? Currently loaded classes? Class definitions in JAR files on the classpath? Plugins available for download?

It's possible to enumerate the currently enabled plugins and check each one to see if it implements a particular interface. This is how my Studio Framework finds Studio plugins.

It's also possible to enumerate JARs on the classpath looking for classes that implement a particular interface. This is how my framework used to do it prior to V7.

Beyond that you're going to have to define what you're trying to do more precisely in order to know whether it's practical.
__________________
-- Greg
Reply With Quote
  #4  
Old 08-17-2010, 11:12 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Quote:
Originally Posted by PLUCKYHD View Post
Looking at Sean's interface classes it appears new ones are added to his via a property so it appears it can't be grabbed automatically if I am correct in my thinking.
I'm not sure what you are referring to by my interfaces?

But as greg noted, it is possible to load every single class in the system, and then test if that class implements the specififed interface. While this is OK for some cases (ie, greg does this in his studio plugins i think), I don't recommend doing this for core code, since you'd actually load every class into memory. Many jars on the system rarely use all classes in the jar, so you'd be loading each class needlessly, and consuming extra memory.
Reply With Quote
  #5  
Old 08-17-2010, 11:50 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Quote:
Originally Posted by GKusnick View Post
What do you mean by "all currently available implementations"? Currently loaded classes? Class definitions in JAR files on the classpath? Plugins available for download?

It's possible to enumerate the currently enabled plugins and check each one to see if it implements a particular interface. This is how my Studio Framework finds Studio plugins.

It's also possible to enumerate JARs on the classpath looking for classes that implement a particular interface. This is how my framework used to do it prior to V7.

Beyond that you're going to have to define what you're trying to do more precisely in order to know whether it's practical.
Okay sorry. Basically I am trying to get all loaded classes by the plugin system. (really don't want to have to load them as they should already be loaded if enabled correct) so I can go through them and see if the implement a certain interface.

Hopefully I explained it better that time.

Quote:
Originally Posted by stuckless View Post
I'm not sure what you are referring to by my interfaces?
Sean,

I am probably misreading but I am refering to this part of your fanart code api from phoenix.

Quote:
* Any developers wishing to use thier own Fanart Support system can careate an implemenation for {@link IFanartSupport} and register it
* using the phoenix/mediametadata/fanartSupportClass property
*
* <pre>
* phoenix/mediametadata/fanartSupportClass=sagex.phoenix.fanart.SageMCFanartSupport
* </pre>
How are you suppose to register that and how do you pick it up is it just based on that property ?
Reply With Quote
  #6  
Old 08-17-2010, 12:02 PM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Plucky, that property may not do anything at the moment... ie, it's always going to be PhoenixFanartSupport. If you want to provide your own Fanart Support class, then I can work with you to provide a pluggable way for you to register your class implementation. Keep in mind, if you are looking to register your own Fanart Support class, then that class is used to "resolve" fanart on the local filesystem. So a reason to provide an implementation would be if you wanted code that use the phoenix apis to load their local fanart from another area, other than the phoenix fanart folder structure.

Perhaps if you outlined what you are trying to do, I could maybe help with some ideas... also, if you are looking at integrating with phoenix apis, then I can certainly help with that. If you are looking at registering your own providers, etc, then I can look at making that more user friendly from a developer perspective, but I need to know exactly what you are trying to do.
Reply With Quote
  #7  
Old 08-17-2010, 12:05 PM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Quote:
Originally Posted by stuckless View Post
Plucky, that property may not do anything at the moment... ie, it's always going to be PhoenixFanartSupport. If you want to provide your own Fanart Support class, then I can work with you to provide a pluggable way for you to register your class implementation. Keep in mind, if you are looking to register your own Fanart Support class, then that class is used to "resolve" fanart on the local filesystem. So a reason to provide an implementation would be if you wanted code that use the phoenix apis to load their local fanart from another area, other than the phoenix fanart folder structure.

Perhaps if you outlined what you are trying to do, I could maybe help with some ideas... also, if you are looking at integrating with phoenix apis, then I can certainly help with that. If you are looking at registering your own providers, etc, then I can look at making that more user friendly from a developer perspective, but I need to know exactly what you are trying to do.
I was simply using that as an example I am writing my own interface for SMM and just wanted a way to get a list of any other classes that are implementing it so I can give the user and option to chose what implementation to chose. I just saw that on phoenix and figured that is how you were doing it .

I am trying to allow others to write implementation to SMM and let me pick up there classes and offer them as options automatically (if that makes since completely)
Reply With Quote
  #8  
Old 08-17-2010, 12:06 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Quote:
Originally Posted by PLUCKYHD View Post
Basically I am trying to get all loaded classes by the plugin system. (really don't want to have to load them as they should already be loaded if enabled correct) so I can go through them and see if the implement a certain interface.
OK, so if I understand you right you're not looking for all loaded classes, just the ones that are SageTVPlugins. You want to see if there are any enabled plugins whose ImplementationClass also implements your interface. Correct?

This is exactly what my Studio Framework does to find Studio plugins. If you have the Framework installed, you have the source code for it. Look at CospGetEnabled in Hook.java to see how I do it.
__________________
-- Greg
Reply With Quote
  #9  
Old 08-17-2010, 12:08 PM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Quote:
Originally Posted by GKusnick View Post
OK, so if I understand you right you're not looking for all loaded classes, just the ones that are SageTVPlugins. You want to see if there are any enabled plugins whose ImplementationClass also implements your interface. Correct?

This is exactly what my Studio Framework does to find Studio plugins. If you have the Framework installed, you have the source code for it. Look at CospGetEnabled in Hook.java to see how I do it.
spot on thanks I will give that a look. If I have any questions (you know I will) I will report back thanks
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Interface changes in 6.5.11 baudfather SageTV Beta Test Software 1 03-11-2009 04:45 AM
New SageTV Interface matrix35 SageTV Software 183 12-08-2007 02:51 AM
Future SageTV Implementations? cmaffia SageTV Software 1 06-28-2004 10:54 AM
Interface Design CD videogeek SageTV Customizations 0 06-06-2004 12:19 PM


All times are GMT -6. The time now is 02:29 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.