KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > ejb > base > sfsb > store > FileTxStoreManager


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.ejb.base.sfsb.store;
25
26 import java.util.logging.Logger JavaDoc;
27 import java.util.logging.Level JavaDoc;
28 import com.sun.logging.LogDomains;
29
30 import com.sun.ejb.spi.sfsb.store.SFSBTxStoreManager;
31 import com.sun.ejb.spi.sfsb.store.SFSBStoreManager;
32 import com.sun.ejb.spi.sfsb.store.SFSBBeanState;
33 import com.sun.ejb.spi.sfsb.store.SFSBStoreManagerException;
34
35
36 /**
37  * A SFSBTxStoreManager that <b>CANNOT</b> save multiple SFSBBeanStates
38  * as a single transactional unit (Example file system).
39  *
40  * This implementation simply stores each BeanState separately by
41  * calling the appropriate StoreManager's checkpointSave method
42  *
43  * @author Mahesh Kannan
44  */

45 public class FileTxStoreManager
46     implements SFSBTxStoreManager
47 {
48
49     private static final Level JavaDoc TRACE_LEVEL = Level.FINE;
50
51     protected static Logger JavaDoc _logger =
52     LogDomains.getLogger(LogDomains.EJB_LOGGER);
53
54     public FileTxStoreManager() {
55     }
56
57     public void checkpointSave(SFSBBeanState[] beanStates)
58         throws SFSBStoreManagerException
59     {
60     int sz = beanStates.length;
61     for (int i=0; i<sz; i++) {
62         SFSBStoreManager manager = beanStates[i].getSFSBStoreManager();
63         try {
64         if (manager == null) {
65             _logger.log(Level.WARNING,
66             "StoreManager is null. Cannot checkpoint");
67         } else {
68             manager.checkpointSave(beanStates[i]);
69             if (_logger.isLoggable(TRACE_LEVEL)) {
70             _logger.log(TRACE_LEVEL, "Successfully txCheckpointed "
71                 + beanStates.length + " beans...");
72             }
73         }
74         } catch (SFSBStoreManagerException smEx) {
75         _logger.log(Level.WARNING,
76             "StoreManagerException during checkpointSave", smEx);
77         } catch (Throwable JavaDoc th) {
78         _logger.log(Level.WARNING,
79             "Exception during checkpointSave", th);
80         }
81     }
82     }
83
84 }
85
Popular Tags