This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 00dca673b7443f05d9fefd03d832d2009211f81a Author: Mark Thomas <ma...@apache.org> AuthorDate: Tue Sep 26 19:03:57 2023 +0100 Align with 9.0.x onwards --- .../org/apache/catalina/mbeans/ConnectorMBean.java | 15 ++-- .../catalina/mbeans/ContextResourceLinkMBean.java | 17 +++-- .../catalina/mbeans/ContextResourceMBean.java | 17 +++-- .../mbeans/GlobalResourcesLifecycleListener.java | 26 ++++--- java/org/apache/catalina/mbeans/GroupMBean.java | 16 +++-- .../apache/catalina/mbeans/LocalStrings.properties | 46 ++++++++++++ .../catalina/mbeans/LocalStrings_fr.properties | 46 ++++++++++++ .../catalina/mbeans/LocalStrings_ja.properties | 46 ++++++++++++ .../catalina/mbeans/LocalStrings_ko.properties | 46 ++++++++++++ .../catalina/mbeans/LocalStrings_zh_CN.properties | 46 ++++++++++++ java/org/apache/catalina/mbeans/MBeanDumper.java | 21 +++--- java/org/apache/catalina/mbeans/MBeanFactory.java | 82 ++++++---------------- java/org/apache/catalina/mbeans/MBeanUtils.java | 17 +++-- .../catalina/mbeans/MemoryUserDatabaseMBean.java | 35 ++++----- .../catalina/mbeans/NamingResourcesMBean.java | 30 +++++--- java/org/apache/catalina/mbeans/UserMBean.java | 19 ++--- 16 files changed, 379 insertions(+), 146 deletions(-) diff --git a/java/org/apache/catalina/mbeans/ConnectorMBean.java b/java/org/apache/catalina/mbeans/ConnectorMBean.java index 09f1c23859..7cd1a45e95 100644 --- a/java/org/apache/catalina/mbeans/ConnectorMBean.java +++ b/java/org/apache/catalina/mbeans/ConnectorMBean.java @@ -24,6 +24,7 @@ import javax.management.RuntimeOperationsException; import org.apache.catalina.connector.Connector; import org.apache.tomcat.util.IntrospectionUtils; +import org.apache.tomcat.util.res.StringManager; /** * <p> @@ -35,6 +36,8 @@ import org.apache.tomcat.util.IntrospectionUtils; */ public class ConnectorMBean extends ClassNameMBean<Connector> { + private static final StringManager sm = StringManager.getManager(ConnectorMBean.class); + /** * Obtain and return the value of a specific attribute of this MBean. * @@ -49,8 +52,8 @@ public class ConnectorMBean extends ClassNameMBean<Connector> { // Validate the input parameters if (name == null) { - throw new RuntimeOperationsException(new IllegalArgumentException("Attribute name is null"), - "Attribute name is null"); + throw new RuntimeOperationsException(new IllegalArgumentException(sm.getString("mBean.nullName")), + sm.getString("mBean.nullName")); } Connector connector = doGetManagedResource(); @@ -73,14 +76,14 @@ public class ConnectorMBean extends ClassNameMBean<Connector> { // Validate the input parameters if (attribute == null) { - throw new RuntimeOperationsException(new IllegalArgumentException("Attribute is null"), - "Attribute is null"); + throw new RuntimeOperationsException(new IllegalArgumentException(sm.getString("mBean.nullAttribute")), + sm.getString("mBean.nullAttribute")); } String name = attribute.getName(); Object value = attribute.getValue(); if (name == null) { - throw new RuntimeOperationsException(new IllegalArgumentException("Attribute name is null"), - "Attribute name is null"); + throw new RuntimeOperationsException(new IllegalArgumentException(sm.getString("mBean.nullName")), + sm.getString("mBean.nullName")); } Connector connector = doGetManagedResource(); diff --git a/java/org/apache/catalina/mbeans/ContextResourceLinkMBean.java b/java/org/apache/catalina/mbeans/ContextResourceLinkMBean.java index 6f2ca1329e..ae125c95a2 100644 --- a/java/org/apache/catalina/mbeans/ContextResourceLinkMBean.java +++ b/java/org/apache/catalina/mbeans/ContextResourceLinkMBean.java @@ -24,6 +24,7 @@ import javax.management.RuntimeOperationsException; import org.apache.tomcat.util.descriptor.web.ContextResourceLink; import org.apache.tomcat.util.descriptor.web.NamingResources; +import org.apache.tomcat.util.res.StringManager; /** * <p> @@ -35,6 +36,8 @@ import org.apache.tomcat.util.descriptor.web.NamingResources; */ public class ContextResourceLinkMBean extends BaseCatalinaMBean<ContextResourceLink> { + private static final StringManager sm = StringManager.getManager(ContextResourceLinkMBean.class); + /** * Obtain and return the value of a specific attribute of this MBean. * @@ -49,8 +52,8 @@ public class ContextResourceLinkMBean extends BaseCatalinaMBean<ContextResourceL // Validate the input parameters if (name == null) { - throw new RuntimeOperationsException(new IllegalArgumentException("Attribute name is null"), - "Attribute name is null"); + throw new RuntimeOperationsException(new IllegalArgumentException(sm.getString("mBean.nullName")), + sm.getString("mBean.nullName")); } ContextResourceLink cl = doGetManagedResource(); @@ -67,7 +70,7 @@ public class ContextResourceLinkMBean extends BaseCatalinaMBean<ContextResourceL } else { value = (String) cl.getProperty(name); if (value == null) { - throw new AttributeNotFoundException("Cannot find attribute [" + name + "]"); + throw new AttributeNotFoundException(sm.getString("mBean.attributeNotFound", name)); } } @@ -90,15 +93,15 @@ public class ContextResourceLinkMBean extends BaseCatalinaMBean<ContextResourceL // Validate the input parameters if (attribute == null) { - throw new RuntimeOperationsException(new IllegalArgumentException("Attribute is null"), - "Attribute is null"); + throw new RuntimeOperationsException(new IllegalArgumentException(sm.getString("mBean.nullAttribute")), + sm.getString("mBean.nullAttribute")); } String name = attribute.getName(); Object value = attribute.getValue(); if (name == null) { - throw new RuntimeOperationsException(new IllegalArgumentException("Attribute name is null"), - "Attribute name is null"); + throw new RuntimeOperationsException(new IllegalArgumentException(sm.getString("mBean.nullName")), + sm.getString("mBean.nullName")); } ContextResourceLink crl = doGetManagedResource(); diff --git a/java/org/apache/catalina/mbeans/ContextResourceMBean.java b/java/org/apache/catalina/mbeans/ContextResourceMBean.java index 7ba6cc55bd..bad2ec23cf 100644 --- a/java/org/apache/catalina/mbeans/ContextResourceMBean.java +++ b/java/org/apache/catalina/mbeans/ContextResourceMBean.java @@ -24,6 +24,7 @@ import javax.management.RuntimeOperationsException; import org.apache.tomcat.util.descriptor.web.ContextResource; import org.apache.tomcat.util.descriptor.web.NamingResources; +import org.apache.tomcat.util.res.StringManager; /** * <p> @@ -35,6 +36,8 @@ import org.apache.tomcat.util.descriptor.web.NamingResources; */ public class ContextResourceMBean extends BaseCatalinaMBean<ContextResource> { + private static final StringManager sm = StringManager.getManager(ContextResourceMBean.class); + /** * Obtain and return the value of a specific attribute of this MBean. * @@ -49,8 +52,8 @@ public class ContextResourceMBean extends BaseCatalinaMBean<ContextResource> { // Validate the input parameters if (name == null) { - throw new RuntimeOperationsException(new IllegalArgumentException("Attribute name is null"), - "Attribute name is null"); + throw new RuntimeOperationsException(new IllegalArgumentException(sm.getString("mBean.nullName")), + sm.getString("mBean.nullName")); } ContextResource cr = doGetManagedResource(); @@ -69,7 +72,7 @@ public class ContextResourceMBean extends BaseCatalinaMBean<ContextResource> { } else { value = (String) cr.getProperty(name); if (value == null) { - throw new AttributeNotFoundException("Cannot find attribute [" + name + "]"); + throw new AttributeNotFoundException(sm.getString("mBean.attributeNotFound", name)); } } @@ -92,14 +95,14 @@ public class ContextResourceMBean extends BaseCatalinaMBean<ContextResource> { // Validate the input parameters if (attribute == null) { - throw new RuntimeOperationsException(new IllegalArgumentException("Attribute is null"), - "Attribute is null"); + throw new RuntimeOperationsException(new IllegalArgumentException(sm.getString("mBean.nullAttribute")), + sm.getString("mBean.nullAttribute")); } String name = attribute.getName(); Object value = attribute.getValue(); if (name == null) { - throw new RuntimeOperationsException(new IllegalArgumentException("Attribute name is null"), - "Attribute name is null"); + throw new RuntimeOperationsException(new IllegalArgumentException(sm.getString("mBean.nullName")), + sm.getString("mBean.nullName")); } ContextResource cr = doGetManagedResource(); diff --git a/java/org/apache/catalina/mbeans/GlobalResourcesLifecycleListener.java b/java/org/apache/catalina/mbeans/GlobalResourcesLifecycleListener.java index 45bb5e9c13..db858028ba 100644 --- a/java/org/apache/catalina/mbeans/GlobalResourcesLifecycleListener.java +++ b/java/org/apache/catalina/mbeans/GlobalResourcesLifecycleListener.java @@ -37,6 +37,7 @@ import org.apache.catalina.UserDatabase; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; import org.apache.tomcat.util.modeler.Registry; +import org.apache.tomcat.util.res.StringManager; /** @@ -52,6 +53,7 @@ import org.apache.tomcat.util.modeler.Registry; public class GlobalResourcesLifecycleListener implements LifecycleListener { private static final Log log = LogFactory.getLog(GlobalResourcesLifecycleListener.class); + protected static final StringManager sm = StringManager.getManager(GlobalResourcesLifecycleListener.class); // ----------------------------------------------------- Instance Variables @@ -80,8 +82,7 @@ public class GlobalResourcesLifecycleListener implements LifecycleListener { if (Lifecycle.START_EVENT.equals(event.getType())) { if (!(event.getLifecycle() instanceof Server)) { - log.warn("This listener must only be nested within Server elements, but is in [" + - event.getLifecycle().getClass().getSimpleName() + "]."); + log.warn(sm.getString("listener.notServer", event.getLifecycle().getClass().getSimpleName())); } component = event.getLifecycle(); createMBeans(); @@ -103,7 +104,7 @@ public class GlobalResourcesLifecycleListener implements LifecycleListener { try { context = (Context) (new InitialContext()).lookup("java:/"); } catch (NamingException e) { - log.error("No global naming context defined for server"); + log.error(sm.getString("globalResources.noNamingContext")); return; } @@ -111,7 +112,7 @@ public class GlobalResourcesLifecycleListener implements LifecycleListener { try { createMBeans("", context); } catch (NamingException e) { - log.error("Exception processing Global JNDI Resources", e); + log.error(sm.getString("globalResources.createError"), e); } } @@ -145,14 +146,14 @@ public class GlobalResourcesLifecycleListener implements LifecycleListener { try { createMBeans(name, (UserDatabase) value); } catch (Exception e) { - log.error("Exception creating UserDatabase MBeans for " + name, e); + log.error(sm.getString("globalResources.userDatabaseCreateError", name), e); } } } } catch (RuntimeException ex) { - log.error("RuntimeException " + ex); + log.error(sm.getString("globalResources.createError.runtime"), ex); } catch (OperationNotSupportedException ex) { - log.error("Operation not supported " + ex); + log.error(sm.getString("globalResources.createError.operation"), ex); } } @@ -175,7 +176,7 @@ public class GlobalResourcesLifecycleListener implements LifecycleListener { try { MBeanUtils.createMBean(database); } catch (Exception e) { - throw new IllegalArgumentException("Cannot create UserDatabase MBean for resource " + name, e); + throw new IllegalArgumentException(sm.getString("globalResources.createError.userDatabase", name), e); } // Create the MBeans for each defined Role @@ -188,7 +189,8 @@ public class GlobalResourcesLifecycleListener implements LifecycleListener { try { MBeanUtils.createMBean(role); } catch (Exception e) { - throw new IllegalArgumentException("Cannot create Role MBean for role " + role, e); + throw new IllegalArgumentException(sm.getString("globalResources.createError.userDatabase.role", role), + e); } } @@ -202,7 +204,8 @@ public class GlobalResourcesLifecycleListener implements LifecycleListener { try { MBeanUtils.createMBean(group); } catch (Exception e) { - throw new IllegalArgumentException("Cannot create Group MBean for group " + group, e); + throw new IllegalArgumentException( + sm.getString("globalResources.createError.userDatabase.group", group), e); } } @@ -216,7 +219,8 @@ public class GlobalResourcesLifecycleListener implements LifecycleListener { try { MBeanUtils.createMBean(user); } catch (Exception e) { - throw new IllegalArgumentException("Cannot create User MBean for user " + user, e); + throw new IllegalArgumentException(sm.getString("globalResources.createError.userDatabase.user", user), + e); } } } diff --git a/java/org/apache/catalina/mbeans/GroupMBean.java b/java/org/apache/catalina/mbeans/GroupMBean.java index 9721d6e013..f0a46018f0 100644 --- a/java/org/apache/catalina/mbeans/GroupMBean.java +++ b/java/org/apache/catalina/mbeans/GroupMBean.java @@ -18,6 +18,7 @@ package org.apache.catalina.mbeans; import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; @@ -28,6 +29,7 @@ import org.apache.catalina.User; import org.apache.tomcat.util.modeler.BaseModelMBean; import org.apache.tomcat.util.modeler.ManagedBean; import org.apache.tomcat.util.modeler.Registry; +import org.apache.tomcat.util.res.StringManager; /** * <p> @@ -38,6 +40,8 @@ import org.apache.tomcat.util.modeler.Registry; */ public class GroupMBean extends BaseModelMBean { + private static final StringManager sm = StringManager.getManager(GroupMBean.class); + /** * The configuration information registry for our managed beans. */ @@ -56,7 +60,7 @@ public class GroupMBean extends BaseModelMBean { public String[] getRoles() { Group group = (Group) this.resource; - ArrayList<String> results = new ArrayList<>(); + List<String> results = new ArrayList<>(); Iterator<Role> roles = group.getRoles(); while (roles.hasNext()) { Role role = null; @@ -65,7 +69,7 @@ public class GroupMBean extends BaseModelMBean { ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), role); results.add(oname.toString()); } catch (MalformedObjectNameException e) { - throw new IllegalArgumentException("Cannot create object name for role " + role, e); + throw new IllegalArgumentException(sm.getString("userMBean.createError.role", role), e); } } return results.toArray(new String[0]); @@ -78,7 +82,7 @@ public class GroupMBean extends BaseModelMBean { public String[] getUsers() { Group group = (Group) this.resource; - ArrayList<String> results = new ArrayList<>(); + List<String> results = new ArrayList<>(); Iterator<User> users = group.getUsers(); while (users.hasNext()) { User user = null; @@ -87,7 +91,7 @@ public class GroupMBean extends BaseModelMBean { ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), user); results.add(oname.toString()); } catch (MalformedObjectNameException e) { - throw new IllegalArgumentException("Cannot create object name for user " + user, e); + throw new IllegalArgumentException(sm.getString("userMBean.createError.user", user), e); } } return results.toArray(new String[0]); @@ -107,7 +111,7 @@ public class GroupMBean extends BaseModelMBean { } Role role = group.getUserDatabase().findRole(rolename); if (role == null) { - throw new IllegalArgumentException("Invalid role name '" + rolename + "'"); + throw new IllegalArgumentException(sm.getString("userMBean.invalidRole", rolename)); } group.addRole(role); } @@ -126,7 +130,7 @@ public class GroupMBean extends BaseModelMBean { } Role role = group.getUserDatabase().findRole(rolename); if (role == null) { - throw new IllegalArgumentException("Invalid role name [" + rolename + "]"); + throw new IllegalArgumentException(sm.getString("userMBean.invalidRole", rolename)); } group.removeRole(role); } diff --git a/java/org/apache/catalina/mbeans/LocalStrings.properties b/java/org/apache/catalina/mbeans/LocalStrings.properties index 4710ad81ac..19ea1dc1c5 100644 --- a/java/org/apache/catalina/mbeans/LocalStrings.properties +++ b/java/org/apache/catalina/mbeans/LocalStrings.properties @@ -13,7 +13,53 @@ # See the License for the specific language governing permissions and # limitations under the License. +globalResources.createError=Exception processing global JNDI Resources +globalResources.createError.operation=Operation not supported error creating MBeans +globalResources.createError.runtime=Unexpected error creating MBeans +globalResources.createError.userDatabase=Cannot create UserDatabase MBean for resource [{0}] +globalResources.createError.userDatabase.group=Cannot create Group MBean for group [{0}] +globalResources.createError.userDatabase.role=Cannot create Role MBean for role [{0}] +globalResources.createError.userDatabase.user=Cannot create User MBean for user [{0}] +globalResources.noNamingContext=No global naming context defined for server +globalResources.userDatabaseCreateError=Exception creating UserDatabase MBeans for [{0}] + +listener.notServer=This listener must only be nested within Server elements, but is in [{0}]. + +mBean.attributeNotFound=Cannot find attribute [{0}] +mBean.nullAttribute=Attribute is null +mBean.nullName=Attribute name is null + +mBeanDumper.getAttributeError=Error getting attribute [{0}] for object name [{1}] + mBeanFactory.contextCreate.addServicedFail=Unable to create context [{0}] as another component is currently servicing a context with that name +mBeanFactory.contextDestroyError=Error during context [{0}] destroy mBeanFactory.contextRemove.addServicedFail=Unable to remove context [{0}] as another component is currently servicing that context mBeanFactory.managerContext=Manager components may only be added to Contexts. +mBeanFactory.noDeployer=Deployer not found for host [{0}] mBeanFactory.noParent=No parent found with object name [{0}] +mBeanFactory.noService=Service with the domain [{0}] was not found +mBeanFactory.notServer=The container is not a Server + +mBeanUtils.noManagedBean=ManagedBean is not found with [{0}] + +namingResourcesMBean.addAlreadyExists.environment=Specified environment already exists with name [{0}] +namingResourcesMBean.addAlreadyExists.resource=Specified resource name already exists with name [{0}] +namingResourcesMBean.addAlreadyExists.resourceLink=Specified resource link already exists with name [{0}] +namingResourcesMBean.createObjectNameError.environment=Cannot create object name for environment [{0}] +namingResourcesMBean.createObjectNameError.resource=Cannot create object name for resource [{0}] +namingResourcesMBean.createObjectNameError.resourceLink=Cannot create object name for resource link [{0}] +namingResourcesMBean.removeNotFound.environment=Specified environment does not exist with name [{0}] +namingResourcesMBean.removeNotFound.resource=Specified resource does not exist with name [{0}] +namingResourcesMBean.removeNotFound.resourceLink=Specified resource link does not exist with name [{0}] + +userMBean.createError.group=Cannot create object name for group [{0}] +userMBean.createError.role=Cannot create object name for role [{0}] +userMBean.createError.user=Cannot create object name for user [{0}] +userMBean.createMBeanError.group=Exception creating group [{0}] MBean +userMBean.createMBeanError.role=Exception creating role [{0}] MBean +userMBean.createMBeanError.user=Exception creating user [{0}] MBean +userMBean.destroyError.group=Exception destroying group [{0}] MBean +userMBean.destroyError.role=Exception destroying role [{0}] MBean +userMBean.destroyError.user=Exception destroying user [{0}] MBean +userMBean.invalidGroup=Invalid group name [{0}] +userMBean.invalidRole=Invalid role name [{0}] diff --git a/java/org/apache/catalina/mbeans/LocalStrings_fr.properties b/java/org/apache/catalina/mbeans/LocalStrings_fr.properties index 9df7bba059..07c61b85fe 100644 --- a/java/org/apache/catalina/mbeans/LocalStrings_fr.properties +++ b/java/org/apache/catalina/mbeans/LocalStrings_fr.properties @@ -13,6 +13,52 @@ # See the License for the specific language governing permissions and # limitations under the License. +globalResources.createError=Erreur lors du traitement des ressources JNDI globales +globalResources.createError.operation=Une erreur d'opération non supportée s'est produite lors de la création des MBeans +globalResources.createError.runtime=Erreur inattendue lors de la création des MBeans +globalResources.createError.userDatabase=Impossible de créer un MBean UserDatabase pour la ressource [{0}] +globalResources.createError.userDatabase.group=Impossible de créer un MBean Groupe pour le groupe [{0}] +globalResources.createError.userDatabase.role=Impossible de créer un MBean Role pour le rôle [{0}] +globalResources.createError.userDatabase.user=Impossible de créer un MBean User pour l''utilisateur [{0}] +globalResources.noNamingContext=Aucun contexte de nommage global n'a été défini pour le serveur +globalResources.userDatabaseCreateError=Erreur lors de la création des MBeans d''une UserDatabase pour [{0}] + +listener.notServer=Ce listener ne peut être ajouté qu''à des éléments Server, mais est dans [{0}] + +mBean.attributeNotFound=Impossible de trouver l''attribut [{0}] +mBean.nullAttribute=L'attribut est null +mBean.nullName=Le nom d'attribut est null + +mBeanDumper.getAttributeError=Erreur en obtenant l''attribut [{0}] pour le nom d''objet [{1}] + mBeanFactory.contextCreate.addServicedFail=Impossible de créer le contexte [{0}] car un autre composant est en train d''effectuer des opérations de service avec ce nom +mBeanFactory.contextDestroyError=Erreur lors de la destruction du contexte [{0}] mBeanFactory.contextRemove.addServicedFail=Impossible de supprimer le contexte [{0}] car un autre composant est en train d''effectuer des opérations de service avec ce nom mBeanFactory.managerContext=Un gestionnaire de sessions ne peut être ajouté qu'à un contexte +mBeanFactory.noDeployer=Un déployeur n''a pas été trouvé pour l''hôte [{0}] +mBeanFactory.noService=Un Service ayant le domaine [{0}] n''a pas été trouvé +mBeanFactory.notServer=Le conteneur n'est pas un serveur + +mBeanUtils.noManagedBean=Un ManagedBean n''a pas été trouvé avec [{0}] + +namingResourcesMBean.addAlreadyExists.environment=L''environnement spécifié existe déjà avec le nom [{0}] +namingResourcesMBean.addAlreadyExists.resource=La ressource spécifiée existe déjà avec le nom [{0}] +namingResourcesMBean.addAlreadyExists.resourceLink=Le lien de ressource spécifié existe déjà avec le nom [{0}] +namingResourcesMBean.createObjectNameError.environment=Impossible de créer un nom d''objet pour l''environnement [{0}] +namingResourcesMBean.createObjectNameError.resource=Impossible de créer un nom d''objet pour la ressource [{0}] +namingResourcesMBean.createObjectNameError.resourceLink=Impossible de créer un nom d''objet pour le lien de ressource [{0}] +namingResourcesMBean.removeNotFound.environment=L''environnement spécifié n''existe pas avec le nom [{0}] +namingResourcesMBean.removeNotFound.resource=La ressource spécifiée n''existe pas avec le nom [{0}] +namingResourcesMBean.removeNotFound.resourceLink=Le lien de ressource spécifié n''existe pas avec le nom [{0}] + +userMBean.createError.group=Impossible de créer le nom d''objet pour le groupe [{0}] +userMBean.createError.role=Impossible de créer le nom d''objet pour le rôle [{0}] +userMBean.createError.user=Impossible de créer le nom d''objet pour l''utilisateur [{0}] +userMBean.createMBeanError.group=Erreur lors de la création du MBean du groupe [{0}] +userMBean.createMBeanError.role=Erreur lors de la création du MBean du rôle [{0}] +userMBean.createMBeanError.user=Erreur lors de la création du MBean de l''utilisateur [{0}] +userMBean.destroyError.group=Erreur lors de la destruction du MBean dus groupe [{0}] +userMBean.destroyError.role=Erreur lors de la destruction du MBean du rôle [{0}] +userMBean.destroyError.user=Erreur lors de la destruction du MBean de l''utilisateur [{0}] +userMBean.invalidGroup=Nom de groupe [{0}] invalide +userMBean.invalidRole=Nom de rôle [{0}] invalide diff --git a/java/org/apache/catalina/mbeans/LocalStrings_ja.properties b/java/org/apache/catalina/mbeans/LocalStrings_ja.properties index bedf1f2249..92769a5627 100644 --- a/java/org/apache/catalina/mbeans/LocalStrings_ja.properties +++ b/java/org/apache/catalina/mbeans/LocalStrings_ja.properties @@ -13,6 +13,52 @@ # See the License for the specific language governing permissions and # limitations under the License. +globalResources.createError=グローバル JNDI リソース処理中の例外 +globalResources.createError.operation=MBean 作成中の操作未サポートエラー +globalResources.createError.runtime=MBeans 作成中の予期せぬエラー +globalResources.createError.userDatabase=リソース [{0}] のUserDatabase MBeanを作成できません +globalResources.createError.userDatabase.group=グループ [{0}] のGroup MBeanを作成できません +globalResources.createError.userDatabase.role=ロール [{0}] のRole MBeanが作成できません +globalResources.createError.userDatabase.user=ユーザー[{0}]のUser MBeanを作成できません。 +globalResources.noNamingContext=サーバー用に定義されたグローバル・ネーミング・コンテキストがありません。 +globalResources.userDatabaseCreateError=[{0}]のUserDatabase MBeanを作成する際の例外 + +listener.notServer=このlistenerはServer要素内にのみネストする必要がありますが、[{0}] にあります。 + +mBean.attributeNotFound=属性 [{0}] を見つけられません。 +mBean.nullAttribute=属性がnullです +mBean.nullName=属性名がNulです。 + +mBeanDumper.getAttributeError=ObjectName [{1}] の属性 [{0}] を取得中のエラー + mBeanFactory.contextCreate.addServicedFail=別のコンポーネントが現在その名前のコンテキストを処理しているため、コンテキスト [{0}] を作成できません +mBeanFactory.contextDestroyError=コンテキスト [{0}] 破棄中のエラー mBeanFactory.contextRemove.addServicedFail=別のコンポーネントが現在そのコンテキストを処理しているため、コンテキスト [{0}] を削除できません mBeanFactory.managerContext=ManagerコンポーネントはContextにのみ追加できます。 +mBeanFactory.noDeployer=ホスト [{0}] Deployer が見つかりません。 +mBeanFactory.noService=ドメイン [{0}] にサービスがありません。 +mBeanFactory.notServer=コンテナは Server ではありません。 + +mBeanUtils.noManagedBean=[{0}]のManagedBeanが見つかりません + +namingResourcesMBean.addAlreadyExists.environment=指定された環境は名前[{0}]が既に存在します。 +namingResourcesMBean.addAlreadyExists.resource=指定された名前のリソースは [{0}] という名前ですでに存在しています。 +namingResourcesMBean.addAlreadyExists.resourceLink=指定されたリソースリンクはすでに名前[{0}]で存在します。 +namingResourcesMBean.createObjectNameError.environment=environment [{0}]のObjectNameを作成できません。 +namingResourcesMBean.createObjectNameError.resource=リソース [{0}] のObjectNameを作成できません +namingResourcesMBean.createObjectNameError.resourceLink=リソースリンク [{0}] のObjectNameを作成できません +namingResourcesMBean.removeNotFound.environment=指定されたenvironment が名前[{0}]で存在しません。 +namingResourcesMBean.removeNotFound.resource=指定されたリソースが名前[{0}]で存在しません。 +namingResourcesMBean.removeNotFound.resourceLink=指定されたリソースリンクが名前[{0}]で存在しません + +userMBean.createError.group=グループ [{0}] のObjectNameを作成できません +userMBean.createError.role=ロール [{0}] のObjectNameを作成できません +userMBean.createError.user=ユーザー[{0}]のObjectNameを作成できません。 +userMBean.createMBeanError.group=グループ [{0}] MBean作成中の例外 +userMBean.createMBeanError.role=Role [{0}] MBean作成中の例外 +userMBean.createMBeanError.user=ユーザ [{0}] MBean作成中の例外 +userMBean.destroyError.group=グループ [{0}] MBean破棄中の例外 +userMBean.destroyError.role=ロール [{0}] MBeanを破棄する際の例外 +userMBean.destroyError.user=ユーザ [{0}] MBean 破棄中の例外 +userMBean.invalidGroup=不正なグループ名 [{0}] +userMBean.invalidRole=不正なロール名 [{0}] diff --git a/java/org/apache/catalina/mbeans/LocalStrings_ko.properties b/java/org/apache/catalina/mbeans/LocalStrings_ko.properties index aa31ff5570..23360834cc 100644 --- a/java/org/apache/catalina/mbeans/LocalStrings_ko.properties +++ b/java/org/apache/catalina/mbeans/LocalStrings_ko.properties @@ -13,6 +13,52 @@ # See the License for the specific language governing permissions and # limitations under the License. +globalResources.createError=글로벌 JNDI 리소스들을 처리하는 중 예외 발생 +globalResources.createError.operation=MBean들을 생성하는 중 OperationNotSupportedException 발생 +globalResources.createError.runtime=MBean들을 생성하는 중 예기치 않은 오류 발생 +globalResources.createError.userDatabase=리소스 [{0}]을(를) 위한 사용자 데이터베이스 MBean을 생성할 수 없습니다. +globalResources.createError.userDatabase.group=그룹 [{0}]을(를) 위한 그룹 MBean을 생성할 수 없습니다. +globalResources.createError.userDatabase.role=역할 [{0}]을(를) 위한 역할 MBean을 생성할 수 없습니다. +globalResources.createError.userDatabase.user=사용자 [{0}]을(를) 위한 사용자 MBean을 생성할 수 없습니다. +globalResources.noNamingContext=서버를 위한 글로벌 Naming 컨텍스트가 정의되지 않았습니다. +globalResources.userDatabaseCreateError=[{0}]을(를) 위한 사용자 데이터베이스 MBean들을 생성하는 중 예외 발생 + +listener.notServer=리스너 엘리먼트는 서버 엘리먼트 내에 위치해야 합니다만, 현재 [{0}] 내에 있습니다. + +mBean.attributeNotFound=속성 [{0}]을(를) 찾을 수 없습니다. +mBean.nullAttribute=속성이 널입니다. +mBean.nullName=속성 이름이 널입니다. + +mBeanDumper.getAttributeError=객체 이름 [{1}]을(를) 위한 속성 [{0}]을(를) 얻는 중 오류 발생 + mBeanFactory.contextCreate.addServicedFail=다른 구성요소가 한 컨텍스트를 해당 이름으로 현재 서비스 중이므로, 컨텍스트 [{0}]을(를) 생성할 수 없습니다. +mBeanFactory.contextDestroyError=컨텍스트 [{0}]을(를) 소멸시키는 중 오류 발생 mBeanFactory.contextRemove.addServicedFail=다른 구성요소가 해당 컨텍스트를 현재 서비스 중이므로, 컨텍스트 [{0}]을(를) 제거할 수 없습니다. mBeanFactory.managerContext=매니저 구성요소들은 컨텍스트들에만 추가될 수 있습니다. +mBeanFactory.noDeployer=호스트 [{0}]을(를) 위한 배치관리자(Deployer)를 찾을 수 없습니다. +mBeanFactory.noService=도메인 [{0}]에 대한 서비스를 찾을 수 없었습니다. +mBeanFactory.notServer=컨테이너가 서버 객체가 아닙니다. + +mBeanUtils.noManagedBean=[{0}](이)라는 이름의 ManagedBean을 찾을 수 없습니다. + +namingResourcesMBean.addAlreadyExists.environment=[{0}](이)라는 이름으로 지정된 environment가 이미 존재합니다. +namingResourcesMBean.addAlreadyExists.resource=[{0}](이)라는 이름으로 지정된 리소스 이름이 이미 존재합니다. +namingResourcesMBean.addAlreadyExists.resourceLink=[{0}](이)라는 이름의 지정된 리소스 링크가 이미 존재합니다. +namingResourcesMBean.createObjectNameError.environment=Environment [{0}]을(를) 위한 객체 이름을 생성할 수 없습니다. +namingResourcesMBean.createObjectNameError.resource=리소스 [{0}]을(를) 위한 객체 이름을 생성할 수 없습니다. +namingResourcesMBean.createObjectNameError.resourceLink=리소스 링크 [{0}]을(를) 위한 객체 이름을 생성할 수 없습니다. +namingResourcesMBean.removeNotFound.environment=[{0}](이)라는 이름의 지정된 environment가 존재하지 않습니다. +namingResourcesMBean.removeNotFound.resource=[{0}](이)라는 이름의 지정된 리소스가 존재하지 않습니다. +namingResourcesMBean.removeNotFound.resourceLink=[{0}](이)라는 이름으로 지정된 리소스 링크가 존재하지 않습니다. + +userMBean.createError.group=그룹 [{0}]을(를) 위한 객체 이름을 생성할 수 없습니다. +userMBean.createError.role=역할 [{0}]을(를) 위한 객체 이름을 생성할 수 없습니다. +userMBean.createError.user=사용자 [{0}]을(를) 위한 객체 이름을 생성할 수 없습니다. +userMBean.createMBeanError.group=그룹 [{0}] MBean을 생성하는 중 예외 발생 +userMBean.createMBeanError.role=역할 [{0}] MBean을 생성하는 중 예외 발생 +userMBean.createMBeanError.user=사용자 [{0}] MBean을 생성하는 중 예외 발생 +userMBean.destroyError.group=그룹 [{0}] MBean을 소멸시키는 중 예외 발생 +userMBean.destroyError.role=역할 [{0}] MBean을 소멸시키는 중 예외 발생 +userMBean.destroyError.user=사용자 [{0}] MBean을 소멸시키는 중 예외 발생 +userMBean.invalidGroup=유효하지 않은 그룹 이름 [{0}] +userMBean.invalidRole=유효하지 않은 역할 이름 [{0}] diff --git a/java/org/apache/catalina/mbeans/LocalStrings_zh_CN.properties b/java/org/apache/catalina/mbeans/LocalStrings_zh_CN.properties index 785e2c5faa..4d3eaea051 100644 --- a/java/org/apache/catalina/mbeans/LocalStrings_zh_CN.properties +++ b/java/org/apache/catalina/mbeans/LocalStrings_zh_CN.properties @@ -13,6 +13,52 @@ # See the License for the specific language governing permissions and # limitations under the License. +globalResources.createError=处理全局JNDI资源时发生异常 +globalResources.createError.operation=创建MBean时不支持操作 +globalResources.createError.runtime=创建MBean时出现意外错误 +globalResources.createError.userDatabase=无法为资源[{0}]创建用户数据库MBean +globalResources.createError.userDatabase.group=无法为组[{0}]创建组MBean +globalResources.createError.userDatabase.role=无法为角色[{0}]创建角色MBean +globalResources.createError.userDatabase.user=无法为用户[{0}]创建用户MBean +globalResources.noNamingContext=没有为服务器定义全局命名上下文 +globalResources.userDatabaseCreateError=为[{0}]创建用户数据库MBean时发生异常 + +listener.notServer=此侦听器只能嵌套在 Server 元素中,但位于 [{0}] 中。 + +mBean.attributeNotFound=找不到属性[{0}] +mBean.nullAttribute=属性为空 +mBean.nullName=属性名为空 + +mBeanDumper.getAttributeError=获取对象名[{1}]的属性[{0}]时出错 + mBeanFactory.contextCreate.addServicedFail=无法创建上下文[{0}],因为另一个组件正在为具有该名称的上下文提供服务 +mBeanFactory.contextDestroyError=上下文[{0}]销毁期间出错 mBeanFactory.contextRemove.addServicedFail=无法移除上下文[{0}],因为另一个组件正在为具有该名称的上下文提供服务 mBeanFactory.managerContext=管理器组件只能添加到上下文中。 +mBeanFactory.noDeployer=找不到主机[{0}]的部署程序 +mBeanFactory.noService=找不到域为[{0}]的服务 +mBeanFactory.notServer=容器不是服务器 + +mBeanUtils.noManagedBean=找不到具有[{0}]的ManagedBean + +namingResourcesMBean.addAlreadyExists.environment=已存在名为[{0}]的指定环境 +namingResourcesMBean.addAlreadyExists.resource=指定的资源名已存在,名称为[{0}] +namingResourcesMBean.addAlreadyExists.resourceLink=指定的资源链接已存在,名称为[{0}] +namingResourcesMBean.createObjectNameError.environment=无法为环境[{0}]创建对象名 +namingResourcesMBean.createObjectNameError.resource=无法为资源[{0}]创建对象名 +namingResourcesMBean.createObjectNameError.resourceLink=无法为资源链接[{0}]创建对象名 +namingResourcesMBean.removeNotFound.environment=名为[{0}]的指定环境不存在 +namingResourcesMBean.removeNotFound.resource=名为[{0}]的指定资源不存在 +namingResourcesMBean.removeNotFound.resourceLink=名为[{0}]的指定资源链接不存在 + +userMBean.createError.group=无法为组[{0}]创建对象名 +userMBean.createError.role=无法为角色[{0}]创建对象名 +userMBean.createError.user=无法为用户[{0}]创建对象名 +userMBean.createMBeanError.group=创建组[{0}]MBean时发生异常 +userMBean.createMBeanError.role=创建角色[{0}]MBean时发生异常 +userMBean.createMBeanError.user=创建用户[{0}]MBean时发生异常 +userMBean.destroyError.group=销毁组[{0}]MBean时发生异常 +userMBean.destroyError.role=销毁角色[{0}]MBean时发生异常 +userMBean.destroyError.user=销毁用户[{0}]MBean时发生异常 +userMBean.invalidGroup=无效的组名[{0}] +userMBean.invalidRole=无效的角色名[{0}] diff --git a/java/org/apache/catalina/mbeans/MBeanDumper.java b/java/org/apache/catalina/mbeans/MBeanDumper.java index 8aff1b133d..39e84dc165 100644 --- a/java/org/apache/catalina/mbeans/MBeanDumper.java +++ b/java/org/apache/catalina/mbeans/MBeanDumper.java @@ -28,6 +28,7 @@ import javax.management.ObjectName; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; import org.apache.tomcat.util.ExceptionUtils; +import org.apache.tomcat.util.res.StringManager; /** * General helper to dump MBean contents to the log. @@ -35,9 +36,11 @@ import org.apache.tomcat.util.ExceptionUtils; public class MBeanDumper { private static final Log log = LogFactory.getLog(MBeanDumper.class); + protected static final StringManager sm = StringManager.getManager(MBeanDumper.class); private static final String CRLF = "\r\n"; + /** * The following code to dump MBeans has been copied from JMXProxyServlet. * @@ -67,11 +70,11 @@ public class MBeanDumper { MBeanAttributeInfo attrs[] = minfo.getAttributes(); Object value = null; - for (int i = 0; i < attrs.length; i++) { - if (!attrs[i].isReadable()) { + for (MBeanAttributeInfo attr : attrs) { + if (!attr.isReadable()) { continue; } - String attName = attrs[i].getName(); + String attName = attr.getName(); if ("modelerType".equals(attName)) { continue; } @@ -85,19 +88,19 @@ public class MBeanDumper { Throwable cause = rme.getCause(); if (cause instanceof UnsupportedOperationException) { if (log.isDebugEnabled()) { - log.debug("Error getting attribute " + oname + " " + attName, rme); + log.debug(sm.getString("mBeanDumper.getAttributeError", attName, oname), rme); } } else if (cause instanceof NullPointerException) { if (log.isDebugEnabled()) { - log.debug("Error getting attribute " + oname + " " + attName, rme); + log.debug(sm.getString("mBeanDumper.getAttributeError", attName, oname), rme); } } else { - log.error("Error getting attribute " + oname + " " + attName, rme); + log.error(sm.getString("mBeanDumper.getAttributeError", attName, oname), rme); } continue; } catch (Throwable t) { ExceptionUtils.handleThrowable(t); - log.error("Error getting attribute " + oname + " " + attName, t); + log.error(sm.getString("mBeanDumper.getAttributeError", attName, oname), t); continue; } if (value == null) { @@ -148,9 +151,9 @@ public class MBeanDumper { buf.append(CRLF); } return buf.toString(); - } + public static String escape(String value) { // The only invalid char is \n // We also need to keep the string short and split it with \nSPACE @@ -164,7 +167,6 @@ public class MBeanDumper { StringBuilder sb = new StringBuilder(); while (idx >= 0) { appendHead(sb, value, prev, idx); - sb.append("\\n\n "); prev = idx + 1; if (idx == value.length() - 1) { @@ -178,6 +180,7 @@ public class MBeanDumper { return sb.toString(); } + private static void appendHead(StringBuilder sb, String value, int start, int end) { if (end < 1) { return; diff --git a/java/org/apache/catalina/mbeans/MBeanFactory.java b/java/org/apache/catalina/mbeans/MBeanFactory.java index 0efa1d5199..ced9123285 100644 --- a/java/org/apache/catalina/mbeans/MBeanFactory.java +++ b/java/org/apache/catalina/mbeans/MBeanFactory.java @@ -27,6 +27,7 @@ import org.apache.catalina.Context; import org.apache.catalina.Engine; import org.apache.catalina.Host; import org.apache.catalina.JmxEnabled; +import org.apache.catalina.Realm; import org.apache.catalina.Server; import org.apache.catalina.Service; import org.apache.catalina.Valve; @@ -175,7 +176,7 @@ public class MBeanFactory { } } if (service == null || !service.getObjectName().getDomain().equals(domain)) { - throw new Exception("Service with the domain is not found"); + throw new Exception(sm.getString("mBeanFactory.noService", domain)); } return service; @@ -227,6 +228,11 @@ public class MBeanFactory { realm.setUserTable(userTable); // Add the new instance to its parent component + return addRealmToParent(parent, realm); + } + + + private String addRealmToParent(String parent, Realm realm) throws Exception { ObjectName pname = new ObjectName(parent); Container container = getParentContainerFromParent(pname); if (container == null) { @@ -235,7 +241,10 @@ public class MBeanFactory { // Add the new instance to its parent component container.setRealm(realm); // Return the corresponding MBean name - ObjectName oname = realm.getObjectName(); + ObjectName oname = null; + if (realm instanceof JmxEnabled) { + oname = ((JmxEnabled) realm).getObjectName(); + } if (oname != null) { return oname.toString(); } else { @@ -273,7 +282,7 @@ public class MBeanFactory { */ private String createConnector(String parent, String address, int port, boolean isAjp, boolean isSSL) throws Exception { - // Set the protocol + // Set the protocol in the constructor String protocol = isAjp ? "AJP/1.3" : "HTTP/1.1"; Connector retobj = new Connector(protocol); if ((address != null) && (address.length() > 0)) { @@ -340,18 +349,7 @@ public class MBeanFactory { realm.setConnectionURL(connectionURL); // Add the new instance to its parent component - ObjectName pname = new ObjectName(parent); - Container container = getParentContainerFromParent(pname); - // Add the new instance to its parent component - container.setRealm(realm); - // Return the corresponding MBean name - ObjectName oname = realm.getObjectName(); - - if (oname != null) { - return (oname.toString()); - } else { - return null; - } + return addRealmToParent(parent, realm); } @@ -370,18 +368,7 @@ public class MBeanFactory { JNDIRealm realm = new JNDIRealm(); // Add the new instance to its parent component - ObjectName pname = new ObjectName(parent); - Container container = getParentContainerFromParent(pname); - // Add the new instance to its parent component - container.setRealm(realm); - // Return the corresponding MBean name - ObjectName oname = realm.getObjectName(); - - if (oname != null) { - return (oname.toString()); - } else { - return null; - } + return addRealmToParent(parent, realm); } @@ -400,17 +387,7 @@ public class MBeanFactory { MemoryRealm realm = new MemoryRealm(); // Add the new instance to its parent component - ObjectName pname = new ObjectName(parent); - Container container = getParentContainerFromParent(pname); - // Add the new instance to its parent component - container.setRealm(realm); - // Return the corresponding MBean name - ObjectName oname = realm.getObjectName(); - if (oname != null) { - return (oname.toString()); - } else { - return null; - } + return addRealmToParent(parent, realm); } @@ -484,7 +461,7 @@ public class MBeanFactory { sm.getString("mBeanFactory.contextCreate.addServicedFail", contextName)); } } else { - log.warn("Deployer not found for " + pname.getKeyProperty("host")); + log.warn(sm.getString("mBeanFactory.noDeployer", pname.getKeyProperty("host"))); Service service = getService(pname); Engine engine = service.getContainer(); Host host = (Host) engine.findChild(pname.getKeyProperty("host")); @@ -553,7 +530,7 @@ public class MBeanFactory { public String createStandardServiceEngine(String domain, String defaultHost, String baseDir) throws Exception { if (!(container instanceof Server)) { - throw new Exception("Container not Server"); + throw new Exception(sm.getString("mBeanFactory.notServer")); } StandardEngine engine = new StandardEngine(); @@ -620,21 +597,7 @@ public class MBeanFactory { realm.setResourceName(resourceName); // Add the new instance to its parent component - ObjectName pname = new ObjectName(parent); - Container container = getParentContainerFromParent(pname); - // Add the new instance to its parent component - container.setRealm(realm); - // Return the corresponding MBean name - ObjectName oname = realm.getObjectName(); - // FIXME getObjectName() returns null - // ObjectName oname = - // MBeanUtils.createObjectName(pname.getDomain(), realm); - if (oname != null) { - return (oname.toString()); - } else { - return null; - } - + return addRealmToParent(parent, realm); } @@ -656,8 +619,7 @@ public class MBeanFactory { Container container = getParentContainerFromParent(parentName); if (container == null) { - // TODO - throw new IllegalArgumentException(); + throw new IllegalArgumentException(sm.getString("mBeanFactory.noParent", parent)); } Valve valve = (Valve) Class.forName(className).getConstructor().newInstance(); @@ -782,7 +744,7 @@ public class MBeanFactory { throw new IllegalStateException(sm.getString("mBeanFactory.removeContext.addServicedFail", pathStr)); } } else { - log.warn("Deployer not found for " + hostName); + log.warn(sm.getString("mBeanFactory.noDeployer", hostName)); Host host = (Host) engine.findChild(hostName); Context context = (Context) host.findChild(pathStr); // Remove this component from its parent component @@ -791,7 +753,7 @@ public class MBeanFactory { try { ((StandardContext) context).destroy(); } catch (Exception e) { - log.warn("Error during context [" + context.getName() + "] destroy ", e); + log.warn(sm.getString("mBeanFactory.contextDestroyError"), e); } } @@ -884,7 +846,7 @@ public class MBeanFactory { public void removeService(String name) throws Exception { if (!(container instanceof Server)) { - throw new Exception(); + throw new Exception(sm.getString("mBeanFactory.notServer")); } // Acquire a reference to the component to be removed diff --git a/java/org/apache/catalina/mbeans/MBeanUtils.java b/java/org/apache/catalina/mbeans/MBeanUtils.java index 4e989e4c39..7936d601cd 100644 --- a/java/org/apache/catalina/mbeans/MBeanUtils.java +++ b/java/org/apache/catalina/mbeans/MBeanUtils.java @@ -38,6 +38,7 @@ import org.apache.tomcat.util.descriptor.web.ContextResource; import org.apache.tomcat.util.descriptor.web.ContextResourceLink; import org.apache.tomcat.util.modeler.ManagedBean; import org.apache.tomcat.util.modeler.Registry; +import org.apache.tomcat.util.res.StringManager; /** @@ -50,6 +51,8 @@ public class MBeanUtils { // ------------------------------------------------------- Static Variables + protected static final StringManager sm = StringManager.getManager(MBeanUtils.class); + /** * The set of exceptions to the normal rules used by <code>createManagedBean()</code>. The first element of each * pair is a class name, and the second element is the managed bean name. @@ -111,7 +114,7 @@ public class MBeanUtils { String mname = createManagedName(environment); ManagedBean managed = registry.findManagedBean(mname); if (managed == null) { - Exception e = new Exception("ManagedBean is not found with " + mname); + Exception e = new Exception(sm.getString("mBeanUtils.noManagedBean", mname)); throw new MBeanException(e); } String domain = managed.getDomain(); @@ -143,7 +146,7 @@ public class MBeanUtils { String mname = createManagedName(resource); ManagedBean managed = registry.findManagedBean(mname); if (managed == null) { - Exception e = new Exception("ManagedBean is not found with " + mname); + Exception e = new Exception(sm.getString("mBeanUtils.noManagedBean", mname)); throw new MBeanException(e); } String domain = managed.getDomain(); @@ -175,7 +178,7 @@ public class MBeanUtils { String mname = createManagedName(resourceLink); ManagedBean managed = registry.findManagedBean(mname); if (managed == null) { - Exception e = new Exception("ManagedBean is not found with " + mname); + Exception e = new Exception(sm.getString("mBeanUtils.noManagedBean", mname)); throw new MBeanException(e); } String domain = managed.getDomain(); @@ -207,7 +210,7 @@ public class MBeanUtils { String mname = createManagedName(group); ManagedBean managed = registry.findManagedBean(mname); if (managed == null) { - Exception e = new Exception("ManagedBean is not found with " + mname); + Exception e = new Exception(sm.getString("mBeanUtils.noManagedBean", mname)); throw new MBeanException(e); } String domain = managed.getDomain(); @@ -239,7 +242,7 @@ public class MBeanUtils { String mname = createManagedName(role); ManagedBean managed = registry.findManagedBean(mname); if (managed == null) { - Exception e = new Exception("ManagedBean is not found with " + mname); + Exception e = new Exception(sm.getString("mBeanUtils.noManagedBean", mname)); throw new MBeanException(e); } String domain = managed.getDomain(); @@ -271,7 +274,7 @@ public class MBeanUtils { String mname = createManagedName(user); ManagedBean managed = registry.findManagedBean(mname); if (managed == null) { - Exception e = new Exception("ManagedBean is not found with " + mname); + Exception e = new Exception(sm.getString("mBeanUtils.noManagedBean", mname)); throw new MBeanException(e); } String domain = managed.getDomain(); @@ -303,7 +306,7 @@ public class MBeanUtils { String mname = createManagedName(userDatabase); ManagedBean managed = registry.findManagedBean(mname); if (managed == null) { - Exception e = new Exception("ManagedBean is not found with " + mname); + Exception e = new Exception(sm.getString("mBeanUtils.noManagedBean", mname)); throw new MBeanException(e); } String domain = managed.getDomain(); diff --git a/java/org/apache/catalina/mbeans/MemoryUserDatabaseMBean.java b/java/org/apache/catalina/mbeans/MemoryUserDatabaseMBean.java index 945dbb328b..cd8cbfa556 100644 --- a/java/org/apache/catalina/mbeans/MemoryUserDatabaseMBean.java +++ b/java/org/apache/catalina/mbeans/MemoryUserDatabaseMBean.java @@ -18,8 +18,8 @@ package org.apache.catalina.mbeans; import java.util.ArrayList; import java.util.Iterator; +import java.util.List; -import javax.management.MalformedObjectNameException; import javax.management.ObjectName; import org.apache.catalina.Group; @@ -29,6 +29,7 @@ import org.apache.catalina.UserDatabase; import org.apache.tomcat.util.modeler.BaseModelMBean; import org.apache.tomcat.util.modeler.ManagedBean; import org.apache.tomcat.util.modeler.Registry; +import org.apache.tomcat.util.res.StringManager; /** * <p> @@ -40,6 +41,8 @@ import org.apache.tomcat.util.modeler.Registry; */ public class MemoryUserDatabaseMBean extends BaseModelMBean { + private static final StringManager sm = StringManager.getManager(MemoryUserDatabaseMBean.class); + // ----------------------------------------------------- Instance Variables /** @@ -79,7 +82,7 @@ public class MemoryUserDatabaseMBean extends BaseModelMBean { */ public String[] getGroups() { UserDatabase database = (UserDatabase) this.resource; - ArrayList<String> results = new ArrayList<>(); + List<String> results = new ArrayList<>(); Iterator<Group> groups = database.getGroups(); while (groups.hasNext()) { Group group = groups.next(); @@ -94,7 +97,7 @@ public class MemoryUserDatabaseMBean extends BaseModelMBean { */ public String[] getRoles() { UserDatabase database = (UserDatabase) this.resource; - ArrayList<String> results = new ArrayList<>(); + List<String> results = new ArrayList<>(); Iterator<Role> roles = database.getRoles(); while (roles.hasNext()) { Role role = roles.next(); @@ -109,7 +112,7 @@ public class MemoryUserDatabaseMBean extends BaseModelMBean { */ public String[] getUsers() { UserDatabase database = (UserDatabase) this.resource; - ArrayList<String> results = new ArrayList<>(); + List<String> results = new ArrayList<>(); Iterator<User> users = database.getUsers(); while (users.hasNext()) { User user = users.next(); @@ -135,7 +138,7 @@ public class MemoryUserDatabaseMBean extends BaseModelMBean { try { MBeanUtils.createMBean(group); } catch (Exception e) { - throw new IllegalArgumentException("Exception creating group [" + groupname + "] MBean", e); + throw new IllegalArgumentException(sm.getString("userMBean.createMBeanError.group", groupname), e); } return findGroup(groupname); } @@ -155,7 +158,7 @@ public class MemoryUserDatabaseMBean extends BaseModelMBean { try { MBeanUtils.createMBean(role); } catch (Exception e) { - throw new IllegalArgumentException("Exception creating role [" + rolename + "] MBean", e); + throw new IllegalArgumentException(sm.getString("userMBean.createMBeanError.role", rolename), e); } return findRole(rolename); } @@ -176,7 +179,7 @@ public class MemoryUserDatabaseMBean extends BaseModelMBean { try { MBeanUtils.createMBean(user); } catch (Exception e) { - throw new IllegalArgumentException("Exception creating user [" + username + "] MBean", e); + throw new IllegalArgumentException(sm.getString("userMBean.createMBeanError.user", username), e); } return findUser(username); } @@ -198,8 +201,8 @@ public class MemoryUserDatabaseMBean extends BaseModelMBean { try { ObjectName oname = MBeanUtils.createObjectName(managedGroup.getDomain(), group); return oname.toString(); - } catch (MalformedObjectNameException e) { - throw new IllegalArgumentException("Cannot create object name for group [" + groupname + "]", e); + } catch (Exception e) { + throw new IllegalArgumentException(sm.getString("userMBean.createError.group", groupname), e); } } @@ -220,8 +223,8 @@ public class MemoryUserDatabaseMBean extends BaseModelMBean { try { ObjectName oname = MBeanUtils.createObjectName(managedRole.getDomain(), role); return oname.toString(); - } catch (MalformedObjectNameException e) { - throw new IllegalArgumentException("Cannot create object name for role [" + rolename + "]", e); + } catch (Exception e) { + throw new IllegalArgumentException(sm.getString("userMBean.createError.role", rolename), e); } } @@ -243,8 +246,8 @@ public class MemoryUserDatabaseMBean extends BaseModelMBean { try { ObjectName oname = MBeanUtils.createObjectName(managedUser.getDomain(), user); return oname.toString(); - } catch (MalformedObjectNameException e) { - throw new IllegalArgumentException("Cannot create object name for user [" + username + "]", e); + } catch (Exception e) { + throw new IllegalArgumentException(sm.getString("userMBean.createError.user", username), e); } } @@ -264,7 +267,7 @@ public class MemoryUserDatabaseMBean extends BaseModelMBean { MBeanUtils.destroyMBean(group); database.removeGroup(group); } catch (Exception e) { - throw new IllegalArgumentException("Exception destroying group [" + groupname + "] MBean", e); + throw new IllegalArgumentException(sm.getString("userMBean.destroyError.group", groupname), e); } } @@ -284,7 +287,7 @@ public class MemoryUserDatabaseMBean extends BaseModelMBean { MBeanUtils.destroyMBean(role); database.removeRole(role); } catch (Exception e) { - throw new IllegalArgumentException("Exception destroying role [" + rolename + "] MBean", e); + throw new IllegalArgumentException(sm.getString("userMBean.destroyError.role", rolename), e); } } @@ -304,7 +307,7 @@ public class MemoryUserDatabaseMBean extends BaseModelMBean { MBeanUtils.destroyMBean(user); database.removeUser(user); } catch (Exception e) { - throw new IllegalArgumentException("Exception destroying user [" + username + "] MBean", e); + throw new IllegalArgumentException(sm.getString("userMBean.destroyError.user", username), e); } } } diff --git a/java/org/apache/catalina/mbeans/NamingResourcesMBean.java b/java/org/apache/catalina/mbeans/NamingResourcesMBean.java index b1bcbd5a02..0a5c231fb9 100644 --- a/java/org/apache/catalina/mbeans/NamingResourcesMBean.java +++ b/java/org/apache/catalina/mbeans/NamingResourcesMBean.java @@ -29,6 +29,7 @@ import org.apache.tomcat.util.descriptor.web.ContextResourceLink; import org.apache.tomcat.util.modeler.BaseModelMBean; import org.apache.tomcat.util.modeler.ManagedBean; import org.apache.tomcat.util.modeler.Registry; +import org.apache.tomcat.util.res.StringManager; /** * <p> @@ -40,6 +41,8 @@ import org.apache.tomcat.util.modeler.Registry; */ public class NamingResourcesMBean extends BaseModelMBean { + private static final StringManager sm = StringManager.getManager(NamingResourcesMBean.class); + // ----------------------------------------------------- Instance Variables /** @@ -69,7 +72,8 @@ public class NamingResourcesMBean extends BaseModelMBean { ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), env); results.add(oname.toString()); } catch (MalformedObjectNameException e) { - throw new IllegalArgumentException("Cannot create object name for environment " + env, e); + throw new IllegalArgumentException( + sm.getString("namingResourcesMBean.createObjectNameError.environment", env), e); } } return results.toArray(new String[0]); @@ -89,7 +93,8 @@ public class NamingResourcesMBean extends BaseModelMBean { ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), contextResource); results.add(oname.toString()); } catch (MalformedObjectNameException e) { - throw new IllegalArgumentException("Cannot create object name for resource " + contextResource, e); + throw new IllegalArgumentException( + sm.getString("namingResourcesMBean.createObjectNameError.resource", contextResource), e); } } return results.toArray(new String[0]); @@ -109,7 +114,8 @@ public class NamingResourcesMBean extends BaseModelMBean { ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), resourceLink); results.add(oname.toString()); } catch (MalformedObjectNameException e) { - throw new IllegalArgumentException("Cannot create object name for resource " + resourceLink, e); + throw new IllegalArgumentException( + sm.getString("namingResourcesMBean.createObjectNameError.resourceLink", resourceLink), e); } } return results.toArray(new String[0]); @@ -137,7 +143,8 @@ public class NamingResourcesMBean extends BaseModelMBean { } ContextEnvironment env = nresources.findEnvironment(envName); if (env != null) { - throw new IllegalArgumentException("Invalid environment name - already exists '" + envName + "'"); + throw new IllegalArgumentException( + sm.getString("namingResourcesMBean.addAlreadyExists.environment", envName)); } env = new ContextEnvironment(); env.setName(envName); @@ -170,7 +177,8 @@ public class NamingResourcesMBean extends BaseModelMBean { } ContextResource resource = nresources.findResource(resourceName); if (resource != null) { - throw new IllegalArgumentException("Invalid resource name - already exists'" + resourceName + "'"); + throw new IllegalArgumentException( + sm.getString("namingResourcesMBean.addAlreadyExists.resource", resourceName)); } resource = new ContextResource(); resource.setName(resourceName); @@ -202,7 +210,8 @@ public class NamingResourcesMBean extends BaseModelMBean { } ContextResourceLink resourceLink = nresources.findResourceLink(resourceLinkName); if (resourceLink != null) { - throw new IllegalArgumentException("Invalid resource link name - already exists'" + resourceLinkName + "'"); + throw new IllegalArgumentException( + sm.getString("namingResourcesMBean.addAlreadyExists.resourceLink", resourceLinkName)); } resourceLink = new ContextResourceLink(); resourceLink.setName(resourceLinkName); @@ -228,7 +237,8 @@ public class NamingResourcesMBean extends BaseModelMBean { } ContextEnvironment env = nresources.findEnvironment(envName); if (env == null) { - throw new IllegalArgumentException("Invalid environment name '" + envName + "'"); + throw new IllegalArgumentException( + sm.getString("namingResourcesMBean.removeNotFound.environment", envName)); } nresources.removeEnvironment(envName); } @@ -247,7 +257,8 @@ public class NamingResourcesMBean extends BaseModelMBean { } ContextResource resource = nresources.findResource(resourceName); if (resource == null) { - throw new IllegalArgumentException("Invalid resource name '" + resourceName + "'"); + throw new IllegalArgumentException( + sm.getString("namingResourcesMBean.removeNotFound.resource", resourceName)); } nresources.removeResource(resourceName); } @@ -266,7 +277,8 @@ public class NamingResourcesMBean extends BaseModelMBean { } ContextResourceLink resourceLink = nresources.findResourceLink(resourceLinkName); if (resourceLink == null) { - throw new IllegalArgumentException("Invalid resource Link name '" + resourceLinkName + "'"); + throw new IllegalArgumentException( + sm.getString("namingResourcesMBean.removeNotFound.resourceLink", resourceLinkName)); } nresources.removeResourceLink(resourceLinkName); } diff --git a/java/org/apache/catalina/mbeans/UserMBean.java b/java/org/apache/catalina/mbeans/UserMBean.java index 69e48bee12..5d9afa9494 100644 --- a/java/org/apache/catalina/mbeans/UserMBean.java +++ b/java/org/apache/catalina/mbeans/UserMBean.java @@ -18,6 +18,7 @@ package org.apache.catalina.mbeans; import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; @@ -28,6 +29,7 @@ import org.apache.catalina.User; import org.apache.tomcat.util.modeler.BaseModelMBean; import org.apache.tomcat.util.modeler.ManagedBean; import org.apache.tomcat.util.modeler.Registry; +import org.apache.tomcat.util.res.StringManager; /** * <p> @@ -38,6 +40,7 @@ import org.apache.tomcat.util.modeler.Registry; */ public class UserMBean extends BaseModelMBean { + private static final StringManager sm = StringManager.getManager(UserMBean.class); // ----------------------------------------------------- Instance Variables @@ -62,7 +65,7 @@ public class UserMBean extends BaseModelMBean { public String[] getGroups() { User user = (User) this.resource; - ArrayList<String> results = new ArrayList<>(); + List<String> results = new ArrayList<>(); Iterator<Group> groups = user.getGroups(); while (groups.hasNext()) { Group group = null; @@ -71,7 +74,7 @@ public class UserMBean extends BaseModelMBean { ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), group); results.add(oname.toString()); } catch (MalformedObjectNameException e) { - throw new IllegalArgumentException("Cannot create object name for group " + group, e); + throw new IllegalArgumentException(sm.getString("userMBean.createError.group", group), e); } } return results.toArray(new String[0]); @@ -84,7 +87,7 @@ public class UserMBean extends BaseModelMBean { public String[] getRoles() { User user = (User) this.resource; - ArrayList<String> results = new ArrayList<>(); + List<String> results = new ArrayList<>(); Iterator<Role> roles = user.getRoles(); while (roles.hasNext()) { Role role = null; @@ -93,7 +96,7 @@ public class UserMBean extends BaseModelMBean { ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), role); results.add(oname.toString()); } catch (MalformedObjectNameException e) { - throw new IllegalArgumentException("Cannot create object name for role " + role, e); + throw new IllegalArgumentException(sm.getString("userMBean.createError.role", role), e); } } return results.toArray(new String[0]); @@ -115,7 +118,7 @@ public class UserMBean extends BaseModelMBean { } Group group = user.getUserDatabase().findGroup(groupname); if (group == null) { - throw new IllegalArgumentException("Invalid group name '" + groupname + "'"); + throw new IllegalArgumentException(sm.getString("userMBean.invalidGroup", groupname)); } user.addGroup(group); } @@ -134,7 +137,7 @@ public class UserMBean extends BaseModelMBean { } Role role = user.getUserDatabase().findRole(rolename); if (role == null) { - throw new IllegalArgumentException("Invalid role name '" + rolename + "'"); + throw new IllegalArgumentException(sm.getString("userMBean.invalidRole", rolename)); } user.addRole(role); } @@ -153,7 +156,7 @@ public class UserMBean extends BaseModelMBean { } Group group = user.getUserDatabase().findGroup(groupname); if (group == null) { - throw new IllegalArgumentException("Invalid group name '" + groupname + "'"); + throw new IllegalArgumentException(sm.getString("userMBean.invalidGroup", groupname)); } user.removeGroup(group); } @@ -172,7 +175,7 @@ public class UserMBean extends BaseModelMBean { } Role role = user.getUserDatabase().findRole(rolename); if (role == null) { - throw new IllegalArgumentException("Invalid role name '" + rolename + "'"); + throw new IllegalArgumentException(sm.getString("userMBean.invalidRole", rolename)); } user.removeRole(role); } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org