Source Code Cross Referenced for ModulesConfiguration.java in  » Net » Terracotta » org » terracotta » dso » 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 » Net » Terracotta » org.terracotta.dso 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
003:         * notice. All rights reserved.
004:         */
005:        package org.terracotta.dso;
006:
007:        import org.osgi.framework.Bundle;
008:
009:        import com.terracottatech.config.AdditionalBootJarClasses;
010:        import com.terracottatech.config.Autolock;
011:        import com.terracottatech.config.DistributedMethods;
012:        import com.terracottatech.config.DsoApplication;
013:        import com.terracottatech.config.Include;
014:        import com.terracottatech.config.InstrumentedClasses;
015:        import com.terracottatech.config.Locks;
016:        import com.terracottatech.config.Module;
017:        import com.terracottatech.config.NamedLock;
018:        import com.terracottatech.config.Root;
019:        import com.terracottatech.config.Roots;
020:        import com.terracottatech.config.TransientFields;
021:        import com.terracottatech.config.WebApplication;
022:        import com.terracottatech.config.WebApplications;
023:        import com.terracottatech.config.DistributedMethods.MethodExpression;
024:
025:        import java.net.URL;
026:        import java.util.ArrayList;
027:        import java.util.Arrays;
028:        import java.util.List;
029:
030:        public class ModulesConfiguration {
031:            private List<ModuleInfo> fModuleInfoList;
032:            private DsoApplication fApplication;
033:
034:            public ModulesConfiguration() {
035:                fModuleInfoList = new ArrayList();
036:                fApplication = DsoApplication.Factory.newInstance();
037:            }
038:
039:            public ModuleInfo add(Module module) {
040:                ModuleInfo moduleInfo = new ModuleInfo(module);
041:                fModuleInfoList.add(moduleInfo);
042:                return moduleInfo;
043:            }
044:
045:            public ModuleInfo getOrAdd(Module module) {
046:                ModuleInfo moduleInfo = getModuleInfo(module);
047:                if (moduleInfo == null) {
048:                    moduleInfo = add(module);
049:                }
050:                return moduleInfo;
051:            }
052:
053:            public static boolean sameModule(Module m1, Module m2) {
054:                return m1 != null && m2 != null
055:                        && m1.getName().equals(m2.getName())
056:                        && m1.getGroupId().equals(m2.getGroupId())
057:                        && m1.getVersion().equals(m2.getVersion());
058:            }
059:
060:            public ModuleInfo getModuleInfo(Module module) {
061:                for (ModuleInfo moduleInfo : fModuleInfoList) {
062:                    if (sameModule(module, moduleInfo.getModule())) {
063:                        return moduleInfo;
064:                    }
065:                }
066:                return null;
067:            }
068:
069:            public ModuleInfo associateBundle(Bundle bundle) {
070:                for (ModuleInfo moduleInfo : fModuleInfoList) {
071:                    URL location = moduleInfo.getLocation();
072:                    String bundleLocation = bundle.getLocation();
073:
074:                    if (location != null
075:                            && location.toString().equals(bundleLocation)) {
076:                        moduleInfo.setBundle(bundle);
077:                        return moduleInfo;
078:                    }
079:                }
080:                return null;
081:            }
082:
083:            public void setModuleApplication(ModuleInfo moduleInfo,
084:                    DsoApplication application) {
085:                moduleInfo.setApplication(application);
086:                merge(application);
087:            }
088:
089:            public DsoApplication getApplication() {
090:                return fApplication;
091:            }
092:
093:            public void merge(DsoApplication application) {
094:                merge(application, fApplication);
095:            }
096:
097:            public static void merge(DsoApplication src, DsoApplication dest) {
098:                if (src.isSetInstrumentedClasses()) {
099:                    InstrumentedClasses srcInstrumentedClasses = src
100:                            .getInstrumentedClasses();
101:                    InstrumentedClasses destInstrumentedClasses = dest
102:                            .isSetInstrumentedClasses() ? dest
103:                            .getInstrumentedClasses() : dest
104:                            .addNewInstrumentedClasses();
105:                    merge(srcInstrumentedClasses, destInstrumentedClasses);
106:                }
107:
108:                if (src.isSetTransientFields()) {
109:                    TransientFields srcTransientFields = src
110:                            .getTransientFields();
111:                    TransientFields destTransientFields = dest
112:                            .isSetTransientFields() ? dest.getTransientFields()
113:                            : dest.addNewTransientFields();
114:                    merge(srcTransientFields, destTransientFields);
115:                }
116:
117:                if (src.isSetLocks()) {
118:                    Locks srcLocks = src.getLocks();
119:                    Locks destLocks = dest.isSetLocks() ? dest.getLocks()
120:                            : dest.addNewLocks();
121:                    merge(srcLocks, destLocks);
122:                }
123:
124:                if (src.isSetRoots()) {
125:                    Roots srcRoots = src.getRoots();
126:                    Roots destRoots = dest.isSetRoots() ? dest.getRoots()
127:                            : dest.addNewRoots();
128:                    merge(srcRoots, destRoots);
129:                }
130:
131:                if (src.isSetDistributedMethods()) {
132:                    DistributedMethods srcDistributedMethods = src
133:                            .getDistributedMethods();
134:                    DistributedMethods destDistributedMethods = dest
135:                            .isSetDistributedMethods() ? dest
136:                            .getDistributedMethods() : dest
137:                            .addNewDistributedMethods();
138:                    merge(srcDistributedMethods, destDistributedMethods);
139:                }
140:
141:                if (src.isSetAdditionalBootJarClasses()) {
142:                    AdditionalBootJarClasses srcBootClasses = src
143:                            .getAdditionalBootJarClasses();
144:                    AdditionalBootJarClasses destBootClasses = dest
145:                            .isSetAdditionalBootJarClasses() ? dest
146:                            .getAdditionalBootJarClasses() : dest
147:                            .addNewAdditionalBootJarClasses();
148:                    merge(srcBootClasses, destBootClasses);
149:                }
150:
151:                if (src.isSetWebApplications()) {
152:                    WebApplications srcWebApps = src.getWebApplications();
153:                    WebApplications destWebApps = dest.isSetWebApplications() ? dest
154:                            .getWebApplications()
155:                            : dest.addNewWebApplications();
156:                    merge(srcWebApps, destWebApps);
157:                }
158:
159:                if (src.isSetDsoReflectionEnabled()) {
160:                    dest.setDsoReflectionEnabled(src.getDsoReflectionEnabled());
161:                }
162:            }
163:
164:            public static void merge(InstrumentedClasses src,
165:                    InstrumentedClasses dest) {
166:                Include[] includes = src.getIncludeArray();
167:                List<Include> includeList = new ArrayList(Arrays
168:                        .asList(includes));
169:
170:                for (Include include : dest.getIncludeArray()) {
171:                    includeList.add((Include) include.copy());
172:                }
173:                dest.setIncludeArray(includeList.toArray(new Include[0]));
174:            }
175:
176:            public static void merge(TransientFields src, TransientFields dest) {
177:                String[] fields = src.getFieldNameArray();
178:                List<String> fieldList = new ArrayList(Arrays.asList(fields));
179:
180:                fieldList.addAll(Arrays.asList(dest.getFieldNameArray()));
181:                dest.setFieldNameArray(fieldList.toArray(new String[0]));
182:            }
183:
184:            public static void merge(Locks src, Locks dest) {
185:                Autolock[] autolocks = src.getAutolockArray();
186:                List<Autolock> autolockList = new ArrayList(Arrays
187:                        .asList(autolocks));
188:
189:                for (Autolock autolock : dest.getAutolockArray()) {
190:                    autolockList.add((Autolock) autolock.copy());
191:                }
192:                dest.setAutolockArray(autolockList.toArray(new Autolock[0]));
193:
194:                NamedLock[] namedLocks = src.getNamedLockArray();
195:                List<NamedLock> namedLockList = new ArrayList(Arrays
196:                        .asList(namedLocks));
197:
198:                for (NamedLock namedLock : dest.getNamedLockArray()) {
199:                    namedLockList.add((NamedLock) namedLock.copy());
200:                }
201:                dest.setNamedLockArray(namedLockList.toArray(new NamedLock[0]));
202:            }
203:
204:            public static void merge(Roots src, Roots dest) {
205:                Root[] roots = src.getRootArray();
206:                List<Root> rootList = new ArrayList(Arrays.asList(roots));
207:
208:                for (Root root : dest.getRootArray()) {
209:                    rootList.add((Root) root.copy());
210:                }
211:                dest.setRootArray(rootList.toArray(new Root[0]));
212:            }
213:
214:            public static void merge(DistributedMethods src,
215:                    DistributedMethods dest) {
216:                MethodExpression[] methodExprs = src.getMethodExpressionArray();
217:                List<MethodExpression> exprList = new ArrayList(Arrays
218:                        .asList(methodExprs));
219:
220:                for (MethodExpression expr : dest.getMethodExpressionArray()) {
221:                    exprList.add((MethodExpression) expr.copy());
222:                }
223:                dest.setMethodExpressionArray(exprList
224:                        .toArray(new MethodExpression[0]));
225:            }
226:
227:            public static void merge(AdditionalBootJarClasses src,
228:                    AdditionalBootJarClasses dest) {
229:                String[] includes = src.getIncludeArray();
230:                List<String> includeList = new ArrayList(Arrays
231:                        .asList(includes));
232:
233:                includeList.addAll(Arrays.asList(dest.getIncludeArray()));
234:                dest.setIncludeArray(includeList.toArray(new String[0]));
235:            }
236:
237:            public static void merge(WebApplications src, WebApplications dest) {
238:                WebApplication[] webApps = src.getWebApplicationArray();
239:                List<WebApplication> webAppList = new ArrayList(Arrays
240:                        .asList(webApps));
241:
242:                for (WebApplication webApp : dest.getWebApplicationArray()) {
243:                    webAppList.add((WebApplication) webApp.copy());
244:                }
245:                dest.setWebApplicationArray(webAppList
246:                        .toArray(new WebApplication[0]));
247:            }
248:
249:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.