it.imolinfo.jbi4ejb.webservice.generator
Class Util

java.lang.Object
  extended by it.imolinfo.jbi4ejb.webservice.generator.Util

public final class Util
extends java.lang.Object

Cut&paset from it.imolinfo.jbi4corba.webservice.generator.Util methods.

Author:
Marco Piraccini

Method Summary
static void compileJavaClasses(java.lang.String workdirsrc, java.lang.String workdirclasses, java.util.List<java.lang.String> javaSources, java.util.List<java.lang.String> jarFiles, java.util.List<java.lang.String> extraClassPath)
          Compile the java sources.
static boolean containsIgnoreSlashes(java.util.List<java.lang.String> list, java.lang.String myString)
          Contains ignore slashes.
static java.util.Set<java.lang.Class> findClassUsed(java.lang.String dir, java.util.List<java.io.File> classList)
          This method extracs all the classes used as method's parameter or method's result from a class list.
static java.util.List<java.io.File> findFilesFromSourceDirectory(java.lang.String basedirString, java.lang.String extensionFilter)
          This method find all the files in a directory according to the filter.
static java.util.List<java.io.File> findFilesFromSourceDirectoryFromExactFileName(java.lang.String basedirString, java.lang.String exactName)
          This method find all the files in a directory according to the filter.
static java.util.List<java.lang.String> findJavaSources(java.lang.String basedir, java.util.List<java.lang.String> exclude)
          Find java sources in a directory.
static org.objectweb.asm.ClassReader getAsmCLassReader(java.lang.String className)
          This method returns the class reader used for the bytecode manipulation.
static java.net.URLClassLoader getURLClassLoader(java.lang.String absolutePath)
          Gets the URL class loader, setting the parent ClassLoader to this class ClassLoader.
static java.net.URLClassLoader getURLClassLoader(java.lang.String absolutePath, java.lang.ClassLoader parent)
          Gets the URL class loader, setting the parent ClassLoader.
static java.util.List<java.lang.String> prepareClassPath(java.lang.String libDirName)
          The list of names of the jars used in the classpath.
static void saveAsJavaClass(java.lang.String absoluteFileName, byte[] newBytecode)
          Save the bytecode as java class.
static java.lang.String tweakInterfaceClasses(java.lang.String portTypeClassName, java.lang.String classesDirName)
          Tweak interface classes addint the java.rmi.Remote interface.
static void tweakSerializableDecoration(java.lang.String absPath, java.lang.Long newSerialVersionUid)
          This method modify the bytecode of a class: add Serializable interface and set the serial version UID.
static org.objectweb.asm.ClassVisitor tweakSerializableInspection(java.lang.String absPath)
          This method inspect a class to verify if it is Serilizable and to extract the serial version UID (if exists).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

compileJavaClasses

public static void compileJavaClasses(java.lang.String workdirsrc,
                                      java.lang.String workdirclasses,
                                      java.util.List<java.lang.String> javaSources,
                                      java.util.List<java.lang.String> jarFiles,
                                      java.util.List<java.lang.String> extraClassPath)
                               throws ClassGenerationException
Compile the java sources. Cut&paste from from it.imolinfo.jbi4corba.webservice.generator.Util.

Parameters:
workdirsrc - Where the sources are
workdirclasses - Where the sources are compiled
javaSources - The java sources
jarFiles - The jar files to add in the classpath
extraClassPath - The extra classpath
Throws:
ClassGenerationException - If some problem occurs

findJavaSources

public static java.util.List<java.lang.String> findJavaSources(java.lang.String basedir,
                                                               java.util.List<java.lang.String> exclude)
                                                        throws EJBDeployException
Find java sources in a directory.

Parameters:
basedir - The base directory
exclude - The files to exclude
Returns:
the list< string>
Throws:
EJBDeployException - If some problem occurs

containsIgnoreSlashes

public static boolean containsIgnoreSlashes(java.util.List<java.lang.String> list,
                                            java.lang.String myString)
Contains ignore slashes.

Parameters:
list - The list to test
myString - The string to search
Returns:
true, if successful

findFilesFromSourceDirectory

public static java.util.List<java.io.File> findFilesFromSourceDirectory(java.lang.String basedirString,
                                                                        java.lang.String extensionFilter)
