This functionality can only be used in conjunction with Intland professional services. To become part of the early release community please contact sales@intland.com.
codebeamer Listener APIThe codebeamer server internally has a mechanism for dispatching entity lifecycle Events to registered Listeners. EventsThe protocol by which events are communicated, is defined via entity specific Java interfaces, where each type of event is represented as a method.
public interface ProjectListener extends EventListener { /** * This method gets called when a new project is created. * The {@link BaseEvent#getSource()} is the newly created project * @throws VetoException if the listener wishes the change to be rolled back. */ default void projectCreated(BaseEvent<ProjectDto,Void,Void> event) throws VetoException {} /** * This method gets called when a project is updated. * The {@link BaseEvent#getSource()} is the new/updated project state * The {@link BaseEvent#getSecondarySource()} is the old project state before the update * @param event contains the "new" state as "source" and the "old" state as "secondarySource", so you have access to both. * @throws VetoException if the listener wishes the change to be rolled back. */ default void projectUpdated(BaseEvent<ProjectDto,ProjectDto,Void> event) throws VetoException {} /** * This method gets called when a project is deleted. * The {@link BaseEvent#getSource()} is the deleted project * @throws VetoException if the listener wishes the change to be rolled back. */ default void projectDeleted(BaseEvent<ProjectDto,Void,Void> event) throws VetoException {} /** * This method gets called when the daily project statistics are built (typically daily once a night). * The {@link BaseEvent#getSource()} is the project the statistics of which is to be built * The {@link BaseEvent#getSecondarySource()} is the statistics anchor date. * The {@link BaseEvent#getData()} are the {@link DailyProjectStatsDto}, but only in the post event notification. * @throws VetoException if the listener wishes not to build statistics or this project. * @since CB-6.0 */ default void projectDailyStatistics(BaseEvent<ProjectDto,Date,DailyProjectStatsDto> event) throws VetoException {} /** * This method gets called when a user requested to join a project. * The {@link BaseEvent#getSource()} is the project where the {@link BaseEvent#getUser()} wants to join * The {@link BaseEvent#getSecondarySource()} is the comment of the user for the join request * @param event * @throws VetoException */ default void userJoinRequested (BaseEvent<ProjectDto,String,Void> event) throws VetoException {} /** * This method gets called when a project join request was accepted. * The {@link BaseEvent#getSource()} is the project where the join was accepted by the {@link BaseEvent#getUser()} * The {@link BaseEvent#getSecondarySource()} is the comment of the user who accepted the join * The {@link BaseEvent#getData()} is the user whose join request was accepted. * @param event * @throws VetoException */ default void userJoinAccepted (BaseEvent<ProjectDto,String,UserDto> event) throws VetoException {} /** * This method gets called when a project join request was rejected * The {@link BaseEvent#getSource()} is the project where the join was rejected by the {@link BaseEvent#getUser()} * The {@link BaseEvent#getSecondarySource()} is the comment of the user who rejected the join * The {@link BaseEvent#getData()} is the user whose join request was rejected. * @param event * @throws VetoException */ default void userJoinRejected (BaseEvent<ProjectDto,String,UserDto> event) throws VetoException {} }
Information about the event is passed as method parameters, typically in form of a genericBaseEvent object which carries entity and event specific information:
All event communication occurs
therefore runtimeexceptions during listener notification will cause a transactionrollback ! ListingHere is a listing of all codebeamer listener interfaces from package com.intland.codebeamer.event in alphabetic order, including their communicated events:
Please refer to the documentation of a specific entity listener interface method (= event), to see what actual event information is provided. ListenersA codebeamer Event Listener is a Java class that implements one or more listener interfaces.
Therefore
Default Listenerscodebeamer includes a set of default Listeners in the com.intland.codebeamer.event.impl package.
Custom ListenersThe package of your custom Listener class should be a sub-package of com.intland.codebeamer.event.impl. package com.intland.codebeamer.event.impl.sample; import org.springframework.stereotype.Component; import com.intland.codebeamer.event.ProjectListener; @Component("exampleProjectListener") public class ExampleProjectListener implements ProjectListener { } Unless you want to replace a Default Listener (see above) with an extended/custom version, you must not
If a Listenerclass needs access to other codebeamer APIs, it should simply declare appropriate @Autowired variables, e.g. package com.intland.codebeamer.event.impl.sample; import org.springframework.stereotype.Component; import com.intland.codebeamer.event.ProjectListener; import com.intland.codebeamer.manager.ProjectManager; @Component("exampleProjectListener") public class ExampleProjectListener implements ProjectListener { @Autowired private ProjectManager projectManager; ... }
package com.intland.codebeamer.event.impl.sample; import org.springframework.stereotype.Component; import com.intland.codebeamer.event.BaseEvent; import com.intland.codebeamer.event.ProjectListener; import com.intland.codebeamer.event.util.VetoException; import com.intland.codebeamer.persistence.dto.ProjectDto; @Component("exampleProjectListener") public class ExampleProjectListener implements ProjectListener { @Override public void projectCreated(BaseEvent<ProjectDto, Void, Void> event) throws VetoException { ProjectDto project = event.getSource(); if (event.isPreEvent() && project.getCategoryReference() == null) { throw new VetoException("Each project must have a category!"); } } } In CB-10.1 and newer, you only need to override the methods for the events you want to address. Other events are ignored by default. Java IDEDeveloping a custom Listener class in Java requires a Java 8 or newer Standard Edition (SE) Java Development Kit (JDK) plus the following frameworks/libraries:
DeploymentTo deploy your custom Listener class, the Java code must be compiled and the resulting *.class files must be uploaded to the appropriate sub-directory under ~/CB-.../tomcat/webapps/cb/WEB-INF/classes/... on your codebeamer server, where the sub-directory is the equivalent of the extension's package name. ~/CB-../tomcat/webapps/cb/WEB-INF/classes/my-ApplicationContext.xml
UtilsGlobalTypeFacade (utils for shared fields/global types)codebeamer has a utility class GlobalTypeFacade in the com.intland.codebeamer.facade package for global types (shared fields) with the following methods:
Frequently Asked Questions
You can simply leave those method bodies empty, it has no side-effects at all.
No. codebeamer relies on actively using its own listeners to implement several mechanisms. Disabling the default listeners might result in undefined behavior and data failure.
No, there is absolutely no guarantee for which order they receive the notifications. Please do not rely on this.
No. If the listeners are normally notified in this order A, B, C, D and B vetoes the operation, then:
This is a design decision to keep the behavior simple, but powerful enough for most real-life applications. |
Fast Links
codebeamer Overview codebeamer Knowledge Base Services by Intland Software |
This website stores cookies on your computer. These cookies are used to improve your browsing experience, constantly optimize the functionality and content of our website, furthermore helps us to understand your interests and provide more personalized services to you, both on this website and through other media. With your permission we and our partners may use precise geolocation data and identification through device scanning. You may click accept to consent to our and our partners’ processing as described above. Please be aware that some processing of your personal data may not require your consent, but you have a right to object to such processing. By using our website, you acknowledge this notice of our cookie practices. By accepting and continuing to browse this site, you agree to this use. For more information about the cookies we use, please visit our Privacy Policy.Your preferences will apply to this website only.
Note that user-behavior analytics are being captured on this server for the purpose of improving the Codebeamer user experience.