forked from wildfly/wildfly
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request wildfly#17949 from bstansberry/WFLY-19218
[WFLY-19218] Ensure that service mbeans are registered with the mbean…
- Loading branch information
Showing
10 changed files
with
476 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
...n/basic/src/test/java/org/jboss/as/test/integration/sar/order/CustomLifecycleEmitter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* | ||
* Copyright The WildFly Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.jboss.as.test.integration.sar.order; | ||
|
||
import static org.jboss.as.test.integration.sar.order.LifecycleEmitterMBean.invokeListener; | ||
import static org.jboss.as.test.integration.sar.order.LifecycleEmitterMBean.safeInvokeListener; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import javax.management.MBeanRegistration; | ||
import javax.management.MBeanServer; | ||
import javax.management.ObjectName; | ||
|
||
import org.jboss.system.Service; | ||
|
||
public class CustomLifecycleEmitter implements CustomLifecycleEmitterMBean, Service, MBeanRegistration { | ||
|
||
private volatile String id; | ||
private volatile ObjectName listener; | ||
private volatile ObjectName dependency; | ||
private volatile MBeanServer server; | ||
private final List<String> unrecordedEvents = new ArrayList<>(); | ||
|
||
|
||
@Override | ||
public String getId() { | ||
return id; | ||
} | ||
|
||
@Override | ||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
@Override | ||
public ObjectName getDependency() { | ||
return dependency; | ||
} | ||
|
||
@Override | ||
public void setDependency(ObjectName dependency) { | ||
this.dependency = dependency; | ||
} | ||
|
||
@Override | ||
public ObjectName getLifecycleListener() { | ||
return listener; | ||
} | ||
|
||
@Override | ||
public void setLifecycleListener(ObjectName lifecycleListener) { | ||
this.listener = lifecycleListener; | ||
} | ||
|
||
@Override | ||
public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception { | ||
this.server = server; | ||
for (String unrecordedEvent : unrecordedEvents) { | ||
invokeListener(id, unrecordedEvent, server); | ||
} | ||
invokeListener(id, MBEAN_PRE_REGISTERED, server); | ||
return name; | ||
} | ||
|
||
@Override | ||
public void postRegister(Boolean registrationDone) { | ||
safeInvokeListener(id, MBEAN_POST_REGISTERED, server); | ||
} | ||
|
||
@Override | ||
public void preDeregister() throws Exception { | ||
invokeListener(id, MBEAN_PRE_DEREGISTERED, server); | ||
} | ||
|
||
@Override | ||
public void postDeregister() { | ||
safeInvokeListener(id, MBEAN_POST_DEREGISTERED, server); | ||
} | ||
|
||
@Override | ||
public void create() throws Exception { | ||
if (server != null) { | ||
invokeListener(id, MBEAN_CREATED, server); | ||
} else { | ||
unrecordedEvents.add(MBEAN_CREATED); | ||
} | ||
} | ||
|
||
@Override | ||
public void start() throws Exception { | ||
if (server != null) { | ||
invokeListener(id, MBEAN_STARTED, server); | ||
} else { | ||
unrecordedEvents.add(MBEAN_STARTED); | ||
} | ||
} | ||
|
||
@Override | ||
public void stop() { | ||
safeInvokeListener(id, MBEAN_STOPPED, server); | ||
} | ||
|
||
@Override | ||
public void destroy() { | ||
safeInvokeListener(id, MBEAN_DESTROYED, server); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...ic/src/test/java/org/jboss/as/test/integration/sar/order/CustomLifecycleEmitterMBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* Copyright The WildFly Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.jboss.as.test.integration.sar.order; | ||
|
||
public interface CustomLifecycleEmitterMBean extends LifecycleEmitterMBean { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.