package org.neo4j.tutor.security;

import org.neo4j.impl.event.EventListenerAlreadyRegisteredException;
import org.neo4j.impl.event.EventListenerNotRegisteredException;
import org.neo4j.impl.event.EventManager;
import org.neo4j.impl.event.ProActiveEventListener;

public abstract class AbstractSecurityMgr implements ProActiveEventListener
{
	public void registerEventListener()
	{
		try
		{
			EventManager.getManager().registerProActiveEventListener( 
				this, SecurityEvent.ACCESS );
		}
		catch ( EventListenerAlreadyRegisteredException e )
		{
			throw new RuntimeException( e );
		}
		catch ( EventListenerNotRegisteredException e )
		{
			throw new RuntimeException( e );
		}
	}
	
	public void unregisterEventListner()
	{
		try
		{
			EventManager.getManager().unregisterProActiveEventListener( 
				this, SecurityEvent.ACCESS );
		}
		catch ( EventListenerNotRegisteredException e )
		{
			throw new RuntimeException( e );
		}
	}
}
