Last active
August 29, 2015 14:20
-
-
Save xlcommunity/73f857c158e4d82eaea5 to your computer and use it in GitHub Desktop.
ExampleRepositoryEventListener.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
/* | |
* THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, | |
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED | |
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. THIS | |
* CODE AND INFORMATION ARE NOT SUPPORTED BY XEBIALABS. | |
*/ | |
package ext.deployit.listener; | |
import com.xebialabs.deployit.engine.spi.event.*; | |
import com.xebialabs.deployit.plugin.api.udm.ConfigurationItem; | |
import com.xebialabs.deployit.plugin.api.reflect.Type; | |
import com.xebialabs.xlrelease.domain.Release; | |
import nl.javadude.t2bus.Subscribe; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
@DeployitEventListener | |
public class ExampleRepositoryEventListener { | |
private static final Logger logger = LoggerFactory.getLogger(ExampleRepositoryEventListener.class); | |
// templates are stored as releases with status 'TEMPLATE' | |
private static final Type RELEASE_TYPE = Type.valueOf("xlrelease.Release"); | |
@Subscribe | |
public void receiveCisCreated(CisCreatedEvent event) { | |
for (ConfigurationItem ci : event.getCis()) { | |
if (isTemplate(ci)) { | |
logger.info("Received event after creating template: {}", ci); | |
} | |
} | |
} | |
private static boolean isTemplate(ConfigurationItem ci) { | |
return ci.getType().equals(RELEASE_TYPE) && ((Release) ci).isTemplate(); | |
} | |
@Subscribe | |
public void receiveCisUpdated(CisUpdatedEvent event) { | |
for (ConfigurationItem ci : event.getCis()) { | |
if (isTemplate(ci)) { | |
logger.info("Received event after updating template: {}", ci); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment