use of org.apache.servicecomb.core.BootListener.BootEvent in project java-chassis by ServiceComb.
the class SCBEngine method safeTriggerEvent.
protected void safeTriggerEvent(EventType eventType) {
BootEvent event = new BootEvent();
event.setScbEngine(this);
event.setEventType(eventType);
for (BootListener listener : bootListeners) {
try {
listener.onBootEvent(event);
LOGGER.info("BootListener {} succeed to process {}.", listener.getClass().getName(), eventType);
} catch (Throwable e) {
LOGGER.error("BootListener {} failed to process {}.", listener.getClass().getName(), eventType, e);
}
}
}
use of org.apache.servicecomb.core.BootListener.BootEvent in project java-chassis by ServiceComb.
the class TestAuthHandlerBoot method testMicroserviceInstancePublicKey.
@Test
public void testMicroserviceInstancePublicKey() {
AuthHandlerBoot authHandlerBoot = new AuthHandlerBoot();
BootEvent bootEvent = new BootEvent();
bootEvent.setEventType(BootListener.EventType.BEFORE_REGISTRY);
authHandlerBoot.onBootEvent(bootEvent);
String publicKey = RegistrationManager.INSTANCE.getMicroserviceInstance().getProperties().get(DefinitionConst.INSTANCE_PUBKEY_PRO);
Assert.assertNotNull(publicKey);
}
use of org.apache.servicecomb.core.BootListener.BootEvent in project java-chassis by ServiceComb.
the class TestInspectorBootListener method filterEvent.
@Test
public void filterEvent() {
BootEvent event = new BootEvent();
InspectorBootListener listener = new InspectorBootListener(new InspectorConfig(), null);
try (LogCollector logCollector = new LogCollector()) {
for (EventType eventType : EventType.values()) {
if (!EventType.AFTER_TRANSPORT.equals(eventType)) {
event.setEventType(eventType);
listener.onBootEvent(event);
}
}
Assert.assertTrue(logCollector.getEvents().isEmpty());
}
}
use of org.apache.servicecomb.core.BootListener.BootEvent in project java-chassis by ServiceComb.
the class TestInspectorBootListener method disabled.
@Test
public void disabled() {
SCBEngine scbEngine = SCBBootstrap.createSCBEngineForTest();
scbEngine.setProducerMicroserviceMeta(new MicroserviceMeta(scbEngine, "ms", false));
InspectorConfig inspectorConfig = new InspectorConfig().setEnabled(false);
new InspectorBootListener(inspectorConfig, null).onAfterTransport(new BootEvent(scbEngine, EventType.AFTER_TRANSPORT));
Assert.assertNull(scbEngine.getProducerMicroserviceMeta().findSchemaMeta("inspector"));
}
use of org.apache.servicecomb.core.BootListener.BootEvent in project java-chassis by ServiceComb.
the class TestInspectorBootListener method enabled.
@Test
public void enabled() {
Holder<Object> holder = new Holder<>();
SCBEngine scbEngine = SCBBootstrap.createSCBEngineForTest();
scbEngine.setProducerMicroserviceMeta(new MicroserviceMeta(scbEngine, "ms", false));
scbEngine.setProducerProviderManager(new ProducerProviderManager(scbEngine) {
@Override
public SchemaMeta registerSchema(String schemaId, Object instance) {
if ("inspector".equals(schemaId)) {
holder.value = instance;
}
return null;
}
});
InspectorConfig inspectorConfig = new InspectorConfig().setEnabled(true);
new InspectorBootListener(inspectorConfig, null).onAfterTransport(new BootEvent(scbEngine, EventType.AFTER_TRANSPORT));
Assert.assertNotNull(holder.value);
}
Aggregations