Source Code Cross Referenced for CheckEngine.java in  » Code-Analyzer » apache-ivy » org » apache » ivy » core » check » 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 » Code Analyzer » apache ivy » org.apache.ivy.core.check 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         *
017:         */
018:        package org.apache.ivy.core.check;
019:
020:        import java.io.IOException;
021:        import java.net.URL;
022:        import java.text.ParseException;
023:        import java.util.Arrays;
024:        import java.util.HashSet;
025:        import java.util.Iterator;
026:        import java.util.Set;
027:
028:        import org.apache.ivy.core.module.descriptor.Artifact;
029:        import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
030:        import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
031:        import org.apache.ivy.core.resolve.ResolveData;
032:        import org.apache.ivy.core.resolve.ResolveEngine;
033:        import org.apache.ivy.core.resolve.ResolveOptions;
034:        import org.apache.ivy.core.resolve.ResolvedModuleRevision;
035:        import org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistry;
036:        import org.apache.ivy.plugins.resolver.DependencyResolver;
037:        import org.apache.ivy.util.Message;
038:
039:        public class CheckEngine {
040:            private CheckEngineSettings settings;
041:
042:            private ResolveEngine resolveEngine;
043:
044:            public CheckEngine(CheckEngineSettings settings,
045:                    ResolveEngine resolveEngine) {
046:                this .settings = settings;
047:                this .resolveEngine = resolveEngine;
048:            }
049:
050:            /**
051:             * Checks the given ivy file using current settings to see if all dependencies are available,
052:             * with good confs. If a resolver name is given, it also checks that the declared publications
053:             * are available in the corresponding resolver. Note that the check is not performed
054:             * recursively, i.e. if a dependency has itself dependencies badly described or not available,
055:             * this check will not discover it.
056:             */
057:            public boolean check(URL ivyFile, String resolvername) {
058:                try {
059:                    boolean result = true;
060:                    // parse ivy file
061:                    ModuleDescriptor md = ModuleDescriptorParserRegistry
062:                            .getInstance().parseDescriptor(settings, ivyFile,
063:                                    settings.doValidate());
064:
065:                    // check publications if possible
066:                    if (resolvername != null) {
067:                        DependencyResolver resolver = settings
068:                                .getResolver(resolvername);
069:                        String[] confs = md.getConfigurationsNames();
070:                        Set artifacts = new HashSet();
071:                        for (int i = 0; i < confs.length; i++) {
072:                            artifacts.addAll(Arrays.asList(md
073:                                    .getArtifacts(confs[i])));
074:                        }
075:                        for (Iterator iter = artifacts.iterator(); iter
076:                                .hasNext();) {
077:                            Artifact art = (Artifact) iter.next();
078:                            if (!resolver.exists(art)) {
079:                                Message.info("declared publication not found: "
080:                                        + art);
081:                                result = false;
082:                            }
083:                        }
084:                    }
085:
086:                    // check dependencies
087:                    DependencyDescriptor[] dds = md.getDependencies();
088:                    ResolveData data = new ResolveData(resolveEngine,
089:                            new ResolveOptions());
090:                    for (int i = 0; i < dds.length; i++) {
091:                        // check master confs
092:                        String[] masterConfs = dds[i].getModuleConfigurations();
093:                        for (int j = 0; j < masterConfs.length; j++) {
094:                            if (!"*".equals(masterConfs[j].trim())
095:                                    && md.getConfiguration(masterConfs[j]) == null) {
096:                                Message
097:                                        .info("dependency required in non existing conf for "
098:                                                + ivyFile
099:                                                + " \n\tin "
100:                                                + dds[i]
101:                                                        .getDependencyRevisionId()
102:                                                + ": " + masterConfs[j]);
103:                                result = false;
104:                            }
105:                        }
106:                        // resolve
107:                        DependencyResolver resolver = settings
108:                                .getResolver(dds[i].getDependencyRevisionId());
109:                        ResolvedModuleRevision rmr = resolver.getDependency(
110:                                dds[i], data);
111:                        if (rmr == null) {
112:                            Message.info("dependency not found in " + ivyFile
113:                                    + ":\n\t" + dds[i]);
114:                            result = false;
115:                        } else {
116:                            String[] depConfs = dds[i]
117:                                    .getDependencyConfigurations(md
118:                                            .getConfigurationsNames());
119:                            for (int j = 0; j < depConfs.length; j++) {
120:                                if (!Arrays.asList(
121:                                        rmr.getDescriptor()
122:                                                .getConfigurationsNames())
123:                                        .contains(depConfs[j])) {
124:                                    Message
125:                                            .info("dependency configuration is missing for "
126:                                                    + ivyFile
127:                                                    + "\n\tin "
128:                                                    + dds[i]
129:                                                            .getDependencyRevisionId()
130:                                                    + ": " + depConfs[j]);
131:                                    result = false;
132:                                }
133:                                Artifact[] arts = rmr.getDescriptor()
134:                                        .getArtifacts(depConfs[j]);
135:                                for (int k = 0; k < arts.length; k++) {
136:                                    if (!resolver.exists(arts[k])) {
137:                                        Message
138:                                                .info("dependency artifact is missing for "
139:                                                        + ivyFile
140:                                                        + "\n\t in "
141:                                                        + dds[i]
142:                                                                .getDependencyRevisionId()
143:                                                        + ": " + arts[k]);
144:                                        result = false;
145:                                    }
146:                                }
147:                            }
148:                        }
149:                    }
150:                    return result;
151:                } catch (ParseException e) {
152:                    Message.info("parse problem on " + ivyFile + ": " + e);
153:                    return false;
154:                } catch (IOException e) {
155:                    Message.info("io problem on " + ivyFile + ": " + e);
156:                    return false;
157:                } catch (Exception e) {
158:                    Message.info("problem on " + ivyFile + ": " + e);
159:                    return false;
160:                }
161:            }
162:
163:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.