Package com.sun.ejb.codegen
Class Generator
- java.lang.Object
-
- com.sun.ejb.codegen.Generator
-
- Direct Known Subclasses:
GenericHomeGenerator,Remote30WrapperGenerator,RemoteGenerator,ServiceInterfaceGenerator
public abstract class Generator extends Object
The base class for all code generators.
-
-
Constructor Summary
Constructors Constructor Description Generator(ClassLoader loader)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voiddefineClassBody()CallsWrappermethods to configure the class definition.Class<?>generate()Generates the bytecode of the configured class with the usage of the PFL tool.protected abstract Class<?>getAnchorClass()static StringgetBaseName(String fullClassName)ClassLoadergetClassLoader()abstract StringgetGeneratedClassName()protected abstract StringgetPackageName()static StringgetPackageName(String fullClassName)protected Method[]removeRedundantMethods(Method[] methods)Remove duplicates from method array.
-
-
-
Constructor Detail
-
Generator
public Generator(ClassLoader loader)
- Parameters:
loader-ClassLoaderowning generated classes
-
-
Method Detail
-
getPackageName
protected abstract String getPackageName()
- Returns:
- the name of the package of the generated class. Can be null.
-
getGeneratedClassName
public abstract String getGeneratedClassName()
- Returns:
- name of the generated class or interface
-
getAnchorClass
protected abstract Class<?> getAnchorClass()
- Returns:
- loadable class of the same package as
getGeneratedClassName()
-
defineClassBody
protected abstract void defineClassBody()
CallsWrappermethods to configure the class definition. TheWrapperusesThreadLocalinternally, so you should always callWrapper._clear()in finally block after generation to avoid leakages.
-
getClassLoader
public ClassLoader getClassLoader()
- Returns:
ClassLoaderowning the generated class.
-
generate
public Class<?> generate() throws IllegalAccessException
Generates the bytecode of the configured class with the usage of the PFL tool. Then usesMethodHandlesorClassGeneratorto generate the class.WARNING: This selection depends on the classloader capabilities and JVM rules, which change between JDK versions.
- Returns:
Class- Throws:
IllegalAccessException
-
getPackageName
public static String getPackageName(String fullClassName)
- Returns:
- the package name or null.
-
getBaseName
public static String getBaseName(String fullClassName)
- Returns:
- simple class name (including wrapper class and dollar sign if it is internal class)
-
removeRedundantMethods
protected Method[] removeRedundantMethods(Method[] methods)
Remove duplicates from method array.Duplicates will arise if a class/intf and super-class/intf define methods with the same signature. Potentially the throws clauses of the methods may be different (note Java requires that the superclass/intf method have a superset of the exceptions in the derived method).
- Parameters:
methods-- Returns:
- methods which can be generated in an interface
-
-