osgl.version.Version Java Examples

The following examples show how to use osgl.version.Version. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: App.java    From actframework with Apache License 2.0 6 votes vote down vote up
private App() {
    this.version = Version.get();
    this.appBase = new File(".");
    this.layout = ProjectLayout.PredefinedLayout.MAVEN;
    this.appHome = RuntimeDirs.home(this);
    this.config = new AppConfig<>().app(this);
    INST = this;
    Lang.setFieldValue("metricPlugin", Act.class, new SimpleMetricPlugin());
    this.eventEmitted = new HashSet<>();
    this.eventBus = new EventBus(this);
    this.jobManager = new JobManager(this);
    this.classLoader = new AppClassLoader(this);
    this.sessionManager = new SessionManager(this.config, config().cacheService("logout-session"));
    this.dependencyInjector = new GenieInjector(this);
    this.singletonRegistry = new SingletonRegistry(this);
    this.singletonRegistry.register(SingletonRegistry.class, this.singletonRegistry);
    this.singletonRegistry.register(SessionManager.class, this.sessionManager);
    this.singletonRegistry.register(CookieSessionMapper.class, new CookieSessionMapper(this.config));
    this.idGenerator = new IdGenerator();
}
 
Example #2
Source File: AppDescriptor.java    From actframework with Apache License 2.0 5 votes vote down vote up
/**
 * Construct an `AppVersion` with name and version
 *
 * @param appName
 *      the app name
 * @param version
 *      the app version
 */
private AppDescriptor(String appName, String packageName, Version version) {
    if (appName.startsWith("${")) {
        LOGGER.warn("app name is substitute variable - fallback to default app name");
        appName = S.afterLast(packageName, ".");
    }
    this.appName = appName;
    this.packageName = packageName;
    this.version = version;
}
 
Example #3
Source File: AppConfig.java    From actframework with Apache License 2.0 5 votes vote down vote up
private static String appServerHeader() {
    App app = Act.app();
    if (null == app) {
        return "app/1.0";
    }
    String shortId = app.shortId();
    if (null == shortId) {
        shortId = "app";
    }
    Version version = app.version();
    return shortId + "/" + (null == version ? "1.0" : version.getProjectVersion());
}
 
Example #4
Source File: AppDescriptor.java    From actframework with Apache License 2.0 5 votes vote down vote up
private static String ensureAppName(String appName, String packageName, Version version) {
    if (S.blank(appName)) {
        if (!version.isUnknown()) {
            appName = version.getArtifactId();
        }
        if (S.blank(appName)) {
            appName = AppNameInferer.fromPackageName(packageName);
        }
    }
    return appName;
}
 
Example #5
Source File: AppDescriptor.java    From actframework with Apache License 2.0 5 votes vote down vote up
private static String ensureAppName(String appName, Class<?> entryClass, Version version) {
    if (S.blank(appName)) {
        if (!version.isUnknown()) {
            appName = version.getArtifactId();
        }
        if (S.blank(appName)) {
            appName = AppNameInferer.from(entryClass);
        }
    }
    return appName;
}
 
Example #6
Source File: App.java    From actframework with Apache License 2.0 5 votes vote down vote up
protected App(String name, Version version, File appBase, ProjectLayout layout) {
    this.name(name);
    this.version = version;
    this.appBase = appBase;
    this.layout = layout;
    this.appHome = RuntimeDirs.home(this);
    INST = this;
}
 
Example #7
Source File: App.java    From actframework with Apache License 2.0 4 votes vote down vote up
static App create(File appBase, Version version, ProjectLayout layout) {
    return new App(appBase, version, layout);
}
 
Example #8
Source File: App.java    From actframework with Apache License 2.0 4 votes vote down vote up
protected App(File appBase, Version version, ProjectLayout layout) {
    this("MyApp", version, appBase, layout);
}
 
Example #9
Source File: AppDescriptor.java    From actframework with Apache License 2.0 3 votes vote down vote up
/**
 * Create an `AppDescriptor` with appName, package name and app version.
 *
 * If `appName` is `null` or blank, it will try the following
 * approach to get app name:
 *
 * 1. check the {@link Version#getArtifactId() artifact id} and use it unless
 * 2. if artifact id is null or empty, then infer app name using {@link AppNameInferer}
 *
 * @param appName
 *      the app name, optional
 * @param packageName
 *      the package name
 * @param appVersion
 *      the app version
 * @return
 *      an `AppDescriptor`
 */
