From: David Suarez Date: Tue, 5 Sep 2017 21:01:47 +0000 (+0200) Subject: Fix checkstyle issues to enforce it X-Git-Tag: release/oxygen~104 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=c65916d075142dd937cb67e5128a87c05616b834 Fix checkstyle issues to enforce it Fix checkstyle issues to enforce it. Change-Id: I6e876b21f092b6d10e6f9ee1304ddf5a535dcb13 Signed-off-by: David Suarez --- diff --git a/opendaylight/config/config-api/pom.xml b/opendaylight/config/config-api/pom.xml index d05d5ce82d..9242ffecee 100644 --- a/opendaylight/config/config-api/pom.xml +++ b/opendaylight/config/config-api/pom.xml @@ -1,12 +1,13 @@ - + 4.0.0 org.opendaylight.mdsal binding-parent 0.12.0-SNAPSHOT - + org.opendaylight.controller @@ -32,14 +33,21 @@ to make sure anyone dependending on this artifact inherits it --> compile - - org.opendaylight.yangtools - mockito-configuration - + + org.opendaylight.yangtools + mockito-configuration + + + org.apache.maven.plugins + maven-checkstyle-plugin + + checkstyle.violationSeverity=error + + org.apache.felix maven-bundle-plugin diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ConfigRegistry.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ConfigRegistry.java index 426edc1dec..a3c747bafb 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ConfigRegistry.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ConfigRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -39,8 +39,8 @@ public interface ConfigRegistry extends LookupRegistry, ServiceReferenceReadable * * @param transactionControllerON * {@link ObjectName} of - * {@link org.opendaylight.controller.config.api.jmx.ConfigTransactionControllerMXBean} that was - * received in {@link #beginConfig()} method call. + * {@link org.opendaylight.controller.config.api.jmx.ConfigTransactionControllerMXBean} + * that was received in {@link #beginConfig()} method call. * @return CommitStatus * @throws ValidationException * if validation fails @@ -51,20 +51,23 @@ public interface ConfigRegistry extends LookupRegistry, ServiceReferenceReadable throws ConflictingVersionException, ValidationException; /** + * List of open configuration transactions. + * * @return list of open configuration transactions. */ List getOpenConfigs(); /** * Will return true unless there was a transaction that succeeded during - * validation but failed in second phase of commit. In this case the server - * is unstable and its state is undefined. + * validation but failed in second phase of commit. In this case the server is + * unstable and its state is undefined. */ boolean isHealthy(); /** + * Get the module names available in the system. + * * @return module factory names available in the system */ Set getAvailableModuleNames(); - } diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ConfigTransactionController.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ConfigTransactionController.java index bd9002c624..c234da7df5 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ConfigTransactionController.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ConfigTransactionController.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -21,13 +21,14 @@ public interface ConfigTransactionController extends LookupRegistry, ServiceRefe * Create new configuration bean. * * @param moduleName + * name of the module * @param instanceName + * name of the instance * @return ObjectName of newly created module * @throws InstanceAlreadyExistsException * if given ifcName and instanceName is already registered */ - ObjectName createModule(String moduleName, String instanceName) - throws InstanceAlreadyExistsException; + ObjectName createModule(String moduleName, String instanceName) throws InstanceAlreadyExistsException; /** * Re-creates an existing module configuration bean. @@ -49,8 +50,7 @@ public interface ConfigTransactionController extends LookupRegistry, ServiceRefe * @param objectName * can be either read-only module name that can be obtained using * {@link ConfigRegistry#lookupConfigBean(String, String)} or - * writable module name that must contain current transaction - * name. + * writable module name that must contain current transaction name. * @throws InstanceNotFoundException * if module is not found * @throws IllegalArgumentException @@ -72,14 +72,17 @@ public interface ConfigTransactionController extends LookupRegistry, ServiceRefe void validateConfig() throws ValidationException; /** + * Get the name of the transaction. * * @return transactionName */ String getTransactionName(); /** - * @return all known module factory names as reported by {@link org.opendaylight.controller.config.spi.ModuleFactory#getImplementationName()} + * Get the names of all available modules. + * + * @return all known module factory names as reported by + * {@link org.opendaylight.controller.config.spi.ModuleFactory#getImplementationName()} */ Set getAvailableModuleNames(); - } diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/DependencyResolver.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/DependencyResolver.java index 813e55426b..e9b63e6f05 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/DependencyResolver.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/DependencyResolver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -26,72 +26,90 @@ import org.opendaylight.yangtools.yang.binding.BaseIdentity; public interface DependencyResolver extends Identifiable { /** - * To be used during validation phase to validate service interface of - * dependent module. + * To be used during validation phase to validate service interface of dependent + * module. * - * @param expectedServiceInterface MBean/MXBean interface which will back the proxy object. - * @param objectName ObjectName of dependent module without transaction name - * (platformON). - * @param jmxAttribute for reporting - * @throws IllegalArgumentException when module is not found - * @throws IllegalStateException if module does not export this - * service interface. + * @param expectedServiceInterface + * MBean/MXBean interface which will back the proxy object. + * @param objectName + * ObjectName of dependent module without transaction name + * (platformON). + * @param jmxAttribute + * for reporting + * @throws IllegalArgumentException + * when module is not found + * @throws IllegalStateException + * if module does not export this service interface. */ - void validateDependency( - Class expectedServiceInterface, - ObjectName objectName, JmxAttribute jmxAttribute); + void validateDependency(Class expectedServiceInterface, ObjectName objectName, + JmxAttribute jmxAttribute); /** * To be used during commit phase to wire actual dependencies. * * @return dependency instance using - * {@link org.opendaylight.controller.config.spi.Module#getInstance()} - * @throws IllegalArgumentException when module is not found + * {@link org.opendaylight.controller.config.spi.Module#getInstance()} + * @throws IllegalArgumentException + * when module is not found */ - T resolveInstance(Class expectedType, ObjectName objectName, - JmxAttribute jmxAttribute); - + T resolveInstance(Class expectedType, ObjectName objectName, JmxAttribute jmxAttribute); /** * To be used during commit phase to resolve identity-ref config attributes. * * @return actual class object generated from identity */ - Class resolveIdentity(IdentityAttributeRef identityRef, Class expectedBaseClass); - + Class resolveIdentity(IdentityAttributeRef identityRef, + Class expectedBaseClass); /** * Validate identity-ref config attribute. */ - void validateIdentity(IdentityAttributeRef identityRef, Class expectedBaseClass, JmxAttribute jmxAttribute); + void validateIdentity(IdentityAttributeRef identityRef, Class expectedBaseClass, + JmxAttribute jmxAttribute); /** - * Can be used during validation or commit phase to get attribute value of dependent module. + * Can be used during validation or commit phase to get attribute value of + * dependent module. * - * @param name either direct ObjectName of a Module (type=Module) or service reference (type=ServiceReference) of dependent Module - * @param attribute String identifying attribute name in JMX. Note that attributes start with upper case. See {@link org.opendaylight.controller.config.api.JmxAttribute#getAttributeName()} + * @param name + * either direct ObjectName of a Module (type=Module) or service + * reference (type=ServiceReference) of dependent Module + * @param attribute + * String identifying attribute name in JMX. Note that attributes + * start with upper case. See + * {@link org.opendaylight.controller.config.api.JmxAttribute#getAttributeName()} */ Object getAttribute(ObjectName name, String attribute) - throws MBeanException, AttributeNotFoundException, - InstanceNotFoundException, ReflectionException; - + throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException; /** - * Helper method around {@link javax.management.JMX#newMXBeanProxy(javax.management.MBeanServerConnection, javax.management.ObjectName, Class)} }. - * Returns MXBean proxy for dependent module. Can be used during validation or commit phase to inspect dependent module's attributes. + * Helper method around. + * {@link javax.management + * .JMX#newMXBeanProxy(javax.management.MBeanServerConnection, javax.management.ObjectName, Class)}}. + * + * Returns MXBean proxy for dependent module. Can be used during validation or + * commit phase to inspect dependent module's attributes. * - * @param objectName either direct ObjectName of a Module (type=Module) or service reference (type=ServiceReference) of dependent Module - * @param interfaceClass MXBean interface to be used as a proxy - * @param type of proxy for type safe return value + * @param objectName + * either direct ObjectName of a Module (type=Module) or service + * reference (type=ServiceReference) of dependent Module + * @param interfaceClass + * MXBean interface to be used as a proxy + * @param + * type of proxy for type safe return value * @return instance of MXBean proxy */ T newMXBeanProxy(ObjectName objectName, Class interfaceClass); /** - * Check whether a dependency will be reused or (re)created. Useful when deciding if current module could be also reused. + * Check whether a dependency will be reused or (re)created. Useful when + * deciding if current module could be also reused. * - * @param objectName ObjectName ID of a dependency - * @param jmxAttribute JMXAttribute ID of a dependency + * @param objectName + * ObjectName ID of a dependency + * @param jmxAttribute + * JMXAttribute ID of a dependency * @return true if the dependency will be reused false otherwise */ boolean canReuseDependency(ObjectName objectName, JmxAttribute jmxAttribute); diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/IdentityAttributeRef.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/IdentityAttributeRef.java index 23d8691f54..a578ac563f 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/IdentityAttributeRef.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/IdentityAttributeRef.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -14,48 +14,50 @@ public final class IdentityAttributeRef { public static final String QNAME_ATTR_NAME = "qNameOfIdentity"; - private final String qNameOfIdentity; + private final String qualifiedNameOfIdentity; @ConstructorProperties(QNAME_ATTR_NAME) - public IdentityAttributeRef(final String qNameOfIdentity) { - if (qNameOfIdentity == null) { + public IdentityAttributeRef(final String qualifiedNameOfIdentity) { + if (qualifiedNameOfIdentity == null) { throw new NullPointerException("Parameter " + QNAME_ATTR_NAME + " is null"); } - this.qNameOfIdentity = qNameOfIdentity; + this.qualifiedNameOfIdentity = qualifiedNameOfIdentity; } public String getqNameOfIdentity() { - return qNameOfIdentity; + return qualifiedNameOfIdentity; } - public Class resolveIdentity(final DependencyResolver resolver, final Class baseIdentity) { + public Class resolveIdentity(final DependencyResolver resolver, + final Class baseIdentity) { return resolver.resolveIdentity(this, baseIdentity); } - public void validateIdentity(final DependencyResolver resolver, final Class baseIdentity, final JmxAttribute jmxAttribute) { + public void validateIdentity(final DependencyResolver resolver, + final Class baseIdentity, final JmxAttribute jmxAttribute) { resolver.validateIdentity(this, baseIdentity, jmxAttribute); } @Override public String toString() { final StringBuilder sb = new StringBuilder("IdentityAttributeRef{"); - sb.append("qNameOfIdentity='").append(qNameOfIdentity).append('\''); + sb.append("qNameOfIdentity='").append(qualifiedNameOfIdentity).append('\''); sb.append('}'); return sb.toString(); } @Override - public boolean equals(final Object o) { - if (this == o) { + public boolean equals(final Object object) { + if (this == object) { return true; } - if (!(o instanceof IdentityAttributeRef)) { + if (!(object instanceof IdentityAttributeRef)) { return false; } - IdentityAttributeRef that = (IdentityAttributeRef) o; + IdentityAttributeRef that = (IdentityAttributeRef) object; - if (!qNameOfIdentity.equals(that.qNameOfIdentity)) { + if (!qualifiedNameOfIdentity.equals(that.qualifiedNameOfIdentity)) { return false; } @@ -64,7 +66,6 @@ public final class IdentityAttributeRef { @Override public int hashCode() { - return qNameOfIdentity.hashCode(); + return qualifiedNameOfIdentity.hashCode(); } - } diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/JmxAttribute.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/JmxAttribute.java index 068322cc89..7b67b95d37 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/JmxAttribute.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/JmxAttribute.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -29,15 +29,15 @@ public class JmxAttribute { } @Override - public boolean equals(final Object o) { - if (this == o) { + public boolean equals(final Object object) { + if (this == object) { return true; } - if (o == null || getClass() != o.getClass()) { + if (object == null || getClass() != object.getClass()) { return false; } - JmxAttribute that = (JmxAttribute) o; + JmxAttribute that = (JmxAttribute) object; if (!attributeName.equals(that.attributeName)) { return false; diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/LookupRegistry.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/LookupRegistry.java index 5d615c2084..0492268338 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/LookupRegistry.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/LookupRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -24,6 +24,7 @@ public interface LookupRegistry { * Find modules with given module name. * * @param moduleName + * name of module * @return objectNames */ Set lookupConfigBeans(String moduleName); @@ -32,11 +33,11 @@ public interface LookupRegistry { * Find read modules. * * @param moduleName - * exact match for searched module name, can contain '*' to match - * all values. + * exact match for searched module name, can contain '*' to match all + * values. * @param instanceName - * exact match for searched instance name, can contain '*' to - * match all values. + * exact match for searched instance name, can contain '*' to match + * all values. * @return objectNames */ Set lookupConfigBeans(String moduleName, String instanceName); @@ -45,17 +46,16 @@ public interface LookupRegistry { * Find read module. * * @param moduleName - * exact match for searched module name, can contain '*' to match - * all values. + * exact match for searched module name, can contain '*' to match all + * values. * @param instanceName - * exact match for searched instance name, can contain '*' to - * match all values. + * exact match for searched instance name, can contain '*' to match + * all values. * @return objectNames * @throws InstanceNotFoundException * if search did not find exactly one instance */ - ObjectName lookupConfigBean(String moduleName, String instanceName) - throws InstanceNotFoundException; + ObjectName lookupConfigBean(String moduleName, String instanceName) throws InstanceNotFoundException; /** * Check that object name corresponds with existing module. @@ -65,21 +65,22 @@ public interface LookupRegistry { */ void checkConfigBeanExists(ObjectName objectName) throws InstanceNotFoundException; - /** + * Get the qNames of all ModuleFactory instances in the system. + * * @return qNames of all ModuleFactory instances in the system */ Set getAvailableModuleFactoryQNames(); /** - * Find all runtime beans + * Find all runtime beans. * * @return objectNames */ Set lookupRuntimeBeans(); /** - * Find all runtime of specified module + * Find all runtime of specified module. * * @param moduleName * of bean diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ModuleIdentifier.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ModuleIdentifier.java index c7d1df895b..600c9eeaec 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ModuleIdentifier.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ModuleIdentifier.java @@ -11,7 +11,8 @@ import org.opendaylight.yangtools.concepts.Identifier; public class ModuleIdentifier implements Identifier { private static final long serialVersionUID = 1L; - private final String factoryName, instanceName; + private final String factoryName; + private final String instanceName; public ModuleIdentifier(final String factoryName, final String instanceName) { if (factoryName == null) { @@ -33,15 +34,15 @@ public class ModuleIdentifier implements Identifier { } @Override - public boolean equals(final Object o) { - if (this == o) { + public boolean equals(final Object object) { + if (this == object) { return true; } - if (o == null || getClass() != o.getClass()) { + if (object == null || getClass() != object.getClass()) { return false; } - ModuleIdentifier that = (ModuleIdentifier) o; + ModuleIdentifier that = (ModuleIdentifier) object; if (!factoryName.equals(that.factoryName)) { return false; diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/RuntimeBeanRegistratorAwareModule.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/RuntimeBeanRegistratorAwareModule.java index e6c92fdb6d..2b46ac79d7 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/RuntimeBeanRegistratorAwareModule.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/RuntimeBeanRegistratorAwareModule.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -21,7 +21,7 @@ public interface RuntimeBeanRegistratorAwareModule extends Module { * to close registrator in their {@link java.io.Closeable#close()} method. Same * module will get the same registrator during reconfiguration. * - * @param rootRuntimeBeanRegistrator + * @param rootRuntimeBeanRegistrator root bean */ void setRuntimeBeanRegistrator( RootRuntimeBeanRegistrator rootRuntimeBeanRegistrator); diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ServiceReferenceReadableRegistry.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ServiceReferenceReadableRegistry.java index a364e54bff..f4ee78784f 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ServiceReferenceReadableRegistry.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ServiceReferenceReadableRegistry.java @@ -15,11 +15,17 @@ import javax.management.ObjectName; public interface ServiceReferenceReadableRegistry { /** - * Lookup object name by fully qualified service interface name and service reference name. - * @param serviceInterfaceQName service interface name - * @param refName service reference name supplied in - * {@link org.opendaylight.controller.config.api.ConfigTransactionController#saveServiceReference(String, String, javax.management.ObjectName)} - * @throws java.lang.IllegalArgumentException if module not found + * Lookup object name by fully qualified service interface name and service + * reference name. + * + * @param serviceInterfaceQName + * service interface name + * @param refName + * service reference name supplied in + * {@link org.opendaylight.controller.config + * .api .ConfigTransactionController#saveServiceReference(String, String, javax.management.ObjectName)} + * @throws java.lang.IllegalArgumentException + * if module not found */ ObjectName lookupConfigBeanByServiceInterfaceName(String serviceInterfaceQName, String refName); @@ -29,34 +35,50 @@ public interface ServiceReferenceReadableRegistry { Map> getServiceMapping(); /** - * Get current mapping between reference names and module object names for given service interface name. - * @param serviceInterfaceQName service interface name - * @throws IllegalArgumentException if there is a mismatch between serviceInterfaceName and objectName + * Get current mapping between reference names and module object names for given + * service interface name. + * + * @param serviceInterfaceQName + * service interface name + * @throws IllegalArgumentException + * if there is a mismatch between serviceInterfaceName and + * objectName */ Map lookupServiceReferencesByServiceInterfaceName(String serviceInterfaceQName); /** * Find all available service interface names of a module. - * @param objectName module object name - * @throws InstanceNotFoundException if search did not find exactly one instance + * + * @param objectName + * module object name + * @throws InstanceNotFoundException + * if search did not find exactly one instance */ Set lookupServiceInterfaceNames(ObjectName objectName) throws InstanceNotFoundException; /** - * @param namespace service interface namespace - * @param localName service interface local name - * @return fully qualified name needed by all other service reference mapping methods. - * @throws java.lang.IllegalArgumentException if namespace or localName is not found + * Get the name of the service interface. + * + * @param namespace + * service interface namespace + * @param localName + * service interface local name + * @return fully qualified name needed by all other service reference mapping + * methods. + * @throws java.lang.IllegalArgumentException + * if namespace or localName is not found */ String getServiceInterfaceName(String namespace, String localName); /** + * Get the reference to that service. + * * @return ObjectName with type=Service that was created using - * {@link org.opendaylight.controller.config.api.ServiceReferenceWritableRegistry#saveServiceReference(String, String, - * javax.management.ObjectName)} + * {@link org.opendaylight.controller + * .config .api.ServiceReferenceWritableRegistry#saveServiceReference(String, + * String, javax.management.ObjectName)} */ ObjectName getServiceReference(String serviceInterfaceQName, String refName) throws InstanceNotFoundException; void checkServiceReferenceExists(ObjectName objectName) throws InstanceNotFoundException; - } diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ServiceReferenceWritableRegistry.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ServiceReferenceWritableRegistry.java index f7b56fe4c2..77fc8dc3c7 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ServiceReferenceWritableRegistry.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ServiceReferenceWritableRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -12,16 +12,25 @@ import javax.management.ObjectName; public interface ServiceReferenceWritableRegistry extends ServiceReferenceReadableRegistry { /** - * Create or update reference name to objectName. Reference name is unique per service interface name. - * @return created or updated object name containing service name and reference name - * @throws IllegalArgumentException if there is a mismatch between serviceInterfaceName and objectName - * @throws InstanceNotFoundException if search did not find exactly one instance + * Create or update reference name to objectName. Reference name is unique per + * service interface name. + * + * @return created or updated object name containing service name and reference + * name + * @throws IllegalArgumentException + * if there is a mismatch between serviceInterfaceName and + * objectName + * @throws InstanceNotFoundException + * if search did not find exactly one instance */ - ObjectName saveServiceReference(String serviceInterfaceName, String refName, ObjectName moduleON) throws InstanceNotFoundException; + ObjectName saveServiceReference(String serviceInterfaceName, String refName, ObjectName moduleON) + throws InstanceNotFoundException; /** * Remove service reference. - * @throws IllegalArgumentException if service interface name is not advertised by any module + * + * @throws IllegalArgumentException + * if service interface name is not advertised by any module */ void removeServiceReference(String serviceInterfaceName, String refName) throws InstanceNotFoundException; @@ -32,6 +41,7 @@ public interface ServiceReferenceWritableRegistry extends ServiceReferenceReadab /** * Remove all service references attached to given module. + * * @return true iif at least one reference was removed */ boolean removeServiceReferences(ObjectName objectName) throws InstanceNotFoundException; diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ValidationException.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ValidationException.java index 1d528e5b00..83e83e9b17 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ValidationException.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ValidationException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -15,18 +15,22 @@ import java.util.Map; import java.util.Map.Entry; /** - * This exception is not intended to be used while implementing modules, - * it aggregates validation exceptions and sends them back to the user. - * Use {@link org.opendaylight.controller.config.api.JmxAttributeValidationException} for - * validating modules instead. + * This exception is not intended to be used while implementing modules, it + * aggregates validation exceptions and sends them back to the user. Use + * {@link org.opendaylight.controller.config.api.JmxAttributeValidationException} + * for validating modules instead. */ public class ValidationException extends Exception { private static final long serialVersionUID = -6072893219820274247L; - private final Map> failedValidations; + private final Map> failedValidations; public ValidationException( - final Map> failedValidations) { + final Map> failedValidations) { super(failedValidations.toString()); this.failedValidations = Collections.unmodifiableMap(failedValidations); } @@ -35,20 +39,17 @@ public class ValidationException extends Exception { final List collectedExceptions) { Map> failedValidations = new HashMap<>(); for (ValidationException ve : collectedExceptions) { - for (Entry> outerEntry : ve - .getFailedValidations().entrySet()) { - for (Entry innerEntry : outerEntry - .getValue().entrySet()) { + for (Entry> outerEntry : ve.getFailedValidations() + .entrySet()) { + for (Entry innerEntry : outerEntry.getValue().entrySet()) { String moduleName = outerEntry.getKey(); String instanceName = innerEntry.getKey(); ExceptionMessageWithStackTrace ex = innerEntry.getValue(); Map instanceToExMap = failedValidations .computeIfAbsent(moduleName, k -> new HashMap<>()); if (instanceToExMap.containsKey(instanceName)) { - throw new IllegalArgumentException( - "Cannot merge with same module name " - + moduleName + " and instance name " - + instanceName); + throw new IllegalArgumentException("Cannot merge with same module name " + moduleName + + " and instance name " + instanceName); } instanceToExMap.put(instanceName, ex); } @@ -57,23 +58,25 @@ public class ValidationException extends Exception { return new ValidationException(failedValidations); } - public static ValidationException createForSingleException( - final ModuleIdentifier moduleIdentifier, final Exception e) { + public static ValidationException createForSingleException(final ModuleIdentifier moduleIdentifier, + final Exception exception) { Map> failedValidations = new HashMap<>(); Map innerMap = new HashMap<>(); failedValidations.put(moduleIdentifier.getFactoryName(), innerMap); - innerMap.put(moduleIdentifier.getInstanceName(), - new ExceptionMessageWithStackTrace(e)); + innerMap.put(moduleIdentifier.getInstanceName(), new ExceptionMessageWithStackTrace(exception)); return new ValidationException(failedValidations); } - public Map> getFailedValidations() { + public Map> getFailedValidations() { return failedValidations; } public static class ExceptionMessageWithStackTrace { - private String message, stackTrace; + private String message; + private String stackTrace; public ExceptionMessageWithStackTrace() { } @@ -83,8 +86,8 @@ public class ValidationException extends Exception { this.stackTrace = stackTrace; } - public ExceptionMessageWithStackTrace(final Exception e) { - this(e.getMessage(), Arrays.toString(e.getStackTrace())); + public ExceptionMessageWithStackTrace(final Exception exception) { + this(exception.getMessage(), Arrays.toString(exception.getStackTrace())); } public String getMessage() { @@ -107,10 +110,8 @@ public class ValidationException extends Exception { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result - + ((message == null) ? 0 : message.hashCode()); - result = prime * result - + ((stackTrace == null) ? 0 : stackTrace.hashCode()); + result = prime * result + (message == null ? 0 : message.hashCode()); + result = prime * result + (stackTrace == null ? 0 : stackTrace.hashCode()); return result; } @@ -147,6 +148,5 @@ public class ValidationException extends Exception { public String toString() { return message; } - } } diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/annotations/ServiceInterfaceAnnotation.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/annotations/ServiceInterfaceAnnotation.java index 23a01a7b51..1adf6c5478 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/annotations/ServiceInterfaceAnnotation.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/annotations/ServiceInterfaceAnnotation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -42,17 +42,17 @@ public @interface ServiceInterfaceAnnotation { boolean registerToOsgi() default true; /** - * Get namespace of {@link #value()} + * Get namespace of {@link #value()}. */ String namespace(); /** - * Get revision of {@link #value()} + * Get revision of {@link #value()}. */ String revision(); /** - * Get local name of {@link #value()} + * Get local name of {@link #value()}. */ String localName(); } diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/CommitStatus.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/CommitStatus.java index 33f811c739..ed9164d151 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/CommitStatus.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/CommitStatus.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -15,42 +15,36 @@ import javax.management.ObjectName; @Immutable public class CommitStatus { - private final List newInstances, reusedInstances, - recreatedInstances; + private final List newInstances; + private final List reusedInstances; + private final List recreatedInstances; /** - * @param newInstances newly created instances - * @param reusedInstances reused instances - * @param recreatedInstances recreated instances + * Constructor. + * + * @param newInstances + * newly created instances + * @param reusedInstances + * reused instances + * @param recreatedInstances + * recreated instances */ - @ConstructorProperties({"newInstances", "reusedInstances", - "recreatedInstances"}) - public CommitStatus(final List newInstances, - final List reusedInstances, - final List recreatedInstances) { + @ConstructorProperties({ "newInstances", "reusedInstances", "recreatedInstances" }) + public CommitStatus(final List newInstances, final List reusedInstances, + final List recreatedInstances) { this.newInstances = Collections.unmodifiableList(newInstances); this.reusedInstances = Collections.unmodifiableList(reusedInstances); - this.recreatedInstances = Collections - .unmodifiableList(recreatedInstances); + this.recreatedInstances = Collections.unmodifiableList(recreatedInstances); } - /** - * @return list of objectNames representing newly created instances - */ public List getNewInstances() { return newInstances; } - /** - * @return list of objectNames representing reused instances - */ public List getReusedInstances() { return reusedInstances; } - /** - * @return list of objectNames representing recreated instances - */ public List getRecreatedInstances() { return recreatedInstances; } @@ -59,14 +53,9 @@ public class CommitStatus { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result - + ((newInstances == null) ? 0 : newInstances.hashCode()); - result = prime - * result - + ((recreatedInstances == null) ? 0 : recreatedInstances - .hashCode()); - result = prime * result - + ((reusedInstances == null) ? 0 : reusedInstances.hashCode()); + result = prime * result + (newInstances == null ? 0 : newInstances.hashCode()); + result = prime * result + (recreatedInstances == null ? 0 : recreatedInstances.hashCode()); + result = prime * result + (reusedInstances == null ? 0 : reusedInstances.hashCode()); return result; } @@ -108,8 +97,7 @@ public class CommitStatus { @Override public String toString() { - return "CommitStatus [newInstances=" + newInstances - + ", reusedInstances=" + reusedInstances + return "CommitStatus [newInstances=" + newInstances + ", reusedInstances=" + reusedInstances + ", recreatedInstances=" + recreatedInstances + "]"; } diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/ObjectNameUtil.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/ObjectNameUtil.java index 1165d7a399..3b7858c477 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/ObjectNameUtil.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/ObjectNameUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -27,9 +27,7 @@ import org.opendaylight.controller.config.api.jmx.constants.ConfigRegistryConsta * {@link #TRANSACTION_NAME_KEY} property set. */ @ThreadSafe -public class ObjectNameUtil { - private ObjectNameUtil() { - } +public final class ObjectNameUtil { public static final String ON_DOMAIN = ConfigRegistryConstants.ON_DOMAIN; public static final String MODULE_FACTORY_NAME_KEY = "moduleFactoryName"; @@ -45,6 +43,9 @@ public class ObjectNameUtil { private static final String REPLACED_QUOTATION_MARK = "\\?"; public static final String ON_WILDCARD = "*"; + private ObjectNameUtil() { + } + public static ObjectName createON(final String on) { try { return new ObjectName(on); @@ -53,10 +54,6 @@ public class ObjectNameUtil { } } - public static ObjectName createONWithDomainAndType(final String type) { - return ConfigRegistryConstants.createONWithDomainAndType(type); - } - public static ObjectName createON(final String name, final String key, final String value) { return ConfigRegistryConstants.createON(name, key, value); } @@ -71,8 +68,11 @@ public class ObjectNameUtil { } - public static ObjectName createTransactionControllerON( - final String transactionName) { + public static ObjectName createONWithDomainAndType(final String type) { + return ConfigRegistryConstants.createONWithDomainAndType(type); + } + + public static ObjectName createTransactionControllerON(final String transactionName) { Map onParams = new HashMap<>(); onParams.put(TRANSACTION_NAME_KEY, transactionName); onParams.put(TYPE_KEY, TYPE_CONFIG_TRANSACTION); @@ -80,29 +80,29 @@ public class ObjectNameUtil { } public static ObjectName createTransactionModuleON(final String transactionName, - final ModuleIdentifier moduleIdentifier) { - return createTransactionModuleON(transactionName, - moduleIdentifier.getFactoryName(), + final ModuleIdentifier moduleIdentifier) { + return createTransactionModuleON(transactionName, moduleIdentifier.getFactoryName(), moduleIdentifier.getInstanceName()); } - public static ObjectName createTransactionModuleON(final String transactionName, - final String moduleName, final String instanceName) { + public static ObjectName createTransactionModuleON(final String transactionName, final String moduleName, + final String instanceName) { Map onParams = createModuleMap(moduleName, instanceName); onParams.put(TRANSACTION_NAME_KEY, transactionName); return createON(ON_DOMAIN, onParams); } - public static ObjectName createTransactionModuleON(final String transactionName, - final ObjectName on) { - return createTransactionModuleON(transactionName, getFactoryName(on), - getInstanceName(on)); + public static ObjectName createTransactionModuleON(final String transactionName, final ObjectName on) { + return createTransactionModuleON(transactionName, getFactoryName(on), getInstanceName(on)); } - public static ObjectName createReadOnlyModuleON( - final ModuleIdentifier moduleIdentifier) { - return createReadOnlyModuleON(moduleIdentifier.getFactoryName(), - moduleIdentifier.getInstanceName()); + public static ObjectName createReadOnlyModuleON(final ModuleIdentifier moduleIdentifier) { + return createReadOnlyModuleON(moduleIdentifier.getFactoryName(), moduleIdentifier.getInstanceName()); + } + + public static ObjectName createReadOnlyModuleON(final String moduleName, final String instanceName) { + Map onParams = createModuleMap(moduleName, instanceName); + return createON(ON_DOMAIN, onParams); } public static ObjectName createReadOnlyServiceON(final String serviceQName, final String refName) { @@ -110,7 +110,8 @@ public class ObjectNameUtil { return createON(ON_DOMAIN, onParams); } - public static ObjectName createTransactionServiceON(final String transactionName, final String serviceQName, final String refName) { + public static ObjectName createTransactionServiceON(final String transactionName, final String serviceQName, + final String refName) { Map onParams = createServiceON(transactionName, serviceQName, refName); return createON(ON_DOMAIN, onParams); } @@ -121,7 +122,8 @@ public class ObjectNameUtil { return unquoteAndUnescape(objectName, quoted); } - // ObjectName supports quotation and ignores tokens like =, but fails to ignore ? sign. + // ObjectName supports quotation and ignores tokens like =, but fails to ignore + // ? sign. // It must be replaced with another character that hopefully does not collide // with actual value. private static String unquoteAndUnescape(final ObjectName objectName, final String quoted) { @@ -147,14 +149,13 @@ public class ObjectNameUtil { } private static Map createServiceON(final String transactionName, final String serviceQName, - final String refName) { + final String refName) { Map result = new HashMap<>(createServiceMap(serviceQName, refName)); result.put(TRANSACTION_NAME_KEY, transactionName); return result; } - private static Map createServiceMap(final String serviceQName, - final String refName) { + private static Map createServiceMap(final String serviceQName, final String refName) { Map onParams = new HashMap<>(); onParams.put(TYPE_KEY, TYPE_SERVICE_REFERENCE); onParams.put(SERVICE_QNAME_KEY, quoteAndEscapeValue(serviceQName)); @@ -162,15 +163,7 @@ public class ObjectNameUtil { return onParams; } - - public static ObjectName createReadOnlyModuleON(final String moduleName, - final String instanceName) { - Map onParams = createModuleMap(moduleName, instanceName); - return createON(ON_DOMAIN, onParams); - } - - private static Map createModuleMap(final String moduleName, - final String instanceName) { + private static Map createModuleMap(final String moduleName, final String instanceName) { Map onParams = new HashMap<>(); onParams.put(TYPE_KEY, TYPE_MODULE); onParams.put(MODULE_FACTORY_NAME_KEY, moduleName); @@ -198,12 +191,10 @@ public class ObjectNameUtil { public static ObjectName withoutTransactionName(final ObjectName inputON) { checkTypeOneOf(inputON, TYPE_MODULE, TYPE_SERVICE_REFERENCE); if (getTransactionName(inputON) == null) { - throw new IllegalArgumentException( - "Expected ObjectName with transaction:" + inputON); + throw new IllegalArgumentException("Expected ObjectName with transaction:" + inputON); } if (!ON_DOMAIN.equals(inputON.getDomain())) { - throw new IllegalArgumentException("Expected different domain: " - + inputON); + throw new IllegalArgumentException("Expected different domain: " + inputON); } Map outputProperties; if (inputON.getKeyProperty(TYPE_KEY).equals(TYPE_MODULE)) { @@ -231,17 +222,14 @@ public class ObjectNameUtil { } - private static void assertDoesNotContain( - final Map additionalProperties, final String key) { + private static void assertDoesNotContain(final Map additionalProperties, final String key) { if (additionalProperties.containsKey(key)) { - throw new IllegalArgumentException( - "Map 'additionalProperties' cannot overwrite attribute " - + key); + throw new IllegalArgumentException("Map 'additionalProperties' cannot overwrite attribute " + key); } } - public static ObjectName createRuntimeBeanName(final String moduleName, - final String instanceName, final Map additionalProperties) { + public static ObjectName createRuntimeBeanName(final String moduleName, final String instanceName, + final Map additionalProperties) { // check that there is no overwriting of default attributes assertDoesNotContain(additionalProperties, MODULE_FACTORY_NAME_KEY); assertDoesNotContain(additionalProperties, INSTANCE_NAME_KEY); @@ -254,11 +242,10 @@ public class ObjectNameUtil { return createON(ON_DOMAIN, map); } - private static Set blacklist = new HashSet<>(Arrays.asList( - MODULE_FACTORY_NAME_KEY, INSTANCE_NAME_KEY, TYPE_KEY)); + private static Set blacklist = new HashSet<>( + Arrays.asList(MODULE_FACTORY_NAME_KEY, INSTANCE_NAME_KEY, TYPE_KEY)); - public static Map getAdditionalPropertiesOfRuntimeBeanName( - final ObjectName on) { + public static Map getAdditionalPropertiesOfRuntimeBeanName(final ObjectName on) { checkType(on, TYPE_RUNTIME_BEAN); Map allProperties = getAdditionalProperties(on); Map result = new HashMap<>(); @@ -288,8 +275,7 @@ public class ObjectNameUtil { public static void checkType(final ObjectName objectName, final String type) { if (!type.equals(objectName.getKeyProperty(TYPE_KEY))) { - throw new IllegalArgumentException("Wrong type, expected '" + type - + "', got " + objectName); + throw new IllegalArgumentException("Wrong type, expected '" + type + "', got " + objectName); } } @@ -299,65 +285,51 @@ public class ObjectNameUtil { return; } } - throw new IllegalArgumentException("Wrong type, expected one of " + Arrays.asList(types) - + ", got " + objectName); + throw new IllegalArgumentException( + "Wrong type, expected one of " + Arrays.asList(types) + ", got " + objectName); } - public static ObjectName createModulePattern(final String moduleName, - final String instanceName) { + public static ObjectName createModulePattern(final String moduleName, final String instanceName) { String finalModuleName = moduleName == null ? ON_WILDCARD : moduleName; String finalInstanceName = instanceName == null ? ON_WILDCARD : instanceName; // do not return object names containing transaction name - ObjectName namePattern = ObjectNameUtil - .createON(ObjectNameUtil.ON_DOMAIN + ":" - + ObjectNameUtil.TYPE_KEY + "=" - + ObjectNameUtil.TYPE_MODULE + "," - + ObjectNameUtil.MODULE_FACTORY_NAME_KEY + "=" - + finalModuleName + "," + "" - + ObjectNameUtil.INSTANCE_NAME_KEY + "=" + finalInstanceName); + ObjectName namePattern = ObjectNameUtil.createON(ObjectNameUtil.ON_DOMAIN + ":" + ObjectNameUtil.TYPE_KEY + "=" + + ObjectNameUtil.TYPE_MODULE + "," + ObjectNameUtil.MODULE_FACTORY_NAME_KEY + "=" + finalModuleName + + "," + "" + ObjectNameUtil.INSTANCE_NAME_KEY + "=" + finalInstanceName); return namePattern; } - public static ObjectName createModulePattern(final String ifcName, - final String instanceName, final String transactionName) { + public static ObjectName createModulePattern(final String ifcName, final String instanceName, + final String transactionName) { String finalIfcName = ifcName == null ? ON_WILDCARD : ifcName; String finalInstanceName = instanceName == null ? ON_WILDCARD : instanceName; String finalTransactionName = transactionName == null ? ON_WILDCARD : transactionName; - return ObjectNameUtil.createON(ObjectNameUtil.ON_DOMAIN - + ":type=Module," + ObjectNameUtil.MODULE_FACTORY_NAME_KEY - + "=" + finalIfcName + "," + ObjectNameUtil.INSTANCE_NAME_KEY + "=" - + finalInstanceName + "," + ObjectNameUtil.TRANSACTION_NAME_KEY - + "=" + finalTransactionName); + return ObjectNameUtil.createON(ObjectNameUtil.ON_DOMAIN + ":type=Module," + + ObjectNameUtil.MODULE_FACTORY_NAME_KEY + "=" + finalIfcName + "," + ObjectNameUtil.INSTANCE_NAME_KEY + + "=" + finalInstanceName + "," + ObjectNameUtil.TRANSACTION_NAME_KEY + "=" + finalTransactionName); } - public static ObjectName createRuntimeBeanPattern(final String moduleName, - final String instanceName) { + public static ObjectName createRuntimeBeanPattern(final String moduleName, final String instanceName) { String finalModuleName = moduleName == null ? ON_WILDCARD : moduleName; String finalInstanceName = instanceName == null ? ON_WILDCARD : instanceName; - return ObjectNameUtil.createON(ObjectNameUtil.ON_DOMAIN + ":" - + ObjectNameUtil.TYPE_KEY + "=" - + ObjectNameUtil.TYPE_RUNTIME_BEAN + "," - + ObjectNameUtil.MODULE_FACTORY_NAME_KEY + "=" + finalModuleName - + "," + ObjectNameUtil.INSTANCE_NAME_KEY + "=" + finalInstanceName - + ",*"); + return ObjectNameUtil.createON(ObjectNameUtil.ON_DOMAIN + ":" + ObjectNameUtil.TYPE_KEY + "=" + + ObjectNameUtil.TYPE_RUNTIME_BEAN + "," + ObjectNameUtil.MODULE_FACTORY_NAME_KEY + "=" + + finalModuleName + "," + ObjectNameUtil.INSTANCE_NAME_KEY + "=" + finalInstanceName + ",*"); } - public static ModuleIdentifier fromON(final ObjectName objectName, - final String expectedType) { + public static ModuleIdentifier fromON(final ObjectName objectName, final String expectedType) { checkType(objectName, expectedType); String factoryName = getFactoryName(objectName); if (factoryName == null) { - throw new IllegalArgumentException( - "ObjectName does not contain module name"); + throw new IllegalArgumentException("ObjectName does not contain module name"); } String instanceName = getInstanceName(objectName); if (instanceName == null) { - throw new IllegalArgumentException( - "ObjectName does not contain instance name"); + throw new IllegalArgumentException("ObjectName does not contain instance name"); } return new ModuleIdentifier(factoryName, instanceName); } diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/constants/ConfigRegistryConstants.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/constants/ConfigRegistryConstants.java index eae93e4d56..08e6d18c64 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/constants/ConfigRegistryConstants.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/constants/ConfigRegistryConstants.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -25,7 +25,8 @@ public class ConfigRegistryConstants { public static final ObjectName OBJECT_NAME = createONWithDomainAndType(TYPE_CONFIG_REGISTRY); - public static final ObjectName OBJECT_NAME_NO_NOTIFICATIONS = createONWithDomainAndType(TYPE_CONFIG_REGISTRY_NO_NOTIFICATIONS); + public static final ObjectName OBJECT_NAME_NO_NOTIFICATIONS = createONWithDomainAndType( + TYPE_CONFIG_REGISTRY_NO_NOTIFICATIONS); public static final String GET_AVAILABLE_MODULE_NAMES_ATTRIBUT_NAME = "AvailableModuleNames"; diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/notifications/CommitJMXNotification.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/notifications/CommitJMXNotification.java index ef53818891..2c79470563 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/notifications/CommitJMXNotification.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/notifications/CommitJMXNotification.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -15,7 +15,8 @@ public class CommitJMXNotification extends ConfigJMXNotification { private static final String AFTER_COMMIT_MESSAGE_TEMPLATE = "Commit successful: %s"; CommitJMXNotification(final NotificationBroadcasterSupport source, final String message) { - super(ConfigJMXNotification.NotificationType.COMMIT, source, String.format(AFTER_COMMIT_MESSAGE_TEMPLATE, message)); + super(ConfigJMXNotification.NotificationType.COMMIT, source, + String.format(AFTER_COMMIT_MESSAGE_TEMPLATE, message)); } @Override @@ -23,9 +24,5 @@ public class CommitJMXNotification extends ConfigJMXNotification { return "CommitJMXNotification{}"; } - /** - * - */ private static final long serialVersionUID = -8587623362011695514L; - } diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/notifications/ConfigJMXNotification.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/notifications/ConfigJMXNotification.java index 842c30aaa5..0d804c5973 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/notifications/ConfigJMXNotification.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/notifications/ConfigJMXNotification.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -15,20 +15,17 @@ import org.opendaylight.controller.config.api.jmx.ObjectNameUtil; public abstract class ConfigJMXNotification extends Notification { - /** - * - */ private static final long serialVersionUID = 6754474563863772845L; private static long sequenceNumber = 1; - public static String TYPE_NAME = "configfNotificationProvider"; - public static ObjectName OBJECT_NAME = ObjectNameUtil.createONWithDomainAndType(TYPE_NAME); + public static final String TYPE_NAME = "configfNotificationProvider"; + public static final ObjectName OBJECT_NAME = ObjectNameUtil.createONWithDomainAndType(TYPE_NAME); private final NotificationType type; - protected ConfigJMXNotification(final NotificationType type, - final NotificationBroadcasterSupport source, final String message) { + protected ConfigJMXNotification(final NotificationType type, final NotificationBroadcasterSupport source, + final String message) { super(type.toString(), source, sequenceNumber++, System.nanoTime(), message); this.type = type; } @@ -39,23 +36,22 @@ public abstract class ConfigJMXNotification extends Notification { } /** - * Sends this notification using source that created it + * Sends this notification using source that created it. */ public void send() { ((NotificationBroadcasterSupport) getSource()).sendNotification(this); } /** - * Creates notification about successful commit execution. - * - * Intended for config-persister. + * Creates notification about successful commit execution. Intended for + * config-persister. */ - public static CommitJMXNotification afterCommit(final NotificationBroadcasterSupport source, final String messages) { + public static CommitJMXNotification afterCommit(final NotificationBroadcasterSupport source, + final String messages) { return new CommitJMXNotification(source, messages); } enum NotificationType { COMMIT } - } diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/osgi/WaitingServiceTracker.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/osgi/WaitingServiceTracker.java index e06d7002dd..839612cb18 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/osgi/WaitingServiceTracker.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/osgi/WaitingServiceTracker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Brocade Communications Systems, Inc. and others. All rights reserved. + * Copyright (c) 2016, 2017 Brocade Communications Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -36,34 +36,39 @@ public final class WaitingServiceTracker implements AutoCloseable { /** * Waits for an OSGi services. * - * @param timeoutInMillis the timeout in millis + * @param timeoutInMillis + * the timeout in millis * @return the service instance - * @throws ServiceNotFoundException if it times out or is interrupted + * @throws ServiceNotFoundException + * if it times out or is interrupted */ @SuppressWarnings("unchecked") public T waitForService(final long timeoutInMillis) throws ServiceNotFoundException { try { T service = (T) tracker.waitForService(timeoutInMillis); - if(service == null) { - throw new ServiceNotFoundException(String.format("OSGi Service %s was not found after %d ms", - serviceInterface, timeoutInMillis)); + if (service == null) { + throw new ServiceNotFoundException( + String.format("OSGi Service %s was not found after %d ms", serviceInterface, timeoutInMillis)); } return service; - } catch(final InterruptedException e) { - throw new ServiceNotFoundException(String.format("Wait for OSGi service %s was interrrupted", - serviceInterface)); + } catch (final InterruptedException e) { + throw new ServiceNotFoundException( + String.format("Wait for OSGi service %s was interrrupted", serviceInterface)); } } /** * Creates an instance. * - * @param serviceInterface the service interface - * @param context the BundleContext + * @param serviceInterface + * the service interface + * @param context + * the BundleContext * @return new WaitingServiceTracker instance */ - public static WaitingServiceTracker create(@Nonnull final Class serviceInterface, @Nonnull final BundleContext context) { + public static WaitingServiceTracker create(@Nonnull final Class serviceInterface, + @Nonnull final BundleContext context) { ServiceTracker tracker = new ServiceTracker<>(context, serviceInterface, null); tracker.open(); return new WaitingServiceTracker<>(serviceInterface, tracker); @@ -72,31 +77,28 @@ public final class WaitingServiceTracker implements AutoCloseable { /** * Creates an instance. * - * @param serviceInterface the service interface - * @param context the BundleContext - * @param filter the OSGi service filter + * @param serviceInterface + * the service interface + * @param context + * the BundleContext + * @param filter + * the OSGi service filter * @return new WaitingServiceTracker instance */ - public static WaitingServiceTracker create(@Nonnull final Class serviceInterface, @Nonnull final BundleContext context, - @Nonnull final String filter) { + public static WaitingServiceTracker create(@Nonnull final Class serviceInterface, + @Nonnull final BundleContext context, @Nonnull final String filter) { String newFilter = String.format("(&(%s=%s)%s)", Constants.OBJECTCLASS, serviceInterface.getName(), filter); try { ServiceTracker tracker = new ServiceTracker<>(context, context.createFilter(newFilter), null); tracker.open(); return new WaitingServiceTracker<>(serviceInterface, tracker); - } catch(final InvalidSyntaxException e) { + } catch (final InvalidSyntaxException e) { throw new IllegalArgumentException(String.format("Invalid OSGi filter %s", newFilter), e); } } @Override public void close() { - try { - tracker.close(); - } catch(final RuntimeException e) { - // The ServiceTracker could throw IllegalStateException if the BundleContext is already closed. - // This is benign so ignore it. - LOG.debug("Error closing ServiceTracker", e); - } + tracker.close(); } } diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/runtime/RuntimeBean.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/runtime/RuntimeBean.java index b7ac7733c9..b4a7ed16b3 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/runtime/RuntimeBean.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/runtime/RuntimeBean.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -8,7 +8,7 @@ package org.opendaylight.controller.config.api.runtime; /** - * Marker interface for all runtime beans + * Marker interface for all runtime beans. */ public interface RuntimeBean { diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/spi/AbstractModule.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/spi/AbstractModule.java index b9addee952..12287c00f5 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/spi/AbstractModule.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/spi/AbstractModule.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -14,10 +14,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Base implementation of Module. This implementation contains base logic for Module reconfiguration with associated fields. - * @param Type of module implementation. Enables easier implementation for the isSame() method + * Base implementation of Module. This implementation contains base logic for + * Module reconfiguration with associated fields. + * + * @param + * Type of module implementation. Enables easier implementation for + * the isSame() method */ -public abstract class AbstractModule> implements org.opendaylight.controller.config.spi.Module { +public abstract class AbstractModule> + implements org.opendaylight.controller.config.spi.Module { private static final Logger LOG = LoggerFactory.getLogger(AbstractModule.class); @@ -32,8 +37,10 @@ public abstract class AbstractModule> implements org /** * Called when module is configured. * - * @param identifier id of current instance. - * @param dependencyResolver resolver used in dependency injection and validation. + * @param identifier + * id of current instance. + * @param dependencyResolver + * resolver used in dependency injection and validation. */ public AbstractModule(final ModuleIdentifier identifier, final DependencyResolver dependencyResolver) { this(identifier, dependencyResolver, null, null); @@ -42,12 +49,19 @@ public abstract class AbstractModule> implements org /** * Called when module is reconfigured. * - * @param identifier id of current instance. - * @param dependencyResolver resolver used in dependency injection and validation. - * @param oldModule old instance of module that is being reconfigred(replaced) by current instance. The old instance can be examined for reuse. - * @param oldInstance old instance wrapped by the old module. This is the resource that is actually being reused if possible or closed otherwise. + * @param identifier + * id of current instance. + * @param dependencyResolver + * resolver used in dependency injection and validation. + * @param oldModule + * old instance of module that is being reconfigred(replaced) by + * current instance. The old instance can be examined for reuse. + * @param oldInstance + * old instance wrapped by the old module. This is the resource that + * is actually being reused if possible or closed otherwise. */ - public AbstractModule(final ModuleIdentifier identifier, final DependencyResolver dependencyResolver, final M oldModule, final AutoCloseable oldInstance) { + public AbstractModule(final ModuleIdentifier identifier, final DependencyResolver dependencyResolver, + final M oldModule, final AutoCloseable oldInstance) { this.identifier = identifier; this.dependencyResolver = dependencyResolver; this.oldModule = oldModule; @@ -64,12 +78,13 @@ public abstract class AbstractModule> implements org } /** - * * General algorithm for spawning/closing and reusing wrapped instances. * - * @return current instance of wrapped resource either by reusing the old one (if present) or constructing a brand new. + * @return current instance of wrapped resource either by reusing the old one + * (if present) or constructing a brand new. */ @Override + @SuppressWarnings("IllegalCatch") public final AutoCloseable getInstance() { if (instance == null) { if (oldInstance != null && canReuseInstance && canReuseInstance(oldModule)) { @@ -79,18 +94,22 @@ public abstract class AbstractModule> implements org if (oldInstance != null) { try { oldInstance.close(); - } catch (final Exception e) { - LOG.error("An error occurred while closing old instance {} for module {}", oldInstance, getIdentifier(), e); + } catch (final Exception exception) { + LOG.error("An error occurred while closing old instance {} for module {}", oldInstance, + getIdentifier(), exception); } } resolveDependencies(); instance = createInstance(); if (instance == null) { - throw new IllegalStateException("Error in createInstance - null is not allowed as return value. Module: " + getIdentifier()); + throw new IllegalStateException( + "Error in createInstance - null is not allowed as return value. Module: " + + getIdentifier()); } } - // Prevent serial memory leak: clear these references as we will not use them again. + // Prevent serial memory leak: clear these references as we will not use them + // again. oldInstance = null; oldModule = null; } @@ -99,35 +118,45 @@ public abstract class AbstractModule> implements org } /** - * @return Brand new instance of wrapped class in case no previous instance is present or reconfiguration is impossible. + * Create instance. + * + * @return Brand new instance of wrapped class in case no previous instance is + * present or reconfiguration is impossible. */ protected abstract AutoCloseable createInstance(); @Override public final boolean canReuse(final Module oldModule) { // Just cast into a specific instance - // TODO unify this method with canReuseInstance (required Module interface to be generic which requires quite a lot of changes) + // TODO unify this method with canReuseInstance (required Module interface to be + // generic which requires quite a lot of changes) return canReuseInstance && getClass().isInstance(oldModule) ? canReuseInstance((M) oldModule) : false; } /** + * Users are welcome to override this method to provide custom logic for + * advanced reusability detection. * - * Users are welcome to override this method to provide custom logic for advanced reusability detection. - * - * @param oldModule old instance of a Module - * @return true if the old instance is reusable false if a new one should be spawned + * @param oldModule + * old instance of a Module + * @return true if the old instance is reusable false if a new one should be + * spawned */ - protected abstract boolean canReuseInstance(final M oldModule); + protected abstract boolean canReuseInstance(M oldModule); /** - * By default the oldInstance is returned since this method is by default called only if the oldModule had the same configuration and dependencies configured. - * Users are welcome to override this method to provide custom logic for advanced reusability. + * By default the oldInstance is returned since this method is by default called + * only if the oldModule had the same configuration and dependencies configured. + * Users are welcome to override this method to provide custom logic for + * advanced reusability. * - * @param oldInstance old instance of a class wrapped by the module + * @param oldInstance + * old instance of a class wrapped by the module * @return reused instance */ protected AutoCloseable reuseInstance(final AutoCloseable oldInstance) { - // implement if instance reuse should be supported. Override canReuseInstance to change the criteria. + // implement if instance reuse should be supported. Override canReuseInstance to + // change the criteria. return oldInstance; } diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/spi/Module.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/spi/Module.java index 4766ad8a47..ad4f2d36c4 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/spi/Module.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/spi/Module.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -11,7 +11,6 @@ import javax.annotation.concurrent.NotThreadSafe; import org.opendaylight.controller.config.api.ModuleIdentifier; import org.opendaylight.yangtools.concepts.Identifiable; - /** * Represents one service that is to be configured. These methods need to be * implemented in addition to the usual attribute getters/setters. Dependencies @@ -19,7 +18,8 @@ import org.opendaylight.yangtools.concepts.Identifiable; * ConfigBeans. *

* In order to guide dependency resolution, the setter method should be - * annotated with {@link org.opendaylight.controller.config.api.annotations.RequireInterface}. + * annotated with + * {@link org.opendaylight.controller.config.api.annotations.RequireInterface}. *

*

* Thread safety note: implementations of this interface are not required to be @@ -27,44 +27,43 @@ import org.opendaylight.yangtools.concepts.Identifiable; *

*/ @NotThreadSafe -public interface Module extends Identifiable{ +public interface Module extends Identifiable { /** - * This method will be called as first phase in two phase commit. Instance - * can check attributes, but is not allowed to do any kind of work that - * could leave any resources open. It is prohibited to call - * {@link #getInstance()} on dependent {@link Module} because it would - * destroy separation between validation and commit phase. + * This method will be called as first phase in two phase commit. Instance can + * check attributes, but is not allowed to do any kind of work that could leave + * any resources open. It is prohibited to call {@link #getInstance()} on + * dependent {@link Module} because it would destroy separation between + * validation and commit phase. * */ void validate(); /** - * Returns 'live' object that was configured using this object. It is - * allowed to call this method only after all ConfigBeans were validated. In - * this method new resources might be opened or old instance might be - * modified. This method must be implemented so that it returns same - * result for a single transaction. Since Module is created per transaction - * this means that it must be safe to cache result of first call. + * Returns 'live' object that was configured using this object. It is allowed to + * call this method only after all ConfigBeans were validated. In this method + * new resources might be opened or old instance might be modified. This method + * must be implemented so that it returns same result for a single transaction. + * Since Module is created per transaction this means that it must be safe to + * cache result of first call. * * - * @return closeable instance: After bundle update the factory might be able - * to copy old configuration into new one without being able to cast - * Module or the instance. Thus to clean up old instance, it will - * call close(). + * @return closeable instance: After bundle update the factory might be able to + * copy old configuration into new one without being able to cast Module + * or the instance. Thus to clean up old instance, it will call close(). */ AutoCloseable getInstance(); - /** * Compare current module with oldModule and if the instance/live object * produced by the old module can be reused in this module as well return true. - * Typically true should be returned if the old module had the same configuration. + * Typically true should be returned if the old module had the same + * configuration. * * - * @param oldModule old instance of Module - * @return true if the instance produced by oldModule can be reused with current instance as well. + * @param oldModule + * old instance of Module + * @return true if the instance produced by oldModule can be reused with current + * instance as well. */ boolean canReuse(Module oldModule); - - } diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/spi/ModuleFactory.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/spi/ModuleFactory.java index 1a8c140c63..37dcd65d0a 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/spi/ModuleFactory.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/spi/ModuleFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -19,15 +19,16 @@ import org.osgi.framework.BundleContext; * needs to be exported into the OSGi Service Registry. Such an instance * provides metadata describing services which can be published from it. * + *

* Each {@link Module} can optionally be instantiated with a - * {@link javax.management.DynamicMBean} which represents the configuration of the currently - * running instance. + * {@link javax.management.DynamicMBean} which represents the configuration of + * the currently running instance. */ public interface ModuleFactory { /** - * Returns the human-friendly implementation name. This value needs to be - * unique within all implementations of all interfaces returned by + * Returns the human-friendly implementation name. This value needs to be unique + * within all implementations of all interfaces returned by * getImplementedInterfaces(). * * @return human-friendly implementation name @@ -42,24 +43,25 @@ public interface ModuleFactory { * @param dependencyResolver * This resolver will return actual config mbean based on its * ObjectName. - * @param bundleContext Reference to OSGi bundleContext that can be used to - * acquire OSGi services, startup configuration and other - * OSGi related information. + * @param bundleContext + * Reference to OSGi bundleContext that can be used to acquire OSGi + * services, startup configuration and other OSGi related + * information. * * @return newly created module * */ - Module createModule(String instanceName, - DependencyResolver dependencyResolver, BundleContext bundleContext); + Module createModule(String instanceName, DependencyResolver dependencyResolver, BundleContext bundleContext); /** * Create a new Module instance. The returned object is expected to use the * dependencyResolver provided when resolving ObjectNames to actual Module - * instances. A reference to an abstract view of the previous configuration - * is also provided in the form of a {@link javax.management.DynamicMBean}. Implementations - * should use the MBeanInfo interface to understand the structure of the - * configuration information. + * instances. A reference to an abstract view of the previous configuration is + * also provided in the form of a {@link javax.management.DynamicMBean}. + * Implementations should use the MBeanInfo interface to understand the + * structure of the configuration information. * + *

* Structural information impacts hot-swap operations in that in order to * perform such a swap the newly loaded code needs to understand the * previously-running instance configuration layout and how to map it onto @@ -70,49 +72,49 @@ public interface ModuleFactory { * ObjectName. * @param old * existing module from platform MBeanServer that is being - * reconfigured. Implementations should inspect its attributes - * using {@link javax.management.DynamicMBean#getAttribute(String)} and set those - * attributes on newly created module. If reconfiguration of live - * instances is supported, this live instance can be retreived + * reconfigured. Implementations should inspect its attributes using + * {@link javax.management.DynamicMBean#getAttribute(String)} and set + * those attributes on newly created module. If reconfiguration of + * live instances is supported, this live instance can be retreived * using * {@link org.opendaylight.controller.config.api.DynamicMBeanWithInstance#getInstance()} * . It is possible that casting this old instance throws - * {@link ClassCastException} when OSGi bundle is being updated. - * In this case, implementation should revert to creating new - * instance. - * @param bundleContext Reference to OSGi bundleContext that can be used to - * acquire OSGi services, startup configuration and other - * OSGi related information. + * {@link ClassCastException} when OSGi bundle is being updated. In + * this case, implementation should revert to creating new instance. + * @param bundleContext + * Reference to OSGi bundleContext that can be used to acquire OSGi + * services, startup configuration and other OSGi related + * information. * * @return newly created module * @throws Exception * if it is not possible to recover configuration from old. This - * leaves server in a running state but no configuration - * transaction can be created. + * leaves server in a running state but no configuration transaction + * can be created. */ - Module createModule(String instanceName, DependencyResolver dependencyResolver, - DynamicMBeanWithInstance old, BundleContext bundleContext) throws Exception; + Module createModule(String instanceName, DependencyResolver dependencyResolver, DynamicMBeanWithInstance old, + BundleContext bundleContext) throws Exception; - boolean isModuleImplementingServiceInterface( - Class serviceInterface); + boolean isModuleImplementingServiceInterface(Class serviceInterface); Set> getImplementedServiceIntefaces(); /** - * Called when ModuleFactory is registered to config manager. - * Useful for populating the registry with pre-existing state. Since - * the method is called for each ModuleFactory separately and transaction - * is committed automatically, returned modules MUST be valid and commitable - * without any manual intervention. + * Called when ModuleFactory is registered to config manager. Useful for + * populating the registry with pre-existing state. Since the method is called + * for each ModuleFactory separately and transaction is committed automatically, + * returned modules MUST be valid and commitable without any manual + * intervention. * - * @param dependencyResolverFactory factory for getting dependency resolvers for each module. - * @param bundleContext Reference to OSGi bundleContext that can be used to - * acquire OSGi services, startup configuration and other - * OSGi related information. + * @param dependencyResolverFactory + * factory for getting dependency resolvers for each module. + * @param bundleContext + * Reference to OSGi bundleContext that can be used to acquire OSGi + * services, startup configuration and other OSGi related + * information. * * @return set of default modules. Null is not allowed. */ Set getDefaultModules(DependencyResolverFactory dependencyResolverFactory, BundleContext bundleContext); - } diff --git a/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/IdentityAttributeRefTest.java b/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/IdentityAttributeRefTest.java index 5533152b9a..b3c2d7461b 100644 --- a/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/IdentityAttributeRefTest.java +++ b/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/IdentityAttributeRefTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -55,10 +55,10 @@ public class IdentityAttributeRefTest { @Test public void testResolveIdentity() throws Exception { DependencyResolver res = mock(DependencyResolver.class); - IdentityAttributeRef a = new IdentityAttributeRef("abcd"); - doReturn(SubIdentity.class).when(res).resolveIdentity(a, Identity.class); - a.resolveIdentity(res, Identity.class); - verify(res).resolveIdentity(a, Identity.class); + IdentityAttributeRef identityAttributeRef = new IdentityAttributeRef("abcd"); + doReturn(SubIdentity.class).when(res).resolveIdentity(identityAttributeRef, Identity.class); + identityAttributeRef.resolveIdentity(res, Identity.class); + verify(res).resolveIdentity(identityAttributeRef, Identity.class); } @Test diff --git a/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/JmxAttributeTest.java b/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/JmxAttributeTest.java index 917218277e..cb0bbafb3a 100644 --- a/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/JmxAttributeTest.java +++ b/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/JmxAttributeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/JmxAttributeValidationExceptionTest.java b/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/JmxAttributeValidationExceptionTest.java index 4df59addc2..c39710acd7 100644 --- a/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/JmxAttributeValidationExceptionTest.java +++ b/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/JmxAttributeValidationExceptionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -26,8 +26,9 @@ public class JmxAttributeValidationExceptionTest { @Test public void testJmxAttributeValidationExceptionElement() throws Exception { JmxAttribute attributeName = new JmxAttribute("attr_name"); - JmxAttributeValidationException e = new JmxAttributeValidationException(attributeName); - assertThat(e.getAttributeNames(), CoreMatchers.hasItem(attributeName)); + JmxAttributeValidationException jmxAttributeValidationException = new JmxAttributeValidationException( + attributeName); + assertThat(jmxAttributeValidationException.getAttributeNames(), CoreMatchers.hasItem(attributeName)); } @Test @@ -36,8 +37,9 @@ public class JmxAttributeValidationExceptionTest { attributeNames.add(new JmxAttribute("att1")); attributeNames.add(new JmxAttribute("att2")); attributeNames.add(new JmxAttribute("att3")); - JmxAttributeValidationException e = new JmxAttributeValidationException(attributeNames); - assertEquals(e.getAttributeNames(), attributeNames); + JmxAttributeValidationException jmxAttributeValidationException = new JmxAttributeValidationException( + attributeNames); + assertEquals(jmxAttributeValidationException.getAttributeNames(), attributeNames); } @Test @@ -46,17 +48,17 @@ public class JmxAttributeValidationExceptionTest { attributeNames.add(new JmxAttribute("att1")); attributeNames.add(new JmxAttribute("att2")); attributeNames.add(new JmxAttribute("att3")); - JmxAttributeValidationException e = new JmxAttributeValidationException("exception str", - new AccessDeniedException(""), attributeNames); - assertEquals(e.getAttributeNames(), attributeNames); + JmxAttributeValidationException jmxAttributeValidationException = new JmxAttributeValidationException( + "exception str", new AccessDeniedException(""), attributeNames); + assertEquals(jmxAttributeValidationException.getAttributeNames(), attributeNames); } @Test public void testJmxAttributeValidationExceptionJmxElement() throws Exception { JmxAttribute attributeName = new JmxAttribute("attr_name"); - JmxAttributeValidationException e = new JmxAttributeValidationException("exception str", - new AccessDeniedException(""), attributeName); - assertEquals(e.getAttributeNames(), Arrays.asList(attributeName)); + JmxAttributeValidationException jmxAttributeValidationException = new JmxAttributeValidationException( + "exception str", new AccessDeniedException(""), attributeName); + assertEquals(jmxAttributeValidationException.getAttributeNames(), Arrays.asList(attributeName)); } @Test @@ -88,8 +90,9 @@ public class JmxAttributeValidationExceptionTest { JmxAttributeValidationException.checkCondition(false, "message", jmxAttribute); } - private void assertJmxEx(final JmxAttributeValidationException e, final String message, final JmxAttribute... attrNames) { - assertEquals(message, e.getMessage()); - assertEquals(Lists.newArrayList(attrNames), e.getAttributeNames()); + private void assertJmxEx(final JmxAttributeValidationException jmxAttributeValidationException, + final String message, final JmxAttribute... attrNames) { + assertEquals(message, jmxAttributeValidationException.getMessage()); + assertEquals(Lists.newArrayList(attrNames), jmxAttributeValidationException.getAttributeNames()); } -} \ No newline at end of file +} diff --git a/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/ModuleIdentifierTest.java b/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/ModuleIdentifierTest.java index edfcc26113..2e78e69ed4 100644 --- a/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/ModuleIdentifierTest.java +++ b/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/ModuleIdentifierTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -19,12 +19,12 @@ public class ModuleIdentifierTest { @Test(expected = IllegalArgumentException.class) public void testConstructor() throws Exception { - ModuleIdentifier m = new ModuleIdentifier(null, "instance"); + ModuleIdentifier moduleIdentifier = new ModuleIdentifier(null, "instance"); } @Test(expected = IllegalArgumentException.class) public void testConstructor2() throws Exception { - ModuleIdentifier m = new ModuleIdentifier("name", null); + ModuleIdentifier moduleIdentifier = new ModuleIdentifier("name", null); } @Test @@ -63,7 +63,7 @@ public class ModuleIdentifierTest { @Test public void testToString() throws Exception { - assertEquals( new ModuleIdentifier("factory", "instance").toString(), + assertEquals(new ModuleIdentifier("factory", "instance").toString(), new ModuleIdentifier("factory", "instance").toString()); } } diff --git a/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/ValidationExceptionTest.java b/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/ValidationExceptionTest.java index 3f4bd85823..5f6db7291a 100644 --- a/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/ValidationExceptionTest.java +++ b/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/ValidationExceptionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -26,16 +26,18 @@ public class ValidationExceptionTest { private final String instance2 = "instance2"; private final ModuleIdentifier mi2 = new ModuleIdentifier("module", instance2); private final String message = "ex message"; - private final Exception e = new IllegalStateException(message); + private final Exception exception = new IllegalStateException(message); @Test public void testCreateFromCollectedValidationExceptions() throws Exception { - ValidationException single = ValidationException.createForSingleException(mi, e); - ValidationException single2 = ValidationException.createForSingleException(mi2, e); + ValidationException single = ValidationException.createForSingleException(mi, exception); + ValidationException single2 = ValidationException.createForSingleException(mi2, exception); - ValidationException collected = ValidationException.createFromCollectedValidationExceptions(Lists.newArrayList(single, single2)); + ValidationException collected = ValidationException + .createFromCollectedValidationExceptions(Lists.newArrayList(single, single2)); - Map> failedMap = collected.getFailedValidations(); + Map> failedMap = collected + .getFailedValidations(); assertEquals(1, failedMap.size()); assertTrue(failedMap.containsKey("module")); @@ -49,8 +51,8 @@ public class ValidationExceptionTest { @Test public void testCreateFromCollectedValidationExceptionsWithDuplicate() throws Exception { - ValidationException single = ValidationException.createForSingleException(mi, e); - ValidationException single2 = ValidationException.createForSingleException(mi, e); + ValidationException single = ValidationException.createForSingleException(mi, exception); + ValidationException single2 = ValidationException.createForSingleException(mi, exception); try { ValidationException.createFromCollectedValidationExceptions(Lists.newArrayList(single, single2)); } catch (final IllegalArgumentException ex) { @@ -63,104 +65,112 @@ public class ValidationExceptionTest { @Test public void testGetTrace() throws Exception { - ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace(); + ValidationException.ExceptionMessageWithStackTrace exp = + new ValidationException.ExceptionMessageWithStackTrace(); exp.setTrace("trace"); Assert.assertEquals(exp.getTrace(), "trace"); } @Test public void testSetMessage() throws Exception { - ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace(); + ValidationException.ExceptionMessageWithStackTrace exp = + new ValidationException.ExceptionMessageWithStackTrace(); exp.setMessage("message"); Assert.assertEquals(exp.getMessage(), "message"); } @Test public void testHashCode() throws Exception { - ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace(); + ValidationException.ExceptionMessageWithStackTrace exp = + new ValidationException.ExceptionMessageWithStackTrace(); Assert.assertEquals(exp.hashCode(), new ValidationException.ExceptionMessageWithStackTrace().hashCode()); } @Test public void testExceptionMessageWithStackTraceConstructor() throws Exception { - ValidationException.ExceptionMessageWithStackTrace exp = - new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"); + ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace( + "string1", "string2"); Assert.assertEquals(exp, exp); } @Test public void testExceptionMessageWithStackTraceConstructor2() throws Exception { - ValidationException.ExceptionMessageWithStackTrace exp = - new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"); + ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace( + "string1", "string2"); Assert.assertNotEquals(exp, null); } @Test public void testExceptionMessageWithStackTraceConstructor3() throws Exception { - ValidationException.ExceptionMessageWithStackTrace exp = - new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"); + ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace( + "string1", "string2"); Assert.assertNotEquals(exp, new Exception()); } @Test public void testExceptionMessageWithStackTraceConstructor4() throws Exception { - ValidationException.ExceptionMessageWithStackTrace exp = - new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"); + ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace( + "string1", "string2"); Assert.assertEquals(exp, new ValidationException.ExceptionMessageWithStackTrace("string1", "string2")); } @Test public void testEqual() throws Exception { - ValidationException.ExceptionMessageWithStackTrace exp = - new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"); + ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace( + "string1", "string2"); ValidationException.ExceptionMessageWithStackTrace exp2 = - new ValidationException.ExceptionMessageWithStackTrace(null, "string2"); + new ValidationException.ExceptionMessageWithStackTrace( + null, "string2"); Assert.assertNotEquals(exp, exp2); } @Test public void testEqual2() throws Exception { - ValidationException.ExceptionMessageWithStackTrace exp = - new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"); + ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace( + "string1", "string2"); ValidationException.ExceptionMessageWithStackTrace exp2 = - new ValidationException.ExceptionMessageWithStackTrace("different", "string2"); + new ValidationException.ExceptionMessageWithStackTrace( + "different", "string2"); Assert.assertNotEquals(exp, exp2); } - @Test public void testEqual3() throws Exception { - ValidationException.ExceptionMessageWithStackTrace exp = - new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"); + ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace( + "string1", "string2"); ValidationException.ExceptionMessageWithStackTrace exp2 = - new ValidationException.ExceptionMessageWithStackTrace("string1", null); + new ValidationException.ExceptionMessageWithStackTrace( + "string1", null); Assert.assertNotEquals(exp, exp2); } @Test public void testEqual4() throws Exception { - ValidationException.ExceptionMessageWithStackTrace exp = - new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"); + ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace( + "string1", "string2"); ValidationException.ExceptionMessageWithStackTrace exp2 = - new ValidationException.ExceptionMessageWithStackTrace("string1", "different"); + new ValidationException.ExceptionMessageWithStackTrace( + "string1", "different"); Assert.assertNotEquals(exp, exp2); } @Test public void testEqual5() throws Exception { - ValidationException.ExceptionMessageWithStackTrace exp = - new ValidationException.ExceptionMessageWithStackTrace(null, "string2"); + ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace( + null, "string2"); ValidationException.ExceptionMessageWithStackTrace exp2 = - new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"); + new ValidationException.ExceptionMessageWithStackTrace( + "string1", "string2"); Assert.assertNotEquals(exp, exp2); } @Test public void testEqual6() throws Exception { - ValidationException.ExceptionMessageWithStackTrace exp = - new ValidationException.ExceptionMessageWithStackTrace("string1", null); + ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace( + "string1", null); ValidationException.ExceptionMessageWithStackTrace exp2 = - new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"); + new ValidationException.ExceptionMessageWithStackTrace( + "string1", "string2"); Assert.assertNotEquals(exp, exp2); } -} \ No newline at end of file +} diff --git a/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/jmx/CommitStatusTest.java b/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/jmx/CommitStatusTest.java index 299446b16e..abea9c5afd 100644 --- a/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/jmx/CommitStatusTest.java +++ b/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/jmx/CommitStatusTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -26,6 +26,7 @@ public class CommitStatusTest { reusedInst.add(new ObjectName("o2: key = val")); recreatedInst.add(new ObjectName("o3: key = k")); } + @Test public void testCommitStatus() throws Exception { CommitStatus status = new CommitStatus(newInst, reusedInst, recreatedInst); diff --git a/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/jmx/ConfigRegistryConstantsTest.java b/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/jmx/ConfigRegistryConstantsTest.java index e6a03135c7..5fb50f700b 100644 --- a/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/jmx/ConfigRegistryConstantsTest.java +++ b/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/jmx/ConfigRegistryConstantsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -8,7 +8,6 @@ package org.opendaylight.controller.config.api.jmx; - import org.junit.Test; import org.opendaylight.controller.config.api.jmx.constants.ConfigRegistryConstants; diff --git a/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/jmx/ObjectNameUtilTest.java b/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/jmx/ObjectNameUtilTest.java index 572765164c..7498561eb2 100644 --- a/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/jmx/ObjectNameUtilTest.java +++ b/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/jmx/ObjectNameUtilTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -45,7 +45,8 @@ public class ObjectNameUtilTest { assertEquals(serviceQName, ObjectNameUtil.getServiceQName(serviceReferenceON)); assertEquals(refName, ObjectNameUtil.getReferenceName(serviceReferenceON)); assertEquals(transaction, ObjectNameUtil.getTransactionName(serviceReferenceON)); - assertEquals(ObjectNameUtil.createReadOnlyServiceON(serviceQName, refName), ObjectNameUtil.withoutTransactionName(serviceReferenceON)); + assertEquals(ObjectNameUtil.createReadOnlyServiceON(serviceQName, refName), + ObjectNameUtil.withoutTransactionName(serviceReferenceON)); serviceReferenceON = ObjectNameUtil.createReadOnlyServiceON(serviceQName, refName); assertFalse(serviceReferenceON.isPattern()); @@ -124,20 +125,23 @@ public class ObjectNameUtilTest { @Test public void testChecks() throws Exception { - final ObjectName on = ObjectNameUtil.createON("customDomain", ObjectNameUtil.TYPE_KEY, ObjectNameUtil.TYPE_MODULE); + final ObjectName on = ObjectNameUtil.createON("customDomain", ObjectNameUtil.TYPE_KEY, + ObjectNameUtil.TYPE_MODULE); - assertFailure( - () -> ObjectNameUtil.checkTypeOneOf(on, ObjectNameUtil.TYPE_RUNTIME_BEAN, ObjectNameUtil.TYPE_CONFIG_TRANSACTION), IllegalArgumentException.class); + assertFailure(() -> ObjectNameUtil.checkTypeOneOf(on, ObjectNameUtil.TYPE_RUNTIME_BEAN, + ObjectNameUtil.TYPE_CONFIG_TRANSACTION), IllegalArgumentException.class); - assertFailure(() -> ObjectNameUtil.checkType(on, ObjectNameUtil.TYPE_RUNTIME_BEAN), IllegalArgumentException.class); + assertFailure(() -> ObjectNameUtil.checkType(on, ObjectNameUtil.TYPE_RUNTIME_BEAN), + IllegalArgumentException.class); assertFailure(() -> ObjectNameUtil.checkDomain(on), IllegalArgumentException.class); } + @SuppressWarnings("IllegalCatch") private void assertFailure(final Runnable test, final Class ex) { try { test.run(); - } catch(final Exception e) { + } catch (final Exception e) { assertTrue("Failed with wrong exception: " + Throwables.getStackTraceAsString(e), e.getClass().isAssignableFrom(ex)); return;