gpt4 book ai didi

ldap - Spring LDAP ODM-入口类应声明为最终警告

转载 作者:行者123 更新时间:2023-12-02 04:02:26 24 4
gpt4 key购买 nike

我使用Spring LDAP ODM映射了Entry(“实体”)。当我使用此类运行单元测试时,初始化时会在控制台中收到警告:

Mar 9, 2012 2:32:40 PM org.springframework.ldap.odm.core.impl.ObjectMetaData <init>
WARNING: The Entry class Superhero should be declared final

映射的类如下所示:
@Entry(objectClasses = {"batman", "superman", "spiderman", "dontworryaboutthese"})
public class Superhero {
@Id
@JsonIgnore
private Name dn;
...

我无法通过Google搜索找到与此警告相关的任何信息。这是记录它的Spring代码:
public ObjectMetaData(Class<?> clazz) {
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("Extracting metadata from %1$s", clazz));
}

// Get object class metadata - the @Entity annotation
Entry entity = (Entry)clazz.getAnnotation(Entry.class);
if (entity != null) {
// Default objectclass name to the class name unless it's specified
// in @Entity(name={objectclass1, objectclass2});
String[] localObjectClasses = entity.objectClasses();
if (localObjectClasses != null && localObjectClasses.length > 0 && localObjectClasses[0].length() > 0) {
for (String localObjectClass:localObjectClasses) {
objectClasses.add(new CaseIgnoreString(localObjectClass));
}
} else {
objectClasses.add(new CaseIgnoreString(clazz.getSimpleName()));
}
} else {
throw new MetaDataException(String.format("Class %1$s must have a class level %2$s annotation", clazz,
Entry.class));
}

// Check the class is final
if (!Modifier.isFinal(clazz.getModifiers())) {
LOG.warn(String.format("The Entry class %1$s should be declared final", clazz.getSimpleName()));
}
...

任何见识将不胜感激。我知道将类声明为final意味着无法扩展它,但是为什么Spring ODM会关心它?

最佳答案

安全原因?

也许通过子类化您的实体,一个人可以在目录中存储其他种类的LDAP条目,从而导致无法预料的行为?

关于ldap - Spring LDAP ODM-入口类应声明为最终警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9640015/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com