Author: kelvingoodson
Date: Tue Apr 13 17:27:13 2010
New Revision: 933709
URL: http://svn.apache.org/viewvc?rev=933709&view=rev
Log:
example use of tuscany.spi custom javadoc tag at package level
Added:
tuscany/sandbox/kgoodson/SourceExplore/pom.xml (with props)
tuscany/sandbox/kgoodson/SourceExplore/src/main/java/sourcehash/
tuscany/sandbox/kgoodson/SourceExplore/src/main/java/sourcehash/HashSPISource.java
(with props)
tuscany/sandbox/kgoodson/SourceExplore/src/main/java/sourcehash/package.html
(with props)
tuscany/sandbox/kgoodson/SourceExplore/src/main/resources/sub_dependencies.dot
Removed:
tuscany/sandbox/kgoodson/SourceExplore/src/main/java/HashSPISource.java
Modified:
tuscany/sandbox/kgoodson/SourceExplore/ (props changed)
Propchange: tuscany/sandbox/kgoodson/SourceExplore/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Apr 13 17:27:13 2010
@@ -0,0 +1,3 @@
+.classpath
+.project
+.settings
Added: tuscany/sandbox/kgoodson/SourceExplore/pom.xml
URL:
http://svn.apache.org/viewvc/tuscany/sandbox/kgoodson/SourceExplore/pom.xml?rev=933709&view=auto
==============================================================================
--- tuscany/sandbox/kgoodson/SourceExplore/pom.xml (added)
+++ tuscany/sandbox/kgoodson/SourceExplore/pom.xml Tue Apr 13 17:27:13 2010
@@ -0,0 +1,194 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>source-explorer</artifactId>
+ <name>Source Explorer</name>
+
+ <repositories>
+
+ <repository>
+ <id>apache.incubator</id>
+ <url>http://people.apache.org/repo/m2-incubating-repository</url>
+ </repository>
+ </repositories>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.6.1</version>
+ <configuration>
+
+ <tags>
+ <tag>
+ <name>tuscany.spi</name>
+ <!-- spi tag for all
places -->
+ <placement>a</placement>
+ <head>Tuscany SPI</head>
+ </tag>
+ </tags>
+
+ </configuration>
+ </plugin>
+ </plugins>
+
+ </reporting>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jaxb2-maven-plugin</artifactId>
+ <version>1.3</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ <type>jar</type>
+ </artifactItem>
+ </artifactItems>
+
<outputDirectory>${project.build.directory}/endorsed</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+
<compilerArgument>-Djava.endorsed.dirs=target/endorsed</compilerArgument>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/jaxb-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.jvnet.jaxb2.maven2</groupId>
+ <artifactId>maven-jaxb2-plugin</artifactId>
+ <version>0.7.1</version>
+ <executions>
+ <execution>
+ <id>generate-jaxb</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+
<generatePackage>org.apache.tuscany.SourceExplore</generatePackage>
+
<generateDirectory>${project.build.directory}/jaxb-source</generateDirectory>
+
<schemaDirectory>${basedir}/src/main/resources</schemaDirectory>
+ <schemaIncludes>
+ <include>projects.xsd</include>
+ </schemaIncludes>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ <finalName>${artifactId}</finalName>
+ </build>
+
+
+ <dependencies>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>rome</groupId>
+ <artifactId>rome</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ <version>2.0.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jvnet.jaxb2_commons</groupId>
+ <artifactId>runtime</artifactId>
+ <version>0.4.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jvnet.jaxb2_commons</groupId>
+ <artifactId>testing</artifactId>
+ <version>0.4.1</version>
+ <scope>test</scope>
+ </dependency>
+
+
+ </dependencies>
+</project>
Propchange: tuscany/sandbox/kgoodson/SourceExplore/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/sandbox/kgoodson/SourceExplore/pom.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
tuscany/sandbox/kgoodson/SourceExplore/src/main/java/sourcehash/HashSPISource.java
URL:
http://svn.apache.org/viewvc/tuscany/sandbox/kgoodson/SourceExplore/src/main/java/sourcehash/HashSPISource.java?rev=933709&view=auto
==============================================================================
---
tuscany/sandbox/kgoodson/SourceExplore/src/main/java/sourcehash/HashSPISource.java
(added)
+++
tuscany/sandbox/kgoodson/SourceExplore/src/main/java/sourcehash/HashSPISource.java
Tue Apr 13 17:27:13 2010
@@ -0,0 +1,160 @@
+package sourcehash;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigInteger;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
+import org.apache.tuscany.SourceExplore.ObjectFactory;
+import org.apache.tuscany.SourceExplore.Package;
+import org.apache.tuscany.SourceExplore.Projects;
+import org.apache.tuscany.SourceExplore.Projects2;
+import org.apache.tuscany.SourceExplore.Projects2.Project;
+
+
+
+public class HashSPISource {
+
+ public static void main(String[] args) throws Throwable {
+
+ ObjectFactory fac = new ObjectFactory();
+
+
+ String sourceRoot = "c:/Dev2/SCA";
+ String inputXML = "src/main/resources/projects.xml";
+
+ JAXBContext jaxbContext = JAXBContext
+ .newInstance("org.apache.tuscany.SourceExplore");
+ Unmarshaller um = jaxbContext.createUnmarshaller();
+
+
+ File inputFile = new
File(inputXML).getAbsoluteFile();
+ Projects p = (Projects)um.unmarshal(inputFile);
+ List<JAXBElement<String>> data =
p.getProjectOrPackage();
+ System.out.println(p);
+
+
+ Projects2 p2 = fac.createProjects2();
+
+
+
+ for (int i = 0; i < data.size(); i++) {
+ Project proj = null;
+
if(!"project".equals(data.get(i).getName().getLocalPart())) {
+ throw new Exception("Expecting
a project element " + i);
+ } else {
+ System.out.println("project: "
+ data.get(i).getValue());
+ proj =
fac.createProjects2Project();
+
proj.setName(data.get(i).getValue());
+ p2.getProject().add(proj);
+ }
+ for(i++;i<data.size() &&
"package".equals(data.get(i).getName().getLocalPart());i++) {
+
if(!"package".equals(data.get(i).getName().getLocalPart())) {
+ throw new
Exception("Expecting a package element " + i);
+ } else {
+ System.out.println("package: "
+ data.get(i).getValue());
+ Package pkg =
fac.createPackage();
+
pkg.setName(data.get(i).getValue());
+ proj.getPackage().add(pkg);
+ processPackage(sourceRoot,
proj, pkg);
+ }
+ }
+ i--;
+ }
+ FileOutputStream fos = new FileOutputStream(new
File("src/main/resources/out.xml").getAbsoluteFile());
+ Marshaller m = jaxbContext.createMarshaller();
+ m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
Boolean.TRUE);
+ m.marshal(p2, fos);
+ fos.close();
+
+
+ }
+
+ private static void processPackage(String sourceRoot, Project proj,
Package pkg) {
+
+ ObjectFactory fac = new ObjectFactory();
+
+ String pkgPath = pkg.getName().replace('.', '/' );
+ String folderPath = sourceRoot +"/" + proj.getName()
+"/src/main/java/" + pkgPath;
+ File folder = new File(folderPath);
+ File[] contents = folder.listFiles();
+
+ List<org.apache.tuscany.SourceExplore.File> files = pkg.getFile();
+ if(contents!= null) {
+ for (File file : contents) {
+ if(ofInterest(file)) {
+ org.apache.tuscany.SourceExplore.File f =
fac.createFile();
+ f.setName(file.getPath());
+ String digest = md5(file);
+ f.setDigest(digest);
+ files.add(f);
+ }
+ System.out.println(file.getName());
+ }
+ }
+ }
+
+ private static String md5(File f) {
+ MessageDigest digest = null;
+ try {
+ digest = MessageDigest.getInstance("MD5");
+ } catch (NoSuchAlgorithmException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+
+ InputStream is = null;
+ String output = null;
+ try {
+ is = new FileInputStream(f);
+ } catch (FileNotFoundException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ byte[] buffer = new byte[8192];
+ int read = 0;
+ try {
+ while( (read = is.read(buffer)) > 0) {
+ digest.update(buffer, 0, read);
+ }
+ byte[] md5sum = digest.digest();
+ BigInteger bigInt = new BigInteger(1, md5sum);
+ output = bigInt.toString(16);
+ System.out.println("MD5: " + output);
+ }
+ catch(IOException e) {
+ throw new RuntimeException("Unable to process file for
MD5", e);
+ }
+ finally {
+ try {
+ is.close();
+ }
+ catch(IOException e) {
+ throw new RuntimeException("Unable to close
input stream for MD5 calculation", e);
+ }
+ }
+ return output;
+ }
+
+ private static boolean ofInterest(File file) {
+ boolean result = false;
+
+ if(!result) result = file.getPath().endsWith(".java");
+ return result;
+ }
+
+
+}
\ No newline at end of file
Propchange:
tuscany/sandbox/kgoodson/SourceExplore/src/main/java/sourcehash/HashSPISource.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
tuscany/sandbox/kgoodson/SourceExplore/src/main/java/sourcehash/HashSPISource.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
tuscany/sandbox/kgoodson/SourceExplore/src/main/java/sourcehash/package.html
URL:
http://svn.apache.org/viewvc/tuscany/sandbox/kgoodson/SourceExplore/src/main/java/sourcehash/package.html?rev=933709&view=auto
==============================================================================
---
tuscany/sandbox/kgoodson/SourceExplore/src/main/java/sourcehash/package.html
(added)
+++
tuscany/sandbox/kgoodson/SourceExplore/src/main/java/sourcehash/package.html
Tue Apr 13 17:27:13 2010
@@ -0,0 +1,16 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+</head>
+<body bgcolor="white">
+
+Produces and XML file containing md5sums for files in a file system hierarchy.
+
+More description blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah
+ blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah.
+
+
[email protected]
+
+</body>
+</html>
\ No newline at end of file
Propchange:
tuscany/sandbox/kgoodson/SourceExplore/src/main/java/sourcehash/package.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
tuscany/sandbox/kgoodson/SourceExplore/src/main/java/sourcehash/package.html
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
tuscany/sandbox/kgoodson/SourceExplore/src/main/resources/sub_dependencies.dot
URL:
http://svn.apache.org/viewvc/tuscany/sandbox/kgoodson/SourceExplore/src/main/resources/sub_dependencies.dot?rev=933709&view=auto
==============================================================================
---
tuscany/sandbox/kgoodson/SourceExplore/src/main/resources/sub_dependencies.dot
(added)
+++
tuscany/sandbox/kgoodson/SourceExplore/src/main/resources/sub_dependencies.dot
Tue Apr 13 17:27:13 2010
@@ -0,0 +1,22 @@
+digraph Dependencies {
+
+ rankdir=LR;
+
+
+
+ "tuscany-assembly" -> "tuscany-monitor"
+ "tuscany-assembly" -> "tuscany-extensibility"
+
+ "tuscany-assembly-xml" ->"tuscany-assembly"
+ "tuscany-assembly-xml" ->"tuscany-contribution"
+
+
+
+
+ "tuscany-common-java" -> "tuscany-sca-api"
+
+ "tuscany-contribution" ->"tuscany-assembly"
+ "tuscany-contribution" ->"tuscany-common"
+ "tuscany-contribution" -> "tuscany-common-java"
+
+}
\ No newline at end of file