Source Code Cross Referenced for Maven2RepositoryAdapter.java in  » EJB-Server-geronimo » car-maven-plugin » org » apache » geronimo » mavenplugins » car » 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 geronimo » car maven plugin » org.apache.geronimo.mavenplugins.car 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         *  Licensed to the Apache Software Foundation (ASF) under one
003:         *  or more contributor license agreements.  See the NOTICE file
004:         *  distributed with this work for additional information
005:         *  regarding copyright ownership.  The ASF licenses this file
006:         *  to you under the Apache License, Version 2.0 (the
007:         *  "License"); you may not use this file except in compliance
008:         *  with the License.  You may obtain a copy of the License at
009:         *
010:         *    http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         *  Unless required by applicable law or agreed to in writing,
013:         *  software distributed under the License is distributed on an
014:         *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         *  KIND, either express or implied.  See the License for the
016:         *  specific language governing permissions and limitations
017:         *  under the License.
018:         */package org.apache.geronimo.mavenplugins.car;
019:
020:        import java.io.File;
021:        import java.io.IOException;
022:        import java.util.Iterator;
023:        import java.util.SortedSet;
024:        import java.util.TreeSet;
025:
026:        import javax.security.auth.login.FailedLoginException;
027:
028:        import org.apache.geronimo.gbean.GBeanInfo;
029:        import org.apache.geronimo.gbean.GBeanInfoBuilder;
030:        import org.apache.geronimo.kernel.repository.Artifact;
031:        import org.apache.geronimo.kernel.repository.FileWriteMonitor;
032:        import org.apache.geronimo.kernel.repository.Version;
033:        import org.apache.geronimo.system.plugin.LocalOpenResult;
034:        import org.apache.geronimo.system.plugin.OpenResult;
035:        import org.apache.geronimo.system.plugin.SourceRepository;
036:        import org.apache.geronimo.system.plugin.model.PluginListType;
037:        import org.apache.geronimo.system.repository.Maven2Repository;
038:        import org.codehaus.mojo.pluginsupport.dependency.DependencyTree;
039:
040:        /**
041:         * Helps adapt Geronimo repositories to Maven repositories for packaging building.
042:         *
043:         * @version $Rev: 615381 $ $Date: 2008-01-25 14:36:57 -0800 (Fri, 25 Jan 2008) $
044:         */
045:        public class Maven2RepositoryAdapter extends Maven2Repository implements 
046:                SourceRepository {
047:            private ArtifactLookup lookup;
048:
049:            private DependencyTree dependencyTree;
050:
051:            public Maven2RepositoryAdapter(DependencyTree dependencyTree,
052:                    final ArtifactLookup lookup) {
053:                super (lookup.getBasedir());
054:                this .dependencyTree = dependencyTree;
055:                this .lookup = lookup;
056:            }
057:
058:            public File getLocation(final Artifact artifact) {
059:                assert artifact != null;
060:
061:                return lookup.getLocation(artifact);
062:            }
063:
064:            public SortedSet list() {
065:                TreeSet<Artifact> list = new TreeSet<Artifact>();
066:                listInternal(list, dependencyTree.getRootNode(), null, null,
067:                        null, null);
068:                return list;
069:            }
070:
071:            public SortedSet list(Artifact query) {
072:                TreeSet<Artifact> list = new TreeSet<Artifact>();
073:                listInternal(list, dependencyTree.getRootNode(), query
074:                        .getGroupId(), query.getArtifactId(), query
075:                        .getVersion(), query.getType());
076:                return list;
077:            }
078:
079:            private void listInternal(TreeSet<Artifact> list,
080:                    DependencyTree.Node node, String groupId,
081:                    String artifactId, Version version, String type) {
082:                if (matches(node.getArtifact(), groupId, artifactId, version,
083:                        type)) {
084:                    list.add(mavenToGeronimoArtifact(node.getArtifact()));
085:                }
086:                for (Iterator iterator = node.getChildren().iterator(); iterator
087:                        .hasNext();) {
088:                    DependencyTree.Node childNode = (DependencyTree.Node) iterator
089:                            .next();
090:                    listInternal(list, childNode, groupId, artifactId, version,
091:                            type);
092:                }
093:            }
094:
095:            private boolean matches(
096:                    org.apache.maven.artifact.Artifact artifact,
097:                    String groupId, String artifactId, Version version,
098:                    String type) {
099:                return (groupId == null || artifact.getGroupId()
100:                        .equals(groupId))
101:                        && (artifactId == null || artifact.getArtifactId()
102:                                .equals(artifactId))
103:                        && (version == null || artifact.getVersion().equals(
104:                                version.toString()))
105:                        && (type == null || artifact.getType().equals(type));
106:            }
107:
108:            protected org.apache.geronimo.kernel.repository.Artifact mavenToGeronimoArtifact(
109:                    final org.apache.maven.artifact.Artifact artifact) {
110:                assert artifact != null;
111:
112:                return new org.apache.geronimo.kernel.repository.Artifact(
113:                        artifact.getGroupId(), artifact.getArtifactId(),
114:                        artifact.getVersion(), artifact.getType());
115:            }
116:
117:            public PluginListType getPluginList() {
118:                throw new RuntimeException("Not implemented");
119:            }
120:
121:            public OpenResult open(Artifact artifact,
122:                    FileWriteMonitor fileWriteMonitor) throws IOException,
123:                    FailedLoginException {
124:                if (!artifact.isResolved()) {
125:                    SortedSet<Artifact> list = list(artifact);
126:                    if (list.isEmpty()) {
127:                        throw new IOException("Could not resolve artifact "
128:                                + artifact + " in repo " + rootFile);
129:                    }
130:                    artifact = list.first();
131:                }
132:                File location = getLocation(artifact);
133:                return new LocalOpenResult(artifact, location);
134:
135:            }
136:
137:            //
138:            // ArtifactLookup
139:            //
140:
141:            public static interface ArtifactLookup {
142:                File getLocation(Artifact artifact);
143:
144:                File getBasedir();
145:            }
146:
147:            //
148:            // GBean
149:            //
150:
151:            public static final GBeanInfo GBEAN_INFO;
152:
153:            static {
154:                GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(
155:                        Maven2RepositoryAdapter.class, "Repository");
156:                infoFactory.addAttribute("lookup", ArtifactLookup.class, true);
157:                infoFactory.addAttribute("dependencies", DependencyTree.class,
158:                        true);
159:                infoFactory.setConstructor(new String[] { "dependencies",
160:                        "lookup" });
161:                GBEAN_INFO = infoFactory.getBeanInfo();
162:            }
163:
164:            public static GBeanInfo getGBeanInfo() {
165:                return GBEAN_INFO;
166:            }
167:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.