top-image

OLDER ARTICLES

Download project: test_junit_report.zip

JBoss Tattletale is a tool that can help you get an overview of the project you are working on or a product that you depend on. It scans the Java Archives (.JAR) files, traverses Java class file directories and generates design quality metrics for each Java package. More, it is a valuable analysis tool of JARs related to JAVA projects. JBoss Tattletale generates a report HTML whose the main HTML file is “index.html”.

This tool will provide you with reports that can help you:

  • Identify dependencies between JAR files
  • Find missing classes from the classpath
  • Spot if a class/package is located in multiple JAR files
  • Spot if the same JAR file is located in multiple locations
  • With a list of what each JAR file requires and provides
  • Verify the SerialVersionUID of a class
  • Find similar JAR files that have different version numbers
  • Find JAR files without a version number
  • Find unused JAR files

Quick start:
JBoss Tattletale will recursively scan the directory passed as the argument for JAR files and then build the reports as HTML files.
Running JBoss Tattletale is very easy:

java -Xmx512m -jar tattletale.jar [-exclude=<excludes>] <sourcedir> [<outputdir>]

where:

  • the “sourcedir” is the directory that contains your Java archives
  • the optional “outputdir” parameter is the directory where you would like your reports to be generated. Analysis reports generate in current directory if no output-directory set. The main file will be generated as index.html.
  • the “-exclude” option let you exclude directories or file on the command line – see the configuration file for syntax.

Examples:

java -Xmx512m -jar C:\MyFiles\Development\Java\tools\tattletale-1.1.2.Final\tattletale.jar   C:\MyFiles\Development\Java\dev\JarRepository    C:\MyFiles\Development\Java\tools\tattletale-1.1.2.Final\huoTattletaleReportsGeneratedJarRepository

If you open the “index.html” file of “huoTattletaleReportsGeneratedJarRepository” directory, you will obtain the following screen with the Dependencies, Reports and Archives sections:

For example, you could see also the circular dependencies between the JARs files like the following screen:

Comments/Remarks:
JBoss Tattletale requires Java Runtime Environment 5 or higher. It is licensed under GNU Lesser General Public License (LGPL) version 2.1 or later.
JBoss Tattletale could be used:

  • With ANT:
    JBoss Tattletale integrates with Apache Ant such that you can generate the reports directly from your build environment (add tattletale.jar, tattletale-ant.jar and javassist.jar to the Apache Ant classpath).
  • With MAVEN:
    JBoss Tattletale integrates with Apache Maven such that you can generate the reports directly from your build environment (add tattletale.jar, tattletale-maven.jar and javassist.jar to the Apache Ant classpath). To be able to use the Tattletale Maven plugin in a Maven project, it is necessary to add the plugin declaration in the pom.xml of the project.

Source/Download: http://www.jboss.org/tattletale

Hi,

I propose you a simple solution based on Spring context, PropertyPlaceholderConfigurer to load and access to properties or parameters in all places of an application.

First, we have a properties’ file (for example) named “myparameters.properties” in the server’s classpath (for example in the “etc” folder of TOMCAT server) containing:

# ################ ENVIRONMENT ##################
huo.config.mail.default.domain=huo-huo.huo

# ################ MAIL PARAMETERS ##################
huo.config.smtp.host=localhost
huo.config.smtp.port=25
huo.config.smtp.mailfrom=fromHuseyin@huo-huo.huo
huo.config.smtp.mailadministrators=tohuo@huo-huo.huo,topas@huo-huo.com,tofr@huo-huo.huo

Secondly, create a class containing a attribute for each parameter of above file. This class must used the “singleton” design pattern:

 
public class ConfigMyParameters {

	// ----------------------------------------------------- PRIVATE ATTRIBUTES
	/**
	 * Singleton instance
	 */
	private static ConfigMyParameters instance = null;

	/**
	 * Default mail domain
	 */
	private String defaultMailDomain = "";

	/**
	 * Contains the identity (email) used to send mails.
	 */
	private String smtpMailFrom = "";

	/**
	 * Smtp server host
	 */
	private String smtpMailhost = "";
	
	/**
	 * Smtp server port
	 */
	private String smtpMailport = "";
     
	/**
	 * Emails' list of administrators
	 */
	private List<String> mailAdministrators = new ArrayList<String>();

	// --------------------------------------------------------- PUBLIC METHODS
	/**
	 * @return an unique instance of the application configuration class.
	 */
	public static synchronized ConfigMyParameters getInstance() {
		if (null == instance) {
			String SPRING_FILE_NAME = "huo-spring-properties-config.xml";
			ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(SPRING_FILE_NAME);
			instance = (ConfigMyParameters) ctx.getBean("ConfigMyParameters");
		} // end-if
		return instance;
	}
	
	// ------------------------------------------------------ GETTERS & SETTERS
         // ....
}

