I am trying to programmatically restart an application by retrieving the owner of its shared interface and calling stop (as recommended by Alga), but it appears that the ownership helper is not behaving as described by the Javadoc.
In the following example, the output on System.out is the owner of the shared interface, not of the referenced object:
OwnershipHelper ownershipHelper = ServiceFactory.getRequiredService(OwnershipHelper.class);
Application app = ownershipHelper.getOwner(myInterface);
System.out.println("App Identifier: " + app.getIdentifier());
From the Javadoc:
/**
* Returns the application that owns the given object.
* <p>
* If the object belongs to the kernel or the application is not found, the method returns {@code null}.
* <p>
* If the object is a proxy object, the implementation should return the application that owns the referenced
* object.
*
* @param object
* the object.
* @return the owner of the object.
*/
@Nullable
Application getOwner(Object object);