Source Code Cross Referenced for DualResolver.java in  » Code-Analyzer » apache-ivy » org » apache » ivy » plugins » resolver » 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.plugins.resolver 
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.plugins.resolver;
019:
020:        import java.io.File;
021:        import java.io.IOException;
022:        import java.text.ParseException;
023:
024:        import org.apache.ivy.core.module.descriptor.Artifact;
025:        import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
026:        import org.apache.ivy.core.module.id.ModuleRevisionId;
027:        import org.apache.ivy.core.report.DownloadReport;
028:        import org.apache.ivy.core.resolve.DownloadOptions;
029:        import org.apache.ivy.core.resolve.ResolveData;
030:        import org.apache.ivy.core.resolve.ResolvedModuleRevision;
031:        import org.apache.ivy.plugins.resolver.util.ResolvedResource;
032:        import org.apache.ivy.util.Message;
033:
034:        /**
035:         * DualResolver is used to resolve dependencies with one dependency revolver, called ivy resolver,
036:         * and then download artifacts found in the resolved dependencies from a second dependency resolver,
037:         * called artifact resolver. It is especially useful with resolvers using repository where there is
038:         * a lot of artifact, but no ivy file, like the maven ibiblio repository. If no ivy file is found by
039:         * the ivy resolver, the artifact resolver is used to check if there is artifact corresponding to
040:         * the request (with default ivy file). For artifact download, however, only the artifact resolver
041:         * is used. Exactly two resolvers should be added to this resolver for it to work properly. The
042:         * first resolver added if the ivy resolver, the second is the artifact one.
043:         */
044:        public class DualResolver extends AbstractResolver {
045:            private DependencyResolver ivyResolver;
046:
047:            private DependencyResolver artifactResolver;
048:
049:            private boolean allownomd = true;
050:
051:            public void add(DependencyResolver resolver) {
052:                if (ivyResolver == null) {
053:                    ivyResolver = resolver;
054:                } else if (artifactResolver == null) {
055:                    artifactResolver = resolver;
056:                } else {
057:                    throw new IllegalStateException(
058:                            "exactly two resolvers must be added: ivy(1) and artifact(2) one");
059:                }
060:            }
061:
062:            public ResolvedModuleRevision getDependency(
063:                    DependencyDescriptor dd, ResolveData data)
064:                    throws ParseException {
065:                if (ivyResolver == null || artifactResolver == null) {
066:                    throw new IllegalStateException(
067:                            "exactly two resolvers must be added: ivy(1) and artifact(2) one");
068:                }
069:                data = new ResolveData(data, doValidate(data));
070:                final ResolvedModuleRevision mr = ivyResolver.getDependency(dd,
071:                        data);
072:                if (mr == null) {
073:                    checkInterrupted();
074:                    if (isAllownomd()) {
075:                        Message.verbose("ivy resolver didn't find "
076:                                + dd.getDependencyRevisionId()
077:                                + ": trying with artifact resolver");
078:                        return artifactResolver.getDependency(dd, data);
079:                    } else {
080:                        return null;
081:                    }
082:                } else {
083:                    return new ResolvedModuleRevision(mr.getResolver(), this ,
084:                            mr.getDescriptor(), mr.getReport());
085:                }
086:            }
087:
088:            public ResolvedResource findIvyFileRef(DependencyDescriptor dd,
089:                    ResolveData data) {
090:                return ivyResolver.findIvyFileRef(dd, data);
091:            }
092:
093:            public void reportFailure() {
094:                ivyResolver.reportFailure();
095:                artifactResolver.reportFailure();
096:            }
097:
098:            public void reportFailure(Artifact art) {
099:                ivyResolver.reportFailure(art);
100:                artifactResolver.reportFailure(art);
101:            }
102:
103:            public DownloadReport download(Artifact[] artifacts,
104:                    DownloadOptions options) {
105:                return artifactResolver.download(artifacts, options);
106:            }
107:
108:            public DependencyResolver getArtifactResolver() {
109:                return artifactResolver;
110:            }
111:
112:            public void setArtifactResolver(DependencyResolver artifactResolver) {
113:                this .artifactResolver = artifactResolver;
114:            }
115:
116:            public DependencyResolver getIvyResolver() {
117:                return ivyResolver;
118:            }
119:
120:            public void setIvyResolver(DependencyResolver ivyResolver) {
121:                this .ivyResolver = ivyResolver;
122:            }
123:
124:            public void publish(Artifact artifact, File src, boolean overwrite)
125:                    throws IOException {
126:                if ("ivy".equals(artifact.getType())) {
127:                    ivyResolver.publish(artifact, src, overwrite);
128:                } else {
129:                    artifactResolver.publish(artifact, src, overwrite);
130:                }
131:            }
132:
133:            public void abortPublishTransaction() throws IOException {
134:                ivyResolver.abortPublishTransaction();
135:                artifactResolver.abortPublishTransaction();
136:            }
137:
138:            public void beginPublishTransaction(ModuleRevisionId module,
139:                    boolean overwrite) throws IOException {
140:                ivyResolver.beginPublishTransaction(module, overwrite);
141:                artifactResolver.beginPublishTransaction(module, overwrite);
142:            }
143:
144:            public void commitPublishTransaction() throws IOException {
145:                ivyResolver.commitPublishTransaction();
146:                artifactResolver.commitPublishTransaction();
147:            }
148:
149:            public void dumpSettings() {
150:                if (ivyResolver == null || artifactResolver == null) {
151:                    throw new IllegalStateException(
152:                            "exactly two resolvers must be added: ivy(1) and artifact(2) one");
153:                }
154:                Message.verbose("\t" + getName() + " [dual "
155:                        + ivyResolver.getName() + " "
156:                        + artifactResolver.getName() + "]");
157:            }
158:
159:            public boolean exists(Artifact artifact) {
160:                return artifactResolver.exists(artifact);
161:            }
162:
163:            public boolean isAllownomd() {
164:                return allownomd;
165:            }
166:
167:            public void setAllownomd(boolean allownomd) {
168:                this.allownomd = allownomd;
169:            }
170:
171:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.