Class HxmReferenceScope
- java.lang.Object
-
- com.hexaly.modeler.HxmReferenceScope
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class HxmReferenceScope extends java.lang.Object implements java.lang.AutoCloseable
A HxmReferenceScope contains a collection of references that can be released together. It simplifies the memory management of objects returned from the modeler API.
When you access a modeler object from the Java API, your Java program takes a new reference to that modeler object. These references are automatically deleted when the associated HexalyModeler object is destroyed. But in the meantime references can prevent objects from being freed even if they are no longer used in the modeler. This is especially true if the interactions between the modeler and your Java programs are complex and are not limited to a few exchanges at the beginning/end of the resolution.
In this case, a HxmReferenceScope allows you to limit the life of your references and can help you to preserve memory.
- Since:
- 11.0
-
-
Constructor Summary
Constructors Constructor Description HxmReferenceScope(HexalyModeler modeler)
Create a new HxmReferenceScope object associated with the modeler in parameter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Releases all references associated with this scope.
-
-
-
Constructor Detail
-
HxmReferenceScope
public HxmReferenceScope(HexalyModeler modeler)
Create a new HxmReferenceScope object associated with the modeler in parameter. All references created from that point anywhere in the API will be automatically associated with this new scope. All these references can then be released in one call toclose()
(or with a try-with-resources statement)- Parameters:
modeler
- The associated modeler.
-
-
Method Detail
-
close
public void close()
Releases all references associated with this scope. It is also disassociated from the modeler and the previous scope is restored as the current one. If the scope has already been closed then this method do nothing and returns immediately.
Note: Releasing a reference does not necessarily imply that the underlying modeler object is destroyed. It is only destroyed if no more references point to it.
- Specified by:
close
in interfacejava.lang.AutoCloseable
-
-