|
| 1 | +/* |
| 2 | + * Copyright 2000-2023 Vaadin Ltd. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 5 | + * use this file except in compliance with the License. You may obtain a copy of |
| 6 | + * the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | + * License for the specific language governing permissions and limitations under |
| 14 | + * the License. |
| 15 | + */ |
| 16 | +package com.vaadin.flow.uitest.ui; |
| 17 | + |
| 18 | +import java.lang.reflect.Field; |
| 19 | +import java.util.Set; |
| 20 | + |
| 21 | +import com.vaadin.flow.component.html.Div; |
| 22 | +import com.vaadin.flow.component.html.Span; |
| 23 | +import com.vaadin.flow.router.Route; |
| 24 | + |
| 25 | +@Route(value = "com.vaadin.flow.uitest.ui.DevModeNoClassCacheView") |
| 26 | +public class DevModeNoClassCacheView extends Div { |
| 27 | + |
| 28 | + @SuppressWarnings("unchecked") |
| 29 | + public DevModeNoClassCacheView() { |
| 30 | + |
| 31 | + try { |
| 32 | + Class<?> reloadCacheClass = Class |
| 33 | + .forName("com.vaadin.flow.spring.ReloadCache"); |
| 34 | + |
| 35 | + // appShellClasses; |
| 36 | + Field appShellClassesField = reloadCacheClass |
| 37 | + .getDeclaredField("appShellClasses"); |
| 38 | + appShellClassesField.setAccessible(true); |
| 39 | + Set<Class<?>> appShellClasses = (Set<Class<?>>) appShellClassesField |
| 40 | + .get(null); |
| 41 | + add(new Span( |
| 42 | + "appshell class count:" + (appShellClasses == null ? "0" |
| 43 | + : appShellClasses.size()))); |
| 44 | + |
| 45 | + // lookupClasses; |
| 46 | + Field lookupClassesField = reloadCacheClass |
| 47 | + .getDeclaredField("lookupClasses"); |
| 48 | + lookupClassesField.setAccessible(true); |
| 49 | + Set<Class<?>> lookupClasses = (Set<Class<?>>) lookupClassesField |
| 50 | + .get(null); |
| 51 | + add(new Span("lookup class count:" |
| 52 | + + (lookupClasses == null ? "0" : lookupClasses.size()))); |
| 53 | + |
| 54 | + // validResources |
| 55 | + Field validResourcesField = reloadCacheClass |
| 56 | + .getDeclaredField("validResources"); |
| 57 | + validResourcesField.setAccessible(true); |
| 58 | + Set<String> validResources = (Set<String>) validResourcesField |
| 59 | + .get(null); |
| 60 | + add(new Span("valid resource count:" |
| 61 | + + (validResources == null ? "0" : validResources.size()))); |
| 62 | + |
| 63 | + // skippedResources |
| 64 | + Field skippedResourcesField = reloadCacheClass |
| 65 | + .getDeclaredField("skippedResources"); |
| 66 | + skippedResourcesField.setAccessible(true); |
| 67 | + Set<String> skippedResources = (Set<String>) skippedResourcesField |
| 68 | + .get(null); |
| 69 | + add(new Span( |
| 70 | + "skipped resource count:" + (skippedResources == null ? "0" |
| 71 | + : skippedResources.size()))); |
| 72 | + |
| 73 | + // dynamicWhiteList; |
| 74 | + Field dynamicWhiteListField = reloadCacheClass |
| 75 | + .getDeclaredField("dynamicWhiteList"); |
| 76 | + dynamicWhiteListField.setAccessible(true); |
| 77 | + Set<String> dynamicWhiteList = (Set<String>) dynamicWhiteListField |
| 78 | + .get(null); |
| 79 | + add(new Span("dynamic white list count:" |
| 80 | + + (dynamicWhiteList == null ? "0" |
| 81 | + : dynamicWhiteList.size()))); |
| 82 | + |
| 83 | + // routePackages; |
| 84 | + Field routePackagesField = reloadCacheClass |
| 85 | + .getDeclaredField("routePackages"); |
| 86 | + routePackagesField.setAccessible(true); |
| 87 | + Set<String> routePackages = (Set<String>) routePackagesField |
| 88 | + .get(null); |
| 89 | + Span span = new Span("route packages count:" |
| 90 | + + (routePackages == null ? "0" : routePackages.size())); |
| 91 | + span.setId("last-span"); |
| 92 | + add(span); |
| 93 | + |
| 94 | + } catch (ClassNotFoundException | NoSuchFieldException |
| 95 | + | IllegalAccessException e) { |
| 96 | + throw new RuntimeException(e); |
| 97 | + } |
| 98 | + } |
| 99 | +} |
0 commit comments