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-31-2008, 12:45 PM
beelzerob beelzerob is offline
Sage Advanced User
 
Join Date: May 2006
Posts: 163
Making the connection between java JAR and an STVi?

I have a 2-part project, where I write java to connect via a TCP port to another PC and grab some XML data and then display that data and its changes within Sage.

I've done part 1...I've now got java code that connects to the other PC and parses the XML (and logs in and checks headers and other stuff other than just parsing XML). And I've now read through the Studio user's guide. I see how you can manipulate menu items and call java functions and all that...but I don't see where I connect these two items that I've created.

I created one other JAR once that ran in the background and made calls to the Sage API and collected info and changed settings in Sage...but it never had any kind of user interface. So that's all I'm familiar with.

Where is the documentation that help me learn about populating a sage screen with data derived from a java program and allowing for 2-way interaction? thanks
Reply With Quote
  #2  
Old 08-31-2008, 01:12 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Chapter 9 of the Studio manual contains a section on "Using Java code" that tells you how to call Java functions from Studio. If you've put your JAR in the SageTV\SageTV\JARs directory, you should be able to refer to your functions by package_class_method name, and the Java runtime will find and load the JAR automatically. If they're not static methods, you'll need to first create an instance of your class via new_package_class(), and then pass it in as the first argument to your non-static methods. But beyond that there isn't anything special you need to do to connect a specific JAR file to a specific STVI.

Populating a screen with data from a Java class is no different than populating it with data from the SageTV API. Just call the functions that return the data you want, and use it to fill table widgets or whatever. Data is data as far as the widgets are concerned; it doesn't matter where it comes from.
__________________
-- Greg
Reply With Quote
  #3  
Old 08-31-2008, 02:47 PM
beelzerob beelzerob is offline
Sage Advanced User
 
Join Date: May 2006
Posts: 163
Ok...so there basically is no main or runnable then? You would just create the object and then call the functions you want on it?

I have to keep a connection going, though, so that means the instance I create has to stay alive. If I create a java class object, then does it stay around so long as they are using the sage screen I created?

Thanks a lot, by the way...that makes sense to me and helps a lot.
Reply With Quote
  #4  
Old 08-31-2008, 04:21 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
A Java object stays around as long as somebody holds a reference to it; once the last reference disappears, it's subject to garbage collection. If you store an object reference in an Attribute widget variable, the object should stay alive as long as that menu is displayed. If you want a longer lifetime than that, you can store a reference in a global using AddGlobalContext (but remember to set the global to null again when you're done with the object).

If you need some sort of global initialization or finalization, there are a couple of ways to accomplish that. The ApplicationStarted hook is one possible place to do initialization, but the BeforeMenuLoad hook on the Main Menu might be a better choice, since that fires during STV reload as well as during system startup. Use a global flag to check to see if your init code has been run once already to avoid re-initializing every time the menu loads. The ApplicationExiting hook provides a place to put some finalization code if you need to close files or connections before Sage shuts down.
__________________
-- Greg
Reply With Quote
  #5  
Old 08-31-2008, 04:31 PM
beelzerob beelzerob is offline
Sage Advanced User
 
Join Date: May 2006
Posts: 163
Thanks a lot, Greg...I think that should be enough info to get me started....certainly pointed in the right direction.
Reply With Quote
  #6  
Old 09-01-2008, 09:40 AM
beelzerob beelzerob is offline
Sage Advanced User
 
Join Date: May 2006
Posts: 163
Greg, do you know of a specific download/addon for sage that utilizes java and the STVi pages like I'm trying to do? Nothing works better than seeing a specific example. I'm just having trouble figuring out the order of the widgets and such.
Reply With Quote
  #7  
Old 09-01-2008, 10:04 AM
nielm's Avatar
nielm nielm is offline
SageTVaholic
 
Join Date: Oct 2003
Location: Belgium
Posts: 4,496
dynamic menus, imdb lookup
__________________
Check out my enhancements for Sage in the Sage Customisations and Sageplugins Wiki
Reply With Quote
  #8  
Old 09-01-2008, 10:27 AM
beelzerob beelzerob is offline
Sage Advanced User
 
Join Date: May 2006
Posts: 163
thanks!
Reply With Quote
  #9  
Old 09-11-2008, 05:34 PM
beelzerob beelzerob is offline
Sage Advanced User
 
Join Date: May 2006
Posts: 163
nielm, I installed dynamic menus, and I think imdb lookup (it never produced the menu item it said it should), but I still didn't find any evidence of java functions being called from inside the studio widgets. Can you point me to a specific menu item that calls java so I can know what to look for?

I have to blow everything away and reinstall to try and fix a problem, so I've got to try again to find those things.
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


All times are GMT -6. The time now is 06:15 PM.


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