diff --git a/packages/hawtio/src/plugins/rbac/rbac-service.ts b/packages/hawtio/src/plugins/rbac/rbac-service.ts index dd07be19..564db40c 100644 --- a/packages/hawtio/src/plugins/rbac/rbac-service.ts +++ b/packages/hawtio/src/plugins/rbac/rbac-service.ts @@ -17,7 +17,7 @@ class RBACService implements IRBACService { this.aclMBean = undefined } - async getACLMBean(): Promise { + getACLMBean(): Promise { if (this.aclMBean) { return this.aclMBean } diff --git a/packages/hawtio/src/plugins/shared/jolokia-service.ts b/packages/hawtio/src/plugins/shared/jolokia-service.ts index b9562807..34c17781 100644 --- a/packages/hawtio/src/plugins/shared/jolokia-service.ts +++ b/packages/hawtio/src/plugins/shared/jolokia-service.ts @@ -127,28 +127,28 @@ class JolokiaService implements IJolokiaService { return this.jolokiaUrl } - async getJolokia(): Promise { + getJolokia(): Promise { if (this.jolokia) { return this.jolokia } // Initialising Jolokia instance - - const jolokia = await this.createJolokia() - // Checking versions - jolokia.version( - onVersionSuccessAndError( - version => { - log.info('Jolokia version:', { client: jolokia.CLIENT_VERSION, agent: version.agent }) - }, - error => log.error('Failed to fetch Jolokia version:', error), - ), - ) - // Start Jolokia - const updateRate = this.loadUpdateRate() - jolokia.start(updateRate) - log.info('Jolokia started with update rate =', updateRate) - return jolokia + this.jolokia = this.createJolokia(jolokia => { + // Checking versions + jolokia.version( + onVersionSuccessAndError( + version => { + log.info('Jolokia version:', { client: jolokia.CLIENT_VERSION, agent: version.agent }) + }, + error => log.error('Failed to fetch Jolokia version:', error), + ), + ) + // Start Jolokia + const updateRate = this.loadUpdateRate() + jolokia.start(updateRate) + log.info('Jolokia started with update rate =', updateRate) + }) + return this.jolokia } private async initJolokiaUrl(): Promise { @@ -212,7 +212,7 @@ class JolokiaService implements IJolokiaService { }) } - private async createJolokia(): Promise { + private async createJolokia(postCreate?: (jolokia: Jolokia) => void): Promise { const jolokiaUrl = await this.getJolokiaUrl() if (!jolokiaUrl) { log.debug('Use dummy Jolokia') @@ -237,6 +237,10 @@ class JolokiaService implements IJolokiaService { // let's check if we can call faster jolokia.list() await this.checkListOptimisation(jolokia) + // Run any post-create processing that should be done before the resolved + // Jolokia is returned + postCreate?.(jolokia) + return jolokia } diff --git a/packages/hawtio/src/plugins/shared/workspace.ts b/packages/hawtio/src/plugins/shared/workspace.ts index d0e488e0..d8cde3e6 100644 --- a/packages/hawtio/src/plugins/shared/workspace.ts +++ b/packages/hawtio/src/plugins/shared/workspace.ts @@ -36,7 +36,7 @@ class Workspace implements IWorkspace { eventService.refresh() } - async getTree(): Promise { + getTree(): Promise { if (this.tree) { return this.tree }