Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Teneo - Programmatic Events
Teneo - Programmatic Events [message #759593] Tue, 29 November 2011 09:55 Go to next message
Herve Ferreira is currently offline Herve FerreiraFriend
Messages: 31
Registered: October 2011
Member

How can I add events (I want to add the pre and post load) in a programmatic way using Teneo?

Thanks in advance
Re: Teneo - Programmatic Events [message #759598 is a reply to message #759593] Tue, 29 November 2011 10:09 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
You can use a Hibernate Interceptor, see this old post on how to enable a Hibernate interceptor with Teneo:
http://www.eclipse.org/forums/index.php/mv/tree/207733/#page_top

gr. Martin

On 11/29/2011 10:55 AM, Herve Ferreira wrote:
>
> How can I add events (I want to add the pre and post load) in a programmatic way using Teneo?
>
> Thanks in advance


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Teneo - Programmatic Events [message #759608 is a reply to message #759598] Tue, 29 November 2011 10:37 Go to previous messageGo to next message
Herve Ferreira is currently offline Herve FerreiraFriend
Messages: 31
Registered: October 2011
Member

The interceptor I already know how to add it.

However what I need is a pre-load and post-load and this is not available as an Interceptor but it's available as an event

e.g.

public class AuditEvent extends DefaultPreLoadEventListener {
	public void onPreLoad(PreLoadEvent event) {
		System.out.println("PreLoadEventListener.onPreLoad(PreLoadEvent)");
		super.onPreLoad(event);
	}
}


As you can see this is a different interface

Tks
Re: Teneo - Programmatic Events [message #759629 is a reply to message #759608] Tue, 29 November 2011 12:07 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Herve,
To do this, create a subclass of the datastore class you are using and override this method:
protected void setEventListeners() {
}

don't forget to call the super implementation:
protected void setEventListeners() {
super.setEventListeners();
}

gr. Martin

On 11/29/2011 11:37 AM, Herve Ferreira wrote:
>
> The interceptor I already know how to add it.
>
> However what I need is a pre-load and post-load and this is not available as an Interceptor but it's available as an event
>
> e.g.
>
>
> public class AuditEvent extends DefaultPreLoadEventListener {
> public void onPreLoad(PreLoadEvent event) {
> System.out.println("PreLoadEventListener.onPreLoad(PreLoadEvent)");
> super.onPreLoad(event);
> }
> }
>
>
> As you can see this is a different interface
>
> Tks


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Teneo - Programmatic Events [message #759672 is a reply to message #759629] Tue, 29 November 2011 15:09 Go to previous message
Herve Ferreira is currently offline Herve FerreiraFriend
Messages: 31
Registered: October 2011
Member

So that someone can use the solution

public class MyHbEntityDataStore extends HbEntityDataStore {

	@Override
	protected void setEventListeners() {
		super.setEventListeners();

		String[] pre = new String[]{ MyTransNetPreLoad.class.getName() }; 
		String[] post = new String[]{ MyTransNetPostLoad.class.getName() };
		
		getConfiguration().setListeners("pre-load",pre);
		getConfiguration().setListeners("post-load",post);

	}
}

public class MyPostLoad extends DefaultPostLoadEventListener {
    public void onPostLoad(PostLoadEvent event) {
        super.onPostLoad(event);
        System.err.println("*** onPostLoad ***");
    }
}

public class MyPreLoad extends DefaultPreLoadEventListener {

    public void onPreLoad(PreLoadEvent event) {
        super.onPreLoad(event);
        System.err.println("*** onPreLoad ***");
    }
}




Thanks
Previous Topic:Teneo Problems using merge HbMapperException
Next Topic:Modifying simulation model using commands?
Goto Forum:
  


Current Time: Fri Apr 26 18:40:38 GMT 2024

Powered by FUDForum. Page generated in 0.03089 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top