private final String type;
private final boolean rw;
- public AttributeEntry(String key, String description, Object value,
- String type, boolean rw) {
+ public AttributeEntry(final String key, final String description, final Object value,
+ final String type, final boolean rw) {
this.key = key;
this.description = description;
this.value = value;
private CloseableUtil() {
}
- public static void closeAll(Iterable<? extends AutoCloseable> autoCloseables) throws Exception {
+ public static void closeAll(final Iterable<? extends AutoCloseable> autoCloseables) throws Exception {
Exception lastException = null;
for (AutoCloseable autoCloseable : autoCloseables) {
try {
autoCloseable.close();
- } catch (Exception e) {
+ } catch (final Exception e) {
if (lastException == null) {
lastException = e;
} else {
private final ObjectName configRegistryON;
private final MBeanServer configMBeanServer;
- public ConfigRegistryJMXClient(MBeanServer configMBeanServer) {
+ public ConfigRegistryJMXClient(final MBeanServer configMBeanServer) {
this(configMBeanServer, OBJECT_NAME);
}
- private ConfigRegistryJMXClient(MBeanServer configMBeanServer, ObjectName configRegistryON) {
+ private ConfigRegistryJMXClient(final MBeanServer configMBeanServer, final ObjectName configRegistryON) {
this.configMBeanServer = configMBeanServer;
this.configRegistryON = configRegistryON;
Set<ObjectInstance> searchResult = configMBeanServer.queryMBeans(configRegistryON, null);
false);
}
- public static ConfigRegistryJMXClient createWithoutNotifications(MBeanServer configMBeanServer) {
+ public static ConfigRegistryJMXClient createWithoutNotifications(final MBeanServer configMBeanServer) {
return new ConfigRegistryJMXClient(configMBeanServer, ConfigRegistryConstants.OBJECT_NAME_NO_NOTIFICATIONS);
}
@Override
public ConfigTransactionJMXClient getConfigTransactionClient(
- String transactionName) {
+ final String transactionName) {
ObjectName objectName = ObjectNameUtil
.createTransactionControllerON(transactionName);
return getConfigTransactionClient(objectName);
@Override
public ConfigTransactionJMXClient getConfigTransactionClient(
- ObjectName objectName) {
+ final ObjectName objectName) {
return new ConfigTransactionJMXClient(configRegistryMXBeanProxy, objectName,
configMBeanServer);
}
* This method will be removed soon.
*/
@Deprecated
- public <T> T newMBeanProxy(ObjectName on, Class<T> clazz) {
+ public <T> T newMBeanProxy(final ObjectName on, final Class<T> clazz) {
ObjectName onObj = translateServiceRefIfPossible(on, clazz, configMBeanServer);
return JMX.newMBeanProxy(configMBeanServer, onObj, clazz);
}
- static ObjectName translateServiceRefIfPossible(ObjectName on, Class<?> clazz, MBeanServer configMBeanServer) {
+ static ObjectName translateServiceRefIfPossible(final ObjectName on, final Class<?> clazz, final MBeanServer configMBeanServer) {
ObjectName onObj = on;
if (ObjectNameUtil.isServiceReference(onObj) && !clazz.equals(ServiceReferenceMXBean.class)) {
ServiceReferenceMXBean proxy = JMX.newMXBeanProxy(configMBeanServer, onObj, ServiceReferenceMXBean.class);
}
- public <T> T newMXBeanProxy(ObjectName on, Class<T> clazz) {
+ public <T> T newMXBeanProxy(final ObjectName on, final Class<T> clazz) {
return JMX.newMXBeanProxy(configMBeanServer, on, clazz);
}
}
@Override
- public CommitStatus commitConfig(ObjectName transactionControllerON)
+ public CommitStatus commitConfig(final ObjectName transactionControllerON)
throws ConflictingVersionException, ValidationException {
return configRegistryMXBeanProxy.commitConfig(transactionControllerON);
}
try {
return (Long) configMBeanServer.getAttribute(configRegistryON,
"Version");
- } catch (JMException e) {
+ } catch (final JMException e) {
throw new RuntimeException(e);
}
}
}
@Override
- public Set<ObjectName> lookupConfigBeans(String moduleName) {
+ public Set<ObjectName> lookupConfigBeans(final String moduleName) {
return configRegistryMXBeanProxy.lookupConfigBeans(moduleName);
}
@Override
- public Set<ObjectName> lookupConfigBeans(String moduleName,
- String instanceName) {
+ public Set<ObjectName> lookupConfigBeans(final String moduleName,
+ final String instanceName) {
return configRegistryMXBeanProxy.lookupConfigBeans(moduleName, instanceName);
}
@Override
- public ObjectName lookupConfigBean(String moduleName, String instanceName)
+ public ObjectName lookupConfigBean(final String moduleName, final String instanceName)
throws InstanceNotFoundException {
return configRegistryMXBeanProxy.lookupConfigBean(moduleName, instanceName);
}
}
@Override
- public Set<ObjectName> lookupRuntimeBeans(String ifcName,
- String instanceName) {
+ public Set<ObjectName> lookupRuntimeBeans(final String ifcName,
+ final String instanceName) {
return configRegistryMXBeanProxy.lookupRuntimeBeans(ifcName, instanceName);
}
@Override
- public void checkConfigBeanExists(ObjectName objectName) throws InstanceNotFoundException {
+ public void checkConfigBeanExists(final ObjectName objectName) throws InstanceNotFoundException {
configRegistryMXBeanProxy.checkConfigBeanExists(objectName);
}
@Override
- public ObjectName lookupConfigBeanByServiceInterfaceName(String serviceInterfaceQName, String refName) {
+ public ObjectName lookupConfigBeanByServiceInterfaceName(final String serviceInterfaceQName, final String refName) {
return configRegistryMXBeanProxy.lookupConfigBeanByServiceInterfaceName(serviceInterfaceQName, refName);
}
}
@Override
- public Map<String, ObjectName> lookupServiceReferencesByServiceInterfaceName(String serviceInterfaceQName) {
+ public Map<String, ObjectName> lookupServiceReferencesByServiceInterfaceName(final String serviceInterfaceQName) {
return configRegistryMXBeanProxy.lookupServiceReferencesByServiceInterfaceName(serviceInterfaceQName);
}
@Override
- public Set<String> lookupServiceInterfaceNames(ObjectName objectName) throws InstanceNotFoundException {
+ public Set<String> lookupServiceInterfaceNames(final ObjectName objectName) throws InstanceNotFoundException {
return configRegistryMXBeanProxy.lookupServiceInterfaceNames(objectName);
}
@Override
- public String getServiceInterfaceName(String namespace, String localName) {
+ public String getServiceInterfaceName(final String namespace, final String localName) {
return configRegistryMXBeanProxy.getServiceInterfaceName(namespace, localName);
}
@Override
- public Object invokeMethod(ObjectName on, String name, Object[] params,
- String[] signature) {
+ public Object invokeMethod(final ObjectName on, final String name, final Object[] params,
+ final String[] signature) {
try {
return configMBeanServer.invoke(on, name, params, signature);
} catch (InstanceNotFoundException | ReflectionException
}
@Override
- public Object getAttributeCurrentValue(ObjectName on, String attributeName) {
+ public Object getAttributeCurrentValue(final ObjectName on, final String attributeName) {
try {
return configMBeanServer.getAttribute(on, attributeName);
} catch (AttributeNotFoundException | InstanceNotFoundException
}
@Override
- public ObjectName getServiceReference(String serviceInterfaceQName, String refName) throws InstanceNotFoundException {
+ public ObjectName getServiceReference(final String serviceInterfaceQName, final String refName) throws InstanceNotFoundException {
return configRegistryMXBeanProxy.getServiceReference(serviceInterfaceQName, refName);
}
@Override
- public void checkServiceReferenceExists(ObjectName objectName) throws InstanceNotFoundException {
+ public void checkServiceReferenceExists(final ObjectName objectName) throws InstanceNotFoundException {
configRegistryMXBeanProxy.checkServiceReferenceExists(objectName);
}
}
private final MBeanServer configMBeanServer;
public ConfigTransactionJMXClient(
- ConfigRegistryMXBean configRegistryMXBeanProxy,
- ObjectName configTransactionControllerON,
- MBeanServer configMBeanServer) {
+ final ConfigRegistryMXBean configRegistryMXBeanProxy,
+ final ObjectName configTransactionControllerON,
+ final MBeanServer configMBeanServer) {
this.configMBeanServer = configMBeanServer;
this.configRegistryMXBeanProxy = configRegistryMXBeanProxy;
this.configTransactionControllerON = configTransactionControllerON;
ConfigTransactionControllerMXBean.class);
}
- public <T> T newMXBeanProxy(ObjectName on, Class<T> clazz) {
+ public <T> T newMXBeanProxy(final ObjectName on, final Class<T> clazz) {
ObjectName onName = on;
// if on is without transaction, add it. Reason is that when using getters on MXBeans the transaction name is stripped
onName = ObjectNameUtil.withTransactionName(onName, getTransactionName());
* This method will be removed soon.
*/
@Deprecated
- public <T> T newMBeanProxy(ObjectName on, Class<T> clazz) {
+ public <T> T newMBeanProxy(final ObjectName on, final Class<T> clazz) {
return JMX.newMBeanProxy(configMBeanServer, on, clazz);
}
}
@Override
- public void assertVersion(int expectedParentVersion,
- int expectedCurrentVersion) {
+ public void assertVersion(final int expectedParentVersion,
+ final int expectedCurrentVersion) {
if (expectedParentVersion != getParentVersion()) {
throw new IllegalStateException();
}
// proxy around ConfigManagerMXBean
@Override
- public ObjectName createModule(String moduleName, String instanceName)
+ public ObjectName createModule(final String moduleName, final String instanceName)
throws InstanceAlreadyExistsException {
return configTransactionControllerMXBeanProxy.createModule(moduleName, instanceName);
}
@Override
- public void reCreateModule(ObjectName objectName) throws InstanceNotFoundException {
+ public void reCreateModule(final ObjectName objectName) throws InstanceNotFoundException {
configTransactionControllerMXBeanProxy.reCreateModule(objectName);
}
@Override
- public void destroyModule(ObjectName objectName)
+ public void destroyModule(final ObjectName objectName)
throws InstanceNotFoundException {
configTransactionControllerMXBeanProxy.destroyModule(objectName);
}
/**
* {@inheritDoc}
*/
- public void destroyConfigBean(String moduleName, String instanceName)
+ public void destroyConfigBean(final String moduleName, final String instanceName)
throws InstanceNotFoundException {
destroyModule(ObjectNameUtil.createTransactionModuleON(
getTransactionName(), moduleName, instanceName));
}
@Override
- public void destroyModule(String moduleName, String instanceName)
+ public void destroyModule(final String moduleName, final String instanceName)
throws InstanceNotFoundException {
destroyModule(ObjectNameUtil.createTransactionModuleON(
getTransactionName(), moduleName, instanceName));
try {
return (Long) configMBeanServer.getAttribute(
configTransactionControllerON, "ParentVersion");
- } catch (JMException e) {
+ } catch (final JMException e) {
throw new RuntimeException(e);
}
}
try {
return (Long) configMBeanServer.getAttribute(
configTransactionControllerON, "Version");
- } catch (JMException e) {
+ } catch (final JMException e) {
throw new RuntimeException(e);
}
}
}
@Override
- public Set<ObjectName> lookupConfigBeans(String moduleName) {
+ public Set<ObjectName> lookupConfigBeans(final String moduleName) {
return configTransactionControllerMXBeanProxy.lookupConfigBeans(moduleName);
}
@Override
- public ObjectName lookupConfigBean(String moduleName, String instanceName)
+ public ObjectName lookupConfigBean(final String moduleName, final String instanceName)
throws InstanceNotFoundException {
return configTransactionControllerMXBeanProxy.lookupConfigBean(moduleName, instanceName);
}
@Override
- public Set<ObjectName> lookupConfigBeans(String moduleName,
- String instanceName) {
+ public Set<ObjectName> lookupConfigBeans(final String moduleName,
+ final String instanceName) {
return configTransactionControllerMXBeanProxy
.lookupConfigBeans(moduleName, instanceName);
}
@Override
- public void checkConfigBeanExists(ObjectName objectName) throws InstanceNotFoundException {
+ public void checkConfigBeanExists(final ObjectName objectName) throws InstanceNotFoundException {
configTransactionControllerMXBeanProxy.checkConfigBeanExists(objectName);
}
@Override
- public ObjectName saveServiceReference(String serviceInterfaceName, String refName, ObjectName moduleON) throws InstanceNotFoundException {
+ public ObjectName saveServiceReference(final String serviceInterfaceName, final String refName, final ObjectName moduleON) throws InstanceNotFoundException {
return configTransactionControllerMXBeanProxy.saveServiceReference(serviceInterfaceName,refName, moduleON);
}
@Override
- public void removeServiceReference(String serviceInterfaceName, String refName) throws InstanceNotFoundException{
+ public void removeServiceReference(final String serviceInterfaceName, final String refName) throws InstanceNotFoundException{
configTransactionControllerMXBeanProxy.removeServiceReference(serviceInterfaceName, refName);
}
}
@Override
- public ObjectName lookupConfigBeanByServiceInterfaceName(String serviceInterfaceQName, String refName) {
+ public ObjectName lookupConfigBeanByServiceInterfaceName(final String serviceInterfaceQName, final String refName) {
return configTransactionControllerMXBeanProxy.lookupConfigBeanByServiceInterfaceName(serviceInterfaceQName, refName);
}
}
@Override
- public Map<String, ObjectName> lookupServiceReferencesByServiceInterfaceName(String serviceInterfaceQName) {
+ public Map<String, ObjectName> lookupServiceReferencesByServiceInterfaceName(final String serviceInterfaceQName) {
return configTransactionControllerMXBeanProxy.lookupServiceReferencesByServiceInterfaceName(serviceInterfaceQName);
}
@Override
- public Set<String> lookupServiceInterfaceNames(ObjectName objectName) throws InstanceNotFoundException {
+ public Set<String> lookupServiceInterfaceNames(final ObjectName objectName) throws InstanceNotFoundException {
return configTransactionControllerMXBeanProxy.lookupServiceInterfaceNames(objectName);
}
@Override
- public String getServiceInterfaceName(String namespace, String localName) {
+ public String getServiceInterfaceName(final String namespace, final String localName) {
return configTransactionControllerMXBeanProxy.getServiceInterfaceName(namespace, localName);
}
@Override
- public boolean removeServiceReferences(ObjectName objectName) throws InstanceNotFoundException {
+ public boolean removeServiceReferences(final ObjectName objectName) throws InstanceNotFoundException {
return configTransactionControllerMXBeanProxy.removeServiceReferences(objectName);
}
@Override
- public ObjectName getServiceReference(String serviceInterfaceQName, String refName) throws InstanceNotFoundException {
+ public ObjectName getServiceReference(final String serviceInterfaceQName, final String refName) throws InstanceNotFoundException {
return configTransactionControllerMXBeanProxy.getServiceReference(serviceInterfaceQName, refName);
}
@Override
- public void checkServiceReferenceExists(ObjectName objectName) throws InstanceNotFoundException {
+ public void checkServiceReferenceExists(final ObjectName objectName) throws InstanceNotFoundException {
configTransactionControllerMXBeanProxy.checkServiceReferenceExists(objectName);
}
@Override
- public Attribute getAttribute(ObjectName on, String attrName) {
+ public Attribute getAttribute(final ObjectName on, final String attrName) {
if (ObjectNameUtil.getTransactionName(on) == null) {
throw new IllegalArgumentException("Not in transaction instance "
+ on + ", no transaction name present");
try {
return new Attribute(attrName, configMBeanServer.getAttribute(on,attrName));
- } catch (JMException e) {
+ } catch (final JMException e) {
throw new IllegalStateException("Unable to get attribute "
+ attrName + " for " + on, e);
}
}
@Override
- public Object getAttributeCurrentValue(ObjectName on, String attrName) {
+ public Object getAttributeCurrentValue(final ObjectName on, final String attrName) {
return getAttribute(on, attrName).getValue();
}
@Override
- public void validateBean(ObjectName configBeanON)
+ public void validateBean(final ObjectName configBeanON)
throws ValidationException {
try {
configMBeanServer.invoke(configBeanON, "validate", null, null);
- } catch (MBeanException e) {
+ } catch (final MBeanException e) {
Exception targetException = e.getTargetException();
if (targetException instanceof ValidationException){
throw (ValidationException) targetException;
} else {
throw new RuntimeException(e);
}
- } catch (JMException e) {
+ } catch (final JMException e) {
throw new RuntimeException(e);
}
}
@Override
- public void setAttribute(ObjectName on, String attrName, Attribute attribute) {
+ public void setAttribute(final ObjectName on, final String attrName, final Attribute attribute) {
if (ObjectNameUtil.getTransactionName(on) == null) {
throw new IllegalArgumentException("Not in transaction instance "
+ on + ", no transaction name present");
try {
configMBeanServer.setAttribute(on, attribute);
- } catch (JMException e) {
+ } catch (final JMException e) {
throw new IllegalStateException("Unable to set attribute "
+ attrName + " for " + on, e);
}
BUILDER_FACTORY.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
BUILDER_FACTORY.setXIncludeAware(false);
BUILDER_FACTORY.setExpandEntityReferences(false);
- } catch (ParserConfigurationException e) {
+ } catch (final ParserConfigurationException e) {
throw new ExceptionInInitializerError(e);
}
BUILDER_FACTORY.setNamespaceAware(true);
private final String typeValue;
- ErrorType(String typeValue) {
+ ErrorType(final String typeValue) {
this.typeValue = Preconditions.checkNotNull(typeValue);
}
return this.typeValue;
}
- public static ErrorType from(String text) {
+ public static ErrorType from(final String text) {
for (ErrorType e : values()) {
if (e.getTypeValue().equalsIgnoreCase(text)) {
return e;
return this.tagValue;
}
- public static ErrorTag from( String text ) {
+ public static ErrorTag from( final String text ) {
for( ErrorTag e: values() )
{
if( e.getTagValue().equals( text ) ) {
private final String severityValue;
- ErrorSeverity(String severityValue) {
+ ErrorSeverity(final String severityValue) {
this.severityValue = Preconditions.checkNotNull(severityValue);
}
return this.severityValue;
}
- public static ErrorSeverity from(String text) {
+ public static ErrorSeverity from(final String text) {
for (ErrorSeverity e : values()) {
if (e.getSeverityValue().equalsIgnoreCase(text)) {
return e;
private final ErrorSeverity errorSeverity;
private final Map<String, String> errorInfo;
- public DocumentedException(String message) {
+ public DocumentedException(final String message) {
this(message,
DocumentedException.ErrorType.APPLICATION,
DocumentedException.ErrorTag.INVALID_VALUE,
this.errorInfo = errorInfo;
}
- public static <E extends Exception> DocumentedException wrap(E exception) throws DocumentedException {
+ public static <E extends Exception> DocumentedException wrap(final E exception) throws DocumentedException {
final Map<String, String> errorInfo = new HashMap<>();
errorInfo.put(ErrorTag.OPERATION_FAILED.name(), "Exception thrown");
throw new DocumentedException(exception.getMessage(), exception, ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED,
ErrorSeverity.ERROR, errorInfo);
}
- public static DocumentedException wrap(ValidationException e) throws DocumentedException {
+ public static DocumentedException wrap(final ValidationException e) throws DocumentedException {
final Map<String, String> errorInfo = new HashMap<>();
errorInfo.put(ErrorTag.OPERATION_FAILED.name(), "Validation failed");
throw new DocumentedException(e.getMessage(), e, ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED,
ErrorSeverity.ERROR, errorInfo);
}
- public static DocumentedException wrap(ConflictingVersionException e) throws DocumentedException {
+ public static DocumentedException wrap(final ConflictingVersionException e) throws DocumentedException {
final Map<String, String> errorInfo = new HashMap<>();
errorInfo.put(ErrorTag.OPERATION_FAILED.name(), "Optimistic lock failed");
throw new DocumentedException(e.getMessage(), e, ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED,
ErrorSeverity.ERROR, errorInfo);
}
- public static DocumentedException fromXMLDocument( Document fromDoc ) {
+ public static DocumentedException fromXMLDocument( final Document fromDoc ) {
ErrorType errorType = ErrorType.APPLICATION;
ErrorTag errorTag = ErrorTag.OPERATION_FAILED;
return new DocumentedException( errorMessage, errorType, errorTag, errorSeverity, errorInfo );
}
- private static Map<String, String> parseErrorInfo( Node node ) {
+ private static Map<String, String> parseErrorInfo( final Node node ) {
Map<String, String> infoMap = new HashMap<>();
NodeList children = node.getChildNodes();
for( int i = 0; i < children.getLength(); i++ ) {
}
}
}
- catch( ParserConfigurationException e ) {
+ catch( final ParserConfigurationException e ) {
// this shouldn't happen
LOG.error("Error outputting to XML document", e);
}
return doc;
}
- private Node createTextNode( Document doc, String tag, String textContent ) {
+ private Node createTextNode( final Document doc, final String tag, final String textContent ) {
Node node = doc.createElementNS( URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, tag );
node.setTextContent( textContent );
return node;
private final Element element;
private static final Logger LOG = LoggerFactory.getLogger(XmlElement.class);
- private XmlElement(Element element) {
+ private XmlElement(final Element element) {
this.element = element;
}
- public static XmlElement fromDomElement(Element e) {
+ public static XmlElement fromDomElement(final Element e) {
return new XmlElement(e);
}
- public static XmlElement fromDomDocument(Document xml) {
+ public static XmlElement fromDomDocument(final Document xml) {
return new XmlElement(xml.getDocumentElement());
}
- public static XmlElement fromString(String s) throws DocumentedException {
+ public static XmlElement fromString(final String s) throws DocumentedException {
try {
return new XmlElement(XmlUtil.readXmlToElement(s));
} catch (IOException | SAXException e) {
}
}
- public static XmlElement fromDomElementWithExpected(Element element, String expectedName) throws DocumentedException {
+ public static XmlElement fromDomElementWithExpected(final Element element, final String expectedName) throws DocumentedException {
XmlElement xmlElement = XmlElement.fromDomElement(element);
xmlElement.checkName(expectedName);
return xmlElement;
}
- public static XmlElement fromDomElementWithExpected(Element element, String expectedName, String expectedNamespace) throws DocumentedException {
+ public static XmlElement fromDomElementWithExpected(final Element element, final String expectedName, final String expectedNamespace) throws DocumentedException {
XmlElement xmlElement = XmlElement.fromDomElementWithExpected(element, expectedName);
xmlElement.checkNamespace(expectedNamespace);
return xmlElement;
return namespaces;
}
- public void checkName(String expectedName) throws UnexpectedElementException {
+ public void checkName(final String expectedName) throws UnexpectedElementException {
if (!getName().equals(expectedName)){
throw new UnexpectedElementException(String.format("Expected %s xml element but was %s", expectedName,
getName()),
}
}
- public void checkNamespaceAttribute(String expectedNamespace) throws UnexpectedNamespaceException, MissingNameSpaceException {
+ public void checkNamespaceAttribute(final String expectedNamespace) throws UnexpectedNamespaceException, MissingNameSpaceException {
if (!getNamespaceAttribute().equals(expectedNamespace))
{
throw new UnexpectedNamespaceException(String.format("Unexpected namespace %s should be %s",
}
}
- public void checkNamespace(String expectedNamespace) throws UnexpectedNamespaceException, MissingNameSpaceException {
+ public void checkNamespace(final String expectedNamespace) throws UnexpectedNamespaceException, MissingNameSpaceException {
if (!getNamespace().equals(expectedNamespace))
{
throw new UnexpectedNamespaceException(String.format("Unexpected namespace %s should be %s",
return element.getTagName();
}
- public String getAttribute(String attributeName) {
+ public String getAttribute(final String attributeName) {
return element.getAttribute(attributeName);
}
- public String getAttribute(String attributeName, String namespace) {
+ public String getAttribute(final String attributeName, final String namespace) {
return element.getAttributeNS(namespace, attributeName);
}
- public NodeList getElementsByTagName(String name) {
+ public NodeList getElementsByTagName(final String name) {
return element.getElementsByTagName(name);
}
- public void appendChild(Element element) {
+ public void appendChild(final Element element) {
this.element.appendChild(element);
}
/**
* Non recursive
*/
- private List<XmlElement> getChildElementsInternal(ElementFilteringStrategy strat) {
+ private List<XmlElement> getChildElementsInternal(final ElementFilteringStrategy strat) {
NodeList childNodes = element.getChildNodes();
final List<XmlElement> result = new ArrayList<>();
for (int i = 0; i < childNodes.getLength(); i++) {
public List<XmlElement> getChildElements() {
return getChildElementsInternal(new ElementFilteringStrategy() {
@Override
- public boolean accept(Element e) {
+ public boolean accept(final Element e) {
return true;
}
});
}
- public List<XmlElement> getChildElementsWithinNamespace(final String childName, String namespace) {
+ public List<XmlElement> getChildElementsWithinNamespace(final String childName, final String namespace) {
return Lists.newArrayList(Collections2.filter(getChildElementsWithinNamespace(namespace),
new Predicate<XmlElement>() {
@Override
- public boolean apply(XmlElement xmlElement) {
+ public boolean apply(final XmlElement xmlElement) {
return xmlElement.getName().equals(childName);
}
}));
public List<XmlElement> getChildElementsWithinNamespace(final String namespace) {
return getChildElementsInternal(new ElementFilteringStrategy() {
@Override
- public boolean accept(Element e) {
+ public boolean accept(final Element e) {
try {
return XmlElement.fromDomElement(e).getNamespace().equals(namespace);
- } catch (MissingNameSpaceException e1) {
+ } catch (final MissingNameSpaceException e1) {
return false;
}
}
public List<XmlElement> getChildElements(final String tagName) {
return getChildElementsInternal(new ElementFilteringStrategy() {
@Override
- public boolean accept(Element e) {
+ public boolean accept(final Element e) {
// localName returns pure localName without prefix
return e.getLocalName().equals(tagName);
}
});
}
- public XmlElement getOnlyChildElement(String childName) throws DocumentedException {
+ public XmlElement getOnlyChildElement(final String childName) throws DocumentedException {
List<XmlElement> nameElements = getChildElements(childName);
if (nameElements.size() != 1){
throw new DocumentedException("One element " + childName + " expected in " + toString(),
return nameElements.get(0);
}
- public Optional<XmlElement> getOnlyChildElementOptionally(String childName) {
+ public Optional<XmlElement> getOnlyChildElementOptionally(final String childName) {
List<XmlElement> nameElements = getChildElements(childName);
if (nameElements.size() != 1) {
return Optional.absent();
List<XmlElement> children = getChildElementsWithinNamespace(namespace);
children = Lists.newArrayList(Collections2.filter(children, new Predicate<XmlElement>() {
@Override
- public boolean apply(XmlElement xmlElement) {
+ public boolean apply(final XmlElement xmlElement) {
return xmlElement.getName().equals(childName);
}
}));
return Optional.of(children.get(0));
}
- public XmlElement getOnlyChildElementWithSameNamespace(String childName) throws DocumentedException {
+ public XmlElement getOnlyChildElementWithSameNamespace(final String childName) throws DocumentedException {
return getOnlyChildElement(childName, getNamespace());
}
List<XmlElement> children = getChildElementsWithinNamespace(namespace.get());
children = Lists.newArrayList(Collections2.filter(children, new Predicate<XmlElement>() {
@Override
- public boolean apply(XmlElement xmlElement) {
+ public boolean apply(final XmlElement xmlElement) {
return xmlElement.getName().equals(childName);
}
}));
return Optional.absent();
}
- public XmlElement getOnlyChildElement(final String childName, String namespace) throws DocumentedException {
+ public XmlElement getOnlyChildElement(final String childName, final String namespace) throws DocumentedException {
List<XmlElement> children = getChildElementsWithinNamespace(namespace);
children = Lists.newArrayList(Collections2.filter(children, new Predicate<XmlElement>() {
@Override
- public boolean apply(XmlElement xmlElement) {
+ public boolean apply(final XmlElement xmlElement) {
return xmlElement.getName().equals(childName);
}
}));
if (element.getNamespaceURI() != null) {
try {
sb.append(", namespace='").append(getNamespace()).append('\'');
- } catch (MissingNameSpaceException e) {
+ } catch (final MissingNameSpaceException e) {
LOG.trace("Missing namespace for element.");
}
}
List<XmlElement> children = getChildElementsWithinNamespace(getNamespace());
return Lists.newArrayList(Collections2.filter(children, new Predicate<XmlElement>() {
@Override
- public boolean apply(XmlElement xmlElement) {
+ public boolean apply(final XmlElement xmlElement) {
return xmlElement.getName().equals(childName);
}
}));
}
- public void checkUnrecognisedElements(List<XmlElement> recognisedElements,
- XmlElement... additionalRecognisedElements) throws DocumentedException {
+ public void checkUnrecognisedElements(final List<XmlElement> recognisedElements,
+ final XmlElement... additionalRecognisedElements) throws DocumentedException {
List<XmlElement> childElements = getChildElements();
childElements.removeAll(recognisedElements);
for (XmlElement additionalRecognisedElement : additionalRecognisedElements) {
}
}
- public void checkUnrecognisedElements(XmlElement... additionalRecognisedElements) throws DocumentedException {
+ public void checkUnrecognisedElements(final XmlElement... additionalRecognisedElements) throws DocumentedException {
checkUnrecognisedElements(Collections.<XmlElement>emptyList(), additionalRecognisedElements);
}
@Override
- public boolean equals(Object o) {
+ public boolean equals(final Object o) {
if (this == o) {
return true;
}
// Performance improvement for messages with size <10k according to
// https://xerces.apache.org/xerces2-j/faq-performance.html
factory.setFeature("http://apache.org/xml/features/dom/defer-node-expansion", false);
- } catch (ParserConfigurationException e) {
+ } catch (final ParserConfigurationException e) {
throw new ExceptionInInitializerError(e);
}
factory.setNamespaceAware(true);
protected DocumentBuilder initialValue() {
try {
return BUILDER_FACTORY.newDocumentBuilder();
- } catch (ParserConfigurationException e) {
+ } catch (final ParserConfigurationException e) {
throw new IllegalStateException("Failed to create threadLocal dom builder", e);
}
}
@Override
- public void set(DocumentBuilder value) {
+ public void set(final DocumentBuilder value) {
throw new UnsupportedOperationException();
}
};
try {
return SCHEMA_FACTORY.newSchema(sources);
- } catch (SAXException e) {
+ } catch (final SAXException e) {
throw new IllegalStateException("Failed to instantiate XML schema", e);
}
}
public static Object evaluateXPath(final XPathExpression expr, final Object rootNode, final QName returnType) {
try {
return expr.evaluate(rootNode, returnType);
- } catch (XPathExpressionException e) {
+ } catch (final XPathExpressionException e) {
throw new IllegalStateException("Error while evaluating xpath expression " + expr, e);
}
}
}
private Set<ObjectName> testClientLookupConfigBeans(
- ConfigTransactionClient client) {
+ final ConfigTransactionClient client) {
Set<ObjectName> beans = client.lookupConfigBeans();
for (ObjectName on : beans) {
assertEquals("Module", on.getKeyProperty("type"));
assertEquals(testClientGetObjectName(jmxTransactionClient), true);
}
- private boolean testClientGetObjectName(ConfigTransactionClient client) {
+ private boolean testClientGetObjectName(final ConfigTransactionClient client) {
return transactionControllerON.equals(client.getObjectName());
}
}
private Set<String> testClientGetAvailableModuleNames(
- ConfigTransactionClient client) {
+ final ConfigTransactionClient client) {
return client.getAvailableModuleNames();
}
assertEquals("transactionName", jmxTN);
}
- private String testClientGetTransactionName(ConfigTransactionClient client) {
+ private String testClientGetTransactionName(final ConfigTransactionClient client) {
return client.getTransactionName();
}
Assert.assertNotNull(on);
}
- private ObjectName testClientCreateModule(ConfigTransactionClient client)
+ private ObjectName testClientCreateModule(final ConfigTransactionClient client)
throws Exception {
return client.createModule("testModuleName", "testInstanceName");
}
}
private Set<ObjectName> testClientLookupConfigBeans2(
- ConfigTransactionClient client, String moduleName) {
+ final ConfigTransactionClient client, final String moduleName) {
Set<ObjectName> beans = client.lookupConfigBeans(moduleName);
assertEquals(1, beans.size());
return beans;
}
private Set<ObjectName> testClientLookupConfigBean(
- ConfigTransactionClient client, String moduleName,
- String instanceName) {
+ final ConfigTransactionClient client, final String moduleName,
+ final String instanceName) {
Set<ObjectName> beans = client.lookupConfigBeans(moduleName,
instanceName);
assertEquals(1, beans.size());
}
private Set<ObjectName> testClientLookupConfigBeans3(
- ConfigTransactionClient client, String moduleName,
- String instanceName) {
+ final ConfigTransactionClient client, final String moduleName,
+ final String instanceName) {
Set<ObjectName> beans = client.lookupConfigBeans(moduleName,
instanceName);
assertEquals(1, beans.size());
test(method, args);
}
- private void test(Method method, Object[] args) throws Exception {
+ private void test(final Method method, final Object[] args) throws Exception {
for (Entry<LookupRegistry, ? extends Set<? extends LookupRegistry>> entry : lookupProvidersToClients
.entrySet()) {
Object expected = method.invoke(entry.getKey(), args);
client.lookupConfigBean(
InstanceNotFoundException.class.getSimpleName(), "");
fail(client.toString());
- } catch (InstanceNotFoundException e) {
+ } catch (final InstanceNotFoundException e) {
}
}
}
@Override
- public CommitStatus commitConfig(ObjectName transactonControllerON)
+ public CommitStatus commitConfig(final ObjectName transactonControllerON)
throws ConflictingVersionException, ValidationException {
if (transactonControllerON == null) {
Exception e = new RuntimeException("message");
}
@Override
- public Set<ObjectName> lookupConfigBeans(String moduleName) {
+ public Set<ObjectName> lookupConfigBeans(final String moduleName) {
if (moduleName.equals(moduleName1)) {
return Sets.newHashSet(conf1, conf2);
} else if (moduleName.equals(moduleName2)) {
}
@Override
- public Set<ObjectName> lookupConfigBeans(String moduleName,
- String instanceName) {
+ public Set<ObjectName> lookupConfigBeans(final String moduleName,
+ final String instanceName) {
if (moduleName.equals(moduleName1) && instanceName.equals(instName1)) {
return Sets.newHashSet(conf2);
} else if (moduleName.equals(moduleName2)
}
@Override
- public ObjectName lookupConfigBean(String moduleName, String instanceName)
+ public ObjectName lookupConfigBean(final String moduleName, final String instanceName)
throws InstanceNotFoundException {
if (moduleName.equals(InstanceNotFoundException.class.getSimpleName())) {
throw new InstanceNotFoundException();
}
@Override
- public Set<ObjectName> lookupRuntimeBeans(String moduleName,
- String instanceName) {
+ public Set<ObjectName> lookupRuntimeBeans(final String moduleName,
+ final String instanceName) {
if (moduleName.equals(moduleName1) && instanceName.equals(instName1)) {
return Sets.<ObjectName> newHashSet(run2);
} else if (moduleName.equals(moduleName2)
}
@Override
- public void checkConfigBeanExists(ObjectName objectName) throws InstanceNotFoundException {
+ public void checkConfigBeanExists(final ObjectName objectName) throws InstanceNotFoundException {
Set<ObjectName> configBeans = Sets.<ObjectName> newHashSet(run1, run2, run3);
if(configBeans.size()>0){
checkBool = true;
}
@Override
- public ObjectName lookupConfigBeanByServiceInterfaceName(String serviceInterfaceQName, String refName) {
+ public ObjectName lookupConfigBeanByServiceInterfaceName(final String serviceInterfaceQName, final String refName) {
if (serviceInterfaceQName.equals(serviceQName1) && refName.equals(refName1)) {
return conf1;
}
}
@Override
- public Map<String, ObjectName> lookupServiceReferencesByServiceInterfaceName(String serviceInterfaceQName) {
+ public Map<String, ObjectName> lookupServiceReferencesByServiceInterfaceName(final String serviceInterfaceQName) {
if(serviceInterfaceQName.equals(serviceQName1)){
map.put("conf1", conf1);
}
@Override
- public Set<String> lookupServiceInterfaceNames(ObjectName objectName) throws InstanceNotFoundException {
+ public Set<String> lookupServiceInterfaceNames(final ObjectName objectName) throws InstanceNotFoundException {
return Sets.<String> newHashSet(serviceQName1, serviceQName2);
}
@Override
- public String getServiceInterfaceName(String namespace, String localName) {
+ public String getServiceInterfaceName(final String namespace, final String localName) {
return null;
}
}
@Override
- public ObjectName getServiceReference(String serviceInterfaceQName, String refName) throws InstanceNotFoundException {
+ public ObjectName getServiceReference(final String serviceInterfaceQName, final String refName) throws InstanceNotFoundException {
return conf1;
}
@Override
- public void checkServiceReferenceExists(ObjectName objectName) throws InstanceNotFoundException {
+ public void checkServiceReferenceExists(final ObjectName objectName) throws InstanceNotFoundException {
throw new UnsupportedOperationException();
}
}
}
@Override
- public ObjectName createModule(String moduleName, String instanceName)
+ public ObjectName createModule(final String moduleName, final String instanceName)
throws InstanceAlreadyExistsException {
//return null;
return ObjectNameUtil.createON(ObjectNameUtil.ON_DOMAIN
}
@Override
- public void reCreateModule(ObjectName objectName) {
+ public void reCreateModule(final ObjectName objectName) {
}
@Override
- public void destroyModule(ObjectName objectName)
+ public void destroyModule(final ObjectName objectName)
throws InstanceNotFoundException {
if(objectName != null){
conf4 = null;
}
@Override
- public Set<ObjectName> lookupConfigBeans(String moduleName) {
+ public Set<ObjectName> lookupConfigBeans(final String moduleName) {
if (moduleName.equals(moduleName1)) {
return Sets.newHashSet(conf1, conf2);
} else if (moduleName.equals(moduleName2)) {
}
@Override
- public ObjectName lookupConfigBean(String moduleName, String instanceName)
+ public ObjectName lookupConfigBean(final String moduleName, final String instanceName)
throws InstanceNotFoundException {
if (moduleName.equals(InstanceNotFoundException.class.getSimpleName())) {
throw new InstanceNotFoundException();
}
@Override
- public Set<ObjectName> lookupConfigBeans(String moduleName,
- String instanceName) {
+ public Set<ObjectName> lookupConfigBeans(final String moduleName,
+ final String instanceName) {
if (moduleName.equals(moduleName1) && instanceName.equals(instName1)) {
return Sets.newHashSet(conf2);
} else if (moduleName.equals(moduleName2)
}
@Override
- public void checkConfigBeanExists(ObjectName objectName) throws InstanceNotFoundException {
+ public void checkConfigBeanExists(final ObjectName objectName) throws InstanceNotFoundException {
check = "configBeanExists";
}
@Override
- public ObjectName saveServiceReference(String serviceInterfaceName, String refName, ObjectName moduleON) throws InstanceNotFoundException {
+ public ObjectName saveServiceReference(final String serviceInterfaceName, final String refName, final ObjectName moduleON) throws InstanceNotFoundException {
return moduleON;
}
@Override
- public void removeServiceReference(String serviceInterfaceName, String refName) {
+ public void removeServiceReference(final String serviceInterfaceName, final String refName) {
check = refName;
}
}
@Override
- public ObjectName lookupConfigBeanByServiceInterfaceName(String serviceInterfaceQName, String refName) {
+ public ObjectName lookupConfigBeanByServiceInterfaceName(final String serviceInterfaceQName, final String refName) {
return conf3;
}
}
@Override
- public Map<String, ObjectName> lookupServiceReferencesByServiceInterfaceName(String serviceInterfaceQName) {
+ public Map<String, ObjectName> lookupServiceReferencesByServiceInterfaceName(final String serviceInterfaceQName) {
mapSub.put("A",conf2);
return mapSub;
}
@Override
- public Set<String> lookupServiceInterfaceNames(ObjectName objectName) throws InstanceNotFoundException {
+ public Set<String> lookupServiceInterfaceNames(final ObjectName objectName) throws InstanceNotFoundException {
return Sets.newHashSet("setA");
}
@Override
- public String getServiceInterfaceName(String namespace, String localName) {
+ public String getServiceInterfaceName(final String namespace, final String localName) {
return check=namespace+localName;
}
@Override
- public boolean removeServiceReferences(ObjectName objectName) throws InstanceNotFoundException {
+ public boolean removeServiceReferences(final ObjectName objectName) throws InstanceNotFoundException {
return true;
}
}
@Override
- public ObjectName getServiceReference(String serviceInterfaceQName, String refName) throws InstanceNotFoundException {
+ public ObjectName getServiceReference(final String serviceInterfaceQName, final String refName) throws InstanceNotFoundException {
return conf3;
}
@Override
- public void checkServiceReferenceExists(ObjectName objectName) throws InstanceNotFoundException {
+ public void checkServiceReferenceExists(final ObjectName objectName) throws InstanceNotFoundException {
check = "referenceExist";
}
}