ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/jakarta/el/TesterBeanNameResolver.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/jakarta/el/TesterBeanNameResolver.java
Status
scanned
Type
file
Name
TesterBeanNameResolver.java
Extension
.java
Programming language
Java
Mime type
text/plain
File type
ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
2685 (2.6 KB)
MD5
3dcd36bcf4c10df61006bbfac9208559
SHA1
40f4d946a553e2295d8ba797471e12e403ff4897
SHA256
f4268dc5bdb0b3fe48d0822136bce55d4493a32d7071c5b61728acd2109f374e
SHA512

      
    
SHA1_git
83c07a619cba854a1ed78970fdbeb05bd7f27292
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TesterBeanNameResolver.java | 2.6 KB |

/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 jakarta.el; import java.util.HashMap; import java.util.Map; public class TesterBeanNameResolver extends BeanNameResolver { public static final String EXCEPTION_TRIGGER_NAME = "exception"; public static final String THROWABLE_TRIGGER_NAME = "throwable"; public static final String READ_ONLY_NAME = "readonly"; private Map<String,Object> beans = new HashMap<>(); private boolean allowCreate = true; public TesterBeanNameResolver() { beans.put(EXCEPTION_TRIGGER_NAME, new Object()); beans.put(THROWABLE_TRIGGER_NAME, new Object()); beans.put(READ_ONLY_NAME, new Object()); } @Override public void setBeanValue(String beanName, Object value) throws PropertyNotWritableException { checkTriggers(beanName); if (allowCreate || beans.containsKey(beanName)) { beans.put(beanName, value); } } @Override public boolean isNameResolved(String beanName) { return beans.containsKey(beanName); } @Override public Object getBean(String beanName) { checkTriggers(beanName); return beans.get(beanName); } @Override public boolean canCreateBean(String beanName) { checkTriggers(beanName); return allowCreate; } public void setAllowCreate(boolean allowCreate) { this.allowCreate = allowCreate; } @Override public boolean isReadOnly(String beanName) { checkTriggers(beanName); return READ_ONLY_NAME.equals(beanName); } private void checkTriggers(String beanName) { if (EXCEPTION_TRIGGER_NAME.equals(beanName)) { throw new RuntimeException(); } if (THROWABLE_TRIGGER_NAME.equals(beanName)) { throw new Error(); } } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
41.03
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 9 9