KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opensubsystems > patterns > mappeddata > logic > impl > MappingControllerImpl


1 /*
2  * Copyright (c) 2006 - 2007 OpenSubsystems s.r.o. Slovak Republic. All rights reserved.
3  *
4  * Project: OpenSubsystems
5  *
6  * $Id: MappingControllerImpl.java,v 1.4 2007/01/28 06:54:52 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.patterns.mappeddata.logic.impl;
23
24 import java.rmi.RemoteException JavaDoc;
25
26 import org.opensubsystems.core.data.DataObject;
27 import org.opensubsystems.core.data.ModifiableDataObject;
28 import org.opensubsystems.core.error.OSSException;
29 import org.opensubsystems.core.logic.impl.StatelessControllerImpl;
30 import org.opensubsystems.core.util.CallContext;
31 import org.opensubsystems.core.util.ThreeIntStruct;
32 import org.opensubsystems.patterns.mappeddata.data.MappedData;
33 import org.opensubsystems.patterns.mappeddata.logic.MappingController;
34 import org.opensubsystems.patterns.mappeddata.persist.MappingFactory;
35
36 /**
37  * Implementation of MappingController interface to manage mapped data records.
38  *
39  * @ejb.bean type="Stateless"
40  * name="MappingController"
41  * jndi-name="org.opensubsystems.patterns.mappeddata.logic.MappingControllerRemote"
42  * local-jndi-name="org.opensubsystems.patterns.mappeddata.logic.MappingController"
43  * @ejb.interface
44  * local-extends="javax.ejb.EJBLocalObject, org.opensubsystems.patterns.mappeddata.logic.MappingController"
45  * extends="javax.ejb.EJBObject, org.opensubsystems.patterns.mappeddata.logic.MappingController"
46  * @ejb.home local-extends="javax.ejb.EJBLocalHome"
47  * extends="javax.ejb.EJBHome"
48  *
49  * @jonas.bean ejb-name="MappingController"
50  * jndi-name="org.opensubsystems.patterns.mappeddata.logic.MappingControllerRemote"
51  *
52  * @version $Id: MappingControllerImpl.java,v 1.4 2007/01/28 06:54:52 bastafidli Exp $
53  * @author Julian Legeny
54  * @code.reviewer Miro Halas
55  * @code.reviewed 1.1 2006/07/03 19:53:01 jlegeny
56  */

57 public class MappingControllerImpl extends StatelessControllerImpl
58                                    implements MappingController
59 {
60    // Cached values ////////////////////////////////////////////////////////////
61

62    /**
63     * Factory to use to execute persistence operations.
64     * Inherited class from this base class has to have instantiated
65     * particular factory that will be used here. It has to be
66     * done within the method constructor().
67     */

68    protected MappingFactory m_mappingFactory;
69
70    // Attributes ///////////////////////////////////////////////////////////////
71

72    /**
73     * Generated serial version id for this class.
74     */

75    private static final long serialVersionUID = -6311825396478182048L;
76
77    // Constructors /////////////////////////////////////////////////////////////
78

79    /**
80     * Default constructor.
81     */

82    public MappingControllerImpl(
83    )
84    {
85       super();
86       
87       // Do not cache anything here since if this controller is run as a stateless
88
// session bean the referenced objects may not be ready
89
m_mappingFactory = null;
90    }
91    
92    // Business logic ///////////////////////////////////////////////////////////
93

94    /**
95     * {@inheritDoc}
96     *
97     * @ejb.interface-method
98     * @ejb.transaction type="Supports"
99     */

100    public DataObject get(
101       int iId
102    ) throws OSSException,
103             RemoteException JavaDoc
104    {
105       MappedData data = null;
106
107       data = (MappedData)m_mappingFactory.get(
108                 iId, CallContext.getInstance().getCurrentDomainId());
109
110       return data;
111    }
112
113    /**
114     * {@inheritDoc}
115     *
116     * @ejb.interface-method
117     * @ejb.transaction type="Required"
118     */

119    public DataObject create(
120       DataObject data
121    ) throws OSSException,
122             RemoteException JavaDoc
123    {
124       MappedData createddata = null;
125
126       createddata = (MappedData)m_mappingFactory.create(data);
127
128       return createddata;
129    }
130
131    /**
132     * {@inheritDoc}
133     *
134     * @ejb.interface-method
135     * @ejb.transaction type="Required"
136     */

137    public ModifiableDataObject save(
138       ModifiableDataObject data
139    ) throws OSSException,
140             RemoteException JavaDoc
141    {
142       MappedData updatedddata = null;
143
144       updatedddata = (MappedData)m_mappingFactory.create(data);
145
146       return updatedddata;
147    }
148
149    /**
150     * {@inheritDoc}
151     *
152     * @ejb.interface-method
153     * @ejb.transaction type="Required"
154     */

155    public void delete(
156       int iId
157    ) throws OSSException,
158             RemoteException JavaDoc
159    {
160       m_mappingFactory.delete(iId,
161                               CallContext.getInstance().getCurrentDomainId());
162    }
163
164    /**
165     * {@inheritDoc}
166     *
167     * @ejb.interface-method
168     * @ejb.transaction type="Required"
169     */

170    public void create(
171       ThreeIntStruct tisValues
172    ) throws OSSException,
173             RemoteException JavaDoc
174    {
175       m_mappingFactory.create(tisValues);
176    }
177
178    /**
179     * {@inheritDoc}
180     *
181     * @ejb.interface-method
182     * @ejb.transaction type="Required"
183     */

184    public void delete(
185       ThreeIntStruct tisValues
186    ) throws OSSException,
187             RemoteException JavaDoc
188    {
189       m_mappingFactory.delete(tisValues);
190    }
191
192    /**
193     * {@inheritDoc}
194     *
195     * @ejb.interface-method
196     * @ejb.transaction type="Supports"
197     */

198    public int[] getMappedData(
199       int iId,
200       int iMappingType
201    ) throws OSSException,
202             RemoteException JavaDoc
203    {
204       int[] arrReturn = null;
205       
206       arrReturn = m_mappingFactory.getMappedData(iId, iMappingType);
207
208       return arrReturn;
209    }
210 }
211
Popular Tags