Source Code Cross Referenced for ConfigurationMetaData.java in  » EJB-Server-JBoss-4.2.1 » server » org » jboss » metadata » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » EJB Server JBoss 4.2.1 » server » org.jboss.metadata 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JBoss, Home of Professional Open Source.
003:         * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004:         * as indicated by the @author tags. See the copyright.txt file in the
005:         * distribution for a full listing of individual contributors.
006:         *
007:         * This is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU Lesser General Public License as
009:         * published by the Free Software Foundation; either version 2.1 of
010:         * the License, or (at your option) any later version.
011:         *
012:         * This software is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this software; if not, write to the Free
019:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021:         */
022:        package org.jboss.metadata;
023:
024:        import java.util.Collection;
025:        import java.util.Iterator;
026:        import java.util.LinkedList;
027:        import java.util.List;
028:
029:        import org.jboss.deployment.DeploymentException;
030:        import org.jboss.mx.util.ObjectNameFactory;
031:        import org.w3c.dom.Element;
032:
033:        /** The configuration information for an EJB container.
034:         *   @author <a href="mailto:sebastien.alborini@m4x.org">Sebastien Alborini</a>
035:         *   @author <a href="mailto:scott.stark@jboss.org">Scott Stark</a>
036:         *   @author <a href="mailto:christoph.jung@infor.de">Christoph G. Jung</a>
037:         *   @version $Revision: 63202 $
038:         */
039:        public class ConfigurationMetaData extends MetaData {
040:            // Constants -----------------------------------------------------
041:            public static final String CMP_2x_13 = "Standard CMP 2.x EntityBean";
042:            public static final String CMP_1x_13 = "Standard CMP EntityBean";
043:            public static final String BMP_13 = "Standard BMP EntityBean";
044:            public static final String STATELESS_13 = "Standard Stateless SessionBean";
045:            public static final String STATEFUL_13 = "Standard Stateful SessionBean";
046:            public static final String MESSAGE_DRIVEN_13 = "Standard Message Driven Bean";
047:            public static final String MESSAGE_INFLOW_DRIVEN = "Standard Message Inflow Driven Bean";
048:
049:            public static final String CLUSTERED_CMP_2x_13 = "Clustered CMP 2.x EntityBean";
050:            public static final String CLUSTERED_CMP_1x_13 = "Clustered CMP EntityBean";
051:            public static final String CLUSTERED_BMP_13 = "Clustered BMP EntityBean";
052:            public static final String CLUSTERED_STATEFUL_13 = "Clustered Stateful SessionBean";
053:            public static final String CLUSTERED_STATELESS_13 = "Clustered Stateless SessionBean";
054:
055:            public static final byte A_COMMIT_OPTION = 0;
056:            public static final byte B_COMMIT_OPTION = 1;
057:            public static final byte C_COMMIT_OPTION = 2;
058:            /** D_COMMIT_OPTION is a lazy load option. By default it synchronizes every 30 seconds */
059:            public static final byte D_COMMIT_OPTION = 3;
060:            public static final String[] commitOptionStrings = { "A", "B", "C",
061:                    "D" };
062:
063:            // Attributes ----------------------------------------------------
064:            private String name;
065:            private String instancePool;
066:            private String instanceCache;
067:            private String persistenceManager;
068:            private String webClassLoader = "org.jboss.web.WebClassLoader";
069:            private String lockClass = "org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock";
070:            private byte commitOption;
071:            private long optionDRefreshRate = 30000;
072:            private boolean callLogging;
073:            private boolean syncOnCommitOnly = false;
074:            /** if true, INSERT will be issued after ejbPostCreate */
075:            private boolean insertAfterEjbPostCreate = false;
076:            /** The container level security domain */
077:            private String securityDomain;
078:            /** The container invoker binding names */
079:            private String[] invokerNames;
080:            /** The InstancePool configuration */
081:            private Element containerPoolConf;
082:            /** The InstanceCache configuration */
083:            private Element containerCacheConf;
084:            /** The ejb container interceptor stack configuration */
085:            private Element containerInterceptorsConf;
086:            /** The JMX object names for container level dependencies */
087:            private Collection depends = new LinkedList();
088:            /** The cluster-config element info */
089:            private ClusterConfigMetaData clusterConfig = null;
090:            /** By the spec ejbStore must be called even for clean instances. But not everyone agrees. */
091:            private boolean ejbStoreForClean;
092:            /** Whether dirty instances that couldn't be evicted from the cache after cache.flush()
093:                should or should not (to prevent potential data inconsistency) be stored*/
094:            private boolean storeNotFlushed = true;
095:
096:            // Static --------------------------------------------------------
097:
098:            // Constructors --------------------------------------------------
099:            public ConfigurationMetaData(String name) {
100:                this .name = name;
101:            }
102:
103:            // Public --------------------------------------------------------
104:
105:            public String getName() {
106:                return name;
107:            }
108:
109:            public String getInstancePool() {
110:                return instancePool;
111:            }
112:
113:            public String getInstanceCache() {
114:                return instanceCache;
115:            }
116:
117:            public String getPersistenceManager() {
118:                return persistenceManager;
119:            }
120:
121:            public String getSecurityDomain() {
122:                return securityDomain;
123:            }
124:
125:            public String[] getInvokers() {
126:                return invokerNames;
127:            }
128:
129:            public String getWebClassLoader() {
130:                return webClassLoader;
131:            }
132:
133:            public String getLockClass() {
134:                return lockClass;
135:            }
136:
137:            public Element getContainerPoolConf() {
138:                return containerPoolConf;
139:            }
140:
141:            public Element getContainerCacheConf() {
142:                return containerCacheConf;
143:            }
144:
145:            public String getDefaultInvokerName() {
146:                if (invokerNames.length == 0)
147:                    throw new IllegalStateException("No invokers defined");
148:                return invokerNames[0];
149:            }
150:
151:            public Element getContainerInterceptorsConf() {
152:                return containerInterceptorsConf;
153:            }
154:
155:            public boolean getCallLogging() {
156:                return callLogging;
157:            }
158:
159:            public boolean getSyncOnCommitOnly() {
160:                return syncOnCommitOnly;
161:            }
162:
163:            public boolean isInsertAfterEjbPostCreate() {
164:                return insertAfterEjbPostCreate;
165:            }
166:
167:            public boolean isEjbStoreForClean() {
168:                return this .ejbStoreForClean;
169:            }
170:
171:            public boolean isStoreNotFlushed() {
172:                return storeNotFlushed;
173:            }
174:
175:            public byte getCommitOption() {
176:                return commitOption;
177:            }
178:
179:            public long getOptionDRefreshRate() {
180:                return optionDRefreshRate;
181:            }
182:
183:            public ClusterConfigMetaData getClusterConfigMetaData() {
184:                return this .clusterConfig;
185:            }
186:
187:            public Collection getDepends() {
188:                return depends;
189:            }
190:
191:            public void importJbossXml(Element element)
192:                    throws DeploymentException {
193:
194:                // everything is optional to allow jboss.xml to modify part of a configuration
195:                // defined in standardjboss.xml
196:
197:                // set call logging
198:                callLogging = Boolean.valueOf(
199:                        getElementContent(getOptionalChild(element,
200:                                "call-logging"), String.valueOf(callLogging)))
201:                        .booleanValue();
202:
203:                // set synchronize on commit only
204:                syncOnCommitOnly = Boolean.valueOf(
205:                        getElementContent(getOptionalChild(element,
206:                                "sync-on-commit-only"), String
207:                                .valueOf(syncOnCommitOnly))).booleanValue();
208:
209:                // set insert-after-ejb-post-create
210:                insertAfterEjbPostCreate = Boolean.valueOf(
211:                        getElementContent(getOptionalChild(element,
212:                                "insert-after-ejb-post-create"), String
213:                                .valueOf(insertAfterEjbPostCreate)))
214:                        .booleanValue();
215:
216:                // ejbStoreForClean
217:                ejbStoreForClean = Boolean.valueOf(
218:                        getElementContent(getOptionalChild(element,
219:                                "call-ejb-store-on-clean"), String
220:                                .valueOf(ejbStoreForClean))).booleanValue();
221:
222:                // store-not-flushed
223:                storeNotFlushed = Boolean.valueOf(
224:                        getElementContent(getOptionalChild(element,
225:                                "store-not-flushed"), String
226:                                .valueOf(storeNotFlushed))).booleanValue();
227:
228:                // set the instance pool
229:                instancePool = getElementContent(getOptionalChild(element,
230:                        "instance-pool"), instancePool);
231:
232:                // set the instance cache
233:                instanceCache = getElementContent(getOptionalChild(element,
234:                        "instance-cache"), instanceCache);
235:
236:                // set the persistence manager
237:                persistenceManager = getElementContent(getOptionalChild(
238:                        element, "persistence-manager"), persistenceManager);
239:
240:                // set the web classloader
241:                webClassLoader = getElementContent(getOptionalChild(element,
242:                        "web-class-loader"), webClassLoader);
243:
244:                // set the lock class
245:                lockClass = getElementContent(getOptionalChild(element,
246:                        "locking-policy"), lockClass);
247:
248:                // set the security domain
249:                securityDomain = getElementContent(getOptionalChild(element,
250:                        "security-domain"), securityDomain);
251:
252:                //Get configured invokers
253:                List invokers = new java.util.ArrayList();
254:
255:                for (Iterator invokerElements = getChildrenByTagName(element,
256:                        "invoker-proxy-binding-name"); invokerElements
257:                        .hasNext();) {
258:                    Element invokerElement = (Element) invokerElements.next();
259:                    String invokerName = getElementContent(invokerElement);
260:                    invokers.add(invokerName);
261:                } // end of for ()
262:
263:                // JBAS-4444, override invokers only if they are specified
264:                if (invokers.isEmpty() == false) {
265:                    invokerNames = (String[]) invokers
266:                            .toArray(new String[invokers.size()]);
267:                }
268:
269:                // set the commit option
270:                String commit = getElementContent(getOptionalChild(element,
271:                        "commit-option"), commitOptionToString(commitOption));
272:
273:                commitOption = stringToCommitOption(commit);
274:
275:                //get the refresh rate for option D
276:                String refresh = getElementContent(getOptionalChild(element,
277:                        "optiond-refresh-rate"), Long
278:                        .toString(optionDRefreshRate / 1000));
279:                optionDRefreshRate = stringToRefreshRate(refresh);
280:
281:                // the classes which can understand the following are dynamically loaded during deployment :
282:                // We save the Elements for them to use later
283:
284:                // The configuration for the container interceptors
285:                containerInterceptorsConf = getOptionalChild(element,
286:                        "container-interceptors", containerInterceptorsConf);
287:
288:                // configuration for instance pool
289:                containerPoolConf = getOptionalChild(element,
290:                        "container-pool-conf", containerPoolConf);
291:
292:                // configuration for instance cache
293:                containerCacheConf = getOptionalChild(element,
294:                        "container-cache-conf", containerCacheConf);
295:
296:                //Get depends object names
297:                for (Iterator dependsElements = getChildrenByTagName(element,
298:                        "depends"); dependsElements.hasNext();) {
299:                    Element dependsElement = (Element) dependsElements.next();
300:                    String dependsName = getElementContent(dependsElement);
301:                    depends.add(ObjectNameFactory.create(dependsName));
302:                } // end of for ()
303:
304:                // Check for clustering configuration
305:                Element clusterConfigElement = getOptionalChild(element,
306:                        "cluster-config");
307:                if (clusterConfigElement != null) {
308:                    clusterConfig = new ClusterConfigMetaData();
309:                    clusterConfig.importJbossXml(clusterConfigElement);
310:                }
311:            }
312:
313:            // Package protected ---------------------------------------------
314:
315:            // Protected -----------------------------------------------------
316:
317:            // Private -------------------------------------------------------
318:            private static String commitOptionToString(byte commitOption)
319:                    throws DeploymentException {
320:                try {
321:                    return commitOptionStrings[commitOption];
322:                } catch (ArrayIndexOutOfBoundsException e) {
323:                    throw new DeploymentException("Invalid commit option: "
324:                            + commitOption);
325:                }
326:            }
327:
328:            private static byte stringToCommitOption(String commitOption)
329:                    throws DeploymentException {
330:                for (byte i = 0; i < commitOptionStrings.length; ++i)
331:                    if (commitOptionStrings[i].equals(commitOption))
332:                        return i;
333:
334:                throw new DeploymentException("Invalid commit option: '"
335:                        + commitOption + "'");
336:            }
337:
338:            /** Parse the refresh rate string into a long
339:             * @param refreshRate in seconds
340:             * @return refresh rate in milliseconds suitable for use in Thread.sleep
341:             * @throws DeploymentException on failure to parse refreshRate as a long
342:             */
343:            private static long stringToRefreshRate(String refreshRate)
344:                    throws DeploymentException {
345:                try {
346:                    long rate = Long.parseLong(refreshRate);
347:                    // Convert from seconds to milliseconds
348:                    rate *= 1000;
349:                    return rate;
350:                } catch (Exception e) {
351:                    throw new DeploymentException(
352:                            "Invalid optiond-refresh-rate '" + refreshRate
353:                                    + "'. Should be a number");
354:                }
355:
356:            }
357:
358:            // Inner classes -------------------------------------------------
359:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.