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
The following commit(s) were added to refs/heads/8.5.x by this push: new 4809c7f Align with master 4809c7f is described below commit 4809c7f70fe3856dd590ec193cdb81ea973f579b Author: Mark Thomas <ma...@apache.org> AuthorDate: Wed Jul 10 09:33:23 2019 +0100 Align with master Code clean-up. i18n improvements, fix SpotBugs warnings, spacing --- java/org/apache/naming/factory/Constants.java | 1 - .../naming/factory/DataSourceLinkFactory.java | 11 ++++----- java/org/apache/naming/factory/FactoryBase.java | 12 ++++++---- .../apache/naming/factory/LocalStrings.properties | 9 +++++++ .../naming/factory/LocalStrings_es.properties | 20 ++++++++++++++++ .../naming/factory/LocalStrings_fr.properties | 28 ++++++++++++++++++++++ .../naming/factory/LocalStrings_ja.properties | 28 ++++++++++++++++++++++ java/org/apache/naming/factory/LookupFactory.java | 2 +- .../org/apache/naming/factory/ResourceFactory.java | 9 +++---- .../apache/naming/factory/ResourceLinkFactory.java | 4 ++-- 10 files changed, 105 insertions(+), 19 deletions(-) diff --git a/java/org/apache/naming/factory/Constants.java b/java/org/apache/naming/factory/Constants.java index 0cc4cf47..b8690af 100644 --- a/java/org/apache/naming/factory/Constants.java +++ b/java/org/apache/naming/factory/Constants.java @@ -45,5 +45,4 @@ public final class Constants { public static final String DEFAULT_LOOKUP_JNDI_FACTORY = Package + ".LookupFactory"; public static final String FACTORY = "factory"; - } diff --git a/java/org/apache/naming/factory/DataSourceLinkFactory.java b/java/org/apache/naming/factory/DataSourceLinkFactory.java index 09a83ef..bd029fe 100644 --- a/java/org/apache/naming/factory/DataSourceLinkFactory.java +++ b/java/org/apache/naming/factory/DataSourceLinkFactory.java @@ -18,7 +18,6 @@ package org.apache.naming.factory; -import java.lang.reflect.Constructor; import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -70,10 +69,10 @@ public class DataSourceLinkFactory extends ResourceLinkFactory { protected Object wrapDataSource(Object datasource, String username, String password) throws NamingException { try { - Class<?> proxyClass = Proxy.getProxyClass(datasource.getClass().getClassLoader(), datasource.getClass().getInterfaces()); - Constructor<?> proxyConstructor = proxyClass.getConstructor(new Class[] { InvocationHandler.class }); - DataSourceHandler handler = new DataSourceHandler((DataSource)datasource, username, password); - return proxyConstructor.newInstance(handler); + DataSourceHandler handler = + new DataSourceHandler((DataSource)datasource, username, password); + return Proxy.newProxyInstance(datasource.getClass().getClassLoader(), + datasource.getClass().getInterfaces(), handler); }catch (Exception x) { if (x instanceof InvocationTargetException) { Throwable cause = x.getCause(); @@ -138,7 +137,7 @@ public class DataSourceLinkFactory extends ResourceLinkFactory { if (iface == DataSource.class) { return ds; } else { - throw new SQLException("Not a wrapper of "+iface.getName()); + throw new SQLException(sm.getString("dataSourceLinkFactory.badWrapper", iface.getName())); } } diff --git a/java/org/apache/naming/factory/FactoryBase.java b/java/org/apache/naming/factory/FactoryBase.java index ee5510e..a49c4b1 100644 --- a/java/org/apache/naming/factory/FactoryBase.java +++ b/java/org/apache/naming/factory/FactoryBase.java @@ -25,12 +25,16 @@ import javax.naming.RefAddr; import javax.naming.Reference; import javax.naming.spi.ObjectFactory; +import org.apache.naming.StringManager; + /** * Abstract base class that provides common functionality required by * sub-classes. This class exists primarily to reduce code duplication. */ public abstract class FactoryBase implements ObjectFactory { + private static final StringManager sm = StringManager.getManager(FactoryBase.class); + /** * Creates a new object instance. * @@ -63,8 +67,7 @@ public abstract class FactoryBase implements ObjectFactory { factoryClass = Class.forName(factoryClassName); } } catch(ClassNotFoundException e) { - NamingException ex = new NamingException( - "Could not load resource factory class"); + NamingException ex = new NamingException(sm.getString("factoryBase.factoryClassError")); ex.initCause(e); throw ex; } @@ -80,8 +83,7 @@ public abstract class FactoryBase implements ObjectFactory { if (t instanceof VirtualMachineError) { throw (VirtualMachineError) t; } - NamingException ex = new NamingException( - "Could not create resource factory instance"); + NamingException ex = new NamingException(sm.getString("factoryBase.factoryCreationError")); ex.initCause(t); throw ex; } @@ -93,7 +95,7 @@ public abstract class FactoryBase implements ObjectFactory { if (factory != null) { return factory.getObjectInstance(obj, name, nameCtx, environment); } else { - throw new NamingException("Cannot create resource instance"); + throw new NamingException(sm.getString("factoryBase.instanceCreationError")); } } diff --git a/java/org/apache/naming/factory/LocalStrings.properties b/java/org/apache/naming/factory/LocalStrings.properties index 628a2ac..692cef2 100644 --- a/java/org/apache/naming/factory/LocalStrings.properties +++ b/java/org/apache/naming/factory/LocalStrings.properties @@ -13,11 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. +dataSourceLinkFactory.badWrapper=Not a wrapper for type [{0}] + +factoryBase.factoryClassError=Could not load resource factory class +factoryBase.factoryCreationError=Could not create resource factory instance +factoryBase.instanceCreationError=Could not create resource instance + lookupFactory.circularReference=Found a circular reference involving [{0}] lookupFactory.createFailed=Could not create instance of JNDI lookup factory class lookupFactory.loadFailed=Could not load JNDI lookup factory class lookupFactory.typeMismatch=The JNDI reference [{0}] was expected to be of type [{1}] but the lookup [{2}] return an object of type [{3}] +resourceFactory.factoryCreationError=Could not create resource factory instance + +resourceLinkFactory.invalidGlobalContext=Caller provided invalid global context resourceLinkFactory.nullType=The local resource link [{0}] that refers to global resource [{1}] does not specify the required attribute type resourceLinkFactory.unknownType=The local resource link [{0}] that refers to global resource [{1}] specified the unknown type [{2}] resourceLinkFactory.wrongType=The local resource link [{0}] that refers to global resource [{1}] was expected to return an instance of [{2}] but returned an instance of [{3}] diff --git a/java/org/apache/naming/factory/LocalStrings_es.properties b/java/org/apache/naming/factory/LocalStrings_es.properties new file mode 100644 index 0000000..926ef6e --- /dev/null +++ b/java/org/apache/naming/factory/LocalStrings_es.properties @@ -0,0 +1,20 @@ +# 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. + +lookupFactory.createFailed=No se pudo crear una instancia de la clase de fábrica JNDI lookup\n +lookupFactory.typeMismatch=La referencia JNDI [{0}] se esperaba que fuera de tipo [{1}] pero la búsqueda [{2}] devolvió un objeto tipo [{3}] + +resourceLinkFactory.nullType=El enlace del recurso local [{0}] que se refiere al recurso global [{1}] no especifica el atributo obligatorio "type" +resourceLinkFactory.unknownType=El enlace del recurso local [{0}] que apunta al recurso global especificado [{1}] de tipo desconocido [{2}]\n diff --git a/java/org/apache/naming/factory/LocalStrings_fr.properties b/java/org/apache/naming/factory/LocalStrings_fr.properties new file mode 100644 index 0000000..18cc08f --- /dev/null +++ b/java/org/apache/naming/factory/LocalStrings_fr.properties @@ -0,0 +1,28 @@ +# 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. + +dataSourceLinkFactory.badWrapper=Pas un enrobeur pour le type [{0}] + +lookupFactory.circularReference=Trouvé une référence circulaire avec [{0}] +lookupFactory.createFailed=Echec de création de l'instance de la classe de fabrique de recherche JNDI +lookupFactory.loadFailed=Echec de chargement de la classe de fabrique de recherche JNDI +lookupFactory.typeMismatch=La référence JNDI [{0}] devrait être de type [{1}] mais la recherche [{2}] retourne un objet de type [{3}] + +resourceFactory.factoryCreationError=Impossible de créer une instance de la fabrique de ressources + +resourceLinkFactory.invalidGlobalContext=L'appelant a fourni un contexte global invalide +resourceLinkFactory.nullType=Le lien local de resource [{0}] qui se réfère à la resource globale [{1}] ne spécifie pas le type d''attribut requis +resourceLinkFactory.unknownType=Le lien local de resource [{0}] qui se réfère à la resource globale [{1}] a spécifié le type inconnu [{2}] +resourceLinkFactory.wrongType=Le lien de ressource local [{0}] qui se réfère à la ressource globale [{1}] devait renvoyer une instance de [{2}] mais à renvoyé une instance de [{3}] diff --git a/java/org/apache/naming/factory/LocalStrings_ja.properties b/java/org/apache/naming/factory/LocalStrings_ja.properties new file mode 100644 index 0000000..0716753 --- /dev/null +++ b/java/org/apache/naming/factory/LocalStrings_ja.properties @@ -0,0 +1,28 @@ +# 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. + +dataSourceLinkFactory.badWrapper=クラス[{0}]のラッパーではありません。 + +lookupFactory.circularReference=[{0}]を含む循環参照が見つかりました。 +lookupFactory.createFailed=JNDI lookup ファクトリークラスのインスタンスを作成できませんでした。 +lookupFactory.loadFailed=JNDIルックアップファクトリクラスをロードできませんでした。 +lookupFactory.typeMismatch=クラス [{1}] を期待する JNDI 参照 [{0}]に、lookup [{2}] はクラス [{3}] のオブジェクトを返却しました。 + +resourceFactory.factoryCreationError=リソースファクトリーのインスタンスを作成できません。 + +resourceLinkFactory.invalidGlobalContext=引数に不正な共通コンテキストが指定されました。 +resourceLinkFactory.nullType=グローバルリソース [{1}] を参照するローカルリソースリンク [{0}] に必要な属性がありません。 +resourceLinkFactory.unknownType=グローバルリソース [{1}] を参照するローカルリソースリンク [{0}] に未知のクラス [{2}] が指定されました。 +resourceLinkFactory.wrongType=グローバルリソース[{1}]を参照するローカルリソースリンク[{0}]は[{2}]のインスタンスを返すと予想されましたが、[{3}]のインスタンスを返しました。 diff --git a/java/org/apache/naming/factory/LookupFactory.java b/java/org/apache/naming/factory/LookupFactory.java index ba47699..6e7455c 100644 --- a/java/org/apache/naming/factory/LookupFactory.java +++ b/java/org/apache/naming/factory/LookupFactory.java @@ -106,7 +106,7 @@ public class LookupFactory implements ObjectFactory { } if (factoryClass != null) { try { - factory = (ObjectFactory) factoryClass.newInstance(); + factory = (ObjectFactory) factoryClass.getConstructor().newInstance(); } catch (Throwable t) { if (t instanceof NamingException) throw (NamingException) t; diff --git a/java/org/apache/naming/factory/ResourceFactory.java b/java/org/apache/naming/factory/ResourceFactory.java index 5bb85f9..a458315 100644 --- a/java/org/apache/naming/factory/ResourceFactory.java +++ b/java/org/apache/naming/factory/ResourceFactory.java @@ -21,6 +21,7 @@ import javax.naming.Reference; import javax.naming.spi.ObjectFactory; import org.apache.naming.ResourceRef; +import org.apache.naming.StringManager; /** * Object factory for Resources. @@ -29,6 +30,8 @@ import org.apache.naming.ResourceRef; */ public class ResourceFactory extends FactoryBase { + private static final StringManager sm = StringManager.getManager(ResourceFactory.class); + @Override protected boolean isReferenceTypeSupported(Object obj) { return obj instanceof ResourceRef; @@ -47,8 +50,7 @@ public class ResourceFactory extends FactoryBase { factory = (ObjectFactory) Class.forName( javaxSqlDataSourceFactoryClassName).getConstructor().newInstance(); } catch (Exception e) { - NamingException ex = new NamingException( - "Could not create resource factory instance"); + NamingException ex = new NamingException(sm.getString("resourceFactory.factoryCreationError")); ex.initCause(e); throw ex; } @@ -69,8 +71,7 @@ public class ResourceFactory extends FactoryBase { if (t instanceof VirtualMachineError) { throw (VirtualMachineError) t; } - NamingException ex = new NamingException( - "Could not create resource factory instance"); + NamingException ex = new NamingException(sm.getString("resourceFactory.factoryCreationError")); ex.initCause(t); throw ex; } diff --git a/java/org/apache/naming/factory/ResourceLinkFactory.java b/java/org/apache/naming/factory/ResourceLinkFactory.java index b09a36a..765a02c 100644 --- a/java/org/apache/naming/factory/ResourceLinkFactory.java +++ b/java/org/apache/naming/factory/ResourceLinkFactory.java @@ -40,7 +40,7 @@ public class ResourceLinkFactory implements ObjectFactory { // ------------------------------------------------------- Static Variables - private static final StringManager sm = StringManager.getManager(ResourceLinkFactory.class); + protected static final StringManager sm = StringManager.getManager(ResourceLinkFactory.class); /** * Global naming context. @@ -102,7 +102,7 @@ public class ResourceLinkFactory implements ObjectFactory { private static void validateGlobalContext(Context globalContext) { if (ResourceLinkFactory.globalContext != null && ResourceLinkFactory.globalContext != globalContext) { - throw new SecurityException("Caller provided invalid global context"); + throw new SecurityException(sm.getString("resourceLinkFactory.invalidGlobalContext")); } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org