开源b3log代码赏析
来源:互联网 发布:网络招生哪家强 编辑:程序博客网 时间:2024/04/30 09:57
package org.b3log.latke;public class testEVN {/** * @param args */public static void main(String[] args) {// TODO Auto-generated method stubLatkes.initRuntimeEnv();System.out.println(Latkes.getRuntimeEnv());}}
输出:
七月 15, 2013 7:55:52 上午 org.b3log.latke.Latkes initRuntimeEnv
INFO: Latke is running on [LOCAL] with mode [DEVELOPMENT]
七月 15, 2013 7:55:53 上午 org.b3log.latke.Latkes initRuntimeEnv
INFO: Runtime database is [MYSQL]
LOCAL
latke.properties:
# Configures the followings before deployserverScheme=httpserverHost=localhostserverPort=8080staticServerScheme=httpstaticServerHost=localhoststaticServerPort=8080# Note: The context path and static path should be "" if deploy app on ROOT. For other cases, starts with '/'# and not ends with '/', for example, /blog contextPath=staticPath=#### Runtime Environment ####runtimeEnv=LOCAL#### Runtime Mode ####runtimeMode=DEVELOPMENT#runtimeMode=PRODUCTION#### Cache Implementation ##### Note: If the runtime environment is LOCAL, the cache will be 'LOCAL' alwayscache=LOCAL#### User Service Implementation ####userService=LOCAL#### Cache ####cache.maxPageCnt=128cache.maxDataCnt=128#### Static resource version ####staticResourceVersion=201211021410
public final class Latkes { /** * Latke configurations (latke.properties). */ private static final Properties LATKE_PROPS = new Properties();try { final InputStream resourceAsStream = Latkes.class.getResourceAsStream("/local.properties");public static void initRuntimeEnv() { LOGGER.log(Level.FINEST, "Initializes runtime environment from configuration file"); final String runtimeEnvValue = LATKE_PROPS.getProperty("runtimeEnv"); if (null != runtimeEnvValue) { runtimeEnv = RuntimeEnv.valueOf(runtimeEnvValue); } if (null == runtimeEnv) { LOGGER.log(Level.FINEST, "Initializes runtime environment by class loading"); try { runtimeEnv = RuntimeEnv.GAE; Class.forName("org.b3log.latke.repository.gae.GAERepository"); } catch (final ClassNotFoundException e) { runtimeEnv = RuntimeEnv.LOCAL; } } final String runtimeModeValue = LATKE_PROPS.getProperty("runtimeMode"); if (null != runtimeModeValue) { runtimeMode = RuntimeMode.valueOf(runtimeModeValue); } else { LOGGER.log(Level.FINEST, "Can't parse runtime mode in latke.properties, default to [DEVELOPMENT]"); runtimeMode = RuntimeMode.DEVELOPMENT; } LOGGER.log(Level.INFO, "Latke is running on [{0}] with mode [{1}]", new Object[] {Latkes.getRuntimeEnv(), Latkes.getRuntimeMode()}); if (RuntimeEnv.LOCAL == runtimeEnv) { // Read local database configurations final RuntimeDatabase runtimeDatabase = getRuntimeDatabase(); LOGGER.log(Level.INFO, "Runtime database is [{0}]", runtimeDatabase); if (RuntimeDatabase.H2 == runtimeDatabase) { final String newTCPServer = Latkes.getLocalProperty("newTCPServer"); if ("true".equals(newTCPServer)) { LOGGER.log(Level.INFO, "Starting H2 TCP server"); final String jdbcURL = Latkes.getLocalProperty("jdbc.URL"); if (Strings.isEmptyOrNull(jdbcURL)) { throw new IllegalStateException("The jdbc.URL in local.properties is required"); } final String[] parts = jdbcURL.split(":"); if (parts.length != Integer.valueOf("5")/* CheckStyle.... */) { throw new IllegalStateException("jdbc.URL should like [jdbc:h2:tcp://localhost:8250/~/] (the port part is required)"); } String port = parts[parts.length - 1]; port = StringUtils.substringBefore(port, "/"); LOGGER.log(Level.FINEST, "H2 TCP port [{0}]", port); try { h2 = Server.createTcpServer(new String[] {"-tcpPort", port, "-tcpAllowOthers"}).start(); } catch (final SQLException e) { final String msg = "H2 TCP server create failed"; LOGGER.log(Level.SEVERE, msg, e); throw new IllegalStateException(msg); } LOGGER.info("Started H2 TCP server"); } } } locale = new Locale("en_US"); }源代码:http://pan.baidu.com/share/link?shareid=1644033861&uk=3878681452
- 开源b3log代码赏析
- 开源b3log代码赏析
- 开源b3log源码赏析
- 序列化-b3log代码赏析
- b3log StaticResources赏析
- B3log 开源
- Preconditions JUnit代码赏析
- AsyncTask 代码赏析
- 优秀代码赏析:CircleImageView
- 简单代码数据赏析
- 开源b3log创建MySQL表
- CRT字符串函数代码赏析
- MTK优美代码赏析3
- 学生管理系统代码赏析
- 开源b3log与本地MySQL的连接
- 开源CMS赏析
- 赏析
- 赏析
- POJ 1050 To the Max
- 浅谈基数排序
- 微积分基础知识
- 可变参数与参数进栈顺序
- 实现服务器与数据库的连接
- 开源b3log代码赏析
- windows下emacs中c++编程简单实例
- 继承和对象自然增长
- 客户端访问服务器的一个例子
- 成员函数和this指针
- 2013 蓝桥杯 全国软件大赛 c/c++ B组 决赛 第 五题
- Apache与tomcat的使用
- 多态和虚函数
- 内核并发处理