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

How to use and Test Java Server Side extension ?

SOLVED
Newbie

How to use and Test Java Server Side extension ?

Hi All,

I have a requirement. I have a value Stream associated with a thing. I am using this data to display on time series chart by using service QueryPropertyHistory. It works perfectly. Now I want to apply some complex logic on this value stream data , which can be easily doable in Java. So, I have decided to go with Java Server Side extension. How to start with this? Any example which can help me to start with this? How can get value stream data using service QueryPropertyHistory in java?

Thanks,

Azim

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions

Re: How to use and Test Java Server Side extension ?

azim hawaldar​,

As per my understanding TRACE will include ERROR and INFO mode so we don't require separate entries for ERROR and INFO for the same package.

Try to log WARN log entry in the code to see if it shows? Also, try to change the ROOT level to INFO.

I hope it helps.

View solution in original post

18 REPLIES 18

Re: How to use and Test Java Server Side extension ?

Could you please provide clarification on which extension you are talking about - did you download it from Marketplace, is it an officially ptc supported extension?

Re: How to use and Test Java Server Side extension ?

Hi azim hawaldar​,

To begin with Java Extension, You need to:

1. Download Java Extension SDK from here.

2. Download Thingworx Eclipese plugin from Marketplace and check the user guide in the same place(Eclipse plugin is optional but it's very helpful for

your to convenienctly create a Thing/ThingTemplate, etc.)

3. Now you are ready to play with Java on Thingworx entity and services(QueryPropertyHistory for example). If you are not sure how to arrange your project structure and how to utilize the ThingWorx SDK,etc, please take reference to the document (I also attached the document here in case you could not open it).

Thanks,

Br,

Anna

Re: How to use and Test Java Server Side extension ?

Hi Anna An​,

I have started with this. I got this document in one of the ptc's link. But this did not answer my question about how to test the code in extension before we import that into composer, so that I am sure that all my code works fine. Also, i could not find how to use QueryPropertyHistory. Appreciate your help if you can give me some sample code of how to consume QueryPropertyHistory and test the code something like junit will be helpful.

Thanks,

Azim

Re: How to use and Test Java Server Side extension ?

Hi azim hawaldar​,

Please refer to following article to see if it answers your query: https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS250862

Re: How to use and Test Java Server Side extension ?

Hello Ankit Gupta​,

I also visited this link but could not find it useful.

Thanks,

Azim

Re: How to use and Test Java Server Side extension ?

Hi azim hawaldar​,

Full coverage unit tests are not possible in ThingWorx, but partial coverage is. If the logic that needs to be preserved is isolated from the statements that require context, then unit tests can be beneficial and functional.

Per my understanding; we would need to compile our project/ make an extension and then import it via composer. Then based on the application logs we can debug our code.

Re: How to use and Test Java Server Side extension ?

Hello Ankit Gupta​,

As per your suggestions, I added log to debug the code. But these logs are not printing in application logs. Below if my code

// class level static logger variable

private static Logger _logger = LogUtilities.getInstance().getApplicationLogger(RollingStockThingTemplate.class);

somewhere in one of the method

_logger.info("Entering Service: GenerateFFTFromStream");

Am I doing anything wrong here?

Thanks,

Azim

Re: How to use and Test Java Server Side extension ?

Hello Ankit Gupta​,

DId you got a chance to look into this? I am waiting for your response. Please check and let me know.

Thanks,

Azim

Re: How to use and Test Java Server Side extension ?

azim hawaldar​,

I will check this and will get back to you.