15
15
16
16
import javax .annotation .processing .AbstractProcessor ;
17
17
import javax .annotation .processing .Filer ;
18
- import javax .annotation .processing .Messager ;
19
18
import javax .annotation .processing .ProcessingEnvironment ;
20
19
import javax .annotation .processing .RoundEnvironment ;
21
20
import javax .annotation .processing .SupportedSourceVersion ;
24
23
import javax .lang .model .element .Element ;
25
24
import javax .lang .model .element .PackageElement ;
26
25
import javax .lang .model .element .TypeElement ;
27
- import javax .lang .model .type .TypeMirror ;
28
26
import javax .tools .FileObject ;
29
27
import javax .tools .JavaFileObject ;
30
28
import javax .tools .StandardLocation ;
@@ -67,51 +65,32 @@ public class SPIProcessor extends AbstractProcessor {
67
65
68
66
69
67
private Filer filer ;
70
- private Messager messager ;
71
68
private ProcessingEnvironment processingEnv ;
72
69
private List <String > discoveredExtensions ;
73
70
private List <ExtensionDeclaration > discoveredBindings ;
74
71
private List <String > discoveredBeanFactories ;
75
72
private List <String > categoryClasses ;
76
73
private List <SubsystemExtensionMetaData > subsystemDeclararions ;
77
74
private List <RuntimeExtensionMetaData > runtimeExtensions ;
78
- private Set <String > modules = new LinkedHashSet <String >();
75
+ private Set <String > modules = new LinkedHashSet <>();
79
76
private Set <String > nameTokens ;
80
- private HashMap <String , String > gwtConfigProps ;
81
77
82
78
@ Override
83
79
public void init (ProcessingEnvironment env ) {
84
80
this .processingEnv = env ;
85
81
this .filer = env .getFiler ();
86
- this .messager = env .getMessager ();
87
- this .discoveredExtensions = new ArrayList <String >();
88
- this .discoveredBindings = new ArrayList <ExtensionDeclaration >();
89
- this .discoveredBeanFactories = new ArrayList <String >();
90
- this .categoryClasses = new ArrayList <String >();
91
- this .subsystemDeclararions = new ArrayList <SubsystemExtensionMetaData >();
92
- this .runtimeExtensions = new ArrayList <RuntimeExtensionMetaData >();
93
- this .nameTokens = new HashSet <String >();
94
-
95
-
96
- parseGwtProperties ();
97
- }
98
-
99
- private void parseGwtProperties () {
100
- // GWT config properties
101
- Map <String , String > options = processingEnv .getOptions ();
102
- gwtConfigProps = new HashMap <String , String >();
103
- for (String key : options .keySet ())
104
- {
105
- if (key .startsWith ("gwt." ))
106
- {
107
- gwtConfigProps .put (key .substring (4 , key .length ()), options .get (key ));
108
- }
109
- }
82
+ this .discoveredExtensions = new ArrayList <>();
83
+ this .discoveredBindings = new ArrayList <>();
84
+ this .discoveredBeanFactories = new ArrayList <>();
85
+ this .categoryClasses = new ArrayList <>();
86
+ this .subsystemDeclararions = new ArrayList <>();
87
+ this .runtimeExtensions = new ArrayList <>();
88
+ this .nameTokens = new HashSet <>();
110
89
}
111
90
112
91
@ Override
113
92
public Set <String > getSupportedAnnotationTypes () {
114
- Set <String > types = new HashSet <String >();
93
+ Set <String > types = new HashSet <>();
115
94
types .add (GinExtension .class .getName ());
116
95
types .add (GinExtensionBinding .class .getName ());
117
96
types .add (BeanFactoryExtension .class .getName ());
@@ -124,6 +103,7 @@ public Set<String> getSupportedAnnotationTypes() {
124
103
public boolean process (Set <? extends TypeElement > typeElements , RoundEnvironment roundEnv ) {
125
104
126
105
if (!roundEnv .processingOver ()) {
106
+
127
107
System .out .println ("Begin Components discovery ..." );
128
108
129
109
Set <? extends Element > extensionElements = roundEnv .getElementsAnnotatedWith (GinExtension .class );
@@ -245,6 +225,7 @@ private void handleGinExtensionElement(Element element) {
245
225
}
246
226
}
247
227
228
+ @ SuppressWarnings ("unchecked" )
248
229
private void handleBeanFactoryElement (Element element ) {
249
230
List <? extends AnnotationMirror > annotationMirrors = element .getAnnotationMirrors ();
250
231
@@ -254,7 +235,6 @@ private void handleBeanFactoryElement(Element element) {
254
235
255
236
if ( annotationType .equals (BeanFactoryExtension .class .getName ()) )
256
237
{
257
- BeanFactoryExtension factory = element .getAnnotation (BeanFactoryExtension .class );
258
238
PackageElement packageElement = processingEnv .getElementUtils ().getPackageOf (element );
259
239
String fqn = packageElement .getQualifiedName ().toString ()+"." +
260
240
element .getSimpleName ().toString ();
@@ -264,7 +244,7 @@ private void handleBeanFactoryElement(Element element) {
264
244
final Collection <? extends AnnotationValue > values = mirror .getElementValues ().values ();
265
245
if (values .size () > 0 ) {
266
246
for (AnnotationValue categoryClass : (List <? extends AnnotationValue >)values .iterator ().next ().getValue ()) {
267
- categoryClasses .add ((( TypeMirror ) categoryClass .getValue () ).toString ());
247
+ categoryClasses .add (categoryClass .getValue ().toString ());
268
248
}
269
249
}
270
250
}
@@ -315,7 +295,7 @@ private void writeFiles() throws Exception {
315
295
}
316
296
317
297
private void writeRuntimeFile () throws Exception {
318
- Map <String , Object > model = new HashMap <String , Object >();
298
+ Map <String , Object > model = new HashMap <>();
319
299
model .put ("runtimeMenuItemExtensions" , runtimeExtensions );
320
300
321
301
JavaFileObject sourceFile = filer .createSourceFile (RUNTIME_FILENAME );
@@ -326,7 +306,7 @@ private void writeRuntimeFile() throws Exception {
326
306
}
327
307
328
308
private void writeSubsystemFile () throws Exception {
329
- Map <String , Object > model = new HashMap <String , Object >();
309
+ Map <String , Object > model = new HashMap <>();
330
310
model .put ("subsystemExtensions" , subsystemDeclararions );
331
311
332
312
JavaFileObject sourceFile = filer .createSourceFile (SUBSYSTEM_FILENAME );
@@ -337,7 +317,7 @@ private void writeSubsystemFile() throws Exception{
337
317
}
338
318
339
319
private void writeBeanFactoryFile () throws Exception {
340
- Map <String , Object > model = new HashMap <String , Object >();
320
+ Map <String , Object > model = new HashMap <>();
341
321
model .put ("extensions" , discoveredBeanFactories );
342
322
model .put ("categoryClasses" , categoryClasses );
343
323
@@ -350,7 +330,7 @@ private void writeBeanFactoryFile() throws Exception{
350
330
351
331
private void writeBindingFile () throws Exception {
352
332
JavaFileObject sourceFile = filer .createSourceFile (BINDING_FILENAME );
353
- Map <String , Object > model = new HashMap <String , Object >();
333
+ Map <String , Object > model = new HashMap <>();
354
334
model .put ("extensions" , discoveredBindings );
355
335
356
336
OutputStream output = sourceFile .openOutputStream ();
@@ -362,7 +342,7 @@ private void writeBindingFile() throws Exception {
362
342
363
343
private void writeGinjectorFile () throws Exception {
364
344
365
- Map <String , Object > model = new HashMap <String , Object >();
345
+ Map <String , Object > model = new HashMap <>();
366
346
model .put ("extensions" , discoveredExtensions );
367
347
368
348
JavaFileObject sourceFile = filer .createSourceFile (EXTENSION_FILENAME );
@@ -377,9 +357,9 @@ private void writeModuleFile() {
377
357
378
358
try
379
359
{
380
- Map <String , Object > model = new HashMap <String , Object >();
360
+ Map <String , Object > model = new HashMap <>();
381
361
model .put ("modules" , modules );
382
- model .put ("properties" , gwtConfigProps );
362
+ model .put ("properties" , processingEnv . getOptions () );
383
363
384
364
FileObject sourceFile = filer .createResource (StandardLocation .SOURCE_OUTPUT , MODULE_PACKAGENAME ,
385
365
MODULE_FILENAME );
@@ -398,9 +378,9 @@ private void writeDevModuleFile() {
398
378
399
379
try
400
380
{
401
- Map <String , Object > model = new HashMap <String , Object >();
381
+ Map <String , Object > model = new HashMap <>();
402
382
model .put ("modules" , modules );
403
- model .put ("properties" , gwtConfigProps );
383
+ model .put ("properties" , processingEnv . getOptions () );
404
384
405
385
FileObject sourceFile = filer .createResource (StandardLocation .SOURCE_OUTPUT , MODULE_PACKAGENAME ,
406
386
MODULE_DEV_FILENAME );
@@ -419,9 +399,9 @@ private void writeProductModuleFile() {
419
399
420
400
try
421
401
{
422
- Map <String , Object > model = new HashMap <String , Object >();
402
+ Map <String , Object > model = new HashMap <>();
423
403
model .put ("modules" , modules );
424
- model .put ("properties" , gwtConfigProps );
404
+ model .put ("properties" , processingEnv . getOptions () );
425
405
426
406
FileObject sourceFile = filer .createResource (StandardLocation .SOURCE_OUTPUT , MODULE_PACKAGENAME ,
427
407
MODULE_PRODUCT_FILENAME );
@@ -441,10 +421,10 @@ private void writeProxyConfigurations() {
441
421
442
422
try
443
423
{
444
- String devHostUrl = gwtConfigProps .get ("console.dev.host" ) != null ?
445
- gwtConfigProps .get ("console.dev.host" ) : "127.0.0.1" ;
424
+ String devHostUrl = processingEnv . getOptions () .get ("console.dev.host" ) != null ?
425
+ processingEnv . getOptions () .get ("console.dev.host" ) : "127.0.0.1" ;
446
426
447
- Map <String , Object > model = new HashMap <String , Object >();
427
+ Map <String , Object > model = new HashMap <>();
448
428
model .put ("devHost" , devHostUrl );
449
429
450
430
FileObject sourceFile = filer .createResource (
0 commit comments