Fix checkstyle issues to enforce it.
Change-Id: I6e876b21f092b6d10e6f9ee1304ddf5a535dcb13
Signed-off-by: David Suarez <david.suarez.fuentes@gmail.com>
<?xml version="1.0" encoding="UTF-8"?>
<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>binding-parent</artifactId>
<version>0.12.0-SNAPSHOT</version>
- <relativePath/>
+ <relativePath />
</parent>
<groupId>org.opendaylight.controller</groupId>
to make sure anyone dependending on this artifact inherits it -->
<scope>compile</scope>
</dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>mockito-configuration</artifactId>
- </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>mockito-configuration</artifactId>
+ </dependency>
</dependencies>
<build>
<plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+ </configuration>
+ </plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
/*
- * 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,
*
* @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
throws ConflictingVersionException, ValidationException;
/**
+ * List of open configuration transactions.
+ *
* @return list of open configuration transactions.
*/
List<ObjectName> 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<String> getAvailableModuleNames();
-
}
/*
- * 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,
* 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.
* @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
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<String> getAvailableModuleNames();
-
}
/*
- * 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,
public interface DependencyResolver extends Identifiable<ModuleIdentifier> {
/**
- * 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<? extends AbstractServiceInterface> expectedServiceInterface,
- ObjectName objectName, JmxAttribute jmxAttribute);
+ void validateDependency(Class<? extends AbstractServiceInterface> 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> T resolveInstance(Class<T> expectedType, ObjectName objectName,
- JmxAttribute jmxAttribute);
-
+ <T> T resolveInstance(Class<T> expectedType, ObjectName objectName, JmxAttribute jmxAttribute);
/**
* To be used during commit phase to resolve identity-ref config attributes.
*
* @return actual class object generated from identity
*/
- <T extends BaseIdentity> Class<? extends T> resolveIdentity(IdentityAttributeRef identityRef, Class<T> expectedBaseClass);
-
+ <T extends BaseIdentity> Class<? extends T> resolveIdentity(IdentityAttributeRef identityRef,
+ Class<T> expectedBaseClass);
/**
* Validate identity-ref config attribute.
*/
- <T extends BaseIdentity> void validateIdentity(IdentityAttributeRef identityRef, Class<T> expectedBaseClass, JmxAttribute jmxAttribute);
+ <T extends BaseIdentity> void validateIdentity(IdentityAttributeRef identityRef, Class<T> 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 <T> 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 <T>
+ * type of proxy for type safe return value
* @return instance of MXBean proxy
*/
<T> T newMXBeanProxy(ObjectName objectName, Class<T> 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);
/*
- * 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,
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 <T extends BaseIdentity> Class<? extends T> resolveIdentity(final DependencyResolver resolver, final Class<T> baseIdentity) {
+ public <T extends BaseIdentity> Class<? extends T> resolveIdentity(final DependencyResolver resolver,
+ final Class<T> baseIdentity) {
return resolver.resolveIdentity(this, baseIdentity);
}
- public <T extends BaseIdentity> void validateIdentity(final DependencyResolver resolver, final Class<T> baseIdentity, final JmxAttribute jmxAttribute) {
+ public <T extends BaseIdentity> void validateIdentity(final DependencyResolver resolver,
+ final Class<T> 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;
}
@Override
public int hashCode() {
- return qNameOfIdentity.hashCode();
+ return qualifiedNameOfIdentity.hashCode();
}
-
}
/*
- * 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,
}
@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;
/*
- * 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,
* Find modules with given module name.
*
* @param moduleName
+ * name of module
* @return objectNames
*/
Set<ObjectName> lookupConfigBeans(String moduleName);
* 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<ObjectName> lookupConfigBeans(String moduleName, String instanceName);
* 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.
*/
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<String> getAvailableModuleFactoryQNames();
/**
- * Find all runtime beans
+ * Find all runtime beans.
*
* @return objectNames
*/
Set<ObjectName> lookupRuntimeBeans();
/**
- * Find all runtime of specified module
+ * Find all runtime of specified module.
*
* @param moduleName
* of bean
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) {
}
@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;
/*
- * 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,
* 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);
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);
Map<String /* serviceInterfaceQName */, Map<String/* refName */, ObjectName>> 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<String /* refName */, ObjectName> 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<String> 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;
-
}
/*
- * 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,
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;
/**
* Remove all service references attached to given module.
+ *
* @return true iif at least one reference was removed
*/
boolean removeServiceReferences(ObjectName objectName) throws InstanceNotFoundException;
/*
- * 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,
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<String/* module name */, Map<String/* instance name */, ExceptionMessageWithStackTrace>> failedValidations;
+ private final Map<String/* module name */,
+ Map<String/* instance name */,
+ ExceptionMessageWithStackTrace>> failedValidations;
public ValidationException(
- final Map<String /* module name */, Map<String /* instance name */, ExceptionMessageWithStackTrace>> failedValidations) {
+ final Map<String /* module name */,
+ Map<String /* instance name */,
+ ExceptionMessageWithStackTrace>> failedValidations) {
super(failedValidations.toString());
this.failedValidations = Collections.unmodifiableMap(failedValidations);
}
final List<ValidationException> collectedExceptions) {
Map<String, Map<String, ExceptionMessageWithStackTrace>> failedValidations = new HashMap<>();
for (ValidationException ve : collectedExceptions) {
- for (Entry<String, Map<String, ExceptionMessageWithStackTrace>> outerEntry : ve
- .getFailedValidations().entrySet()) {
- for (Entry<String, ExceptionMessageWithStackTrace> innerEntry : outerEntry
- .getValue().entrySet()) {
+ for (Entry<String, Map<String, ExceptionMessageWithStackTrace>> outerEntry : ve.getFailedValidations()
+ .entrySet()) {
+ for (Entry<String, ExceptionMessageWithStackTrace> innerEntry : outerEntry.getValue().entrySet()) {
String moduleName = outerEntry.getKey();
String instanceName = innerEntry.getKey();
ExceptionMessageWithStackTrace ex = innerEntry.getValue();
Map<String, ExceptionMessageWithStackTrace> 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);
}
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<String, Map<String, ExceptionMessageWithStackTrace>> failedValidations = new HashMap<>();
Map<String, ExceptionMessageWithStackTrace> 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<String/* module name */, Map<String/* instance name */, ExceptionMessageWithStackTrace>> getFailedValidations() {
+ public Map<String/* module name */,
+ Map<String/* instance name */,
+ ExceptionMessageWithStackTrace>> getFailedValidations() {
return failedValidations;
}
public static class ExceptionMessageWithStackTrace {
- private String message, stackTrace;
+ private String message;
+ private String stackTrace;
public ExceptionMessageWithStackTrace() {
}
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() {
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;
}
public String toString() {
return message;
}
-
}
}
/*
- * 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,
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();
}
/*
- * 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,
@Immutable
public class CommitStatus {
- private final List<ObjectName> newInstances, reusedInstances,
- recreatedInstances;
+ private final List<ObjectName> newInstances;
+ private final List<ObjectName> reusedInstances;
+ private final List<ObjectName> 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<ObjectName> newInstances,
- final List<ObjectName> reusedInstances,
- final List<ObjectName> recreatedInstances) {
+ @ConstructorProperties({ "newInstances", "reusedInstances", "recreatedInstances" })
+ public CommitStatus(final List<ObjectName> newInstances, final List<ObjectName> reusedInstances,
+ final List<ObjectName> 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<ObjectName> getNewInstances() {
return newInstances;
}
- /**
- * @return list of objectNames representing reused instances
- */
public List<ObjectName> getReusedInstances() {
return reusedInstances;
}
- /**
- * @return list of objectNames representing recreated instances
- */
public List<ObjectName> getRecreatedInstances() {
return recreatedInstances;
}
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;
}
@Override
public String toString() {
- return "CommitStatus [newInstances=" + newInstances
- + ", reusedInstances=" + reusedInstances
+ return "CommitStatus [newInstances=" + newInstances + ", reusedInstances=" + reusedInstances
+ ", recreatedInstances=" + recreatedInstances + "]";
}
/*
- * 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,
* {@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";
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);
}
}
- 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);
}
}
- 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<String, String> onParams = new HashMap<>();
onParams.put(TRANSACTION_NAME_KEY, transactionName);
onParams.put(TYPE_KEY, TYPE_CONFIG_TRANSACTION);
}
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<String, String> 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<String, String> onParams = createModuleMap(moduleName, instanceName);
+ return createON(ON_DOMAIN, onParams);
}
public static ObjectName createReadOnlyServiceON(final String serviceQName, final String refName) {
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<String, String> onParams = createServiceON(transactionName, serviceQName, refName);
return createON(ON_DOMAIN, onParams);
}
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) {
}
private static Map<String, String> createServiceON(final String transactionName, final String serviceQName,
- final String refName) {
+ final String refName) {
Map<String, String> result = new HashMap<>(createServiceMap(serviceQName, refName));
result.put(TRANSACTION_NAME_KEY, transactionName);
return result;
}
- private static Map<String, String> createServiceMap(final String serviceQName,
- final String refName) {
+ private static Map<String, String> createServiceMap(final String serviceQName, final String refName) {
Map<String, String> onParams = new HashMap<>();
onParams.put(TYPE_KEY, TYPE_SERVICE_REFERENCE);
onParams.put(SERVICE_QNAME_KEY, quoteAndEscapeValue(serviceQName));
return onParams;
}
-
- public static ObjectName createReadOnlyModuleON(final String moduleName,
- final String instanceName) {
- Map<String, String> onParams = createModuleMap(moduleName, instanceName);
- return createON(ON_DOMAIN, onParams);
- }
-
- private static Map<String, String> createModuleMap(final String moduleName,
- final String instanceName) {
+ private static Map<String, String> createModuleMap(final String moduleName, final String instanceName) {
Map<String, String> onParams = new HashMap<>();
onParams.put(TYPE_KEY, TYPE_MODULE);
onParams.put(MODULE_FACTORY_NAME_KEY, moduleName);
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<String, String> outputProperties;
if (inputON.getKeyProperty(TYPE_KEY).equals(TYPE_MODULE)) {
}
- private static void assertDoesNotContain(
- final Map<String, String> additionalProperties, final String key) {
+ private static void assertDoesNotContain(final Map<String, String> 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<String, String> additionalProperties) {
+ public static ObjectName createRuntimeBeanName(final String moduleName, final String instanceName,
+ final Map<String, String> additionalProperties) {
// check that there is no overwriting of default attributes
assertDoesNotContain(additionalProperties, MODULE_FACTORY_NAME_KEY);
assertDoesNotContain(additionalProperties, INSTANCE_NAME_KEY);
return createON(ON_DOMAIN, map);
}
- private static Set<String> blacklist = new HashSet<>(Arrays.asList(
- MODULE_FACTORY_NAME_KEY, INSTANCE_NAME_KEY, TYPE_KEY));
+ private static Set<String> blacklist = new HashSet<>(
+ Arrays.asList(MODULE_FACTORY_NAME_KEY, INSTANCE_NAME_KEY, TYPE_KEY));
- public static Map<String, String> getAdditionalPropertiesOfRuntimeBeanName(
- final ObjectName on) {
+ public static Map<String, String> getAdditionalPropertiesOfRuntimeBeanName(final ObjectName on) {
checkType(on, TYPE_RUNTIME_BEAN);
Map<String, String> allProperties = getAdditionalProperties(on);
Map<String, String> result = new HashMap<>();
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);
}
}
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);
}
/*
- * 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,
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";
/*
- * 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,
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
return "CommitJMXNotification{}";
}
- /**
- *
- */
private static final long serialVersionUID = -8587623362011695514L;
-
}
/*
- * 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,
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;
}
}
/**
- * 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
}
-
}
/*
- * 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,
/**
* 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 <T> WaitingServiceTracker<T> create(@Nonnull final Class<T> serviceInterface, @Nonnull final BundleContext context) {
+ public static <T> WaitingServiceTracker<T> create(@Nonnull final Class<T> serviceInterface,
+ @Nonnull final BundleContext context) {
ServiceTracker<T, ?> tracker = new ServiceTracker<>(context, serviceInterface, null);
tracker.open();
return new WaitingServiceTracker<>(serviceInterface, tracker);
/**
* 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 <T> WaitingServiceTracker<T> create(@Nonnull final Class<T> serviceInterface, @Nonnull final BundleContext context,
- @Nonnull final String filter) {
+ public static <T> WaitingServiceTracker<T> create(@Nonnull final Class<T> serviceInterface,
+ @Nonnull final BundleContext context, @Nonnull final String filter) {
String newFilter = String.format("(&(%s=%s)%s)", Constants.OBJECTCLASS, serviceInterface.getName(), filter);
try {
ServiceTracker<T, ?> 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();
}
}
/*
- * 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,
package org.opendaylight.controller.config.api.runtime;
/**
- * Marker interface for all runtime beans
+ * Marker interface for all runtime beans.
*/
public interface RuntimeBean {
/*
- * 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,
import org.slf4j.LoggerFactory;
/**
- * Base implementation of Module. This implementation contains base logic for Module reconfiguration with associated fields.
- * @param <M> Type of module implementation. Enables easier implementation for the <code>isSame()</code> method
+ * Base implementation of Module. This implementation contains base logic for
+ * Module reconfiguration with associated fields.
+ *
+ * @param <M>
+ * Type of module implementation. Enables easier implementation for
+ * the <code>isSame()</code> method
*/
-public abstract class AbstractModule<M extends AbstractModule<M>> implements org.opendaylight.controller.config.spi.Module {
+public abstract class AbstractModule<M extends AbstractModule<M>>
+ implements org.opendaylight.controller.config.spi.Module {
private static final Logger LOG = LoggerFactory.getLogger(AbstractModule.class);
/**
* 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);
/**
* 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;
}
/**
- *
* 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)) {
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;
}
}
/**
- * @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;
}
/*
- * 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,
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
* ConfigBeans.
* <p>
* 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}.
* </p>
* <p>
* Thread safety note: implementations of this interface are not required to be
* </p>
*/
@NotThreadSafe
-public interface Module extends Identifiable<ModuleIdentifier>{
+public interface Module extends Identifiable<ModuleIdentifier> {
/**
- * 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);
-
-
}
/*
- * 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,
* needs to be exported into the OSGi Service Registry. Such an instance
* provides metadata describing services which can be published from it.
*
+ * <p>
* 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
* @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.
*
+ * <p>
* 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
* 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<? extends AbstractServiceInterface> serviceInterface);
+ boolean isModuleImplementingServiceInterface(Class<? extends AbstractServiceInterface> serviceInterface);
Set<Class<? extends AbstractServiceInterface>> 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<? extends Module> getDefaultModules(DependencyResolverFactory dependencyResolverFactory,
BundleContext bundleContext);
-
}
/*
- * 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,
@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
/*
- * 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,
/*
- * 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,
@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
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
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
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
+}
/*
- * 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,
@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
@Test
public void testToString() throws Exception {
- assertEquals( new ModuleIdentifier("factory", "instance").toString(),
+ assertEquals(new ModuleIdentifier("factory", "instance").toString(),
new ModuleIdentifier("factory", "instance").toString());
}
}
/*
- * 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,
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<String, Map<String, ValidationException.ExceptionMessageWithStackTrace>> failedMap = collected.getFailedValidations();
+ Map<String, Map<String, ValidationException.ExceptionMessageWithStackTrace>> failedMap = collected
+ .getFailedValidations();
assertEquals(1, failedMap.size());
assertTrue(failedMap.containsKey("module"));
@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) {
@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
+}
/*
- * 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,
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);
/*
- * 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,
package org.opendaylight.controller.config.api.jmx;
-
import org.junit.Test;
import org.opendaylight.controller.config.api.jmx.constants.ConfigRegistryConstants;
/*
- * 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,
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());
@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<? extends Exception> 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;