-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: filterable class scanning of JAR (#19299)
* feat: filterable class scanning of JAR This change improves optimization of class scanning of `VaadinServletContextInitializer` by reading optional configuration file within a JAR dependency. Configuration file is a regular properties file that can contain `vaadin.allowed-packages` or `vaadin.blocked-packages` to exclude/include packages being scanned by `VaadinServletContextInitializer`. Package exclusion/inclusion effects only classes in the JAR/module where `META-INF/VAADIN/package.properties` is located at. Notice that this is only affecting the performance of the class scanning of Vaadin specific annotations and types and this feature is not meant to be used for excluding packages from the whole application. E.g. excluding `VaadinServiceInitListener` in a Spring application is not stopping Spring and Vaadin initializing it anyway, although some time-consuming actions like `DevModeServletContextListener` would still exclude it for optimization. Fixes: #19117 * chore: refactoring and Javadoc * chore: cleaned up IT * chore: updated version to 24.5-SNAPSHOT * chore: updated computeMatrix.js * chore: formatting * chore: added sub-modules * chore: serialized FilterableResourceResolver * chore: refactored code review findings * chore: serialized PackageInfo
- Loading branch information
Showing
22 changed files
with
1,153 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
flow-tests/vaadin-spring-tests/test-spring-filter-packages/lib-allowed/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright 2000-2024 Vaadin Ltd. | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
~ use this file except in compliance with the License. You may obtain a copy of | ||
~ the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
~ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
~ License for the specific language governing permissions and limitations under | ||
~ the License. | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<artifactId>vaadin-test-spring-filter-packages</artifactId> | ||
<groupId>com.vaadin</groupId> | ||
<version>24.5-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>vaadin-test-spring-filter-packages-lib-allowed</artifactId> | ||
<name>Library with vaadin.allowed-packages property | ||
</name> | ||
|
||
<packaging>jar</packaging> | ||
<properties> | ||
<maven.deploy.skip>true</maven.deploy.skip> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>flow-server</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
29 changes: 29 additions & 0 deletions
29
...-packages/lib-allowed/src/main/java/com/vaadin/flow/spring/test/allowed/BlockedRoute.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2000-2024 Vaadin Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package com.vaadin.flow.spring.test.allowed; | ||
|
||
import com.vaadin.flow.component.html.Div; | ||
import com.vaadin.flow.router.Route; | ||
|
||
/** | ||
* Blocked route in a jar package. | ||
*/ | ||
@Route("blocked-route-in-jar") | ||
public class BlockedRoute extends Div { | ||
|
||
public BlockedRoute() { | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...ain/java/com/vaadin/flow/spring/test/allowed/startup/CustomVaadinServiceInitListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright 2000-2024 Vaadin Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package com.vaadin.flow.spring.test.allowed.startup; | ||
|
||
import com.vaadin.flow.server.ServiceInitEvent; | ||
import com.vaadin.flow.server.VaadinServiceInitListener; | ||
|
||
public class CustomVaadinServiceInitListener | ||
implements VaadinServiceInitListener { | ||
|
||
@Override | ||
public void serviceInit(ServiceInitEvent event) { | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...llowed/src/main/java/com/vaadin/flow/spring/test/allowed/startup/vaadin/AllowedRoute.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright 2000-2024 Vaadin Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package com.vaadin.flow.spring.test.allowed.startup.vaadin; | ||
|
||
import com.vaadin.flow.component.html.Div; | ||
import com.vaadin.flow.router.Route; | ||
|
||
@Route(value = "allowed-route-in-jar") | ||
public class AllowedRoute extends Div { | ||
|
||
public AllowedRoute() { | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...-spring-filter-packages/lib-allowed/src/main/resources/META-INF/VAADIN/package.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
vaadin.allowed-packages=com/vaadin/flow/spring/test/allowed/startup |
42 changes: 42 additions & 0 deletions
42
flow-tests/vaadin-spring-tests/test-spring-filter-packages/lib-blocked/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright 2000-2024 Vaadin Ltd. | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
~ use this file except in compliance with the License. You may obtain a copy of | ||
~ the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
~ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
~ License for the specific language governing permissions and limitations under | ||
~ the License. | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<artifactId>vaadin-test-spring-filter-packages</artifactId> | ||
<groupId>com.vaadin</groupId> | ||
<version>24.5-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>vaadin-test-spring-filter-packages-lib-blocked</artifactId> | ||
<name>Library with vaadin.blocked-packages property | ||
</name> | ||
|
||
<packaging>jar</packaging> | ||
<properties> | ||
<maven.deploy.skip>true</maven.deploy.skip> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>flow-server</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
26 changes: 26 additions & 0 deletions
26
...es/lib-blocked/src/main/java/com/vaadin/flow/spring/test/blocked/ScannedAllowedRoute.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright 2000-2024 Vaadin Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package com.vaadin.flow.spring.test.blocked; | ||
|
||
import com.vaadin.flow.component.html.Div; | ||
import com.vaadin.flow.router.Route; | ||
|
||
@Route("allowed-route-in-another-jar") | ||
public class ScannedAllowedRoute extends Div { | ||
|
||
public ScannedAllowedRoute() { | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...a/com/vaadin/flow/spring/test/blocked/startup/BlockedCustomVaadinServiceInitListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright 2000-2024 Vaadin Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package com.vaadin.flow.spring.test.blocked.startup; | ||
|
||
import com.vaadin.flow.server.ServiceInitEvent; | ||
import com.vaadin.flow.server.VaadinServiceInitListener; | ||
|
||
public class BlockedCustomVaadinServiceInitListener | ||
implements VaadinServiceInitListener { | ||
|
||
@Override | ||
public void serviceInit(ServiceInitEvent event) { | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...src/main/java/com/vaadin/flow/spring/test/blocked/startup/vaadin/ScannedBlockedRoute.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright 2000-2024 Vaadin Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package com.vaadin.flow.spring.test.blocked.startup.vaadin; | ||
|
||
import com.vaadin.flow.component.html.Div; | ||
import com.vaadin.flow.router.Route; | ||
|
||
@Route(value = "blocked-route-in-scanned-jar") | ||
public class ScannedBlockedRoute extends Div { | ||
|
||
public ScannedBlockedRoute() { | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...-spring-filter-packages/lib-blocked/src/main/resources/META-INF/VAADIN/package.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
vaadin.blocked-packages=com/vaadin/flow/spring/test/blocked/startup |
42 changes: 42 additions & 0 deletions
42
flow-tests/vaadin-spring-tests/test-spring-filter-packages/lib-exclude/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright 2000-2024 Vaadin Ltd. | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
~ use this file except in compliance with the License. You may obtain a copy of | ||
~ the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
~ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
~ License for the specific language governing permissions and limitations under | ||
~ the License. | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<artifactId>vaadin-test-spring-filter-packages</artifactId> | ||
<groupId>com.vaadin</groupId> | ||
<version>24.5-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>vaadin-test-spring-filter-packages-lib-exclude</artifactId> | ||
<name>Library with vaadin.blocked-jar property | ||
</name> | ||
|
||
<packaging>jar</packaging> | ||
<properties> | ||
<maven.deploy.skip>true</maven.deploy.skip> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>flow-server</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
42 changes: 42 additions & 0 deletions
42
flow-tests/vaadin-spring-tests/test-spring-filter-packages/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright 2000-2024 Vaadin Ltd. | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
~ use this file except in compliance with the License. You may obtain a copy of | ||
~ the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
~ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
~ License for the specific language governing permissions and limitations under | ||
~ the License. | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<artifactId>vaadin-spring-tests</artifactId> | ||
<groupId>com.vaadin</groupId> | ||
<version>24.5-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>vaadin-test-spring-filter-packages</artifactId> | ||
<name>The main module for a Spring boot package filter tests | ||
</name> | ||
|
||
<packaging>pom</packaging> | ||
<properties> | ||
<maven.deploy.skip>true</maven.deploy.skip> | ||
</properties> | ||
|
||
<modules> | ||
<module>lib-allowed</module> | ||
<module>lib-blocked</module> | ||
<module>lib-exclude</module> | ||
<module>ui</module> | ||
</modules> | ||
|
||
</project> |
Oops, something went wrong.