From 0aaa7657e8d06d753dcc356dac82e997c09329d9 Mon Sep 17 00:00:00 2001 From: kelvingoodson Date: Tue, 13 Apr 2010 17:27:13 +0000 Subject: example use of tuscany.spi custom javadoc tag at package level git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@933709 13f79535-47bb-0310-9956-ffa450edef68 --- sandbox/kgoodson/SourceExplore/pom.xml | 194 +++++++++++++++++++++ .../SourceExplore/src/main/java/HashSPISource.java | 158 ----------------- .../src/main/java/sourcehash/HashSPISource.java | 160 +++++++++++++++++ .../src/main/java/sourcehash/package.html | 16 ++ .../src/main/resources/sub_dependencies.dot | 22 +++ 5 files changed, 392 insertions(+), 158 deletions(-) create mode 100644 sandbox/kgoodson/SourceExplore/pom.xml delete mode 100644 sandbox/kgoodson/SourceExplore/src/main/java/HashSPISource.java create mode 100644 sandbox/kgoodson/SourceExplore/src/main/java/sourcehash/HashSPISource.java create mode 100644 sandbox/kgoodson/SourceExplore/src/main/java/sourcehash/package.html create mode 100644 sandbox/kgoodson/SourceExplore/src/main/resources/sub_dependencies.dot (limited to 'sandbox/kgoodson') diff --git a/sandbox/kgoodson/SourceExplore/pom.xml b/sandbox/kgoodson/SourceExplore/pom.xml new file mode 100644 index 0000000000..f08c1a11bb --- /dev/null +++ b/sandbox/kgoodson/SourceExplore/pom.xml @@ -0,0 +1,194 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-SNAPSHOT + ../pom.xml + + source-explorer + Source Explorer + + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.6.1 + + + + + tuscany.spi + + a + Tuscany SPI + + + + + + + + + + + + + + org.codehaus.mojo + jaxb2-maven-plugin + 1.3 + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy + generate-sources + + copy + + + + + javax.xml.bind + jaxb-api + 2.1 + jar + + + ${project.build.directory}/endorsed + false + true + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + -Djava.endorsed.dirs=target/endorsed + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.0 + + + + add-source + generate-sources + + add-source + + + + target/jaxb-source + + + + + + + + org.jvnet.jaxb2.maven2 + maven-jaxb2-plugin + 0.7.1 + + + generate-jaxb + generate-sources + + generate + + + + + org.apache.tuscany.SourceExplore + ${project.build.directory}/jaxb-source + ${basedir}/src/main/resources + + projects.xsd + + + + + + ${artifactId} + + + + + + + junit + junit + 4.5 + test + + + rome + rome + 1.0 + + + javax.xml.bind + jaxb-api + 2.0 + + + + com.sun.xml.bind + jaxb-impl + 2.0.3 + + + org.jvnet.jaxb2_commons + runtime + 0.4.1 + + + org.jvnet.jaxb2_commons + testing + 0.4.1 + test + + + + + diff --git a/sandbox/kgoodson/SourceExplore/src/main/java/HashSPISource.java b/sandbox/kgoodson/SourceExplore/src/main/java/HashSPISource.java deleted file mode 100644 index 0567942f99..0000000000 --- a/sandbox/kgoodson/SourceExplore/src/main/java/HashSPISource.java +++ /dev/null @@ -1,158 +0,0 @@ -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> 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 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 diff --git a/sandbox/kgoodson/SourceExplore/src/main/java/sourcehash/HashSPISource.java b/sandbox/kgoodson/SourceExplore/src/main/java/sourcehash/HashSPISource.java new file mode 100644 index 0000000000..6ac7067e46 --- /dev/null +++ b/sandbox/kgoodson/SourceExplore/src/main/java/sourcehash/HashSPISource.java @@ -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> 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 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 diff --git a/sandbox/kgoodson/SourceExplore/src/main/java/sourcehash/package.html b/sandbox/kgoodson/SourceExplore/src/main/java/sourcehash/package.html new file mode 100644 index 0000000000..57353774be --- /dev/null +++ b/sandbox/kgoodson/SourceExplore/src/main/java/sourcehash/package.html @@ -0,0 +1,16 @@ + + + + + + +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. + + +@tuscany.spi + + + \ No newline at end of file diff --git a/sandbox/kgoodson/SourceExplore/src/main/resources/sub_dependencies.dot b/sandbox/kgoodson/SourceExplore/src/main/resources/sub_dependencies.dot new file mode 100644 index 0000000000..a8e9e90fac --- /dev/null +++ b/sandbox/kgoodson/SourceExplore/src/main/resources/sub_dependencies.dot @@ -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 -- cgit v1.2.3