Replies: 11 comments 27 replies
-
Could you describe a usecase where you would use this? Not sure is this should live in the framework or util spec. Or just wrapping the apache directory ldap builder with an filter inteface |
Beta Was this translation helpful? Give feedback.
-
Just everywhere where one can pass a filter (or string) in the framework to filter services or match things against a set of properties. |
Beta Was this translation helpful? Give feedback.
-
There is also a similar method in |
Beta Was this translation helpful? Give feedback.
-
Because it was discussed in the Spec-Call today as well about throwing an It was also argued that even syntactically valid filters can be semantically incorrect and therefore still cause exceptions to be thrown. But from my understanding those exceptions would then not be |
Beta Was this translation helpful? Give feedback.
-
Strings are immutable, builders are not. We did not go into details on overloading core APIs to take a FilterBuilder where Strings are used today (e.g. BundleContext.addServiceListener(ServiceListener, String)). Careful consideration will be needed when specifying how a framework implementation uses the mutable object if we are to pass in FilterBuilder objects to core APIs and what are the expected behaviors if a builder changes after it has been given to the framework. |
Beta Was this translation helpful? Give feedback.
-
I like the builder idea in general. But I also understand Toms and BJ's arguments, not having that in the framework. |
Beta Was this translation helpful? Give feedback.
-
Btw. is there a reason why |
Beta Was this translation helpful? Give feedback.
-
Just curious, can someone explain why a filter must be "trusted"? Can I do anything bad with a custom filter impl? Independent of this I think one could enhance @HannesWell idea in a simpler way by havein a method (e.g. for the equinox case) the following way:
This will always return a "good" framework managed filter but prevents parsing the filter again if it is already of the desired type. Passing strings with semantics is really bad as there is only runtime-checking and no compile-time (or even IDE-typing-time) checks so if a string is not a string (=some text without semantics that needs be parsed) I always would prefer an Object with an (interface) type. A good example is from the context of m2e/maven where the GAV is a string and there are a lots of constructors like
this is a complete mess as one can easily mess up thing by e.g. accidentally flipping |
Beta Was this translation helpful? Give feedback.
-
By the way I don't think we need a dedicated "Builder" type but can use the functional style of recent java API, e.g. assume the Filterinterface is enhanced with these methods (framework impl might override for better performance)
one can construct the examples from the Filter Javadoc like this:
|
Beta Was this translation helpful? Give feedback.
-
I just came along an example that I think is high-level enough (so no "we want to discourage use of...) and probably involves programmatic use cases as well (so no "filter only created once"), and of wider audience (so no "is of rarely use") and even part of OSGi Spec already (so no "they better should use") and uses a builder pattern to construct object that is the Repository Service Specification. Just some examples where non trivial filters are constructed, and even if they are static for demonstration purpose would often be constructed at runtime because of some programmatic input:
|
Beta Was this translation helpful? Give feedback.
-
@laeubi fyi: bnd has a FilterBuilder |
Beta Was this translation helpful? Give feedback.
-
org.osgi.framework.FrameworkUtil
has methodcreateFilter(String)
that throwsInvalidSyntaxException
because there is no way to know if the filter is not malformed.It would be great to have something like
https://nightlies.apache.org/directory/api/1.0.2/apidocs/org/apache/directory/ldap/client/api/search/FilterBuilder.html
as an alternative to build a string using a builder-pattern instead of passing a raw string and need to build it manually.
This even would not require to parse the string again, because the builder can build the required objects internally.
Beta Was this translation helpful? Give feedback.
All reactions