KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > orm > ojb > PersistenceBrokerCallback


1 /*
2  * Copyright 2002-2005 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.springframework.orm.ojb;
18
19 import java.sql.SQLException JavaDoc;
20
21 import org.apache.ojb.broker.PersistenceBroker;
22 import org.apache.ojb.broker.PersistenceBrokerException;
23 import org.apache.ojb.broker.accesslayer.LookupException;
24
25 /**
26  * Callback interface for OJB PersistenceBroker code.
27  * To be used with PersistenceBrokerTemplate's execute method,
28  * assumably often as anonymous classes within a method implementation.
29  *
30  * <p>The typical implementation will call PersistenceBroker CRUD to
31  * perform some operations on persistent objects.
32  *
33  * @author Juergen Hoeller
34  * @since 1.1
35  * @see PersistenceBrokerTemplate
36  */

37 public interface PersistenceBrokerCallback {
38
39     /**
40      * Gets called by <code>PersistenceBrokerTemplate.execute</code> with an active
41      * PersistenceBroker. Does not need to care about activating or closing the
42      * PersistenceBroker, or handling transactions.
43      *
44      * <p>Allows for returning a result object created within the callback,
45      * i.e. a domain object or a collection of domain objects.
46      * A thrown RuntimeException is treated as application exception,
47      * it gets propagated to the caller of the template.
48      *
49      * @param pb active PersistenceBroker
50      * @return a result object, or null if none
51      * @throws PersistenceBrokerException in case of OJB errors
52      * @throws LookupException if thrown by OJB lookup methods
53      * @throws SQLException in case of errors on direct JDBC access
54      * @see PersistenceBrokerTemplate#execute
55      */

56     Object JavaDoc doInPersistenceBroker(PersistenceBroker pb)
57         throws PersistenceBrokerException, LookupException, SQLException JavaDoc;
58
59 }
60
Popular Tags