KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opensubsystems > core > logic > impl > BasicDataControllerImpl


1 /*
2  * Copyright (c) 2005 - 2007 OpenSubsystems s.r.o. Slovak Republic. All rights reserved.
3  *
4  * Project: OpenSubsystems
5  *
6  * $Id: BasicDataControllerImpl.java,v 1.7 2007/01/28 06:54:51 bastafidli Exp $
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; version 2 of the License.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */

21
22 package org.opensubsystems.core.logic.impl;
23
24 import org.opensubsystems.core.data.DataObject;
25 import org.opensubsystems.core.error.OSSException;
26 import org.opensubsystems.core.logic.BasicDataController;
27 import org.opensubsystems.core.persist.BasicDataFactory;
28 import org.opensubsystems.core.util.CallContext;
29
30 /**
31  * Implementation of BasicDataController interface to manage data. It can be used
32  * by any component which provides BasicDataFactory to access the data. If this
33  * class is used in J2EE environment each method implementation may create
34  * transaction boundary.
35  *
36  * We do not want to generate EJB for this class since it is abstract base
37  * class for real EJBs
38  * @ejb.bean generate="false"
39  *
40  * We need to generate interface since xdoclet will require them for interfaces
41  * derived from BasicDataController. Since remote and local interfaces have to
42  * extend different ejb interfaces and we have only one base interface, the
43  * extends tags have to except our controller contain also the interfaces
44  * required by the spec
45  * @ejb.interface
46  * local-extends="javax.ejb.EJBLocalObject, org.opensubsystems.core.logic.BasicDataController"
47  * extends="javax.ejb.EJBObject, org.opensubsystems.core.logic.BasicDataController"
48  *
49  * @version $Id: BasicDataControllerImpl.java,v 1.7 2007/01/28 06:54:51 bastafidli Exp $
50  * @author Miro Halas
51  * @code.reviewer Miro Halas
52  * @code.reviewed 1.1 2005/08/16 05:25:54 bastafidl
53  */

54 public abstract class BasicDataControllerImpl extends DataControllerImpl
55                                               implements BasicDataController
56 {
57    /**
58     * {@inheritDoc}
59     *
60     * @ejb.interface-method
61     * @ejb.transaction type="Required"
62     */

63    public DataObject create(
64       DataObject data
65    ) throws OSSException
66    {
67       return getDataFactory(data).create(data);
68    }
69
70    /**
71     * This implementation will delete only the default data object supported
72     * by this controller in case the controller supports multiple data types.
73     *
74     * @ejb.interface-method
75     * @ejb.transaction type="Required"
76     *
77     * @param iId {@inheritDoc}
78     * @throws OSSException {@inheritDoc}
79     */

80    public void delete(
81       int iId
82    ) throws OSSException
83    {
84       ((BasicDataFactory)getDataFactory()).delete(iId,
85          CallContext.getInstance().getCurrentDomainId());
86    }
87
88    // Helper methods ///////////////////////////////////////////////////////////
89

90    /**
91     * Get data factory which can be used to access persistence layer for a data
92     * object managed by this controller. In case the controller supports
93     * multiple data types this method should look at the type of the data and
94     * return the factory supporting given data type.
95     *
96     * @param data - data object which will be manipulated using the returned factory
97     * @return DataFactory - data factory for given data object
98     */

99    protected abstract BasicDataFactory getDataFactory(
100       DataObject data
101    );
102 }
103
Popular Tags