org.jooq.RecordListener Maven / Gradle / Ivy
/**
* Copyright (c) 2009-2016, Data Geekery GmbH (http://www.datageekery.com)
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Other licenses:
* -----------------------------------------------------------------------------
* Commercial licenses for this work are available. These replace the above
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
* database integrations.
*
* For more information, please visit: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq;
import java.util.EventListener;
/**
* A listener for manipulation events on {@link UpdatableRecord}s.
*
* Users may want to centrally inject custom behaviour when manipulating their
* {@link UpdatableRecord} objects, performing CRUD. This service provider
* allows to hook in callback method implementations for before or after any of
* these methods:
*
* - {@link UpdatableRecord#store()}
* - {@link UpdatableRecord#insert()}
* - {@link UpdatableRecord#update()}
* - {@link UpdatableRecord#delete()}
* - {@link UpdatableRecord#refresh()}
*
*
* @author Lukas Eder
*/
public interface RecordListener extends EventListener {
/**
* Called before storing an UpdatableRecord
.
*
* Implementations are allowed to modify {@link RecordContext#record()}
* prior to storing. Note that modifying the record's primary key value may
* influence whether storing results in an INSERT
or
* UPDATE
statement.
*
* A store event will generate a nested {@link #insertStart(RecordContext)}
* or {@link #updateStart(RecordContext)} event.
*
* @see UpdatableRecord#store()
*/
void storeStart(RecordContext ctx);
/**
* Called after storing an UpdatableRecord
.
*
* Implementations are allowed to modify {@link RecordContext#record()}
* after storing. Note that modifying the record's primary key value may
* influence whether storing results in an INSERT
or
* UPDATE
statement.
*
* A store event will generate a nested {@link #insertEnd(RecordContext)}
* or {@link #updateEnd(RecordContext)} event.
*
* @see UpdatableRecord#store()
*/
void storeEnd(RecordContext ctx);
/**
* Called before inserting an UpdatableRecord
.
*
* Implementations are allowed to modify {@link RecordContext#record()}
* prior to inserting.
*
* @see UpdatableRecord#insert()
*/
void insertStart(RecordContext ctx);
/**
* Called after inserting an UpdatableRecord
.
*
* Implementations are allowed to modify {@link RecordContext#record()}
* after inserting.
*
* @see UpdatableRecord#insert()
*/
void insertEnd(RecordContext ctx);
/**
* Called before updating an UpdatableRecord
.
*
* Implementations are allowed to modify {@link RecordContext#record()}
* prior to updating.
*
* @see UpdatableRecord#update()
*/
void updateStart(RecordContext ctx);
/**
* Called after updating an UpdatableRecord
.
*
* Implementations are allowed to modify {@link RecordContext#record()}
* after updating.
*
* @see UpdatableRecord#update()
*/
void updateEnd(RecordContext ctx);
/**
* Called before deleting an UpdatableRecord
.
*
* Implementations are allowed to modify {@link RecordContext#record()}
* prior to deleting.
*
* @see UpdatableRecord#delete()
*/
void deleteStart(RecordContext ctx);
/**
* Called after deleting an UpdatableRecord
.
*
* Implementations are allowed to modify {@link RecordContext#record()}
* after deleting.
*
* @see UpdatableRecord#delete()
*/
void deleteEnd(RecordContext ctx);
/**
* Called before loading an UpdatableRecord
.
*
* Implementations are allowed to modify {@link RecordContext#record()}
* prior to loading.
*/
void loadStart(RecordContext ctx);
/**
* Called after loading an UpdatableRecord
.
*
* Implementations are allowed to modify {@link RecordContext#record()}
* after loading.
*/
void loadEnd(RecordContext ctx);
/**
* Called before refreshing an UpdatableRecord
.
*
* Implementations are allowed to modify {@link RecordContext#record()}
* prior to refreshing.
*
* @see UpdatableRecord#refresh()
*/
void refreshStart(RecordContext ctx);
/**
* Called after refreshing an UpdatableRecord
.
*
* Implementations are allowed to modify {@link RecordContext#record()}
* after refreshing.
*
* @see UpdatableRecord#refresh()
*/
void refreshEnd(RecordContext ctx);
/**
* Called when an exception occurs.
*/
void exception(RecordContext ctx);
}