Successfully reported this slideshow.

Jakarta Commons - Don't re-invent the wheel

1,818 views

Published on

Many projects use at least some of them - the Jakarta Commons libraries. Small reusable libraries simplifying the day-to-day work of thousands of java programmers. But over time the jakarta commons project has grown and the number of components makes it harder and harder to keep track. This session will try to give an overview of the components available and how the Jakarta Commons community is organized.

Published in: Technology, Education
  • time saving utils
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Jakarta Commons - Don't re-invent the wheel

  1. 1. Jakarta Commons Torsten Curdt don’t re-invent the wheel
  2. 2. Increase Productivity
  3. 3. Re-use to Excel
  4. 4. •Faster •Better designed •Less time •Smaller team
  5. 5. How did we do it?
  6. 6. Know your libraries!
  7. 7. Sharing QA
  8. 8. Heritage
  9. 9. Charter “Creation of small re-useable components that can be used across projects. They are supposed to have as few dependencies as possible, meant to be well tested and compatible with the current de-facto standard version of the JDK”
  10. 10. Growth Sandbox Proper Dormant
  11. 11. Project Stats 45 Sandbox 34 Proper 34 38 Dormant 23 11 10 0 Active Inactive
  12. 12. Proper
  13. 13. CLI Options options = new Options(); options.addOption(quot;hquot;, false, quot;display usagequot;); CommandLine line = parser.parse(options, args); if(line.hasOption(quot;hquot;)) { HelpFormatter f = new HelpFormatter(); f.printHelp(quot;myprogramquot;, options); ...
  14. 14. Collections Map map = new CaseInsensitiveMap(); map.put(quot;Onequot;, quot;Onequot;); map.get(quot;ONEquot;); Map colorMap = MapUtils.toMap(new String[][] {{ {quot;redquot;, quot;#FF0000quot;}, {quot;greenquot;, quot;#00FF00quot;}, {quot;bluequot;, quot;#0000FFquot;} });
  15. 15. Email SimpleEmail email = new SimpleEmail(); email.setHostName(quot;mail.myserver.comquot;); email.addTo(quot;jdoe@somewhere.orgquot;, quot;John Doequot;); email.setFrom(quot;me@apache.orgquot;, quot;Mequot;); email.setSubject(quot;Test messagequot;); email.setMsg(quot;A simple test of commons-emailquot;); email.send();
  16. 16. IO InputStream in; OutputStream out; IOUtils.copy(in, out); ... byte[] data = IOUtils.toByteArray(in);
  17. 17. JXPath XPathContext context = JXPathContext.newContext(dom); String value = (String) context.getValue(quot;/my/xpath/to/valuequot;);
  18. 18. Lang String s = “Apache Jakarta Commons”; StringUtils.right(s, 7); // “Commons” String n = “0”; StringUtils.leftPad(s, 4, ‘0’); // “0000”
  19. 19. Logging public class C { private Log log = LogFactory.getLog(C.class); ... if (log.isDebugEnabled()) { log.debug(quot;log messagequot;); }
  20. 20. Net NNTPClient client = new NNTPClient(); client.connect(quot;news.server.netquot;); NewsgroupInfo[] = client.listNewsgroups(); client.disconnect();
  21. 21. Primitives ArrayByteList list = new ArrayByteList(); list.add(byte); list.removeElementAt(index); byte[] bytes = list.toArray();
  22. 22. VFS FileSystemManager fs = VFS.getManager(); FileObject jar = fs.resolveFile( quot;jar:lib/aJarFile.jarquot; ); FileObject[] childs = jar.getChildren(); for (int i=0; i < childs.length; i++ ) { ...
  23. 23. Overview attributes, beanutils, betwixt, chain, cli, codec, collections, configuration, daemon, dbcp, dbutils, digester, discovery, el, email, fileupload, httpclient, io, jelly, jexl, jxpath, lang, launcher, logging, math, modeler, net, pool, primitives, scxml, transaction, validator, vfs
  24. 24. Sandbox
  25. 25. CSV String[][] data = CSVParser.parse(string); CSVParser parser = new CSVParser(reader,’;’); String[][] data = parser.getAllValues();
  26. 26. Exec OutputStream out; OutputStream error; CommandLine cl = new CommandLineImpl(); cl.setExecutable(quot;path/to/exequot;); cl.addArgument(quot;argquot;); exec.execute(cl, out, error);
  27. 27. Javaflow class MyRunnable implements Runnable { public void run() { for(int i=0; i<10; i++ ) Continuation.suspend(); }} Continuation c = Continuation.startWith( new MyRunnable()); Continuation d = Continuation.continueWith(c); ...
  28. 28. JCI JavaCompiler compiler = new EclipseJavaCompiler(); ResourceStore store = new MemoryResourceStore(); CompilationResult result = compiler.compile( new String[] { quot;org/MyClass.javaquot; }, new FileResourceReader(directory), store );
  29. 29. OpenPGP keyRing = new BouncyCastleKeyRing( secret, public, password); signer = new BouncyCastleOpenPgpSigner(); signer.detachedSign( fileInputStream signatureOutputStream, keyId, keyRing, true );
  30. 30. Proxy o = (MyObject) new CglibProxyFactory() .createInterceptorProxy( new MyObjectImpl(), new LoggingInterceptor(log), new Class[]{ MyObject.class }); o.test(”test”); [DEBUG] - BEGIN test(test) [DEBUG] - END test()
  31. 31. Overview compress, csv, exec, i18n, id, javaflow, jci, openpgp, pipeline, proxy
  32. 32. Dormant
  33. 33. Overview benchmark, cache, clazz, codec- mulipart, combo, contract, events, feedparser, filters, functor, grant, graph2, http, jex, jjar, jpath, jrcs, jux, latka, mapper, messenger, pattern, periodicity, reflect, resources, rupert, scaffold, services, servlet, simplestore, tbm, test, threading, threadpool, workflow, xmlio, xmlunit, xo
  34. 34. Not invented here
  35. 35. We need you!
  36. 36. Thanks!

×