Repository navigation
Expand file tree
/
Copy pathApp.java
More file actions
879 lines (749 loc) · 24.7 KB
/
Copy pathApp.java
File metadata and controls
879 lines (749 loc) · 24.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
package act.app;
import act.Act;
import act.Destroyable;
import act.app.data.BinderManager;
import act.app.data.StringValueResolverManager;
import act.app.event.AppEventId;
import act.app.util.AppCrypto;
import act.app.util.NamedPort;
import act.app.util.SimpleTypeInstanceFactory;
import act.cli.CliDispatcher;
import act.cli.bytecode.CommanderByteCodeScanner;
import act.conf.AppConfLoader;
import act.conf.AppConfig;
import act.conf.AppConfigKey;
import act.controller.bytecode.ControllerByteCodeScanner;
import act.data.DataPropertyRepository;
import act.data.JodaDateTimeCodec;
import act.data.util.ActPropertyHandlerFactory;
import act.di.DependencyInjectionBinder;
import act.di.DependencyInjector;
import act.event.AppEventListenerBase;
import act.event.EventBus;
import act.event.bytecode.SimpleEventListenerByteCodeScanner;
import act.handler.builtin.StaticFileGetter;
import act.job.AppJobManager;
import act.job.bytecode.JobByteCodeScanner;
import act.mail.MailerConfigManager;
import act.mail.MailerContext;
import act.mail.bytecode.MailerByteCodeScanner;
import act.route.RouteSource;
import act.route.RouteTableRouterBuilder;
import act.route.Router;
import act.util.*;
import act.view.ActServerError;
import org.osgl.$;
import org.osgl.Osgl;
import org.osgl.cache.CacheService;
import org.osgl.cache.CacheServiceProvider;
import org.osgl.http.H;
import org.osgl.http.HttpConfig;
import org.osgl.logging.L;
import org.osgl.logging.Logger;
import org.osgl.storage.IStorageService;
import org.osgl.util.*;
import java.io.File;
import java.util.EventObject;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static act.app.event.AppEventId.*;
/**
* {@code App} represents an application that is deployed in a Act container
*/
public class App extends DestroyableBase {
public static Logger logger = L.get(App.class);
private static App INST;
public enum F {
;
public static $.Predicate<String> JAVA_SOURCE = S.F.endsWith(".java");
public static $.Predicate<String> JAR_FILE = S.F.endsWith(".jar");
public static $.Predicate<String> CONF_FILE = S.F.endsWith(".conf").or(S.F.endsWith(".properties"));
public static $.Predicate<String> ROUTES_FILE = $.F.eq(RouteTableRouterBuilder.ROUTES_FILE);
}
private volatile String profile;
private String name;
private File appBase;
private File appHome;
private Router router;
private CliDispatcher cliDispatcher;
private Map<NamedPort, Router> moreRouters;
private AppConfig config;
private AppClassLoader classLoader;
private ProjectLayout layout;
private AppBuilder builder;
private EventBus eventBus;
private AppCodeScannerManager scannerManager;
private DbServiceManager dbServiceManager;
private AppJobManager jobManager;
private CliServer cliServer;
private MailerConfigManager mailerConfigManager;
private StringValueResolverManager resolverManager;
private SingletonRegistry singletonRegistry;
private BinderManager binderManager;
private AppInterceptorManager interceptorManager;
private DependencyInjector<?> dependencyInjector;
private IStorageService uploadFileStorageService;
private AppServiceRegistry appServiceRegistry;
private Map<String, Daemon> daemonRegistry;
private AppCrypto crypto;
private IdGenerator idGenerator;
private CacheService cache;
// used in dev mode only
private CompilationException compilationException;
private AppEventId currentState;
private Set<AppEventId> eventEmitted;
private Thread mainThread;
protected App() {
INST = this;
}
protected App(File appBase, ProjectLayout layout) {
this("MyApp", appBase, layout);
}
protected App(String name, File appBase, ProjectLayout layout) {
this.name = name;
this.appBase = appBase;
this.layout = layout;
this.appHome = RuntimeDirs.home(this);
INST = this;
}
public static App instance() {
return INST;
}
App name(String name) {
this.name = name;
return this;
}
public String name() {
return name;
}
public String profile() {
if (null == profile) {
synchronized (this) {
if (null == profile) {
String s = SysProps.get(AppConfigKey.PROFILE.key());
if (null == s) {
s = Act.mode().name().toLowerCase();
}
profile = s;
}
}
}
return profile;
}
public AppConfig config() {
return config;
}
public CliDispatcher cliDispatcher() {
return cliDispatcher;
}
public Router router() {
return router;
}
public Router router(String name) {
if (S.blank(name)) {
return router();
}
for (Map.Entry<NamedPort, Router> entry : moreRouters.entrySet()) {
if (S.eq(entry.getKey().name(), name)) {
return entry.getValue();
}
}
return null;
}
public Router router(NamedPort port) {
if (null == port) {
return router();
}
return moreRouters.get(port);
}
public AppCrypto crypto() {
return crypto;
}
/**
* The base dir where an application sit within
*/
public File base() {
return appBase;
}
/**
* The home dir of an application, referenced only
* at runtime.
* <p><b>Note</b> when app is running in dev mode, {@code appHome}
* shall be {@code appBase/target}, while app is deployed to
* Act at other mode, {@code appHome} shall be the same as
* {@code appBase}</p>
*/
public File home() {
return appHome;
}
public AppClassLoader classLoader() {
return classLoader;
}
public ProjectLayout layout() {
return layout;
}
public synchronized void detectChanges() {
classLoader.detectChanges();
if (null != compilationException) {
throw ActServerError.of(compilationException);
}
}
public void restart() {
build();
refresh();
}
/**
* In dev mode it could request app to refresh. However if
* the request is issued in a thread that will be interrupted
* e.g. the cli thread, it should call refresh in an new thread
*/
public void asyncRefresh() {
new Thread() {
@Override
public void run() {
refresh();
}
}.start();
}
public boolean isStarted() {
return currentState == POST_START;
}
public boolean isMainThread() {
return Thread.currentThread() == mainThread;
}
public void shutdown() {
Act.shutdownApp(this);
}
@Override
protected void releaseResources() {
mainThread.interrupt();
logger.info("App shutting down ....");
for (Daemon d : daemonRegistry.values()) {
stopDaemon(d);
}
shutdownCliServer();
shutdownEventBus();
shutdownJobManager();
clearServiceResourceManager();
classLoader = null;
}
public synchronized void refresh() {
logger.info("App starting ....");
profile = null;
initServiceResourceManager();
mainThread = Thread.currentThread();
eventEmitted = C.newSet();
initSingletonRegistry();
initEventBus();
emit(EVENT_BUS_INITIALIZED);
loadConfig();
emit(CONFIG_LOADED);
Act.viewManager().reload(this);
initCache();
initDataPropertyRepository();
initCrypto();
initIdGenerator();
initJobManager();
initDaemonRegistry();
initInterceptorManager();
initResolverManager();
initBinderManager();
initUploadFileStorageService();
initRouters();
emit(ROUTER_INITIALIZED);
loadRoutes();
emit(ROUTER_LOADED);
initCliDispatcher();
initCliServer();
initDbServiceManager();
emit(DB_SVC_LOADED);
loadGlobalPlugin();
initScannerManager();
loadActScanners();
loadBuiltInScanners();
emit(PRE_LOAD_CLASSES);
initClassLoader();
emit(AppEventId.CLASS_LOADER_INITIALIZED);
preloadClasses();
try {
scanAppCodes();
compilationException = null;
} catch (CompilationException e) {
compilationException = e;
throw ActServerError.of(e);
}
//classLoader().loadClasses();
emit(APP_CODE_SCANNED);
emit(CLASS_LOADED);
initMailerConfigManager();
// setting context class loader here might lead to memory leaks
// and cause weird problems as class loader been set to thread
// could be switched to handling other app in ACT or still hold
// old app class loader instance after the app been refreshed
// - Thread.currentThread().setContextClassLoader(classLoader());
// let's any emit the dependency injector loaded event
// in case some other service depend on this event.
// If any DI plugin e.g. guice has emitted this event
// already, it doesn't matter we emit the event again
// because once app event is consumed the event listeners
// are cleared
emit(DEPENDENCY_INJECTOR_LOADED);
emit(DEPENDENCY_INJECTOR_PROVISIONED);
emit(SINGLETON_PROVISIONED);
emit(PRE_START);
emit(START);
daemonKeeper();
logger.info("App[%s] started", name());
emit(POST_START);
}
public AppBuilder builder() {
return builder;
}
void build() {
builder = AppBuilder.build(this);
}
void hook() {
Act.hook(this);
}
public File tmpDir() {
return new File(this.layout().target(appBase), "tmp");
}
public File file(String path) {
return new File(home(), path);
}
public File resource(String path) {
return new File(this.layout().resource(appBase), path);
}
public void registerDaemon(Daemon daemon) {
daemonRegistry.put(daemon.id(), daemon);
}
public void unregisterDaemon(Daemon daemon) {
daemonRegistry.remove(daemon.id());
}
List<Daemon> registeredDaemons() {
return C.list(daemonRegistry.values());
}
Daemon registeredDaemon(String id) {
return daemonRegistry.get(id);
}
public <T> void registerSingleton(Class<? extends T> cls, T instance) {
if (null != singletonRegistry) {
singletonRegistry.register(cls, instance);
}
}
public void registerSingletonClass(Class<?> aClass) {
singletonRegistry.register(aClass);
}
public void registerSingleton(Object instance) {
singletonRegistry.register(instance.getClass(), instance);
}
public AppInterceptorManager interceptorManager() {
return interceptorManager;
}
public AppCodeScannerManager scannerManager() {
return scannerManager;
}
public DbServiceManager dbServiceManager() {
return dbServiceManager;
}
public StringValueResolverManager resolverManager() {
return resolverManager;
}
public BinderManager binderManager() {
return binderManager;
}
public CacheService cache() {
return cache;
}
public MailerConfigManager mailerConfigManager() {
return mailerConfigManager;
}
public EventBus eventBus() {
return eventBus;
}
public AppJobManager jobManager() {
return jobManager;
}
public App injector(DependencyInjector<?> dependencyInjector) {
E.NPE(dependencyInjector);
E.illegalStateIf(null != this.dependencyInjector, "Dependency injection factory already set");
this.dependencyInjector = dependencyInjector;
return this;
}
public <T extends DependencyInjector<T>> T injector() {
return (T) dependencyInjector;
}
public IStorageService uploadFileStorageService() {
return uploadFileStorageService;
}
public String sign(String message) {
return crypto().sign(message);
}
public String encrypt(String message) {
return crypto().encrypt(message);
}
public String decrypt(String message) {
return crypto().decrypt(message);
}
public <T> T singleton(Class<T> clz) {
return singletonRegistry.get(clz);
}
/**
* Get/Create new instance of a class specified by the className
* <p/>
* **Note** if the class is a singleton class, then the singleton instance
* will be returned
*
* @param className the className of the instance to be returned
* @param <T> the generic type of the class
* @return the instance of the class
*/
public <T> T newInstance(String className) {
Class<T> c = $.classForName(className, classLoader());
return newInstance(c);
}
public <T> T newInstance(String className, ActContext context) {
Class<T> c = $.classForName(className, classLoader());
return newInstance(c, context);
}
public <T> T newInstance(Class<T> clz) {
T t = singleton(clz);
if (null != t) {
return t;
}
t = SimpleTypeInstanceFactory.newInstance(clz);
if (null != t) {
return t;
}
if (null != dependencyInjector) {
return dependencyInjector.create(clz);
} else {
return $.newInstance(clz);
}
}
<T> T newInstance(Class<T> clz, ActContext context) {
if (ActionContext.class == clz) {
return $.cast(context);
}
if (CliContext.class == clz) {
return $.cast(context);
}
if (MailerContext.class == clz) {
return $.cast(context);
}
return newInstance(clz);
}
@Override
public int hashCode() {
return appBase.hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof App) {
App that = (App) obj;
return $.eq(that.appBase, appBase);
}
return false;
}
@Override
public String toString() {
return S.builder("app@[").append(appBase).append("]").toString();
}
/**
* Return an ID in string that is unique across the cluster
*
* @return
*/
public String cuid() {
return idGenerator.genId();
}
public <T extends AppService<T>> T service(Class<T> serviceClass) {
return appServiceRegistry.lookup(serviceClass);
}
App register(final AppService service) {
return register(service, false);
}
App register(final AppService service, boolean noDiBinder) {
if (null == appServiceRegistry) {
return this; // for unit test only
}
appServiceRegistry.register(service);
if (null != eventBus && !noDiBinder) {
eventBus.bind(AppEventId.DEPENDENCY_INJECTOR_LOADED, new AppEventListenerBase() {
@Override
public void on(EventObject event) throws Exception {
final App app = App.this;
eventBus.emit(new DependencyInjectionBinder(app, service.getClass()) {
@Override
public Object resolve(App app) {
return app.service(service.getClass());
}
});
}
});
}
return this;
}
public void emit(AppEventId appEvent) {
currentState = appEvent;
eventEmitted().add(appEvent);
EventBus bus = eventBus();
if (null != bus) {
bus.emit(appEvent);
}
}
private Set<AppEventId> eventEmitted() {
return eventEmitted;
}
public boolean eventEmitted(AppEventId appEvent) {
return eventEmitted().contains(appEvent);
}
public AppEventId currentState() {
return currentState;
}
private void loadConfig() {
JsonUtilConfig.configure(this);
File conf = RuntimeDirs.conf(this);
logger.debug("loading app configuration: %s ...", appBase.getAbsolutePath());
config = new AppConfLoader().load(conf);
config.app(this);
registerSingleton(AppConfig.class, config);
registerValueObjectCodec();
}
// TODO: move this to somewhere that is more appropriate
private void registerValueObjectCodec() {
ValueObject.register(new JodaDateTimeCodec(config));
}
private void initIdGenerator() {
idGenerator = new IdGenerator(
config().nodeIdProvider(),
config().startIdProvider(),
config().sequenceProvider(),
config().longEncoder()
);
}
private void initDaemonRegistry() {
if (null != daemonRegistry) {
Destroyable.Util.tryDestroyAll(daemonRegistry.values());
}
daemonRegistry = C.newMap();
jobManager.on(AppEventId.START, new Runnable() {
@Override
public void run() {
jobManager.fixedDelay("daemon-keeper", new Runnable() {
@Override
public void run() {
daemonKeeper();
}
}, "1mn");
}
});
}
private void daemonKeeper() {
final String KEY_COUNTER = "c";
final String KEY_SEQ_NO = "sn";
final String KEY_LAST_SEQ_NO = "lsn";
for (final Daemon d : daemonRegistry.values()) {
Daemon.State state = d.state();
if (state == Daemon.State.STARTED) {
// daemon running successfully, clear the error recovery state
if (d.getAttribute(KEY_COUNTER) != null) {
d.removeAttribute(KEY_COUNTER);
d.removeAttribute(KEY_SEQ_NO);
d.removeAttribute(KEY_LAST_SEQ_NO);
}
} else if (state == Daemon.State.STOPPED) {
startDaemon(d);
} else if (state == Daemon.State.ERROR) {
// try to recover daemon, the recovery duration shall
// follow a fibonacci sequence
Integer counter = d.getAttribute(KEY_COUNTER);
Integer seqNo, lastSeqNo;
if (null == counter) {
counter = 1;
seqNo = 1;
lastSeqNo = 0;
} else {
seqNo = d.getAttribute(KEY_SEQ_NO);
lastSeqNo = d.getAttribute(KEY_LAST_SEQ_NO);
}
if (--counter == 0) {
startDaemon(d);
int nextSeqNo = seqNo + lastSeqNo;
lastSeqNo = seqNo;
seqNo = nextSeqNo;
counter = seqNo;
d.setAttribute(KEY_SEQ_NO, seqNo);
d.setAttribute(KEY_LAST_SEQ_NO, lastSeqNo);
}
d.setAttribute(KEY_COUNTER, counter);
}
}
}
private void startDaemon(final Daemon daemon) {
jobManager().now(new Runnable() {
@Override
public void run() {
try {
daemon.start();
} catch (Exception e) {
logger.error(e, "Error starting daemon [%s]", daemon.id());
}
}
});
}
private void stopDaemon(final Daemon daemon) {
daemon.stop();
}
private void initServiceResourceManager() {
clearServiceResourceManager();
appServiceRegistry = new AppServiceRegistry(this);
}
private void clearServiceResourceManager() {
if (null != appServiceRegistry) {
eventBus().emit(STOP);
appServiceRegistry.destroy();
dependencyInjector = null;
if (null != cache) {
cache.shutdown();
}
}
}
private void initUploadFileStorageService() {
uploadFileStorageService = UploadFileStorageService.create(this);
}
private void initCliDispatcher() {
cliDispatcher = new CliDispatcher(this);
}
private void initCliServer() {
try {
cliServer = new CliServer(this);
} catch (Exception e) {
logger.error(e, "Error initializing CLI server");
}
}
private void shutdownCliServer() {
if (null != cliServer) {
cliServer.destroy();
}
}
private void initRouters() {
router = new Router(this);
moreRouters = C.newMap();
List<NamedPort> ports = config().namedPorts();
for (NamedPort port : ports) {
moreRouters.put(port, new Router(this, port.name()));
}
}
private void initEventBus() {
eventBus = new EventBus(this);
}
public void shutdownEventBus() {
if (null != eventBus) {
eventBus.destroy();
}
}
private void initCache() {
cache = CacheServiceProvider.Impl.Simple.get("_act_app_");
cache.startup();
HttpConfig.setCacheServiceProvider(new CacheServiceProvider() {
@Override
public CacheService get() {
return cache;
}
@Override
public CacheService get(String name) {
return CacheServiceProvider.Impl.Simple.get(name);
}
});
}
private void initCrypto() {
crypto = new AppCrypto(config());
registerSingleton(AppCrypto.class, crypto);
}
private void initJobManager() {
jobManager = new AppJobManager(this);
}
private void shutdownJobManager() {
if (null != jobManager) {
jobManager.destroy();
}
}
private void initInterceptorManager() {
interceptorManager = new AppInterceptorManager(this);
}
private void initScannerManager() {
scannerManager = new AppCodeScannerManager(this);
}
private void initDbServiceManager() {
dbServiceManager = new DbServiceManager(this);
}
private void initDataPropertyRepository() {
new DataPropertyRepository(this);
}
private void initMailerConfigManager() {
mailerConfigManager = new MailerConfigManager(this);
}
private void loadGlobalPlugin() {
Act.appServicePluginManager().applyTo(this);
}
private void loadActScanners() {
Act.scannerPluginManager().initApp(this);
}
private void loadBuiltInScanners() {
scannerManager.register(new ClassInfoByteCodeScanner());
scannerManager.register(new ControllerByteCodeScanner());
scannerManager.register(new MailerByteCodeScanner());
scannerManager.register(new JobByteCodeScanner());
scannerManager.register(new SimpleEventListenerByteCodeScanner());
scannerManager.register(new CommanderByteCodeScanner());
}
private void loadRoutes() {
loadBuiltInRoutes();
logger.debug("loading app routing table: %s ...", appBase.getPath());
File routes = RuntimeDirs.routes(this);
if (!(routes.isFile() && routes.canRead())) {
logger.warn("Cannot find routeTable file: %s", appBase.getPath());
// guess the app is purely using annotation based routes
return;
}
List<String> lines = IO.readLines(routes);
new RouteTableRouterBuilder(lines).build(router);
}
private void loadBuiltInRoutes() {
router().addMapping(H.Method.GET, "/asset/", new StaticFileGetter(layout().asset(base())), RouteSource.BUILD_IN);
router().addMapping(H.Method.GET, "/~upload/{path}", new UploadFileStorageService.UploadFileGetter(), RouteSource.BUILD_IN);
}
private void initClassLoader() {
classLoader = Act.mode().classLoader(this);
}
private void preloadClasses() {
classLoader.preload();
}
private void initResolverManager() {
resolverManager = new StringValueResolverManager(this);
Osgl.propertyHandlerFactory = new ActPropertyHandlerFactory(this);
}
private void initBinderManager() {
binderManager = new BinderManager(this);
}
private void initSingletonRegistry() {
singletonRegistry = new SingletonRegistry(this);
singletonRegistry.register(App.class, this);
appServiceRegistry.bulkRegisterSingleton();
}
private void loadPlugins() {
// TODO: load app level plugins
}
private void scanAppCodes() {
classLoader().scan();
//classLoader().scan();
}
static App create(File appBase, ProjectLayout layout) {
return new App(appBase, layout);
}
}