English 中文(简体)
Strategy for garbage collecting Java objects created by custom OpenOffice spreadsheet functions
原标题:

I have written an OpenOffice / LibreOffice add-in that implements some custom Calc spreadsheet functions in Java. Some of these functions create Java objects that are then logically associated with the result of the function and thus also associated with the cell that the function is used in.

(Assuming for now that the function is being called from a cell formula and not from the Function Wizard or some other context).

OpenOffice does not tell custom functions which cell they are being called from, so it is not easy to figure out that association. If the parameters to the function are cell addresses then it is possible to look at those cells and find the cells that are dependent on them - this narrows down the possibilities.

It could be possible to include a unique key for the Java object in the result if it is a string, but that is ugly. I could then periodically scan all cells to make sure that the unique key is still present in one or more cells.

However, the function could also be nested within other functions in a formula, so there is no guarantee that the key will end up being visible in the resulting value of the cell.

I am looking for a clean way to detect that the logical reference to the object has gone away (because the instance of the function was called with different args, or the formula containing the function has been deleted or altered).

Edit: Returning an XVolatileResult looked promising, however the removeResultListener() call-back is never called when a formula is deleted (except at document close).

Some more clarification: A custom function is implemented as an instance method of an Uno component (there may be more than one custom function on a single component). Only one instance of the component is ever created.

The function method is called with string or numeric arguments, corresponding to the arguments in the spreadsheet formula. It is also possible to receive the args as cell references rather than values.

The result of the function is a string or numeric value or an XVolatileResult. It is not possible to return an arbitrary Java object.

I am creating Java objects as a side-effect of evaluating the function and I want to be able to reference those objects in other formulas in other cells.

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签