String fullName = typeDescr.getType().getFullName();
JavaDialectRuntimeData dialect = (JavaDialectRuntimeData) pkgRegistry.getDialectRuntimeRegistry().getDialectData( "java" );
switch ( type.getKind() ) {
case TRAIT :
try {
ClassBuilder tb = this.configuration.getClassBuilderFactory().getTraitBuilder();
byte[] d = tb.buildClass( def );
String resourceName = JavaDialectRuntimeData.convertClassToResourcePath( fullName );
dialect.putClassDefinition( resourceName, d );
if ( ruleBase != null ) {
ruleBase.registerAndLoadTypeDefinition( fullName, d );
} else {
dialect.write( resourceName, d );
}
} catch ( Exception e ) {
this.results.add( new TypeDeclarationError( typeDescr,
"Unable to compile declared trait " + fullName +
": " + e.getMessage() + ";" ) );
}
break;
case ENUM :
try {
ClassBuilder eb = this.configuration.getClassBuilderFactory().getEnumClassBuilder();
byte[] d = eb.buildClass( def );
String resourceName = JavaDialectRuntimeData.convertClassToResourcePath( fullName );
dialect.putClassDefinition( resourceName, d );
if ( ruleBase != null ) {
ruleBase.registerAndLoadTypeDefinition( fullName, d );
} else {
dialect.write( resourceName, d );
}
} catch ( Exception e ) {
e.printStackTrace();
this.results.add( new TypeDeclarationError( typeDescr,
"Unable to compile declared enum " + fullName +
": " + e.getMessage() + ";" ) );
}
break;
case CLASS :
default :
try {
ClassBuilder cb = this.configuration.getClassBuilderFactory().getBeanClassBuilder();
byte[] d = cb.buildClass( def );
String resourceName = JavaDialectRuntimeData.convertClassToResourcePath( fullName );
dialect.putClassDefinition( resourceName, d );
if ( ruleBase != null ) {
ruleBase.registerAndLoadTypeDefinition( fullName, d );
}