public static AppDescriptor of(String appName, String packageName, Version appVersion) {
    String[] packages = packageName.split(S.COMMON_SEP);
    String effectPackageName = packageName;
    if (packages.length > 0) {
        effectPackageName = packages[0];
    }
    E.illegalArgumentIf(!JavaNames.isPackageOrClassName(effectPackageName),
            "valid package name expected. found: " + effectPackageName);
    return new AppDescriptor(ensureAppName(appName, effectPackageName, $.requireNotNull(appVersion)),
            packageName,
            appVersion);
}
 
Example #10
Source File: Act.java    From actframework with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the app version
 *
 * @return
 *      the app version
 */
public static Version appVersion() {
    return app().version();
}
 
Example #11
Source File: Act.java    From actframework with Apache License 2.0 2 votes vote down vote up
/**
 * Start Act application with specified app name, app version and
 * scan page via an app class
 *
 * @param appName
 *      the app name
 * @param anyAppClass
 *      specifies the scan package
 * @param appVersion
 *      the app version tag
 * @throws Exception
 *      any exception raised during act start up
 */
public static void start(String appName, Class<?> anyAppClass, Version appVersion) throws Exception {
    bootstrap(AppDescriptor.of(appName, anyAppClass, appVersion));
}
 
Example #12
Source File: Act.java    From actframework with Apache License 2.0 2 votes vote down vote up
/**
 * Start Act application with specified app name, app version and scan package
 *
 * @param appName
 *      the app name
 * @param scanPackage
 *      the scan package, the package could be separated by {@link Constants#LIST_SEPARATOR}
 * @param appVersion
 *      the app version tag
 * @throws Exception any exception raised during act start up
 */
public static void start(String appName, String scanPackage, Version appVersion) throws Exception {
    bootstrap(AppDescriptor.of(appName, scanPackage, appVersion));
}
 
Example #13
Source File: AppDescriptor.java    From actframework with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the app version
 * @return
 *      the app version
 */
public Version getVersion() {
    return version;
}
 
Example #14
Source File: AppDescriptor.java    From actframework with Apache License 2.0 2 votes vote down vote up
/**
 * Create an `AppDescriptor` with appName, entry class and app version.
 *
 * If `appName` is `null` or blank, it will try the following
 * approach to get app name:
 *
 * 1. check the {@link Version#getArtifactId() artifact id} and use it unless
 * 2. if artifact id is null or empty, then infer app name using {@link AppNameInferer}
 *
 * @param appName
 *      the app name, optional
 * @param entryClass
 *      the entry class
 * @param appVersion
 *      the app version
 * @return
 *      an `AppDescriptor`
 */
public static AppDescriptor of(String appName, Class<?> entryClass, Version appVersion) {
    return new AppDescriptor(ensureAppName(appName, entryClass, $.requireNotNull(appVersion)),
            JavaNames.packageNameOf(entryClass),
            appVersion);
}
 
Example #15
Source File: AppDescriptor.java    From actframework with Apache License 2.0 2 votes vote down vote up
/**
 * Create an `AppDescriptor` with appName and entry class specified.
 *
 * If `appName` is `null` or blank, it will try the following
 * approach to get app name:
 *
 * 1. check the {@link Version#getArtifactId() artifact id} and use it unless
 * 2. if artifact id is null or empty, then infer app name using {@link AppNameInferer}
 *
 * @param appName
 *      the app name
 * @param entryClass
 *      the entry class
 * @return
 *      an `AppDescriptor` instance
 */
public static AppDescriptor of(String appName, Class<?> entryClass) {
    System.setProperty("osgl.version.suppress-var-found-warning", "true");
    return of(appName, entryClass, Version.of(entryClass));
}
 
Example #16
Source File: AppDescriptor.java    From actframework with Apache License 2.0 2 votes vote down vote up
/**
 * Create an `AppDescriptor` with appName and package name specified
 *
 * If `appName` is `null` or blank, it will try the following
 * approach to get app name:
 *
 * 1. check the {@link Version#getArtifactId() artifact id} and use it unless
 * 2. if artifact id is null or empty, then infer app name using {@link AppNameInferer}
 *
 * @param appName
 *      the app name
 * @param packageName
 *      the package name of the app
 * @return
 *      an `AppDescriptor` instance
 */
public static AppDescriptor of(String appName, String packageName) {
    String[] packages = packageName.split(S.COMMON_SEP);
    return of(appName, packageName, Version.ofPackage(packages[0]));
}
 
Example #17
Source File: App.java    From actframework with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the app version
 *
 * @return the app version
 */
public Version version() {
    return version;
}