Administration and Development > Integration Hub Capabilities > Resource Providers > Java-Based Resource Providers > Thing-Based Resource Provider
  
Thing-Based Resource Provider
com.ptc.resource.ThingBasedResourceProvider is a subclass of com.ptc.resource.ResourceProvider whose resources are all things in ThingWorx that implement a specified thing shape. This subclass also has its own thing template named PTC.Resource.ThingBasedResourceProviderTemplate. You can create resource providers that expose Things tagged with a desired thing shape using the ThingWorx Composer. You can do this by creating a thing from the PTC.Resource.ThingBasedResourceProviderTemplate thing template, specifying the required Resource thing shape configuration setting, and adjusting other necessary configuration settings.
Alternatively, you can create your own subclass of com.ptc.resource.ThingBasedResourceProvider and expose it as a thing template, creating resource provider instances from the new thing template instead. For example, you might do this if you want to provide default configuration settings in a thing template from which multiple similar resource providers can be created.
The com.ptc.resource.crm.ThingworxCustomerResourceProvider is an example of such a Java class:
@ThingworxBaseTemplateDefinition(name = "PTC.Resource.ThingBasedResourceProviderTemplate")
public class ThingworxCustomerResourceProvider extends ThingBasedResourceProvider {
public static final String DISPLAY_NAME_PROPERTY = "DisplayName";
@Override
protected void initializeThing() throws Exception {
addMapping(DISPLAY_NAME_PROPERTY, DISPLAY_NAME_PROPERTY, BaseTypes.STRING, false);
addMapping(NAME_PROPERTY, DISPLAY_NAME_PROPERTY, BaseTypes.STRING, false);
super.initializeThing();
}
Resource Thing Shapes
Each thing-based resource provider provides all things that implement the thing shape specified by its ResourceThingShape setting. Any thing that implements two such resource thing shapes is (redundantly) provided by two different resource providers. For example, a single asset showing up twice in asset lists but with a different ID and icon is not desired.
Unless there is a clear need to do so, it is highly recommended that you avoid using any resource thing shape to denote anything other than the resource provider mapping. Doing so would allow multiple such thing shapes to apply to a single thing and would not dictate that all things with those traits be provided by a single resource provider. Providing things using multiple resource providers becomes necessary when some things are intended to differ in capabilities, relationship roles, or attribute mappings.
Implementing a resource thing shape in an asset thing template is not recommended. Once a thing has been created, you cannot change what thing template it derives from. Therefore, any assets created from a thing template that implements a resource thing shape will permanently implement that thing shape unless you modify the template itself (thus changing all its assets). If the thing template is not editable, you must reconfigure the existing resource provider to use a different resource thing shape, and reconfigure all existing assets associated with the existing provider to implement an appropriate resource thing shape in order to map the asset to a new resource provider. However, if the asset thing directly implements a resource thing shape, you can modify the individual asset things that you want to remap.