|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectit.imolinfo.jbi4corba.webservice.generator.Util
public class Util
A collection of utility methods.
| Field Summary | |
|---|---|
static String |
PROTOCOL
The platform dependent protocol used to load file and classes. |
| Constructor Summary | |
|---|---|
Util()
Default constructor. |
|
| Method Summary | |
|---|---|
static boolean |
buildDirectory(File file)
Builds the directory. |
static Class |
classLoad(String dir,
File classAsFile)
|
static Class |
classLoad(String dir,
String className)
Load ths class using the class name in the target directory. |
static Class |
classLoad(String dir,
String className,
boolean addParent)
Load ths class using the class name in the target directory. |
static Class |
classLoadQuiet(String dir,
String className)
Try to load the class the class name in the target directory; if no class is found, NO EXCEPTION IS THROWN. |
static void |
compileJavaClasses(String workdirsrc,
String workdirclasses,
List<String> javaSources,
List<String> jarFiles,
List<String> extraClassPath)
XXX javadoc. |
static void |
compileRemoteClassesNoValueMethodsOFF(String classesDir,
String className,
List<String> extraClasspath)
|
static void |
compileRemoteClassesNoValueMethodsON(String classesDir,
String className,
List<String> extraClasspath)
|
static void |
copyInputStream(InputStream in,
OutputStream out)
Copy an input stream to an output. |
static File |
createUniqueDirectory(File rootDir,
String seed)
Creates an unique directory form the seed (seed.tmp) in the rootDir. |
static void |
debug(String message,
Collection collection)
|
static void |
debug(String message,
Map map)
|
static Map<String,List<MethodSignature>> |
extractMethodSignatureOfTheCorbaOperations(String sourceDir)
This method extracts all the MethodSignature in the 'Operations' source files. |
static Long |
extractSerialVersionUid(Class classToSerialize)
|
static Map<Long,String> |
extractSerialVersionUid(String classesDir,
List<String> pathList)
|
static List<String> |
findAllDefaultFactory(String basedir)
This method find all the java source file with the suffix 'DefaultFacoty.java'. |
static Set<Class> |
findAllTypesUsedInIDL(String dir)
This method extracts all the types used in idl file. |
static Set<Class> |
findClassUsed(String dir,
List<File> classList)
This method extracs all the class used as method's parameter or method's result. |
static Set<Class> |
findClassUsedInTheOperations(String dir)
This method extracs all the class used as method's parameter or method's result. |
protected static Map<String,List<String>> |
findCorbaEnum(String bin)
This method find the corba enum. |
static List<File> |
findFilesFromSourceDirectory(String basedirString,
String extensionFilter)
This method find all the files in a directory according to the filter. |
static List<Class> |
findGeneratedClasses(String classesDir,
ClassLoader classLoader)
This method find all the '.class' files in classesDir. |
static List<String> |
findIdlFiles(String basedir)
Finding the *.idl files in the directory 'basedir'. |
static List<String> |
findJavaSources(String basedir)
Finding the *.java files in the directory 'basedir'. |
static List<String> |
findJavaSources(String basedir,
List<String> exclude)
|
static Map<String,List<String>> |
findOnewayOperations(String bin)
This method is used to discover the 'oneway' operations inside a corba stub. |
static String |
generateImplementationClass(ClassLoader urlClassLoader,
String remoteClassName,
boolean addRemoteSupport)
This method load the class 'remoteClassName' using the ClassLoader in input and generates an implementation class. |
static String |
generateSpecialEnumClass(String aPackage,
String aClassName,
List<String> labelList)
This method generates the source code of a standard enum class with some special features. |
protected static String |
generateTheBodyOfTheMethodForImplTie(MethodSignature methodSignature,
boolean addRemoteSupport)
This method is used to generate the body of the methods of the the class that must be implement the skeleton (tie) previously created. |
static List<String> |
generateValueTypeFactoryJbi4corba(List<String> vtList,
String basedir)
This method generates the new valuetypes factories. |
static org.objectweb.asm.ClassReader |
getAsmCLassReader(String className)
This method returns the class reader used for the bytecode manipulation. |
static org.objectweb.asm.ClassReader |
getAsmCLassReader(String classesDirName,
String className)
|
static String |
getClassName(File file,
String basedir,
String extension)
Gets the class name from the file absolute path, representing both "java" and "class" file names |
static String |
getClassName(String absoluteFilePath,
String basedir,
String extension)
Gets the class name from the file absolute path, representing both "java" and "class" file names |
static HashMap<String,String> |
getTypesMap(String dir)
findAllTypes - finds all types defined in IDL |
static String |
getValueTypeIdFromHelperClass(String helper,
ClassLoader cl)
|
static boolean |
isThrowableSubClass(Class cls)
isThrowableSubClass |
protected static String |
methodImplementation(List<MethodSignature> msList,
boolean addRemoteSupport)
This method is used to generate the source code of the methods in the list. |
static List<String> |
prepareClassPath(String libDirName)
The list of names of the jars used in the classpath. |
static Map<String,List<String>> |
replaceCorbaEnumaration(String src,
String bin)
This method finds the corba enumerations and replace them with a standard enum classes. |
static String |
replaceDotWithSeparator(String s)
This method replaces the dot with a file sperator. |
static String |
replaceSeparatorWithDot(String s)
This method replaces the file sperator with a dot. |
static void |
saveAsJavaClass(String absoluteFileName,
byte[] newBytecode)
|
static void |
saveAsJavaClass(String classesDirName,
String relativeFileName,
byte[] newBytecode)
|
static File |
saveAsJavaSource(String code,
String dir,
String name)
This method save a java file. |
static File |
saveFile(String code,
String dir,
String name)
This method saves a file. |
static Map<String,List<String>> |
tweakOnewayInspection(String absPath)
This method is used to inspect the bytecode of a class to discover the corba 'oneway' requests. |
static void |
tweakSerializableDecoration(String absPath,
Long newSerialVersionUid)
This method modify the bytecode of a class: add Serializable interface and set the serial version UID. |
static ClassMetaInfo |
tweakSerializableInspection(String absPath)
This method inspect a class to verify if it is Serilizable and to extract the serial version UID (if exists). |
static Map<String,Object> |
valueTypeMapHandler(List<String> vtList,
String classesDirName,
ClassLoader cl)
XXX javadoc. |
static Map<String,Object> |
valueTypeMapHandlerWithJbi4corbaFactory(List<String> vtList,
String classesDirName,
ClassLoader cl)
XXX javadoc. |
static List<String> |
valueTypesImpl(String workdirsrc,
boolean addToStringEquals)
The files with the 'DefaultFactory.java' suffix instantiate a value type but the implementation of this data types must be provided by the developers. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String PROTOCOL
| Constructor Detail |
|---|
public Util()
| Method Detail |
|---|
public static void compileRemoteClassesNoValueMethodsON(String classesDir,
String className,
List<String> extraClasspath)
throws ClassGenerationException
classesDir - The classes dirclassName - The class nameextraClasspath - The extra class path
ClassGenerationException - The class generation exception
public static void compileRemoteClassesNoValueMethodsOFF(String classesDir,
String className,
List<String> extraClasspath)
throws ClassGenerationException
classesDir - The classes dirclassName - The class nameextraClasspath - The extra class path
ClassGenerationException - The class generation exception
public static List<String> findJavaSources(String basedir)
throws Jbi4CorbaException
basedir - The directory where the method looks up the files.
Jbi4CorbaException - The Jbi4Corba exception
public static List<String> findJavaSources(String basedir,
List<String> exclude)
throws Jbi4CorbaException
basedir - The basedirexclude - The exclude
Jbi4CorbaException - The Jbi4Corba exception
public static List<String> findAllDefaultFactory(String basedir)
throws IOException
basedir - The directory inspected.
IOException - The IO exception
public static List<String> findIdlFiles(String basedir)
throws Jbi4CorbaException
basedir - The directory where the method looks up the files.
Jbi4CorbaException - The Jbi4Corba exception
public static List<File> findFilesFromSourceDirectory(String basedirString,
String extensionFilter)
baseDirString (not only in the subdirectories).
basedirString - The directory where the method works.extensionFilter - The filter (the suffix of the files).
public static void compileJavaClasses(String workdirsrc,
String workdirclasses,
List<String> javaSources,
List<String> jarFiles,
List<String> extraClassPath)
throws ClassGenerationException
workdirsrc - The work dir srcworkdirclasses - The workdir classesjavaSources - The java sourcesjarFiles - The jar filesextraClassPath - The extra class path
ClassGenerationException - The class generation exception
public static Map<String,List<MethodSignature>> extractMethodSignatureOfTheCorbaOperations(String sourceDir)
throws ClassGenerationException
sourceDir - The directory where we find the files.
ClassGenerationException - The class generation exception
public static Set<Class> findClassUsedInTheOperations(String dir)
throws ClassGenerationException
dir - Where looking for the classes.
ClassGenerationException - The class generation exception
public static Set<Class> findAllTypesUsedInIDL(String dir)
throws ClassGenerationException
dir - Where looking for the classes.
ClassGenerationException - The class generation exception
public static HashMap<String,String> getTypesMap(String dir)
throws ClassGenerationException
dir - typeClasses -
ClassGenerationException
public static Set<Class> findClassUsed(String dir,
List<File> classList)
throws ClassGenerationException
dir - The dirclassList - The class list
ClassGenerationException - The class generation exception
public static Class classLoad(String dir,
File classAsFile)
throws ClassGenerationException
dir - The dirclassAsFile - The class AsFile
ClassGenerationException - The class generation exception
public static Class classLoad(String dir,
String className)
throws ClassGenerationException
dir - The dirclassAsFile - The class AsFileaddParent - if true, link the classLoader with the Util ClassLoader.
ClassGenerationException - The class generation exception
public static Class classLoad(String dir,
String className,
boolean addParent)
throws ClassGenerationException
dir - The dirclassAsFile - The class AsFileaddParent - if true, link the classLoader with the Util ClassLoader.
ClassGenerationException - The class generation exception
public static List<Class> findGeneratedClasses(String classesDir,
ClassLoader classLoader)
throws ClassGenerationException
classesDir - The directory to inspect.classLoader - The class loader used to istantiate the classes.
ClassGenerationException - The class generation exception
public static String getClassName(String absoluteFilePath,
String basedir,
String extension)
throws ClassGenerationException
absoluteFilePath - The file absolute pathbasedir - The base dir pathextension - ".class" or ".java"
ClassGenerationException - The class generation exception
public static String getClassName(File file,
String basedir,
String extension)
throws ClassGenerationException
file - The filebasedir - The base dir pathextension - ".class" or ".java"
ClassGenerationException - The class generation exception
public static org.objectweb.asm.ClassReader getAsmCLassReader(String classesDirName,
String className)
throws ClassGenerationException
classesDirName - The classes dir nameclassName - The class name
ClassGenerationException - The class generation exception
public static org.objectweb.asm.ClassReader getAsmCLassReader(String className)
throws ClassGenerationException
className - The absolute path of the class (eg: /var/Foo.class).
ClassGenerationException - The class generation exception.
public static void saveAsJavaClass(String classesDirName,
String relativeFileName,
byte[] newBytecode)
throws ClassGenerationException
classesDirName - The classes dir namerelativeFileName - The relative file namenewBytecode - The new Bytecode
ClassGenerationException - The class generation exception
public static void saveAsJavaClass(String absoluteFileName,
byte[] newBytecode)
throws ClassGenerationException
absoluteFileName - The absolute file namenewBytecode - The new Byte code
ClassGenerationException - The class generation exception
public static File saveAsJavaSource(String code,
String dir,
String name)
throws ClassGenerationException
code - The code of the file.dir - The directory where the file will be save.name - The name of the file.
ClassGenerationException - The class generation exception.
public static File saveFile(String code,
String dir,
String name)
throws ClassGenerationException
content - The content of the file stored in a stringdir - The directory where the file will be save.name - The name of the file.
ClassGenerationException - The class generation exception.
public static List<String> valueTypesImpl(String workdirsrc,
boolean addToStringEquals)
throws ClassGenerationException
workdirsrc - The directory where the method look for the 'DefaultFactory'
java files. The generated files will be placed here.addToStringEquals - If true the method toString and equals will be added.
ClassGenerationException - The class generation exceptionpublic static String replaceSeparatorWithDot(String s)
s - The working string.
public static String replaceDotWithSeparator(String s)
s - The working path.
public static Map<String,Object> valueTypeMapHandler(List<String> vtList,
String classesDirName,
ClassLoader cl)
throws ClassGenerationException
vtList - The vt listclassesDirName - The classes dir namecl - The class loader
ClassGenerationException - The class generation exception
public static Map<String,Object> valueTypeMapHandlerWithJbi4corbaFactory(List<String> vtList,
String classesDirName,
ClassLoader cl)
throws ClassGenerationException
vtList - The vt listclassesDirName - The classes dir namecl - The class loader
ClassGenerationException - The class generation exception
public static String getValueTypeIdFromHelperClass(String helper,
ClassLoader cl)
throws ClassGenerationException
helper - The helpercl - The class loader
ClassGenerationException - The class generation exception
public static List<String> prepareClassPath(String libDirName)
throws ClassGenerationException
libDirName - The directory where the jars are located.
ClassGenerationException - The class generation exception
public static List<String> generateValueTypeFactoryJbi4corba(List<String> vtList,
String basedir)
throws ClassGenerationException
vtList - The list of valuetypes.basedir - The directory where the sources are located.
ClassGenerationException - If the one new factory cannot saved.
public static void tweakSerializableDecoration(String absPath,
Long newSerialVersionUid)
throws ClassGenerationException
absPath - The absolute path of the class to modify.newSerialVersionUid - The new serialVersionUID.
ClassGenerationException - The class generation exception
public static ClassMetaInfo tweakSerializableInspection(String absPath)
throws ClassGenerationException
absPath - The absolute path of the class to inspect.
ClassGenerationException - The class generation exception
public static Map<String,List<String>> findOnewayOperations(String bin)
throws ClassGenerationException
bin - The classes directory.
ClassGenerationException - The class generation exception
public static Map<String,List<String>> tweakOnewayInspection(String absPath)
throws ClassGenerationException
absPath - The absolute path of the corba stub.
ClassGenerationException - The class generation exception
public static Map<String,List<String>> replaceCorbaEnumaration(String src,
String bin)
throws ClassGenerationException
src - The source directory.bin - The classes directory.
ClassGenerationException - The class generation exception
public static String generateSpecialEnumClass(String aPackage,
String aClassName,
List<String> labelList)
aPackage - The package of the class.aClassName - The simple class name.labelList - The list of label for the enumaration.
protected static Map<String,List<String>> findCorbaEnum(String bin)
throws ClassGenerationException
bin - The classes directory.
ClassGenerationException - The class generation exception
public static String generateImplementationClass(ClassLoader urlClassLoader,
String remoteClassName,
boolean addRemoteSupport)
throws ClassGenerationException
urlClassLoader - The ClassLoader used to load the class.remoteClassName - The full name of the Interface to implement.addRemoteSupport - Check if adding Remote interface to the implementation class is needed
ClassGenerationException - When the class name is empty or the class does not exist.
protected static String methodImplementation(List<MethodSignature> msList,
boolean addRemoteSupport)
msList - A list of method's signature.
protected static String generateTheBodyOfTheMethodForImplTie(MethodSignature methodSignature,
boolean addRemoteSupport)
methodSignature - The method's signature.
public static Map<Long,String> extractSerialVersionUid(String classesDir,
List<String> pathList)
throws ClassGenerationException
ClassGenerationExceptionpublic static Long extractSerialVersionUid(Class classToSerialize)
public static void debug(String message,
Collection collection)
message - The messagecollection - The collection
public static void debug(String message,
Map map)
message - The messagemap - A map
public static File createUniqueDirectory(File rootDir,
String seed)
throws IOException
rootDir - seed -
IOExceptionpublic static boolean buildDirectory(File file)
file -
public static void copyInputStream(InputStream in,
OutputStream out)
throws IOException
in - out -
IOException
public static Class classLoadQuiet(String dir,
String className)
throws ClassGenerationException
dir - The dirclassAsFile - The class AsFile
ClassGenerationException - The class generation exceptionpublic static boolean isThrowableSubClass(Class cls)
cls -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||