Modified: tomcat/tc7.0.x/trunk/java/org/apache/naming/ServiceRef.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/naming/ServiceRef.java?rev=1831267&r1=1831266&r2=1831267&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/naming/ServiceRef.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/naming/ServiceRef.java Wed May 9 16:14:21 2018 @@ -5,25 +5,19 @@ * 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 org.apache.naming; -import java.util.Enumeration; import java.util.Vector; -import javax.naming.Context; -import javax.naming.RefAddr; -import javax.naming.Reference; import javax.naming.StringRefAddr; /** @@ -31,18 +25,16 @@ import javax.naming.StringRefAddr; * * @author Fabien Carrion */ - -public class ServiceRef extends Reference { +public class ServiceRef extends AbstractRef { private static final long serialVersionUID = 1L; - // -------------------------------------------------------------- Constants /** * Default factory for this reference. */ - public static final String DEFAULT_FACTORY = - org.apache.naming.factory.Constants.DEFAULT_SERVICE_FACTORY; + public static final String DEFAULT_FACTORY = + org.apache.naming.factory.Constants.DEFAULT_SERVICE_FACTORY; /** @@ -61,7 +53,7 @@ public class ServiceRef extends Referenc /** * Wsdl Location address type. */ - public static final String WSDL = "wsdl"; + public static final String WSDL = "wsdl"; /** @@ -83,21 +75,21 @@ public class ServiceRef extends Referenc /** - * The vector to save the handler Reference objects, because they can't be saved in the addrs vector. + * The vector to save the handler Reference objects, because they can't be + * saved in the addrs vector. */ - private Vector<HandlerRef> handlers = new Vector<HandlerRef>(); + private final Vector<HandlerRef> handlers = new Vector<HandlerRef>(); - // ----------------------------------------------------------- Constructors - - public ServiceRef(String refname, String serviceInterface, String[] serviceQname, + public ServiceRef(String refname, String serviceInterface, String[] serviceQname, String wsdl, String jaxrpcmapping) { this(refname, serviceInterface, serviceQname, wsdl, jaxrpcmapping, null, null); } + public ServiceRef(@SuppressWarnings("unused") String refname, - String serviceInterface, String[] serviceQname, + String serviceInterface, String[] serviceQname, String wsdl, String jaxrpcmapping, String factory, String factoryLocation) { super(serviceInterface, factory, factoryLocation); @@ -125,14 +117,9 @@ public class ServiceRef extends Referenc } - // ----------------------------------------------------- Instance Variables - - - // ------------------------------------------------------ Reference Methods - - /** * Add and Get Handlers classes. + * @return the handler */ public HandlerRef getHandler() { return handlers.remove(0); @@ -149,58 +136,8 @@ public class ServiceRef extends Referenc } - /** - * Retrieves the class name of the factory of the object to which this - * reference refers. - */ - @Override - public String getFactoryClassName() { - String factory = super.getFactoryClassName(); - if (factory != null) { - return factory; - } else { - factory = System.getProperty(Context.OBJECT_FACTORIES); - if (factory != null) { - return null; - } else { - return DEFAULT_FACTORY; - } - } - } - - - // --------------------------------------------------------- Public Methods - - - /** - * Return a String rendering of this object. - */ @Override - public String toString() { - - StringBuilder sb = new StringBuilder("ServiceRef["); - sb.append("className="); - sb.append(getClassName()); - sb.append(",factoryClassLocation="); - sb.append(getFactoryClassLocation()); - sb.append(",factoryClassName="); - sb.append(getFactoryClassName()); - Enumeration<RefAddr> refAddrs = getAll(); - while (refAddrs.hasMoreElements()) { - RefAddr refAddr = refAddrs.nextElement(); - sb.append(",{type="); - sb.append(refAddr.getType()); - sb.append(",content="); - sb.append(refAddr.getContent()); - sb.append("}"); - } - sb.append("]"); - return (sb.toString()); - + protected String getDefaultFactoryClassName() { + return DEFAULT_FACTORY; } - - - // ------------------------------------------------------------- Properties - - }
Modified: tomcat/tc7.0.x/trunk/java/org/apache/naming/TransactionRef.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/naming/TransactionRef.java?rev=1831267&r1=1831266&r2=1831267&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/naming/TransactionRef.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/naming/TransactionRef.java Wed May 9 16:14:21 2018 @@ -5,41 +5,32 @@ * 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 org.apache.naming; -import javax.naming.Context; -import javax.naming.Reference; - /** * Represents a reference address to a transaction. * * @author Remy Maucherat */ -public class TransactionRef extends Reference { +public class TransactionRef extends AbstractRef { private static final long serialVersionUID = 1L; - // -------------------------------------------------------------- Constants /** * Default factory for this reference. */ - public static final String DEFAULT_FACTORY = - org.apache.naming.factory.Constants.DEFAULT_TRANSACTION_FACTORY; - - - // ----------------------------------------------------------- Constructors + public static final String DEFAULT_FACTORY = + org.apache.naming.factory.Constants.DEFAULT_TRANSACTION_FACTORY; /** @@ -61,33 +52,8 @@ public class TransactionRef extends Refe } - // ----------------------------------------------------- Instance Variables - - - // ------------------------------------------------------ Reference Methods - - - /** - * Retrieves the class name of the factory of the object to which this - * reference refers. - */ @Override - public String getFactoryClassName() { - String factory = super.getFactoryClassName(); - if (factory != null) { - return factory; - } else { - factory = System.getProperty(Context.OBJECT_FACTORIES); - if (factory != null) { - return null; - } else { - return DEFAULT_FACTORY; - } - } + protected String getDefaultFactoryClassName() { + return DEFAULT_FACTORY; } - - - // ------------------------------------------------------------- Properties - - } Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1831267&r1=1831266&r2=1831267&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Wed May 9 16:14:21 2018 @@ -106,6 +106,10 @@ Annotations 1.0 is available. Document the requirement to use the Java endorsed mechanism to use Common Annotations 1.1. (markt) </fix> + <scode> + Refactor the <code>org.apache.naming</code> package to reduce duplicate + code. Duplicate code identified by the Simian tool. (markt) + </scode> </changelog> </subsection> <subsection name="Jasper"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org