cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

External Enumerated Value Lists reset

Highlighted
Regular Member

External Enumerated Value Lists reset

Hello,

Does anyone has an example on how you have implemented the reset of an enumeration list.

I have a class that generate a list of wtpart in a text file. But I need to stop windchill and clear the cache to gets the new data.

I'm trying to use this method but I'm struggling to get the EnumerationInfoProvider.

EnumerationInfomanager.resetEnumeration(EnumerationInfoProvider)

 

If anyone has an example it will be great.

Note I used the following code to generate my list:

https://www.ptc.com/en/support/article?n=CS138327&source=subscription

 

thanks

1 REPLY 1
Highlighted

Re: External Enumerated Value Lists reset

Try adding this to your initialize method, I included some context to show source of some variable names.  Every time initialize runs, it sets a timer to expire the cache.  Note that after resetEnumeration is called, the cache will be marked as expired on the server, and the initialize only runs again the next time it is needed.  At that moment, the cache will be fresh, and the timer resets.

 

...
import wt.session.SessionContext;
import wt.session.SessionThread;
...
public class Replace_With_Class_Name_Of_This_EnumerationInfoProvider implements EnumerationInfoProvider {
...
	private static final String ENUMERATION_NAME = "Your Enumeration Name";
	private EnumerationInfoManager enumInfoManager = null;
	private String parameters = null;
	private static final AtomicLong threadNumber = new AtomicLong();
...
	public void initialize(EnumerationInfoManager manager, String params) {
...
	    Runnable cacheResetSessionThread = new Runnable ()  {
	    	public void run ()  {
	    		try {
	    			// Note this runs once and exits - because after clearing cache, its job is done.  The next time data is needed, the server will
	    			// call initialize again, which will run this code again.
    				long timerDelay = 30 * 60 * 1000L;  // in milliseconds
    				Thread.sleep(timerDelay);
    				if(enumInfoManager != null) {
    					enumInfoManager.resetEnumeration(Replace_With_Class_Name_Of_This_EnumerationInfoProvider.this);
    				}
	    		}
	    		catch (InterruptedException e) {
	    			Thread.currentThread().interrupt();
	    			e.printStackTrace();
	    		}
	    	}
	    };
	    String sessionThreadName = ENUMERATION_NAME+"-"+threadNumber.incrementAndGet();
	    SessionThread sessionThread = new SessionThread(cacheResetSessionThread, new SessionContext(),sessionThreadName);
	    sessionThread.start();

 

Announcements