This method find all the files in a directory according to the filter.

Parameters:
basedirString - The directory where the method works.
extensionFilter - The filter (the suffix of the files).
Returns:
the found files

findFilesFromSourceDirectoryFromExactFileName

public static java.util.List<java.io.File> findFilesFromSourceDirectoryFromExactFileName(java.lang.String basedirString,
                                                                                         java.lang.String exactName)
This method find all the files in a directory according to the filter. Its similar to findFilesFromSourceDirectory method, except that looks fpr the EXACT file name and adds the base directory in the search.

Parameters:
basedirString - The directory where the method works.
exactName - The exact file name
Returns:
the found files

tweakInterfaceClasses

public static java.lang.String tweakInterfaceClasses(java.lang.String portTypeClassName,
                                                     java.lang.String classesDirName)
                                              throws ClassGenerationException
Tweak interface classes addint the java.rmi.Remote interface.

Parameters:
portTypeClassName - The interface class name
classesDirName - The classes directory
Returns:
the remote class name
Throws:
ClassGenerationException - If some problem occurs

saveAsJavaClass

public static void saveAsJavaClass(java.lang.String absoluteFileName,
                                   byte[] newBytecode)
                            throws ClassGenerationException
Save the bytecode as java class.

Parameters:
absoluteFileName - The file name
newBytecode - The bytecode to save
Throws:
ClassGenerationException - If some problem occurs

getURLClassLoader

public static java.net.URLClassLoader getURLClassLoader(java.lang.String absolutePath,
                                                        java.lang.ClassLoader parent)
                                                 throws java.net.MalformedURLException
Gets the URL class loader, setting the parent ClassLoader.

Parameters:
absolutePath - The url classloader path
parent - The parent classloader
Returns:
the URL class loader The classloader parent
Throws:
java.net.MalformedURLException - If the URL is not well formed

getURLClassLoader

public static java.net.URLClassLoader getURLClassLoader(java.lang.String absolutePath)
                                                 throws java.net.MalformedURLException
Gets the URL class loader, setting the parent ClassLoader to this class ClassLoader.

Parameters:
absolutePath - The urel classloader path
Returns:
the URL class loader
Throws:
java.net.MalformedURLException - If the URL is not well formed

tweakSerializableDecoration

public static void tweakSerializableDecoration(java.lang.String absPath,
                                               java.lang.Long newSerialVersionUid)
                                        throws ClassGenerationException
This method modify the bytecode of a class: add Serializable interface and set the serial version UID.

Parameters:
absPath - The absolute path of the class to modify.
newSerialVersionUid - The new serialVersionUID.
Throws:
ClassGenerationException - If some problem occurs

tweakSerializableInspection

public static org.objectweb.asm.ClassVisitor tweakSerializableInspection(java.lang.String absPath)
                                                                  throws ClassGenerationException
This method inspect a class to verify if it is Serilizable and to extract the serial version UID (if exists).

Parameters:
absPath - The absolute path of the class to inspect.
Returns:
The class visitor where the information are stored.
Throws:
ClassGenerationException - If some problem occurs

getAsmCLassReader

public static org.objectweb.asm.ClassReader getAsmCLassReader(java.lang.String className)
                                                       throws ClassGenerationException
This method returns the class reader used for the bytecode manipulation.

Parameters:
className - The absolute path of the class (eg: /var/Foo.class).
Returns:
The class reader associated to the input class.
Throws:
ClassGenerationException - If some problem occurs

findClassUsed

public static java.util.Set<java.lang.Class> findClassUsed(java.lang.String dir,
                                                           java.util.List<java.io.File> classList)
                                                    throws ClassGenerationException
This method extracs all the classes used as method's parameter or method's result from a class list.

Parameters:
dir - The directory where to search the classes
classList - The classes file list
Returns:
The classes Set
Throws:
ClassGenerationException - If some problem occurs

prepareClassPath

public static java.util.List<java.lang.String> prepareClassPath(java.lang.String libDirName)
                                                         throws ClassGenerationException
The list of names of the jars used in the classpath.

Parameters:
libDirName - The directory where the jars are located.
Returns:
The list of names of the jars used in the classpath.
Throws:
ClassGenerationException - If some problem occurs


Copyright © 2007-2008 Imola Informatica. All Rights Reserved.