diff --git a/java/ql/test/library-tests/frameworks/spring/componentscan/SpringBasePackages.expected b/java/ql/test/library-tests/frameworks/spring/componentscan/SpringBasePackages.expected new file mode 100644 index 000000000000..e369b610c567 --- /dev/null +++ b/java/ql/test/library-tests/frameworks/spring/componentscan/SpringBasePackages.expected @@ -0,0 +1,6 @@ +| com.semmle.a | +| com.semmle.b | +| com.semmle.c | +| com.semmle.d | +| com.semmle.e | +| com.semmle.h | diff --git a/java/ql/test/library-tests/frameworks/spring/componentscan/SpringBasePackages.ql b/java/ql/test/library-tests/frameworks/spring/componentscan/SpringBasePackages.ql new file mode 100644 index 000000000000..bc1595e10130 --- /dev/null +++ b/java/ql/test/library-tests/frameworks/spring/componentscan/SpringBasePackages.ql @@ -0,0 +1,5 @@ +import java +import SpringProfiles + +from SpringBasePackage basePackage +select basePackage diff --git a/java/ql/test/library-tests/frameworks/spring/componentscan/SpringComponent.expected b/java/ql/test/library-tests/frameworks/spring/componentscan/SpringComponent.expected new file mode 100644 index 000000000000..0efcc0e678f6 --- /dev/null +++ b/java/ql/test/library-tests/frameworks/spring/componentscan/SpringComponent.expected @@ -0,0 +1,7 @@ +| com/semmle/e/DeadProfileComponent.java:8:14:8:33 | DeadProfileComponent | dead | +| com/semmle/e/LiveConfiguration.java:16:14:16:30 | LiveConfiguration | live | +| com/semmle/e/LiveProfileComponent.java:8:14:8:33 | LiveProfileComponent | live | +| com/semmle/e/LiveRestController.java:12:14:12:31 | LiveRestController | live | +| com/semmle/f/DeadConfiguration.java:9:14:9:30 | DeadConfiguration | dead | +| com/semmle/g/ProfileComponent.java:6:14:6:29 | ProfileComponent | dead | +| com/semmle/h/WebXMLLiveConfiguration.java:11:14:11:36 | WebXMLLiveConfiguration | live | diff --git a/java/ql/test/library-tests/frameworks/spring/componentscan/SpringComponent.ql b/java/ql/test/library-tests/frameworks/spring/componentscan/SpringComponent.ql new file mode 100644 index 000000000000..70f4c321baed --- /dev/null +++ b/java/ql/test/library-tests/frameworks/spring/componentscan/SpringComponent.ql @@ -0,0 +1,6 @@ +import java +import SpringProfiles + +from SpringComponent springComponent, string isLive +where if springComponent.isLive() then isLive = "live" else isLive = "dead" +select springComponent, isLive diff --git a/java/ql/test/library-tests/frameworks/spring/componentscan/SpringProfiles.expected b/java/ql/test/library-tests/frameworks/spring/componentscan/SpringProfiles.expected new file mode 100644 index 000000000000..f8c6a575bacc --- /dev/null +++ b/java/ql/test/library-tests/frameworks/spring/componentscan/SpringProfiles.expected @@ -0,0 +1,4 @@ +| !annotationProfile | annotationProfile | inactive | +| annotationProfile | annotationProfile | active | +| sometimesEnabledProfile | sometimesEnabledProfile | active | +| xmlConfigurationProfile | xmlConfigurationProfile | inactive | diff --git a/java/ql/test/library-tests/frameworks/spring/componentscan/SpringProfiles.ql b/java/ql/test/library-tests/frameworks/spring/componentscan/SpringProfiles.ql new file mode 100644 index 000000000000..218e49f68855 --- /dev/null +++ b/java/ql/test/library-tests/frameworks/spring/componentscan/SpringProfiles.ql @@ -0,0 +1,6 @@ +import java +import SpringProfiles + +from SpringProfileExpr springProfileExpr, string active +where if springProfileExpr.isActive() then active = "active" else active = "inactive" +select springProfileExpr, springProfileExpr.getProfile(), active diff --git a/java/ql/test/library-tests/frameworks/spring/componentscan/SpringProfiles.qll b/java/ql/test/library-tests/frameworks/spring/componentscan/SpringProfiles.qll new file mode 100644 index 000000000000..b6269002bce5 --- /dev/null +++ b/java/ql/test/library-tests/frameworks/spring/componentscan/SpringProfiles.qll @@ -0,0 +1,20 @@ +import java +import semmle.code.java.frameworks.spring.Spring + +/** + * A marker class that marks the XML configuration profile as never enabled. This should allow us to deduce that the + * com.semmle.g.ProfileComponent is dead, because com.semmle.g is only a base package in the + * profile-config.xml file, which is only enabled if xmlConfigurationProfile is enabled. + */ +class XmlConfigurationProfile extends NeverEnabledSpringProfile { + XmlConfigurationProfile() { this = "xmlConfigurationProfile" } +} + +/** + * A marker class that marks the annotation profile as always enabled. This should allow us to deduce that the + * com.semmle.e.DeadProfileComponent is dead, because the profile is "!annotationProfile", and that + * com.semmle.e.LiveProfileComponent is live, because the profile is "annotationProfile". + */ +class AnnotationProfile extends AlwaysEnabledSpringProfile { + AnnotationProfile() { this = "annotationProfile" } +} diff --git a/java/ql/test/library-tests/frameworks/spring/componentscan/WEB-INF/web.xml b/java/ql/test/library-tests/frameworks/spring/componentscan/WEB-INF/web.xml new file mode 100644 index 000000000000..ce6f221a32bb --- /dev/null +++ b/java/ql/test/library-tests/frameworks/spring/componentscan/WEB-INF/web.xml @@ -0,0 +1,17 @@ + + + + + + contextClass + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + + contextConfigLocation + com.semmle.h + + \ No newline at end of file diff --git a/java/ql/test/library-tests/frameworks/spring/componentscan/com/semmle/d/DMarkerClass.java b/java/ql/test/library-tests/frameworks/spring/componentscan/com/semmle/d/DMarkerClass.java new file mode 100644 index 000000000000..05d4c367c4e3 --- /dev/null +++ b/java/ql/test/library-tests/frameworks/spring/componentscan/com/semmle/d/DMarkerClass.java @@ -0,0 +1,3 @@ +package com.semmle.d; + +public interface DMarkerClass {} diff --git a/java/ql/test/library-tests/frameworks/spring/componentscan/com/semmle/e/DeadProfileComponent.java b/java/ql/test/library-tests/frameworks/spring/componentscan/com/semmle/e/DeadProfileComponent.java new file mode 100644 index 000000000000..05f1e751a0a9 --- /dev/null +++ b/java/ql/test/library-tests/frameworks/spring/componentscan/com/semmle/e/DeadProfileComponent.java @@ -0,0 +1,8 @@ +package com.semmle.e; + +import org.springframework.context.annotation.Profile; +import org.springframework.stereotype.Component; + +@Component +@Profile({"!annotationProfile"}) +public class DeadProfileComponent {} diff --git a/java/ql/test/library-tests/frameworks/spring/componentscan/com/semmle/e/LiveConfiguration.java b/java/ql/test/library-tests/frameworks/spring/componentscan/com/semmle/e/LiveConfiguration.java new file mode 100644 index 000000000000..282294e4db58 --- /dev/null +++ b/java/ql/test/library-tests/frameworks/spring/componentscan/com/semmle/e/LiveConfiguration.java @@ -0,0 +1,16 @@ +package com.semmle.e; + +import com.semmle.d.DMarkerClass; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +/** + * This configuration is live because the config.xml file contains a component-scan element that + * includes com.semmle.e as a base package. + */ +@Configuration +@ComponentScan( + value = "com.semmle.a", + basePackages = {"com.semmle.b", "com.semmle.c"}, + basePackageClasses = {DMarkerClass.class}) +public class LiveConfiguration {} diff --git a/java/ql/test/library-tests/frameworks/spring/componentscan/com/semmle/e/LiveProfileComponent.java b/java/ql/test/library-tests/frameworks/spring/componentscan/com/semmle/e/LiveProfileComponent.java new file mode 100644 index 000000000000..6ed265b3d922 --- /dev/null +++ b/java/ql/test/library-tests/frameworks/spring/componentscan/com/semmle/e/LiveProfileComponent.java @@ -0,0 +1,8 @@ +package com.semmle.e; + +import org.springframework.context.annotation.Profile; +import org.springframework.stereotype.Component; + +@Component +@Profile({"annotationProfile"}) +public class LiveProfileComponent {} diff --git a/java/ql/test/library-tests/frameworks/spring/componentscan/com/semmle/e/LiveRestController.java b/java/ql/test/library-tests/frameworks/spring/componentscan/com/semmle/e/LiveRestController.java new file mode 100644 index 000000000000..483c723bef7d --- /dev/null +++ b/java/ql/test/library-tests/frameworks/spring/componentscan/com/semmle/e/LiveRestController.java @@ -0,0 +1,18 @@ +package com.semmle.e; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * Live because it is in a live package, and has a {@code RestController} annotation which is + * annotated with {@code @Controller} which is annotated with {@code @Component}, making it a + * component. + */ +@RestController +public class LiveRestController { + + @RequestMapping(value = {"/"}) + public String testMethod() { + return "result"; + } +} diff --git a/java/ql/test/library-tests/frameworks/spring/componentscan/com/semmle/f/DeadConfiguration.java b/java/ql/test/library-tests/frameworks/spring/componentscan/com/semmle/f/DeadConfiguration.java new file mode 100644 index 000000000000..33970b7fd3d2 --- /dev/null +++ b/java/ql/test/library-tests/frameworks/spring/componentscan/com/semmle/f/DeadConfiguration.java @@ -0,0 +1,9 @@ +package com.semmle.f; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +/** This is a dead configuration class, because this class is not in a registered base package. */ +@Configuration +@ComponentScan("com.semmle.f") +public class DeadConfiguration {} diff --git a/java/ql/test/library-tests/frameworks/spring/componentscan/com/semmle/g/ProfileComponent.java b/java/ql/test/library-tests/frameworks/spring/componentscan/com/semmle/g/ProfileComponent.java new file mode 100644 index 000000000000..bdad8b47d8d8 --- /dev/null +++ b/java/ql/test/library-tests/frameworks/spring/componentscan/com/semmle/g/ProfileComponent.java @@ -0,0 +1,6 @@ +package com.semmle.g; + +import org.springframework.stereotype.Component; + +@Component +public class ProfileComponent {} diff --git a/java/ql/test/library-tests/frameworks/spring/componentscan/com/semmle/h/WebXMLLiveConfiguration.java b/java/ql/test/library-tests/frameworks/spring/componentscan/com/semmle/h/WebXMLLiveConfiguration.java new file mode 100644 index 000000000000..b816906d236e --- /dev/null +++ b/java/ql/test/library-tests/frameworks/spring/componentscan/com/semmle/h/WebXMLLiveConfiguration.java @@ -0,0 +1,11 @@ +package com.semmle.h; + +import org.springframework.context.annotation.Configuration; + +/** + * This configuration is live because the web.xml file specifies + * AnnotationConfigWebApplicationContext as the {@code contextClass}, and has a + * contextConfigLocation value that includes this package (com.semmle.h). + */ +@Configuration +public class WebXMLLiveConfiguration {} diff --git a/java/ql/test/library-tests/frameworks/spring/componentscan/config.xml b/java/ql/test/library-tests/frameworks/spring/componentscan/config.xml new file mode 100644 index 000000000000..c7c7ccaf4369 --- /dev/null +++ b/java/ql/test/library-tests/frameworks/spring/componentscan/config.xml @@ -0,0 +1,12 @@ + + + + + \ No newline at end of file diff --git a/java/ql/test/library-tests/frameworks/spring/componentscan/options b/java/ql/test/library-tests/frameworks/spring/componentscan/options new file mode 100644 index 000000000000..df84ab0bc1c5 --- /dev/null +++ b/java/ql/test/library-tests/frameworks/spring/componentscan/options @@ -0,0 +1,2 @@ +//semmle-extractor-options: --javac-args -cp +//semmle-extractor-options: ${testdir}/../../../../stubs/springframework-5.3.8/ diff --git a/java/ql/test/library-tests/frameworks/spring/componentscan/profile-config.xml b/java/ql/test/library-tests/frameworks/spring/componentscan/profile-config.xml new file mode 100644 index 000000000000..94b94eb83592 --- /dev/null +++ b/java/ql/test/library-tests/frameworks/spring/componentscan/profile-config.xml @@ -0,0 +1,12 @@ + + + + + \ No newline at end of file diff --git a/java/ql/test/stubs/springframework-5.3.8/org/springframework/beans/BeansException.java b/java/ql/test/stubs/springframework-5.3.8/org/springframework/beans/BeansException.java new file mode 100644 index 000000000000..f3816a16db50 --- /dev/null +++ b/java/ql/test/stubs/springframework-5.3.8/org/springframework/beans/BeansException.java @@ -0,0 +1,53 @@ +/* + * Copyright 2002-2017 the original author or authors. + * + * 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 + * + * https://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 org.springframework.beans; + +import org.springframework.core.NestedRuntimeException; +import org.springframework.lang.Nullable; + +/** + * Abstract superclass for all exceptions thrown in the beans package + * and subpackages. + * + *

