KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > web > session > PersistenceType


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 /*
25  * Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved.
26  * Use is subject to license terms.
27  */

28
29 package com.sun.enterprise.web.session;
30
31 /**
32  * Represents each of the persistence mechanisms supported by the session
33  * managers.
34  */

35 public final class PersistenceType {
36
37     // ------------------------------------------------------- Static Variables
38

39     /**
40      * Memory based persistence for sessions (i.e. none);
41      */

42     public static final PersistenceType MEMORY =
43         new PersistenceType("memory");
44
45     /**
46      * File based persistence for sessions.
47      */

48     public static final PersistenceType FILE =
49         new PersistenceType("file");
50
51     /**
52      * Custom/user implemented session manager.
53      */

54     public static final PersistenceType CUSTOM =
55         new PersistenceType("custom");
56     
57     /**
58      * old iWS 6.0 style session manager.
59      */

60     public static final PersistenceType S1WS60 =
61         new PersistenceType("s1ws60");
62
63     /**
64      * old iWS 6.0 style
65      * MMapSessionManager.
66      */

67     public static final PersistenceType MMAP =
68         new PersistenceType("mmap");
69
70     /**
71      * JDBC based persistence for sessions.
72      */

73     public static final PersistenceType JDBC =
74         new PersistenceType("jdbc");
75     
76     /**
77      * HADB based persistence for sessions.
78      */

79     public static final PersistenceType HA =
80         new PersistenceType("ha");
81     
82     /**
83      * SJSWS replicated persistence for sessions.
84      */

85     public static final PersistenceType REPLICATED =
86         new PersistenceType("replicated");
87
88     // ----------------------------------------------------------- Constructors
89

90     /**
91      * Default constructor that sets its type to the specified string.
92      */

93     private PersistenceType(String JavaDoc type) {
94         _type = type;
95     }
96
97     // ----------------------------------------------------- Instance Variables
98

99     /**
100      * The persistence type specifier.
101      */

102     private String JavaDoc _type = null;
103
104     // ------------------------------------------------------------- Properties
105

106     /**
107      * Returns a string describing the persistence mechanism that the
108      * object represents.
109      */

110     public String JavaDoc getType() {
111         return _type;
112     }
113
114     // --------------------------------------------------------- Static Methods
115

116     /**
117      * Parse the specified string and return the corresponding instance
118      * of this class that represents the persistence type specified
119      * in the string.
120      */

121     public static PersistenceType parseType(String JavaDoc type) {
122         // Default persistence type is MEMORY
123
PersistenceType pType = MEMORY;
124         if (type != null) {
125             if (type.equalsIgnoreCase(FILE.getType()))
126                 pType = FILE;
127             else if (type.equalsIgnoreCase(CUSTOM.getType()))
128                 pType = CUSTOM;
129             else if (type.equalsIgnoreCase(S1WS60.getType()))
130                 pType = S1WS60;
131             else if (type.equalsIgnoreCase(MMAP.getType()))
132                 pType = MMAP;
133             else if (type.equalsIgnoreCase(JDBC.getType()))
134                 pType = JDBC;
135             else if (type.equalsIgnoreCase(HA.getType()))
136                 pType = HA;
137             else if (type.equalsIgnoreCase(REPLICATED.getType()))
138                 pType = REPLICATED;
139         }
140         return pType;
141     }
142     
143     /**
144      * Parse the specified string and return the corresponding instance
145      * of this class that represents the persistence type specified
146      * in the string. Default back into passed-in parameter
147      */

148     public static PersistenceType parseType(String JavaDoc type, PersistenceType defaultType) {
149         // Default persistence type is defaultTypee
150
PersistenceType pType = defaultType;
151         if (type != null) {
152             if (type.equalsIgnoreCase(MEMORY.getType()))
153                 pType = MEMORY;
154             else if (type.equalsIgnoreCase(FILE.getType()))
155                 pType = FILE;
156             else if (type.equalsIgnoreCase(CUSTOM.getType()))
157                 pType = CUSTOM;
158             else if (type.equalsIgnoreCase(S1WS60.getType()))
159                 pType = S1WS60;
160             else if (type.equalsIgnoreCase(MMAP.getType()))
161                 pType = MMAP;
162             else if (type.equalsIgnoreCase(JDBC.getType()))
163                 pType = JDBC;
164             else if (type.equalsIgnoreCase(HA.getType()))
165                 pType = HA;
166             else if (type.equalsIgnoreCase(REPLICATED.getType()))
167                 pType = REPLICATED;
168         }
169         return pType;
170     }
171
172 }
173
174
Popular Tags