001/* -*- mode: Java; c-basic-offset: 2; indent-tabs-mode: nil; coding: utf-8-unix -*- 002 * 003 * Copyright © 2017 MicroBean. 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 014 * implied. See the License for the specific language governing 015 * permissions and limitations under the License. 016 */ 017package org.microbean.helm.maven; 018 019import java.util.EventListener; 020import java.util.Objects; 021 022import hapi.services.tiller.Tiller.GetReleaseStatusResponseOrBuilder; 023 024import org.apache.maven.plugin.logging.Log; 025 026/** 027 * A {@link ReleaseStatusListener} that {@linkplain 028 * Log#info(CharSequence) logs} the {@link 029 * hapi.services.tiller.Tiller.GetReleaseStatusResponseOrBuilder} 030 * {@linkplain 031 * ReleaseStatusEvent#getReleaseStatusResponseOrBuilder() associated 032 * with a <code>ReleaseStatusEvent</code>}. 033 * 034 * @author <a href="https://about.me/lairdnelson" 035 * target="_parent">Laird Nelson</a> 036 * 037 * @see ReleaseStatusEvent 038 * 039 * @see ReleaseStatusListener 040 */ 041public class AbstractReleaseStatusListener implements ReleaseStatusListener { 042 043 044 /* 045 * Constructors. 046 */ 047 048 049 /** 050 * Creates a new {@link AbstractReleaseStatusListener}. 051 */ 052 public AbstractReleaseStatusListener() { 053 super(); 054 } 055 056 057 /* 058 * Instance methods. 059 */ 060 061 062 /** 063 * {@linkplain Log#info(CharSequence) Logs} the {@link 064 * hapi.services.tiller.Tiller.GetReleaseStatusResponseOrBuilder} 065 * {@linkplain 066 * ReleaseStatusEvent#getReleaseStatusResponseOrBuilder() 067 * associated with a <code>ReleaseStatusEvent</code>}. 068 * 069 * @param event the {@link ReleaseStatusEvent} describing the 070 * release status; may be {@code null} in which case no action will 071 * be taken 072 * 073 * @see ReleaseStatusEvent 074 * 075 * @see 076 * hapi.services.tiller.Tiller.GetReleaseStatusResponseOrBuilder#toString() 077 */ 078 @Override 079 public void releaseStatusRetrieved(final ReleaseStatusEvent event) { 080 if (event != null) { 081 final GetReleaseStatusResponseOrBuilder getReleaseStatusResponseOrBuilder = event.getReleaseStatusResponseOrBuilder(); 082 final Log log = event.getLog(); 083 if (log != null && log.isInfoEnabled()) { 084 log.info(String.valueOf(getReleaseStatusResponseOrBuilder)); 085 } 086 } 087 } 088 089}