Note that this is a runtime (unchecked) exception. Beans exceptions + * are usually fatal; there is no reason for them to be checked. + * + * @author Rod Johnson + * @author Juergen Hoeller + */ +@SuppressWarnings("serial") +public abstract class BeansException extends NestedRuntimeException { + + /** + * Create a new BeansException with the specified message. + * @param msg the detail message + */ + public BeansException(String msg) { + super(msg); + } + + /** + * Create a new BeansException with the specified message + * and root cause. + * @param msg the detail message + * @param cause the root cause + */ + public BeansException(@Nullable String msg, @Nullable Throwable cause) { + super(msg, cause); + } + +} diff --git a/java/ql/test/stubs/springframework-5.3.8/org/springframework/beans/FatalBeanException.java b/java/ql/test/stubs/springframework-5.3.8/org/springframework/beans/FatalBeanException.java new file mode 100644 index 000000000000..7c6e1d941cb5 --- /dev/null +++ b/java/ql/test/stubs/springframework-5.3.8/org/springframework/beans/FatalBeanException.java @@ -0,0 +1,48 @@ +/* + * Copyright 2002-2017 the original author or authors. + * + * 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 + * + * https://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 org.springframework.beans; + +import org.springframework.lang.Nullable; + +/** + * Thrown on an unrecoverable problem encountered in the + * beans packages or sub-packages, e.g. bad class or field. + * + * @author Rod Johnson + */ +@SuppressWarnings("serial") +public class FatalBeanException extends BeansException { + + /** + * Create a new FatalBeanException with the specified message. + * @param msg the detail message + */ + public FatalBeanException(String msg) { + super(msg); + } + + /** + * Create a new FatalBeanException with the specified message + * and root cause. + * @param msg the detail message + * @param cause the root cause + */ + public FatalBeanException(String msg, @Nullable Throwable cause) { + super(msg, cause); + } + +} diff --git a/java/ql/test/stubs/springframework-5.3.8/org/springframework/beans/factory/BeanDefinitionStoreException.java b/java/ql/test/stubs/springframework-5.3.8/org/springframework/beans/factory/BeanDefinitionStoreException.java new file mode 100644 index 000000000000..7a04cd37fc2f --- /dev/null +++ b/java/ql/test/stubs/springframework-5.3.8/org/springframework/beans/factory/BeanDefinitionStoreException.java @@ -0,0 +1,111 @@ +/* + * Copyright 2002-2018 the original author or authors. + * + * 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 + * + * https://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 org.springframework.beans.factory; + +import org.springframework.beans.FatalBeanException; +import org.springframework.lang.Nullable; + +/** + * Exception thrown when a BeanFactory encounters an invalid bean definition: + * e.g. in case of incomplete or contradictory bean metadata. + * + * @author Rod Johnson + * @author Juergen Hoeller + * @author Rob Harrop + */ +@SuppressWarnings("serial") +public class BeanDefinitionStoreException extends FatalBeanException { + + /** + * Create a new BeanDefinitionStoreException. + * @param msg the detail message (used as exception message as-is) + */ + public BeanDefinitionStoreException(String msg) { + super(msg); + } + + /** + * Create a new BeanDefinitionStoreException. + * @param msg the detail message (used as exception message as-is) + * @param cause the root cause (may be {@code null}) + */ + public BeanDefinitionStoreException(String msg, @Nullable Throwable cause) { + super(msg, cause); + } + + /** + * Create a new BeanDefinitionStoreException. + * @param resourceDescription description of the resource that the bean definition came from + * @param msg the detail message (used as exception message as-is) + */ + public BeanDefinitionStoreException(@Nullable String resourceDescription, String msg) { + super(msg); + } + + /** + * Create a new BeanDefinitionStoreException. + * @param resourceDescription description of the resource that the bean definition came from + * @param msg the detail message (used as exception message as-is) + * @param cause the root cause (may be {@code null}) + */ + public BeanDefinitionStoreException(@Nullable String resourceDescription, String msg, @Nullable Throwable cause) { + super(msg, cause); + } + + /** + * Create a new BeanDefinitionStoreException. + * @param resourceDescription description of the resource that the bean definition came from + * @param beanName the name of the bean + * @param msg the detail message (appended to an introductory message that indicates + * the resource and the name of the bean) + */ + public BeanDefinitionStoreException(@Nullable String resourceDescription, String beanName, String msg) { + this(resourceDescription, beanName, msg, null); + } + + /** + * Create a new BeanDefinitionStoreException. + * @param resourceDescription description of the resource that the bean definition came from + * @param beanName the name of the bean + * @param msg the detail message (appended to an introductory message that indicates + * the resource and the name of the bean) + * @param cause the root cause (may be {@code null}) + */ + public BeanDefinitionStoreException( + @Nullable String resourceDescription, String beanName, String msg, @Nullable Throwable cause) { + super("Invalid bean definition with name '" + beanName + "' defined in " + resourceDescription + ": " + msg, + cause); + } + + + /** + * Return the description of the resource that the bean definition came from, if available. + */ + @Nullable + public String getResourceDescription() { + return null; + } + + /** + * Return the name of the bean, if available. + */ + @Nullable + public String getBeanName() { + return null; + } + +} diff --git a/java/ql/test/stubs/springframework-5.3.8/org/springframework/beans/factory/NoSuchBeanDefinitionException.java b/java/ql/test/stubs/springframework-5.3.8/org/springframework/beans/factory/NoSuchBeanDefinitionException.java new file mode 100644 index 000000000000..798d8748f7da --- /dev/null +++ b/java/ql/test/stubs/springframework-5.3.8/org/springframework/beans/factory/NoSuchBeanDefinitionException.java @@ -0,0 +1,128 @@ +/* + * Copyright 2002-2018 the original author or authors. + * + * 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 + * + * https://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 org.springframework.beans.factory; + +import org.springframework.beans.BeansException; +import org.springframework.core.ResolvableType; +import org.springframework.lang.Nullable; + +/** + * Exception thrown when a {@code BeanFactory} is asked for a bean instance for which it + * cannot find a definition. This may point to a non-existing bean, a non-unique bean, + * or a manually registered singleton instance without an associated bean definition. + * + * @author Rod Johnson + * @author Juergen Hoeller + * @author Stephane Nicoll + * @see BeanFactory#getBean(String) + * @see BeanFactory#getBean(Class) + * @see NoUniqueBeanDefinitionException + */ +@SuppressWarnings("serial") +public class NoSuchBeanDefinitionException extends BeansException { + + /** + * Create a new {@code NoSuchBeanDefinitionException}. + * @param name the name of the missing bean + */ + public NoSuchBeanDefinitionException(String name) { + super("No bean named '" + name + "' available"); + } + + /** + * Create a new {@code NoSuchBeanDefinitionException}. + * @param name the name of the missing bean + * @param message detailed message describing the problem + */ + public NoSuchBeanDefinitionException(String name, String message) { + super("No bean named '" + name + "' available: " + message); + } + + /** + * Create a new {@code NoSuchBeanDefinitionException}. + * @param type required type of the missing bean + */ + public NoSuchBeanDefinitionException(Class type) { + this((String)null); + } + + /** + * Create a new {@code NoSuchBeanDefinitionException}. + * @param type required type of the missing bean + * @param message detailed message describing the problem + */ + public NoSuchBeanDefinitionException(Class type, String message) { + this((String)null, message); + } + + /** + * Create a new {@code NoSuchBeanDefinitionException}. + * @param type full type declaration of the missing bean + * @since 4.3.4 + */ + public NoSuchBeanDefinitionException(ResolvableType type) { + super("No qualifying bean of type '" + type + "' available"); + } + + /** + * Create a new {@code NoSuchBeanDefinitionException}. + * @param type full type declaration of the missing bean + * @param message detailed message describing the problem + * @since 4.3.4 + */ + public NoSuchBeanDefinitionException(ResolvableType type, String message) { + super("No qualifying bean of type '" + type + "' available: " + message); + } + + + /** + * Return the name of the missing bean, if it was a lookup by name that failed. + */ + @Nullable + public String getBeanName() { + return null; + } + + /** + * Return the required type of the missing bean, if it was a lookup by type + * that failed. + */ + @Nullable + public Class getBeanType() { + return null; + } + + /** + * Return the required {@link ResolvableType} of the missing bean, if it was a lookup + * by type that failed. + * @since 4.3.4 + */ + @Nullable + public ResolvableType getResolvableType() { + return null; + } + + /** + * Return the number of beans found when only one matching bean was expected. + * For a regular NoSuchBeanDefinitionException, this will always be 0. + * @see NoUniqueBeanDefinitionException + */ + public int getNumberOfBeansFound() { + return 0; + } + +} diff --git a/java/ql/test/stubs/springframework-5.3.8/org/springframework/beans/factory/config/BeanDefinition.java b/java/ql/test/stubs/springframework-5.3.8/org/springframework/beans/factory/config/BeanDefinition.java new file mode 100644 index 000000000000..799fdc9d7460 --- /dev/null +++ b/java/ql/test/stubs/springframework-5.3.8/org/springframework/beans/factory/config/BeanDefinition.java @@ -0,0 +1,19 @@ +/* + * Copyright 2002-2020 the original author or authors. + * + * 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 + * + * https://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 org.springframework.beans.factory.config; + +public interface BeanDefinition { } diff --git a/java/ql/test/stubs/springframework-5.3.8/org/springframework/beans/factory/support/BeanDefinitionRegistry.java b/java/ql/test/stubs/springframework-5.3.8/org/springframework/beans/factory/support/BeanDefinitionRegistry.java new file mode 100644 index 000000000000..a1f47e536030 --- /dev/null +++ b/java/ql/test/stubs/springframework-5.3.8/org/springframework/beans/factory/support/BeanDefinitionRegistry.java @@ -0,0 +1,108 @@ +/* + * Copyright 2002-2018 the original author or authors. + * + * 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 + * + * https://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 org.springframework.beans.factory.support; + +import org.springframework.beans.factory.BeanDefinitionStoreException; +import org.springframework.beans.factory.NoSuchBeanDefinitionException; +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.core.AliasRegistry; + +/** + * Interface for registries that hold bean definitions, for example RootBeanDefinition + * and ChildBeanDefinition instances. Typically implemented by BeanFactories that + * internally work with the AbstractBeanDefinition hierarchy. + * + *

This is the only interface in Spring's bean factory packages that encapsulates + * registration of bean definitions. The standard BeanFactory interfaces + * only cover access to a fully configured factory instance. + * + *

Spring's bean definition readers expect to work on an implementation of this + * interface. Known implementors within the Spring core are DefaultListableBeanFactory + * and GenericApplicationContext. + * + * @author Juergen Hoeller + * @since 26.11.2003 + * @see org.springframework.beans.factory.config.BeanDefinition + * @see AbstractBeanDefinition + * @see RootBeanDefinition + * @see ChildBeanDefinition + * @see DefaultListableBeanFactory + * @see org.springframework.context.support.GenericApplicationContext + * @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader + * @see PropertiesBeanDefinitionReader + */ +public interface BeanDefinitionRegistry extends AliasRegistry { + + /** + * Register a new bean definition with this registry. + * Must support RootBeanDefinition and ChildBeanDefinition. + * @param beanName the name of the bean instance to register + * @param beanDefinition definition of the bean instance to register + * @throws BeanDefinitionStoreException if the BeanDefinition is invalid + * @throws BeanDefinitionOverrideException if there is already a BeanDefinition + * for the specified bean name and we are not allowed to override it + * @see GenericBeanDefinition + * @see RootBeanDefinition + * @see ChildBeanDefinition + */ + void registerBeanDefinition(String beanName, BeanDefinition beanDefinition) + throws BeanDefinitionStoreException; + + /** + * Remove the BeanDefinition for the given name. + * @param beanName the name of the bean instance to register + * @throws NoSuchBeanDefinitionException if there is no such bean definition + */ + void removeBeanDefinition(String beanName) throws NoSuchBeanDefinitionException; + + /** + * Return the BeanDefinition for the given bean name. + * @param beanName name of the bean to find a definition for + * @return the BeanDefinition for the given name (never {@code null}) + * @throws NoSuchBeanDefinitionException if there is no such bean definition + */ + BeanDefinition getBeanDefinition(String beanName) throws NoSuchBeanDefinitionException; + + /** + * Check if this registry contains a bean definition with the given name. + * @param beanName the name of the bean to look for + * @return if this registry contains a bean definition with the given name + */ + boolean containsBeanDefinition(String beanName); + + /** + * Return the names of all beans defined in this registry. + * @return the names of all beans defined in this registry, + * or an empty array if none defined + */ + String[] getBeanDefinitionNames(); + + /** + * Return the number of beans defined in the registry. + * @return the number of beans defined in the registry + */ + int getBeanDefinitionCount(); + + /** + * Determine whether the given bean name is already in use within this registry, + * i.e. whether there is a local bean or alias registered under this name. + * @param beanName the name to check + * @return whether the given bean name is already in use + */ + boolean isBeanNameInUse(String beanName); + +} diff --git a/java/ql/test/stubs/springframework-5.3.8/org/springframework/beans/factory/support/BeanNameGenerator.java b/java/ql/test/stubs/springframework-5.3.8/org/springframework/beans/factory/support/BeanNameGenerator.java new file mode 100644 index 000000000000..d7d3c9b35d72 --- /dev/null +++ b/java/ql/test/stubs/springframework-5.3.8/org/springframework/beans/factory/support/BeanNameGenerator.java @@ -0,0 +1,38 @@ +/* + * Copyright 2002-2007 the original author or authors. + * + * 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 + * + * https://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 org.springframework.beans.factory.support; + +import org.springframework.beans.factory.config.BeanDefinition; + +/** + * Strategy interface for generating bean names for bean definitions. + * + * @author Juergen Hoeller + * @since 2.0.3 + */ +public interface BeanNameGenerator { + + /** + * Generate a bean name for the given bean definition. + * @param definition the bean definition to generate a name for + * @param registry the bean definition registry that the given definition + * is supposed to be registered with + * @return the generated bean name + */ + String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry); + +} diff --git a/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/AnnotationScopeMetadataResolver.java b/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/AnnotationScopeMetadataResolver.java new file mode 100644 index 000000000000..a4c456f45458 --- /dev/null +++ b/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/AnnotationScopeMetadataResolver.java @@ -0,0 +1,69 @@ +/* + * Copyright 2002-2017 the original author or authors. + * + * 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 + * + * https://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 org.springframework.context.annotation; + +import java.lang.annotation.Annotation; + +import org.springframework.beans.factory.config.BeanDefinition; + +/** + * A {@link ScopeMetadataResolver} implementation that by default checks for + * the presence of Spring's {@link Scope @Scope} annotation on the bean class. + * + *

The exact type of annotation that is checked for is configurable via + * {@link #setScopeAnnotationType(Class)}. + * + * @author Mark Fisher + * @author Juergen Hoeller + * @author Sam Brannen + * @since 2.5 + * @see org.springframework.context.annotation.Scope + */ +public class AnnotationScopeMetadataResolver implements ScopeMetadataResolver { + + /** + * Construct a new {@code AnnotationScopeMetadataResolver}. + * @see #AnnotationScopeMetadataResolver(ScopedProxyMode) + * @see ScopedProxyMode#NO + */ + public AnnotationScopeMetadataResolver() { + } + + /** + * Construct a new {@code AnnotationScopeMetadataResolver} using the + * supplied default {@link ScopedProxyMode}. + * @param defaultProxyMode the default scoped-proxy mode + */ + public AnnotationScopeMetadataResolver(ScopedProxyMode defaultProxyMode) { + } + + + /** + * Set the type of annotation that is checked for by this + * {@code AnnotationScopeMetadataResolver}. + * @param scopeAnnotationType the target annotation type + */ + public void setScopeAnnotationType(Class scopeAnnotationType) { + } + + + @Override + public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) { + return null; + } + +} diff --git a/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/ComponentScan.java b/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/ComponentScan.java new file mode 100644 index 000000000000..5a2c4ddea43d --- /dev/null +++ b/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/ComponentScan.java @@ -0,0 +1,225 @@ +/* + * Copyright 2002-2020 the original author or authors. + * + * 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 + * + * https://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 org.springframework.context.annotation; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Repeatable; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.springframework.beans.factory.support.BeanNameGenerator; +import org.springframework.core.annotation.AliasFor; + +/** + * Configures component scanning directives for use with @{@link Configuration} classes. + * Provides support parallel with Spring XML's {@code } element. + * + *

Either {@link #basePackageClasses} or {@link #basePackages} (or its alias + * {@link #value}) may be specified to define specific packages to scan. If specific + * packages are not defined, scanning will occur from the package of the + * class that declares this annotation. + * + *

Note that the {@code } element has an + * {@code annotation-config} attribute; however, this annotation does not. This is because + * in almost all cases when using {@code @ComponentScan}, default annotation config + * processing (e.g. processing {@code @Autowired} and friends) is assumed. Furthermore, + * when using {@link AnnotationConfigApplicationContext}, annotation config processors are + * always registered, meaning that any attempt to disable them at the + * {@code @ComponentScan} level would be ignored. + * + *

See {@link Configuration @Configuration}'s Javadoc for usage examples. + * + * @author Chris Beams + * @author Juergen Hoeller + * @author Sam Brannen + * @since 3.1 + * @see Configuration + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +@Documented +@Repeatable(ComponentScans.class) +public @interface ComponentScan { + + /** + * Alias for {@link #basePackages}. + *

Allows for more concise annotation declarations if no other attributes + * are needed — for example, {@code @ComponentScan("org.my.pkg")} + * instead of {@code @ComponentScan(basePackages = "org.my.pkg")}. + */ + @AliasFor("basePackages") + String[] value() default {}; + + /** + * Base packages to scan for annotated components. + *

{@link #value} is an alias for (and mutually exclusive with) this + * attribute. + *

Use {@link #basePackageClasses} for a type-safe alternative to + * String-based package names. + */ + @AliasFor("value") + String[] basePackages() default {}; + + /** + * Type-safe alternative to {@link #basePackages} for specifying the packages + * to scan for annotated components. The package of each class specified will be scanned. + *

Consider creating a special no-op marker class or interface in each package + * that serves no purpose other than being referenced by this attribute. + */ + Class[] basePackageClasses() default {}; + + /** + * The {@link BeanNameGenerator} class to be used for naming detected components + * within the Spring container. + *

The default value of the {@link BeanNameGenerator} interface itself indicates + * that the scanner used to process this {@code @ComponentScan} annotation should + * use its inherited bean name generator, e.g. the default + * {@link AnnotationBeanNameGenerator} or any custom instance supplied to the + * application context at bootstrap time. + * @see AnnotationConfigApplicationContext#setBeanNameGenerator(BeanNameGenerator) + * @see AnnotationBeanNameGenerator + * @see FullyQualifiedAnnotationBeanNameGenerator + */ + Class nameGenerator() default BeanNameGenerator.class; + + /** + * The {@link ScopeMetadataResolver} to be used for resolving the scope of detected components. + */ + Class scopeResolver() default AnnotationScopeMetadataResolver.class; + + /** + * Indicates whether proxies should be generated for detected components, which may be + * necessary when using scopes in a proxy-style fashion. + *

The default is defer to the default behavior of the component scanner used to + * execute the actual scan. + *

Note that setting this attribute overrides any value set for {@link #scopeResolver}. + * @see ClassPathBeanDefinitionScanner#setScopedProxyMode(ScopedProxyMode) + */ + ScopedProxyMode scopedProxy() default ScopedProxyMode.DEFAULT; + + /** + * Controls the class files eligible for component detection. + *

Consider use of {@link #includeFilters} and {@link #excludeFilters} + * for a more flexible approach. + */ + String resourcePattern() default ""; + + /** + * Indicates whether automatic detection of classes annotated with {@code @Component} + * {@code @Repository}, {@code @Service}, or {@code @Controller} should be enabled. + */ + boolean useDefaultFilters() default true; + + /** + * Specifies which types are eligible for component scanning. + *

Further narrows the set of candidate components from everything in {@link #basePackages} + * to everything in the base packages that matches the given filter or filters. + *

Note that these filters will be applied in addition to the default filters, if specified. + * Any type under the specified base packages which matches a given filter will be included, + * even if it does not match the default filters (i.e. is not annotated with {@code @Component}). + * @see #resourcePattern() + * @see #useDefaultFilters() + */ + Filter[] includeFilters() default {}; + + /** + * Specifies which types are not eligible for component scanning. + * @see #resourcePattern + */ + Filter[] excludeFilters() default {}; + + /** + * Specify whether scanned beans should be registered for lazy initialization. + *

Default is {@code false}; switch this to {@code true} when desired. + * @since 4.1 + */ + boolean lazyInit() default false; + + + /** + * Declares the type filter to be used as an {@linkplain ComponentScan#includeFilters + * include filter} or {@linkplain ComponentScan#excludeFilters exclude filter}. + */ + @Retention(RetentionPolicy.RUNTIME) + @Target({}) + @interface Filter { + + /** + * The type of filter to use. + *

Default is {@link FilterType#ANNOTATION}. + * @see #classes + * @see #pattern + */ + FilterType type() default FilterType.ANNOTATION; + + /** + * Alias for {@link #classes}. + * @see #classes + */ + @AliasFor("classes") + Class[] value() default {}; + + /** + * The class or classes to use as the filter. + *

The following table explains how the classes will be interpreted + * based on the configured value of the {@link #type} attribute. + * + * + * + * + * + * + * + * + *
{@code FilterType}Class Interpreted As
{@link FilterType#ANNOTATION ANNOTATION}the annotation itself
{@link FilterType#ASSIGNABLE_TYPE ASSIGNABLE_TYPE}the type that detected components should be assignable to
{@link FilterType#CUSTOM CUSTOM}an implementation of {@link TypeFilter}
+ *

When multiple classes are specified, OR logic is applied + * — for example, "include types annotated with {@code @Foo} OR {@code @Bar}". + *

Custom {@link TypeFilter TypeFilters} may optionally implement any of the + * following {@link org.springframework.beans.factory.Aware Aware} interfaces, and + * their respective methods will be called prior to {@link TypeFilter#match match}: + *

+ *

Specifying zero classes is permitted but will have no effect on component + * scanning. + * @since 4.2 + * @see #value + * @see #type + */ + @AliasFor("value") + Class[] classes() default {}; + + /** + * The pattern (or patterns) to use for the filter, as an alternative + * to specifying a Class {@link #value}. + *

If {@link #type} is set to {@link FilterType#ASPECTJ ASPECTJ}, + * this is an AspectJ type pattern expression. If {@link #type} is + * set to {@link FilterType#REGEX REGEX}, this is a regex pattern + * for the fully-qualified class names to match. + * @see #type + * @see #classes + */ + String[] pattern() default {}; + + } + +} diff --git a/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/ComponentScans.java b/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/ComponentScans.java new file mode 100644 index 000000000000..cf1e033e29e3 --- /dev/null +++ b/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/ComponentScans.java @@ -0,0 +1,44 @@ +/* + * Copyright 2002-2015 the original author or authors. + * + * 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 + * + * https://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 org.springframework.context.annotation; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Container annotation that aggregates several {@link ComponentScan} annotations. + * + *

Can be used natively, declaring several nested {@link ComponentScan} annotations. + * Can also be used in conjunction with Java 8's support for repeatable annotations, + * where {@link ComponentScan} can simply be declared several times on the same method, + * implicitly generating this container annotation. + * + * @author Juergen Hoeller + * @since 4.3 + * @see ComponentScan + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +@Documented +public @interface ComponentScans { + + ComponentScan[] value(); + +} diff --git a/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/Condition.java b/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/Condition.java new file mode 100644 index 000000000000..d8e31bc36084 --- /dev/null +++ b/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/Condition.java @@ -0,0 +1,34 @@ +/* + * Copyright 2002-2020 the original author or authors. + * + * 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 + * + * https://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 org.springframework.context.annotation; + +import org.springframework.core.type.AnnotatedTypeMetadata; + +@FunctionalInterface +public interface Condition { + + /** + * Determine if the condition matches. + * @param context the condition context + * @param metadata the metadata of the {@link org.springframework.core.type.AnnotationMetadata class} + * or {@link org.springframework.core.type.MethodMetadata method} being checked + * @return {@code true} if the condition matches and the component can be registered, + * or {@code false} to veto the annotated component's registration + */ + boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata); + +} diff --git a/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/ConditionContext.java b/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/ConditionContext.java new file mode 100644 index 000000000000..3a43f2275535 --- /dev/null +++ b/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/ConditionContext.java @@ -0,0 +1,26 @@ +/* + * Copyright 2002-2020 the original author or authors. + * + * 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 + * + * https://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 org.springframework.context.annotation; + +/** + * Context information for use by {@link Condition} implementations. + * + * @author Phillip Webb + * @author Juergen Hoeller + * @since 4.0 + */ +public interface ConditionContext { } diff --git a/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/Conditional.java b/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/Conditional.java new file mode 100644 index 000000000000..80e5f5cca548 --- /dev/null +++ b/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/Conditional.java @@ -0,0 +1,70 @@ +/* + * Copyright 2002-2020 the original author or authors. + * + * 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 + * + * https://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 org.springframework.context.annotation; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Indicates that a component is only eligible for registration when all + * {@linkplain #value specified conditions} match. + * + *

A condition is any state that can be determined programmatically + * before the bean definition is due to be registered (see {@link Condition} for details). + * + *

The {@code @Conditional} annotation may be used in any of the following ways: + *

+ * + *

If a {@code @Configuration} class is marked with {@code @Conditional}, + * all of the {@code @Bean} methods, {@link Import @Import} annotations, and + * {@link ComponentScan @ComponentScan} annotations associated with that + * class will be subject to the conditions. + * + *

NOTE: Inheritance of {@code @Conditional} annotations + * is not supported; any conditions from superclasses or from overridden + * methods will not be considered. In order to enforce these semantics, + * {@code @Conditional} itself is not declared as + * {@link java.lang.annotation.Inherited @Inherited}; furthermore, any + * custom composed annotation that is meta-annotated with + * {@code @Conditional} must not be declared as {@code @Inherited}. + * + * @author Phillip Webb + * @author Sam Brannen + * @since 4.0 + * @see Condition + */ +@Target({ElementType.TYPE, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface Conditional { + + /** + * All {@link Condition} classes that must {@linkplain Condition#matches match} + * in order for the component to be registered. + */ + Class[] value(); + +} diff --git a/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/Configuration.java b/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/Configuration.java index 0024b3ba8338..91521cf45876 100644 --- a/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/Configuration.java +++ b/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/Configuration.java @@ -1,7 +1,54 @@ package org.springframework.context.annotation; +import java.lang.annotation.Documented; import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.springframework.core.annotation.AliasFor; +import org.springframework.stereotype.Component; + @Target(ElementType.TYPE) -public @interface Configuration {} \ No newline at end of file +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Component +public @interface Configuration { + + /** + * Explicitly specify the name of the Spring bean definition associated with the + * {@code @Configuration} class. If left unspecified (the common case), a bean + * name will be automatically generated. + *

The custom name applies only if the {@code @Configuration} class is picked + * up via component scanning or supplied directly to an + * {@link AnnotationConfigApplicationContext}. If the {@code @Configuration} class + * is registered as a traditional XML bean definition, the name/id of the bean + * element will take precedence. + * @return the explicit component name, if any (or empty String otherwise) + * @see AnnotationBeanNameGenerator + */ + @AliasFor(annotation = Component.class) + String value() default ""; + + /** + * Specify whether {@code @Bean} methods should get proxied in order to enforce + * bean lifecycle behavior, e.g. to return shared singleton bean instances even + * in case of direct {@code @Bean} method calls in user code. This feature + * requires method interception, implemented through a runtime-generated CGLIB + * subclass which comes with limitations such as the configuration class and + * its methods not being allowed to declare {@code final}. + *

The default is {@code true}, allowing for 'inter-bean references' via direct + * method calls within the configuration class as well as for external calls to + * this configuration's {@code @Bean} methods, e.g. from another configuration class. + * If this is not needed since each of this particular configuration's {@code @Bean} + * methods is self-contained and designed as a plain factory method for container use, + * switch this flag to {@code false} in order to avoid CGLIB subclass processing. + *

Turning off bean method interception effectively processes {@code @Bean} + * methods individually like when declared on non-{@code @Configuration} classes, + * a.k.a. "@Bean Lite Mode" (see {@link Bean @Bean's javadoc}). It is therefore + * behaviorally equivalent to removing the {@code @Configuration} stereotype. + * @since 5.2 + */ + boolean proxyBeanMethods() default true; + +} diff --git a/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/FilterType.java b/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/FilterType.java new file mode 100644 index 000000000000..36466ffe69a4 --- /dev/null +++ b/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/FilterType.java @@ -0,0 +1,63 @@ +/* + * Copyright 2002-2013 the original author or authors. + * + * 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 + * + * https://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 org.springframework.context.annotation; + +/** + * Enumeration of the type filters that may be used in conjunction with + * {@link ComponentScan @ComponentScan}. + * + * @author Mark Fisher + * @author Juergen Hoeller + * @author Chris Beams + * @since 2.5 + * @see ComponentScan + * @see ComponentScan#includeFilters() + * @see ComponentScan#excludeFilters() + * @see org.springframework.core.type.filter.TypeFilter + */ +public enum FilterType { + + /** + * Filter candidates marked with a given annotation. + * @see org.springframework.core.type.filter.AnnotationTypeFilter + */ + ANNOTATION, + + /** + * Filter candidates assignable to a given type. + * @see org.springframework.core.type.filter.AssignableTypeFilter + */ + ASSIGNABLE_TYPE, + + /** + * Filter candidates matching a given AspectJ type pattern expression. + * @see org.springframework.core.type.filter.AspectJTypeFilter + */ + ASPECTJ, + + /** + * Filter candidates matching a given regex pattern. + * @see org.springframework.core.type.filter.RegexPatternTypeFilter + */ + REGEX, + + /** Filter candidates using a given custom + * {@link org.springframework.core.type.filter.TypeFilter} implementation. + */ + CUSTOM + +} diff --git a/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/Profile.java b/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/Profile.java new file mode 100644 index 000000000000..0c72d663abd9 --- /dev/null +++ b/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/Profile.java @@ -0,0 +1,36 @@ +/* + * Copyright 2002-2018 the original author or authors. + * + * 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 + * + * https://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 org.springframework.context.annotation; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.TYPE, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Conditional(ProfileCondition.class) +public @interface Profile { + + /** + * The set of profiles for which the annotated component should be registered. + */ + String[] value(); + +} diff --git a/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/ProfileCondition.java b/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/ProfileCondition.java new file mode 100644 index 000000000000..20d7ce43d37a --- /dev/null +++ b/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/ProfileCondition.java @@ -0,0 +1,37 @@ +/* + * Copyright 2002-2018 the original author or authors. + * + * 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 + * + * https://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 org.springframework.context.annotation; + +import org.springframework.core.type.AnnotatedTypeMetadata; + +/** + * {@link Condition} that matches based on the value of a {@link Profile @Profile} + * annotation. + * + * @author Chris Beams + * @author Phillip Webb + * @author Juergen Hoeller + * @since 4.0 + */ +class ProfileCondition implements Condition { + + @Override + public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { + return true; + } + +} diff --git a/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/ScopeMetadata.java b/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/ScopeMetadata.java new file mode 100644 index 000000000000..70af46f774c4 --- /dev/null +++ b/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/ScopeMetadata.java @@ -0,0 +1,19 @@ +/* + * Copyright 2002-2012 the original author or authors. + * + * 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 + * + * https://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 org.springframework.context.annotation; + +public class ScopeMetadata { } diff --git a/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/ScopeMetadataResolver.java b/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/ScopeMetadataResolver.java new file mode 100644 index 000000000000..c030fbdf4585 --- /dev/null +++ b/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/ScopeMetadataResolver.java @@ -0,0 +1,45 @@ +/* + * Copyright 2002-2016 the original author or authors. + * + * 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 + * + * https://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 org.springframework.context.annotation; + +import org.springframework.beans.factory.config.BeanDefinition; + +/** + * Strategy interface for resolving the scope of bean definitions. + * + * @author Mark Fisher + * @since 2.5 + * @see org.springframework.context.annotation.Scope + */ +@FunctionalInterface +public interface ScopeMetadataResolver { + + /** + * Resolve the {@link ScopeMetadata} appropriate to the supplied + * bean {@code definition}. + *

Implementations can of course use any strategy they like to + * determine the scope metadata, but some implementations that spring + * immediately to mind might be to use source level annotations + * present on {@link BeanDefinition#getBeanClassName() the class} of the + * supplied {@code definition}, or to use metadata present in the + * {@link BeanDefinition#attributeNames()} of the supplied {@code definition}. + * @param definition the target bean definition + * @return the relevant scope metadata; never {@code null} + */ + ScopeMetadata resolveScopeMetadata(BeanDefinition definition); + +} diff --git a/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/ScopedProxyMode.java b/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/ScopedProxyMode.java new file mode 100644 index 000000000000..08e7fd8e32a1 --- /dev/null +++ b/java/ql/test/stubs/springframework-5.3.8/org/springframework/context/annotation/ScopedProxyMode.java @@ -0,0 +1,58 @@ +/* + * Copyright 2002-2020 the original author or authors. + * + * 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 + * + * https://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 org.springframework.context.annotation; + +/** + * Enumerates the various scoped-proxy options. + * + *

For a more complete discussion of exactly what a scoped proxy is, see the + * section of the Spring reference documentation entitled 'Scoped beans as + * dependencies'. + * + * @author Mark Fisher + * @since 2.5 + * @see ScopeMetadata + */ +public enum ScopedProxyMode { + + /** + * Default typically equals {@link #NO}, unless a different default + * has been configured at the component-scan instruction level. + */ + DEFAULT, + + /** + * Do not create a scoped proxy. + *

This proxy-mode is not typically useful when used with a + * non-singleton scoped instance, which should favor the use of the + * {@link #INTERFACES} or {@link #TARGET_CLASS} proxy-modes instead if it + * is to be used as a dependency. + */ + NO, + + /** + * Create a JDK dynamic proxy implementing all interfaces exposed by + * the class of the target object. + */ + INTERFACES, + + /** + * Create a class-based proxy (uses CGLIB). + */ + TARGET_CLASS + +} diff --git a/java/ql/test/stubs/springframework-5.3.8/org/springframework/core/AliasRegistry.java b/java/ql/test/stubs/springframework-5.3.8/org/springframework/core/AliasRegistry.java new file mode 100644 index 000000000000..689b3aeea9be --- /dev/null +++ b/java/ql/test/stubs/springframework-5.3.8/org/springframework/core/AliasRegistry.java @@ -0,0 +1,59 @@ +/* + * Copyright 2002-2020 the original author or authors. + * + * 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 + * + * https://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 org.springframework.core; + +/** + * Common interface for managing aliases. Serves as a super-interface for + * {@link org.springframework.beans.factory.support.BeanDefinitionRegistry}. + * + * @author Juergen Hoeller + * @since 2.5.2 + */ +public interface AliasRegistry { + + /** + * Given a name, register an alias for it. + * @param name the canonical name + * @param alias the alias to be registered + * @throws IllegalStateException if the alias is already in use + * and may not be overridden + */ + void registerAlias(String name, String alias); + + /** + * Remove the specified alias from this registry. + * @param alias the alias to remove + * @throws IllegalStateException if no such alias was found + */ + void removeAlias(String alias); + + /** + * Determine whether the given name is defined as an alias + * (as opposed to the name of an actually registered component). + * @param name the name to check + * @return whether the given name is an alias + */ + boolean isAlias(String name); + + /** + * Return the aliases for the given name, if defined. + * @param name the name to check for aliases + * @return the aliases, or an empty array if none + */ + String[] getAliases(String name); + +} diff --git a/java/ql/test/stubs/springframework-5.3.8/org/springframework/core/ResolvableType.java b/java/ql/test/stubs/springframework-5.3.8/org/springframework/core/ResolvableType.java new file mode 100644 index 000000000000..bd05cee4ec1e --- /dev/null +++ b/java/ql/test/stubs/springframework-5.3.8/org/springframework/core/ResolvableType.java @@ -0,0 +1,21 @@ +/* + * Copyright 2002-2024 the original author or authors. + * + * 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 + * + * https://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 org.springframework.core; + +import java.io.Serializable; + +public class ResolvableType implements Serializable { } diff --git a/java/ql/test/stubs/springframework-5.3.8/org/springframework/core/type/AnnotatedTypeMetadata.java b/java/ql/test/stubs/springframework-5.3.8/org/springframework/core/type/AnnotatedTypeMetadata.java new file mode 100644 index 000000000000..2213647938d9 --- /dev/null +++ b/java/ql/test/stubs/springframework-5.3.8/org/springframework/core/type/AnnotatedTypeMetadata.java @@ -0,0 +1,19 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * 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 + * + * https://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 org.springframework.core.type; + +public interface AnnotatedTypeMetadata { }