Skip to content

Commit

Permalink
PAYARA-2066 Validation for duplicate @ManagedBean names (#1960)
Browse files Browse the repository at this point in the history
  • Loading branch information
jGauravGupta authored and smillidge committed Sep 16, 2017
1 parent 1be4c39 commit 60d98f7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,22 @@ public Set<EntityManagerFactory> getEntityManagerFactories() {

public void addManagedBean(ManagedBeanDescriptor desc) {
if (!hasManagedBeanByBeanClass(desc.getBeanClassName())) {
//check for uniqueness of ManagedBean name, if defined
if (desc.isNamed()) {
for (ManagedBeanDescriptor managedBeanDescriptor : managedBeans) {
if (managedBeanDescriptor.isNamed() && desc.getName().equals(managedBeanDescriptor.getName())) {
//duplicate ManagedBean found
throw new RuntimeException(localStrings.getLocalString(
"entreprise.deployment.exceptionduplicatemanagedbeandefinition",
"ManagedBean [{0}] cannot have same name [{1}] already used by "
+ "another ManagedBean [{2}]", new Object[]{
desc.getBeanClassName(),
managedBeanDescriptor.getName(),
managedBeanDescriptor.getBeanClassName()
}));
}
}
}
managedBeans.add(desc);
desc.setBundle(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ entreprise.deployment.exceptionduplicatedatasourcedefinition=This descriptor/cla
entreprise.deployment.exceptionduplicateconnectionfactorydefinition=This descriptor/class cannot have connection factory definitions of same name : [{0}]
entreprise.deployment.exceptionduplicatejmsconnectionfactorydefinition=This descriptor/class cannot have jms connection factory definitions of same name : [{0}]
entreprise.deployment.exceptionduplicatejmsdestinationdefinition=This descriptor/class cannot have jms destination definitions of same name : [{0}]
entreprise.deployment.exceptionduplicatemanagedbeandefinition=ManagedBean [{0}] cannot have same name [{1}] already used by another ManagedBean [{2}]

warning.static_content.packaged=Warning: [{0}] does not exist. No static content files will be packaged.
enterprise.deployment.errorwithexternaldescriptors=Supplied External Descriptors [{0}] are incorrect
Expand Down

0 comments on commit 60d98f7

Please sign in to comment.