Java ThingShape Extension context not finding correct thing
I have created a Java Extension as a ThingShape, when I add it to multiple Things on the platform, the ThreadLocalContext.getMeContext() returns the information for the Thing that was connected to first NOT the Thing that the current ThingShape is connected to.
Here is how it is set up
Thing1
- ThingShape Extension connected to Thing1
Thing2
- ThinShape Extension connected to Thing2
If I connect to Thing1 -- the first connection - everything works, Then I disconnect my device and connect a different device to Thing2 (which has the same type of extension) The Thing2 calls will return information grabbed by the extension about Thing1 -- even though it is NOT connected to Thing1.
Here is the code I am using in the java extension (ThingShape) I use this to send information to the Thing the extension is connected to as well as the device.
Object me = ThreadLocalContext.getMeContext();
if (me instanceof Thing) {
// ------------------------------
// Assign connected thing to me
// ------------------------------
Thing connectedThing = (Thing) me;
// -------------------------------------------
// Get thing name for personalization string
// -------------------------------------------
_thingName = _connectedThing.getName();
}
How do I get the Thing object in the java extension of the thing I am calling - I have tried extending my class to Thing instead of ThingShape and using
StringPrimitive name = (StringPrimitive)this.getPropertyValue("name");
But this returns a null value or blank, I have tried totally disconnecting the previous edge device from the platform before making the calls as well as making the calls at the same time -- the extension will ONLY see the Thing that the device made the first connection to, no subsequent connections to other Things are found unless I restart the platform. If you can connect to multiple "Things" and those things each have the thingshape extension added individually - there should be a way to ensure the extension uses the Thing that the edge device is connected to.
In short if I call the Thing from the edge device to call a service that is within the extension -- it call the service on the Thing that was first connected to NOT the Thing that the edge device is calling.
Any help would be greatly appreciated!

