SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Studio

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 12-11-2009, 11:48 AM
jphipps jphipps is offline
Sage Expert
 
Join Date: Aug 2006
Location: Maryland
Posts: 512
Context/ThreadLocal data

I am writing a few java methods, and I want to keep track of some information ( objects ) that is unique to each extender that connects. I am assuming this is related to the age old problem of the context.. I have tried using ThreadLocal variables, and they seem to work in none UI widgets, but it seems the UI widget must be executing in another thread so they don't have access to that data. For example, if i do a DebugLog() and print the results of a method that is returning a ThreadLocal variable, it works fine, but if you use the same method to display on the screen, it returns null. Does anyone know if this is how it is working or how to store data specific to a context?

Thanks,
Jeff
Reply With Quote
  #2  
Old 12-11-2009, 12:12 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Seems like the most straightforward approach would be to avoid static methods and create a new instance of your class for each running client. Use AddGlobalContext() to store your instance in a global variable specific to that client, and check that variable for null in the Main Menu's BeforeMenuLoad hook to see if it's been initialized yet. Then pass the instance in to your class method calls. That's how classes and objects are meant to work, so why not use them that way?
__________________
-- Greg
Reply With Quote
  #3  
Old 12-11-2009, 12:26 PM
jphipps jphipps is offline
Sage Expert
 
Join Date: Aug 2006
Location: Maryland
Posts: 512
I was trying to avoid having to pass the object reference in on the STV code for each method call. A majority of the code is shared between all connection so the server so i used static calls to reference the instantiated objects, but I have a few bits of data that I needed specifiy to that clients connection. I guess I will do that if I can't find away around it..

Thanks,
Jeff
Reply With Quote
Reply


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

Advanced Search
Display Modes

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
Zap2It & SageTV: Built-in data not affected; Alternatives for EPG data not included? Opus4 SageTV EPG Service 20 08-21-2008 06:31 PM
Help with accessing Variables and variable Context. stanger89 SageTV Studio 6 11-01-2006 09:38 AM
Obtaining correct UI context dflachbart SageTV Studio 3 07-17-2006 07:10 AM
EPG list change based on user's context jtt88 SageTV Customizations 0 06-16-2004 02:16 PM


All times are GMT -6. The time now is 02:41 PM.


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