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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Is it possible to override a service in a thingshape in a thing with java code ?

Vidh
7-Bedrock

Is it possible to override a service in a thingshape in a thing with java code ?

Assume that i have a ThingShape  named SolvableSolutionProvider and it has a method submitJob() ;

If i mark the method as overrideable i can override the implementation provided in the Thingshape in the template or a thing.

Is it possible to provide a java implementation for the method ?

4 REPLIES 4
LeoDias
3-Visitor
(To:Vidh)

Also interested in knowing, how to override an service using the extension sdk.

Any help?

PaiChung
22-Sapphire I
(To:Vidh)

In 7.x you can now override Services.

Not sure how to do it with extensions sorry.

mhollenbach
5-Regular Member
(To:Vidh)

In the metadata of an entity you want the isAllowOverride="true" aspect to be set. That is pertaining to a service defined in XML.

When you use the Eclipse plugin, if you right-click on a .java file and hover over the ThingWorx menu option you have the ability to add a new Service or Property to that class. Add a new service, and there will be an "allow Override" checkbox available for you to select by default. Finish creating that service and you will see the aspect added. This is only available with the 7.x extension sdk and latest ThingWorx plugin for Eclipse.

The service will look something like this (see isAllowOverride set to true below):

@ThingworxServiceDefinition(name = "TestingService", description = "", category = "", isAllowOverride = true, aspects = {

  "isAsync:false" })

@ThingworxServiceResult(name = "Result", description = "", baseType = "NOTHING")

public void TestingService() {

       _logger.trace("Entering Service: TestingService");

       _logger.trace("Exiting Service: TestingService");

}

Thanks, I resorted to a similar workaround.

Defined the main ThingTemplate in the Composer, with an overridable service.

Afterwards in the extension, added a ThingTemplate  which had the previous one (created in the composer) as the BaseTemplate. Defined the same service signature. And "voilà"

Top Tags