Comments (5)
AutoService project can be used for generating config for ServiceLoader
from source during compile time. It uses java annotation processor. Very easy to use. Very easy to implement. No dependency from Spring and no classpath walking at runtime.
from zally.
Wow, thanks for this interesting idea and proof of concept π
You are totally right, without Spring integrations in other tools should be quite easy. For this we could fledge out the rule evaluation in a library and link this library to the server.
How could #75 be implemented with this approach? We'd like to make rule set configurable on runtime. As far as I understood your code, you have to provide the configuration in manifest file in META-INF.
from zally.
Regarding #75 I could imagine to give every Rule-Implementation a unique id/shortname (think of modules/checks in Checkstyle). Then after loading every rule available in classpath and picked up by ServiceLoader, just filter via standard 'java.util.function.Predicate' and return a new RuleValidator-object containing only filtered rules. That would be the easiest thing to try first.
Which rules to include can be specified by a zally.yaml maybe of if nothing specified, every rule kicks in. In zally.yaml a 'include', 'exclude' section can exists to let the user define what makes sense for him/her.
For going with ids/shortnames it would helpful for a user to build then back-links to specific rules in the report (like in the checkstyle-link above). But I think I've seen something like that already, right?
Regards
JΓΆrg
from zally.
Regarding #75 - I totally agree with @jbellmann, as long as we have full list of Rule
implementations we can filter it out by any criteria.
Regarding ServiceLoader mechanism:
I've experimented with this approach. It works fine but there is one substantial downside:
you need to explicitly list all your implementations in separate file (correct me if I'm wrong). Since in our case all implementations are known at compile time there is no value in it. You can simply write code like that:
val allRules = listOf(
AvoidJavascriptKeywordsRule(),
ExtractBasePathRule(),
...
)
(in fact first version of Zally worked exactly like that). Maintaining such list is proven to be tedious and error-prone in a long run.
If we want to move core validation logic into separate module that doesn't depend on Spring, I would suggest to use same mechanism as in Spring: classpath walking.
Possible implementation could be reflections. Perhaps we could even get rid of annotations and pick any class that implements Rule interface unless the class is marked with @Ignore
.
from zally.
Given that:
- #843 was rejected because it's "re-creating what Spring does already"
- We make heavy use of Spring AOP in https://github.com/zalando/zally/blob/master/server/src/main/java/de/zalando/zally/util/ast/MethodCallRecorder.kt
It appears that the switch to a Spring-free ServiceLoader mechanism is not happening and this issue can be closed.
from zally.
Related Issues (20)
- refactor: RFC 9457 obsoletes 7807, refer to it HOT 2
- Tooling: removes archived repositories HOT 1
- meta-information: do not copy the API-ID HOT 2
- Status codes publish to main HOT 1
- add more examples to query parameters HOT 1
- fix: using headers anchor (#783) HOT 1
- feat: add exception for partner IAM (#767)
- feat: add new rule to prefer single resources (#764) HOT 1
- feat: improve guidance on total counts (#731) HOT 1
- new rule: may use asynchronous processing HOT 1
- FunctionalNamingForHostnames only works with zalando domains HOT 1
- feat: improve response (code) guidance (#787, #762, #737)
- issue start web-ui on mac-os HOT 2
- Spring upgrade to address CVEs
- fix discrepancy between 109 and 111
- Fix typo in best-practices.adoc
- Add suggested changes from API guild discussion (POST usage) HOT 1
- Update security section about uid scope HOT 1
- Fix typo in introduction.adoc
- Add best practices section for rule 108
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zally.