This is an automated email from the ASF dual-hosted git repository.
robbie pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis-console.git
The following commit(s) were added to refs/heads/main by this push:
new 189aae8 ARTEMIS-4780 - Artemis web console does not ever set
'artemisJmxDomain' in localStorage
189aae8 is described below
commit 189aae887d37724bcc0460fac073105f8462d7d8
Author: Andy Taylor <[email protected]>
AuthorDate: Mon Aug 12 12:15:56 2024 +0100
ARTEMIS-4780 - Artemis web console does not ever set 'artemisJmxDomain' in
localStorage
expose a config file that can be shded to change the domain used
---
.../artemis-extension/public/artemisconfig.json | 5 ++
.../artemis-extension/artemis/artemis-service.ts | 51 ++-------------
.../artemis-extension/artemis/config-manager.ts | 76 ++++++++++++++++++++++
.../src/artemis-extension/artemis/context.ts | 6 +-
.../src/artemis-extension/artemis/globals.ts | 1 -
.../src/artemis-extension/artemis/index.ts | 7 +-
.../src/artemis-extension/artemis/util/jmx.ts | 6 --
pom.xml | 1 +
8 files changed, 94 insertions(+), 59 deletions(-)
diff --git
a/artemis-console-extension/artemis-extension/public/artemisconfig.json
b/artemis-console-extension/artemis-extension/public/artemisconfig.json
new file mode 100644
index 0000000..1922dd5
--- /dev/null
+++ b/artemis-console-extension/artemis-extension/public/artemisconfig.json
@@ -0,0 +1,5 @@
+{
+ "jmx": {
+ "domain": "org.apache.activemq.artemis"
+ }
+}
\ No newline at end of file
diff --git
a/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/artemis-service.ts
b/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/artemis-service.ts
index eb12b49..20db62b 100644
---
a/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/artemis-service.ts
+++
b/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/artemis-service.ts
@@ -17,8 +17,9 @@
import { ActiveSort, Filter } from './table/ArtemisTable'
import { jolokiaService, MBeanNode } from '@hawtio/react'
import { createAddressObjectName, createQueueObjectName } from './util/jmx'
-import { contextNodeType, contextsType, domainNodeType, endpointNodeType,
jmxDomain, log } from './globals'
+import { log } from './globals'
import { Message } from './messages/MessageView'
+import { configManager } from './config-manager'
export type BrokerInfo = {
name: string
@@ -110,7 +111,6 @@ export type BrokerTopology = {
}
-const BROKER_SEARCH_PATTERN = jmxDomain + ":broker=*";
const LIST_NETWORK_TOPOLOGY_SIG = "listNetworkTopology";
const SEND_MESSAGE_SIG =
"sendMessage(java.util.Map,int,java.lang.String,boolean,java.lang.String,java.lang.String,boolean)";
const DELETE_ADDRESS_SIG = "deleteAddress(java.lang.String)";
@@ -149,7 +149,8 @@ class ArtemisService {
}
private async initBrokerObjectName(): Promise<string> {
- var search = await jolokiaService.search(BROKER_SEARCH_PATTERN);
+ const config = await configManager.getArtemisconfig();
+ var search = await jolokiaService.search(config.jmx.domain +
":broker=*");
return search[0] ? search[0] : "";
}
@@ -588,50 +589,6 @@ class ArtemisService {
checkCanBrowseQueue = (queueMBean: MBeanNode ): boolean => {
return (this.DEBUG_PRIVS && queueMBean?.hasInvokeRights(BROWSE_SIG))
?? false;
}
-
-
- findContext(node: MBeanNode): MBeanNode | null {
- if (!this.hasDomain(node)) return null
-
- if (this.isDomainNode(node)) {
- // The camel domain node so traverse to context folder & recurse
- return this.findContext(node.getIndex(0) as MBeanNode)
- }
-
- if (this.isContextsFolder(node)) {
- if (node.childCount() === 0) return null
-
- // Find first context node in the list
- return node.getIndex(0)
- }
-
- if (this.isContext(node)) {
- return node
- }
-
- // Node is below a context so navigate up the tree
- return node.findAncestor(ancestor => this.isContext(ancestor))
- }
-
- hasDomain(node: MBeanNode): boolean {
- return jmxDomain === node.getMetadata('domain')
- }
-
- isContextsFolder(node: MBeanNode): boolean {
- return this.hasDomain(node) && node.getType() === contextsType
- }
-
- isContext(node: MBeanNode): boolean {
- return this.hasDomain(node) && node.getType() === contextNodeType
- }
-
- isDomainNode(node: MBeanNode): boolean {
- return node.getType() === domainNodeType
- }
-
- isEndpointNode(node: MBeanNode): boolean {
- return this.hasDomain(node) && node.getType() === endpointNodeType
- }
}
export const artemisService = new ArtemisService()
\ No newline at end of file
diff --git
a/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/config-manager.ts
b/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/config-manager.ts
new file mode 100644
index 0000000..daf99a6
--- /dev/null
+++
b/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/config-manager.ts
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ import { log } from "./globals"
+
+export type Artemisconfig = {
+ /**
+ * Configuration for branding & styles.
+ */
+ jmx: JMXConfig
+
+}
+
+/**
+ * JMX configuration type.
+ */
+export type JMXConfig = {
+ domain: string
+}
+
+export const ARTEMISCONFIG_JSON = 'artemisconfig.json'
+
+class ConfigManager {
+ private config?: Promise<Artemisconfig>
+
+ getArtemisconfig(): Promise<Artemisconfig> {
+ if (this.config) {
+ return this.config
+ }
+
+ this.config = this.loadConfig()
+ return this.config
+ }
+
+
+ private async loadConfig(): Promise<Artemisconfig> {
+
+ try {
+ const res = await fetch(ARTEMISCONFIG_JSON)
+ if (!res.ok) {
+ log.info("Unable to load Artemis Config, using Default");
+ return {
+ jmx: {
+ domain: "org.apache.activemq.artemis"
+ }
+ }
+ }
+
+ const config = await res.json()
+ log.info("Loaded Artemis Config:", config);
+ return config
+ } catch (err) {
+ log.info("Unable to load Artemis Config, using Default");
+ return {
+ jmx: {
+ domain: "org.apache.activemq.artemis"
+ }
+ }
+ }
+ }
+}
+
+export const configManager = new ConfigManager()
diff --git
a/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/context.ts
b/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/context.ts
index e6e7ce0..30bde50 100644
---
a/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/context.ts
+++
b/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/context.ts
@@ -18,7 +18,8 @@ import { eventService, EVENT_REFRESH,MBeanNode, MBeanTree,
PluginNodeSelectionCo
import { TreeViewDataItem } from "@patternfly/react-core";
import { createContext, useContext, useEffect, useState } from "react";
import { useNavigate } from 'react-router-dom'
-import { artemisPluginName, jmxDomain } from "./globals";
+import { artemisPluginName } from "./globals";
+import { configManager } from "./config-manager";
/**
* Custom React hook for using the Artemis MBean tree.
@@ -34,7 +35,8 @@ export function useArtemisTree() {
const populateTree = async () => {
const wkspTree: MBeanTree = await workspace.getTree();
- const rootNode = wkspTree.find(node => node.name === jmxDomain)
+ const config = await configManager.getArtemisconfig();
+ const rootNode = wkspTree.find(node => node.name === config.jmx.domain)
if (rootNode && rootNode.children && rootNode.children.length > 0) {
if (rootNode.children[0].objectName) {
rootNode.children[0].addMetadata("type", "brokerType");
diff --git
a/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/globals.ts
b/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/globals.ts
index 85ee2fa..b90dbf4 100644
---
a/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/globals.ts
+++
b/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/globals.ts
@@ -27,7 +27,6 @@ export const artemisJMXPluginTitle = 'Artemis JMX'
export const artemisJMXPluginPath = '/treeartemisJMX'
export const log = Logger.get(artemisPluginName)
-export const jmxDomain = 'org.apache.activemq.artemis'
export const domainNodeType = 'Camel Domain'
export const contextsType = 'contexts'
export const contextNodeType = 'context'
diff --git
a/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/index.ts
b/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/index.ts
index 75c2250..4a81bad 100644
---
a/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/index.ts
+++
b/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/index.ts
@@ -18,8 +18,9 @@ import { HawtioPlugin, hawtio, helpRegistry, workspace,
preferencesRegistry} fro
import { Artemis } from './Artemis'
import { ArtemisJMX } from './ArtemisJMX'
import { ArtemisPreferences } from './ArtemisPreferences'
-import { log, artemisPluginName, artemisPluginTitle, artemisPluginPath,
artemisJMXPluginName, artemisJMXPluginPath, artemisJMXPluginTitle, jmxDomain,
} from './globals'
+import { log, artemisPluginName, artemisPluginTitle, artemisPluginPath,
artemisJMXPluginName, artemisJMXPluginPath, artemisJMXPluginTitle } from
'./globals'
import help from './help.md'
+import { configManager } from './config-manager'
export const artemis: HawtioPlugin = () => {
@@ -33,7 +34,7 @@ export const artemis: HawtioPlugin = () => {
path: artemisPluginPath,
component: Artemis,
order: -2,
- isActive: async () =>
workspace.treeContainsDomainAndProperties(jmxDomain),
+ isActive: async () => workspace.treeContainsDomainAndProperties((await
configManager.getArtemisconfig()).jmx.domain),
})
hawtio.addPlugin({
@@ -42,7 +43,7 @@ export const artemis: HawtioPlugin = () => {
path: artemisJMXPluginPath,
component: ArtemisJMX,
order: -1,
- isActive: async () =>
workspace.treeContainsDomainAndProperties(jmxDomain),
+ isActive: async () => workspace.treeContainsDomainAndProperties((await
configManager.getArtemisconfig()).jmx.domain),
})
helpRegistry.add(artemisPluginName, artemisPluginTitle, help, 1)
diff --git
a/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/util/jmx.ts
b/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/util/jmx.ts
index aa04942..47ed6b8 100644
---
a/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/util/jmx.ts
+++
b/artemis-console-extension/artemis-extension/src/artemis-extension/artemis/util/jmx.ts
@@ -15,7 +15,6 @@
* limitations under the License.
*/
import { MBeanNode } from "@hawtio/react";
-import { jmxDomain } from "../globals";
const ADDRESS_COMPONENT_PART = ",component=addresses,address=\"";
const ADDRESS_SUBCOMPONENT_PART = "\",subcomponent=queues,routing-type=\"";
@@ -23,7 +22,6 @@ const ADDRESS_TYPE_PART = "\",queue=\"";
const STRING_DELIMETER = "\"";
const QUEUE_COMPONENT = "component=queues";
const ADDRESS_COMPONENT = "component=addresses";
-const DOMAIN = "domain";
/**
* Create the queue object name which would look like
@@ -44,7 +42,3 @@ export function isQueue(node: MBeanNode): boolean {
export function isAddress(node: MBeanNode): boolean {
return node != null && node.objectName != null &&
node.objectName?.includes(ADDRESS_COMPONENT) &&
!node.objectName?.includes(QUEUE_COMPONENT);
}
-
-export function hasDomain(node: MBeanNode): boolean {
- return node && jmxDomain === node.getProperty(DOMAIN);
-}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 1607567..08f686c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -206,6 +206,7 @@
<exclude>artemis-console-extension/artemis-extension/yarn.lock</exclude>
<exclude>README.md</exclude>
<exclude>artemis-console-extension/artemis-extension/public/hawtconfig.json</exclude>
+
<exclude>artemis-console-extension/artemis-extension/public/artemisconfig.json</exclude>
<exclude>.github/**</exclude>
<!-- NPM files -->
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact