class EurekaInstanceRegisteredListener {

    @EventListener
    public void listen(EurekaInstanceRegisteredEvent event) {
        final InstanceInfo instanceInfo = event.getInstanceInfo();
        final Map<String, String> metadata = instanceInfo.getMetadata();
        final String serviceId = EurekaUtils.getServiceIdFromInstanceId(instanceInfo.getInstanceId());

        metadataTranslationService.translateMetadata(serviceId, metadata);
        metadataDefaultsService.updateMetadata(serviceId, metadata);

        if (StringUtils.equalsIgnoreCase(GatewayNotifier.GATEWAY_SERVICE_ID, serviceId)) {
            /**
             * meanwhile gateway was down, another Gateway could receive logout, those invalidated credentials should
             * be distributed to this new Gateway
             */
            gatewayNotifier.distributeInvalidatedCredentials(instanceInfo.getInstanceId());
        }
        // ie. new instance can have different authentication (than other one), this is reason to evict caches on gateway
        gatewayNotifier.serviceUpdated(serviceId, instanceInfo.getInstanceId());
    }

}