public class App extends LogSupportedDestroyableBase
App
represents an application that is deployed in a Act container
Modifier and Type | Class and Description |
---|---|
static class |
App.F |
static interface |
App.HotReloadListener |
Destroyable.Util
DASHED_LINE, DOUBLE_DASHED_LINE, HASH_SYMBOL_LINE, logger, STAR_LINE, TILD_LINE
Modifier | Constructor and Description |
---|---|
protected |
App(File appBase,
osgl.version.Version version,
ProjectLayout layout) |
protected |
App(String name,
osgl.version.Version version,
File appBase,
ProjectLayout layout) |
addSubResource, destroy, isDestroyed, reload, scope
debug, debug, error, error, fatal, fatal, info, info, isDebugEnabled, isTraceEnabled, logger, printCenter, printCenterWithLead, printDashedLine, printDoubleDashedLine, printHashSimbolLine, println, printStarLine, printTildLine, trace, trace, warn, warn
protected App(File appBase, osgl.version.Version version, ProjectLayout layout)
protected App(String name, osgl.version.Version version, File appBase, ProjectLayout layout)
public static App instance()
public String name()
Returns the name of the app
public osgl.version.Version version()
Returns the app version
public String shortId()
Returns short id which is derived from passed in app name.
Note App.shortId()
is by no means to create a unique identifier of application.
public String profile()
public Act.Mode mode()
public boolean isDev()
public boolean isProd()
public AppConfig<?> config()
public CliDispatcher cliDispatcher()
public CliServer cliServer()
public CaptchaManager captchaManager()
public Router router()
public Router sysRouter()
public Router cliOverHttpRouter()
public Router adminRouter()
public AppCrypto crypto()
public File base()
The base dir where an application sit within
public File home()
The home dir of an application, referenced only at runtime.
Note when app is running in dev mode, appHome
shall be appBase/target
, while app is deployed to Act at other mode, appHome
shall be the same as appBase
public AppClassLoader classLoader()
public ProjectLayout layout()
public void registerHotReloadListener(App.HotReloadListener listener)
public boolean checkUpdates(boolean async)
Check if app needs updates.
async
- refresh app async or synctrue
if there are updates and app require hot reloadpublic boolean checkUpdatesNonBlock(boolean async)
public void detectChanges()
public void restart()
public void handleBlockIssue(Throwable e)
public void asyncRefresh()
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 boolean isStarted()
public boolean wasStarted()
Check if the app has been started before. This could be useful to fix some state issue that caused by hotreload in dev mode
public boolean isLoading()
public boolean isMainThread()
public void shutdown()
public void shutdown(int exitCode)
protected void releaseResources()
releaseResources
in class LogSupportedDestroyableBase
public void refresh(boolean async)
public RequestHandler blockIssueHandler()
public void refresh()
public boolean hasBlockIssue()
Check if the app has block issue set
true
if the app has block issue encountered during start uppublic act.app.AppBuilder builder()
public <T extends ClassMetaInfoBase<T>> ClassMetaInfoManager<T> classMetaInfoManager(Class<T> metaInfoType)
public void register(ClassMetaInfoManager<?> classMetaInfoManager)
public boolean isSingleton(Class<?> cls)
Report if a class is registered into singleton registry
cls
- the classtrue
if the class is registered into singleton registrypublic boolean isSingleton(Object o)
public File tmpDir()
public SampleDataProviderManager sampleDataProviderManager()
public void registerDaemon(Daemon daemon)
public void unregisterDaemon(Daemon daemon)
public <T> void registerSingleton(Class<? extends T> cls, T instance)
public void registerSingletonClass(Class<?> aClass)
public void registerSingleton(Object instance)
public AppInterceptorManager interceptorManager()
public SessionManager sessionManager()
public AppCodeScannerManager scannerManager()
public DbServiceManager dbServiceManager()
public StringValueResolverManager resolverManager()
public BinderManager binderManager()
public org.osgl.cache.CacheService cache()
public org.osgl.cache.CacheService cache(String name)
public MailerConfigManager mailerConfigManager()
public EventBus eventBus()
public HttpClientService httpClientService()
public MasterEntityMetaInfoRepo entityMetaInfoRepo()
public JobManager jobManager()
public MetricMetaInfoRepo metricMetaInfoRepo()
@Deprecated public <DI extends DependencyInjector> App injector(DI dependencyInjector)
public <DI extends DependencyInjector> DI injector()
public SingletonRegistry singletonRegistry()
public UploadFileStorageService uploadFileStorageService()
public PrincipalProvider principalProvider()
public void registerPrincipalProvider(PrincipalProvider principalProvider)
public <T> T singleton(Class<T> clz)
public <T> T getInstance(String className)
Get/Create new instance of a class specified by the className
This method will call the build in DependencyInjector
to load the instance. And this is dependency inject process, not a simple constructor call
Note the class will be loaded by the app’s classLoader()
T
- the generic type of the classclassName
- the className of the instance to be returnedpublic <T> T getInstance(Class<T> clz)
Get/Create new instance of a class
This method will call the build in DependencyInjector
to load the instance. And this is dependency inject process, not a simple constructor call
T
- the generic type of the classclz
- the classpublic URL getResource(String name)
Finds the resource with the given name.
This call delegate to ClassLoader.getResource(String)
on App classloader
.
name
- the resource nameURL
to the resource if found or null
if not found.public InputStream getResourceAsStream(String name)
Returns an input stream for reading the specified resource.
This will call ClassLoader.getResourceAsStream(String)
on classLoader()
.
name
- the resource namenull
if resource not foundpublic <K,V> Map<K,V> createMap()
public <K,V> ConcurrentMap<K,V> createConcurrentMap()
public <E> Set<E> createSet()
public <T> Class<T> classForName(String className)
Load/get a class by name using the app’s classLoader()
className
- the name of the class to be loadedpublic String cuid()
Return an ID in string that is unique across the cluster
public <T extends AppService<T>> T service(Class<T> serviceClass)
public void emit(SysEventId sysEvent)
public boolean eventEmitted(SysEventId sysEvent)
public SysEventId currentState()
public boolean hasMoreRouters()
public void shutdownEventBus()
public static App testInstance()
Copyright © 2014–2021 ActFramework. All rights reserved.