And lastly, we need to create a spring context in order to load the properties’ file “myparameters.properties” with the singleton “ConfigMyParameters.java”. In our example, this file is named “huo-spring-properties-config.xml” (cf the “ConfigMyParameters.java” class.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="
	http://www.springframework.org/schema/beans
	http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
	http://www.springframework.org/schema/tx
	http://www.springframework.org/schema/tx/spring-tx-2.0.xsd            
	http://www.springframework.org/schema/context
	http://www.springframework.org/schema/context/spring-context-2.5.xsd"
	default-autowire="no"
	default-lazy-init="false"
	default-dependency-check="none">

	<!-- 
	 | Retrieve the common configuration datasource, constants,...
	 --> 
	<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="locations">
			<value>classpath:myparameters.properties</value>
		</property>
	</bean>
	

	<!-- 
	 | This bean is only used to determine in which environment this business is executed
	 -->
	<bean id="ConfigMyParameters" class="huo.ConfigMyParameters">
		<!-- 
		 | ENVIRONMENT 
		 -->
		<property name="defaultMailDomain" value="${huo.config.mail.default.domain}" />

		<!--
		 | SMTP Parameters 
		 -->
		<property name="smtpMailhost" value="${huo.config.smtp.host}" />
		<property name="smtpMailport" value="${huo.config.smtp.port}" />
		<property name="smtpMailFrom" value="${huo.config.smtp.mailfrom}" />
		<property name="mailAdministrators" value="${huo.config.smtp.mailadministrators}" />
	</bean>
</beans>

So, all application’s properties or parameters are accessible in all places of the application due to the “ConfigMyParameters” class.
Example: ConfigMyParameters.getInstance().getMailAdministratorsAsArray()

To add a new parameter, it is necessary to:

  • add a line in the file “myparameters.properties” the form “KEY = VALUE”,
  • add a new private attribute in the class “ConfigMyParameters” with getter/setter,
  • change the Spring context file “huo-spring-properties-config.xml” to perform the mapping between the new parameter in properties’ file and class “ConfigMyParameters”.

SpringLoadAndAccessProperties.zip

Here, I want present you a powerfull command line tool for daily tasks named Swiss File Knife (SFK), which a lot of features:

  • Search text and binary files.
  • Filter and replace text in files.
  • Instant FTP and HTTP server, for easy file transfer between machines.
  • List directory tree sizes and files.
  • Zero installation, all-in-one executable.
  • Open source for Windows (9x/NT/XP/Vista/7), Linux and Mac.

SFK simply runs instantly, anywhere. SFK Base is free. SFK Extended Edition can also process .zip .jar .tar.gz and .tar.bz2 contents directly. To use this tool:

  • download the free swiss file knife base from sourceforge.
  • unpack the tool using winzip or unzip.
  • open the Windows Command Line or a Linux shell.

Personaly, I use SFK in order to search a specific class in a lot of jars files:

echo off 
sfk list -zip R:javadeveclipse_workspacesdefault-3.3myprojectlibs | find "DocumentController.class"

with for example the following results:

R:\java\dev\comlipse_workspaces\default-3.3\myproject\target\classes\com\huo\myproject\site\controller\DocumentController.class
R:\java\dev\comlipse_workspaces\default-3.3\myproject\target\myproject-0.1.000.war\WEB-INF\classes\com\huo\myproject\site\controller\DocumentController.class
R:\java\dev\comlipse_workspaces\default-3.3\myproject\trash\target-20120328-110646\classes\com\huo\myproject\site\controller\DocumentController.class
R:\java\dev\comlipse_workspaces\default-3.3\myproject\trash\target-20120328-110646\myproject-0.1.000.war\WEB-INF\classes\com\huo\myproject\site\controller\DocumentController.class
R:\java\dev\comlipse_workspaces\default-3.3\myproject\trash\target-20120329-095643\classes\com\huo\myproject\site\controller\DocumentController.class
R:\java\dev\comlipse_workspaces\default-3.3\myproject\trash\target-20120329-095643\myproject-0.1.000.war\WEB-INF\classes\com\huo\myproject\site\controller\DocumentController.class
R:\java\dev\comlipse_workspaces\default-3.3\myproject\trash\target-20120329-100611\classes\com\huo\myproject\site\controller\DocumentController.class
R:\java\dev\comlipse_workspaces\default-3.3\myproject\trash\target-20120329-100611\myproject-0.1.000.war\WEB-INF\classes\com\huo\myproject\site\controller\DocumentController.class
R:\java\dev\comlipse_workspaces\default-3.3\myproject\trash\target-20120417-144045\classes\com\huo\myproject\site\controller\DocumentController.class
R:\java\dev\comlipse_workspaces\default-3.3\myproject\trash\target-20120417-144045\myproject-0.1.000.war\WEB-INF\classes\com\huo\myproject\site\controller\DocumentController.class
R:\java\dev\comlipse_workspaces\default-3.3\myproject\war\WEB-INF\classes\com\huo\myproject\site\controller\DocumentController.class

But SFK makes daily tasks easy a lot of others things: find and extract text in binary files, list dir tree sizes, filter and replace text, run an instant ftp server, http server for easy file transfer, find duplicate files, join many text files into one, create and verify md5 checksum lists, run a command on all files, detab text, create hexdumps from files, trace contents of a tcp connection, find dependencies between files, print colored text to terminal, locate commands in the path, print last lines of a file, convert CR/LF, hex to binary, binary to source code, split and join large files, list the contents of all .zip .jar .tar.gz and .tar.bz2 files…etc.

Source: http://stahlworks.com/dev/swiss-file-knife.html
Download: http://sourceforge.net/projects/swissfileknife/

Page 51 of 54:« First« 48 49 50 51 52 53 54 »
bottom-img
Copyright ® 2012 Huseyin Ozveren. No reproduction, even partial, can be used from this site and all its contents including text, documents, images, etc.. without the express permission of the author.