I am currently using the PropertyFilter to filter some properties from my bean classes before they are send to the client. This works great, since it is very ease to implement a concrete class that implements this interface and the apply(Object source, String name, Object value) function.
However, there is one BIG problem with this interface. It calls every getter of the bean before the property gets filtered. In most cases this is a good thing, because it offers the possibility to filter the property by its value. But when working with a database this also has a great disadvantage, because the query is send to the database before filtering.
I would like to filter some properties based on their name, no matter what their value is (f.e. i want to send a book's name to the client, but not its content…). By now the PropertyFilter filters out the unwanted properties but still queries them from the bean (and getContent() of my book is very expensive, since it queries the database and joins several database tables).
I noticed that what i want could be done by using a JsonBeanProcessor for every bean that i want to filter, but that would add multiple JsonBeanProcessors to my project and takes quite some time. Wouldn't it be a better idea to add another filter possibility (lets call it PropertyNameFilter), which defines the function "boolean apply(Object source, String name)" (without the value) that filters out properties BEFORE the bean's getter is invoked? (This would reduce my database queries to a minimum and increase speed by far)
Regards,
Nikolaus Krismer
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi!
I am currently using the PropertyFilter to filter some properties from my bean classes before they are send to the client. This works great, since it is very ease to implement a concrete class that implements this interface and the apply(Object source, String name, Object value) function.
However, there is one BIG problem with this interface. It calls every getter of the bean before the property gets filtered. In most cases this is a good thing, because it offers the possibility to filter the property by its value. But when working with a database this also has a great disadvantage, because the query is send to the database before filtering.
I would like to filter some properties based on their name, no matter what their value is (f.e. i want to send a book's name to the client, but not its content…). By now the PropertyFilter filters out the unwanted properties but still queries them from the bean (and getContent() of my book is very expensive, since it queries the database and joins several database tables).
I noticed that what i want could be done by using a JsonBeanProcessor for every bean that i want to filter, but that would add multiple JsonBeanProcessors to my project and takes quite some time. Wouldn't it be a better idea to add another filter possibility (lets call it PropertyNameFilter), which defines the function "boolean apply(Object source, String name)" (without the value) that filters out properties BEFORE the bean's getter is invoked? (This would reduce my database queries to a minimum and increase speed by far)
Regards,
Nikolaus Krismer