# Jira plugin cache problem

**URL:** <https://community.developer.atlassian.com/t/jira-plugin-cache-problem/2717>\
**Category:** Jira Development\
**Tags:** jira-server, java\
**Created:** [April 19, 2017, 10:54am UTC](https://community.developer.atlassian.com/t/jira-plugin-cache-problem/2717 "2017-04-19T10:54:00Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![david.pinn](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/david.pinn/32/36134_2.png) [@david.pinn](https://community.developer.atlassian.com/u/david.pinn)\
**Post date:** [April 21, 2017, 6:11am UTC](https://community.developer.atlassian.com/t/jira-plugin-cache-problem/2717/7 "2017-04-21T06:11:49Z")

</div>

Try something like this:

```auto
public class Foo implements InitializingBean, DisposableBean {

    private final EventPublisher eventPublisher;

    public Foo(EventPublisher eventPublisher) {
        this.eventPublisher = eventPublisher;
    }

    /** Called when the plugin has been enabled */
    @Override
    public void afterPropertiesSet() {
        eventPublisher.register(this);
    }

    /** Called when the plugin is being disabled or removed */
    @Override
    public void destroy() throws Exception {
        eventPublisher.unregister(this);
    }

    @EventListener
    public void onBlah(BlahEvent event) {
        ...
    }
}

```

…and don’t forget to register the class as a component in your `atlassian-plugin.xml` file:

```auto
<component key="myFoo" class="com.example.Foo" />

```

… oh, and also import the `EventPublisher` component:

```auto
    <component-import key="eventPublisher"
        interface="com.atlassian.event.api.EventPublisher" />

```

---

_[View the full topic](https://community.developer.atlassian.com/t/jira-plugin-cache-problem/2717)._
