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

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

How to add Java service to FileRepository via extension - possible?

benr
1-Newbie

How to add Java service to FileRepository via extension - possible?

I'm trying to create a Thingworx extension that adds a special type of ThingTemplate to the system. I'd like the base template to be a FileRepository, so Things that use the template can read a spreadsheet and use custom services to interrogate the spreadsheet.

I have my extension created to the point where I can see my custom services appear in the composer, but it's just on a generic ThingTemplate, not one that uses FileRepository. It seems that if I try and modify my project in that way, I can then see all the FileRepository services on my new template, but my custom services disappear.

I have a few questions:
- Does the Java class that powers my ThingPackage need to extend Thing or FileRepositoryThing?
- In my metadata.xml, should my ThingTemplate 'thingPackage' and 'effectiveThingPackage' attributes both point to my custom ThingPackage?
- Is it correct for my ThingTemplate's 'baseThingTemplate' attribute to be FileRepository?

The problem I'm having is that I can either see my custom service on my template, OR the file repository services, but not both at the same time.

1 REPLY 1
mhollenbach
5-Regular Member
(To:benr)

Hello BenR,

If you want to use the FileRepository as your baseThingTemplate then you will need to implement a ThingShape within your ThingPackage that has your custom services defined.


1. You would simply nest the following within your custom <ThingPackage></ThingPackage> tags: 

<ImplementedShapes>

&lt;ImplementedShape name="YourCustomThingShape" type="ThingShape" /&gt;

</ImplementedShapes>


2. In metadata.xml for the ThingTemplate tags yes, you should make thingPackage and effectiveThingPackage both point to the custom ThingPackage and the baseThingTemplate point to FileRepository.


3. Below all of those tags you will want to do the following:

<ThingShapes>

&lt;ThingShape name="YourCustomThingShape"&gt;

<PropertyDefinitions/>

<ServiceDefinitions>

<ServiceDefinition>

&lt;ResultType baseType="+YourDesiredType" name="YourCustomServiceName" +/&gt;

<ParameterDefinitions />

</ServiceDefinition>

</ServiceDefinitions>

</ThingShape>

</ThingShapes>


By defining this separate ThingShape you should no longer lose your custom services.


Regards,

Meghan Hollenbach



Top Tags