Package org.eweb4j.config.bean

Examples of org.eweb4j.config.bean.ConfigBean


  public synchronized static void writeProp(String propId, String key,
      Object value) throws IOException {
    if (propId == null)
      return;

    ConfigBean cb = (ConfigBean) SingleBeanCache.get(ConfigBean.class);
    List<Prop> files = cb.getProperties().getFile();
    for (Prop f : files) {
      if (propId.equals(f.getId())) {

        Hashtable<String, String> map = props.get(propId);
        if (map == null) {
View Full Code Here


import org.eweb4j.util.xml.XMLWriter;

public class DAOConfig {
  public synchronized static String check() {
    String error = null;
    ConfigBean cb = (ConfigBean) SingleBeanCache
        .get(ConfigConstant.CONFIGBEAN_ID);
    if (cb == null)
      return null;

    DBInfoXmlFiles dbInfoXmlFiles = cb.getOrm().getDbInfoXmlFiles();
    if (dbInfoXmlFiles == null)
      return ConfigInfoCons.CANNOT_READ_CONFIG_FILE;

    for (String filePath : dbInfoXmlFiles.getPath()) {
      if (filePath == null || filePath.length() == 0)
View Full Code Here

public class DataSourceCreator {

  public static DataSource create(DBInfoConfigBean dbInfo)
      throws Exception {

    ConfigBean cb = (ConfigBean) SingleBeanCache
        .get(ConfigConstant.CONFIGBEAN_ID);
    Class<?> cls = Class.forName(cb.getOrm().getDataSource());
    DataSource ds = (DataSource) cls.newInstance();

    List<Property> properties = dbInfo.getProperty();

    // 通过反射将配置信息注入到数据源对象中
View Full Code Here

*
*/
public class ORMConfig {
  public synchronized static String check() {
    String error = null;
    ConfigBean cb = (ConfigBean) SingleBeanCache
        .get(ConfigConstant.CONFIGBEAN_ID);
    if (cb == null)
      return null;

    List<String> ormXmlFilePaths = cb.getOrm().getOrmXmlFiles().getPath();
    for (String filePath : ormXmlFilePaths) {
      if (filePath == null || filePath.length() == 0)
        continue;

      File configFile = new File("orm" + filePath);
View Full Code Here

public class EWebConfigInit {

  public static void main(String[] args) {

    ConfigBean cb = ConfigBeanCreator.getConfigBean();

    // 设置是否每次启动框架都重新读取配置文件
    cb.setReload("false");

    // --------设置properties配置文件----------------------------
    Prop prop = new Prop();
    // 是否全局
    prop.setGlobal("false");
    // 文件ID
    prop.setId("DemoConstant");
    // 文件保存路径,相对路径,相对于${ConfigBasePath}
    prop.setPath("demo-constant.properties");
    cb.getProperties().getFile().add(prop);
    // -----------------------------------------------------------

    // --------IOC相关的配置---------------------------------------
    cb.getIoc().setOpen("true");
    // 是否开启调试功能,目前调试仅是控制台输出日志信息
    cb.getIoc().setDebug("true");
    // 日志文件保存路径,相对于${ConfigBasePath}
    cb.getIoc().setLogFile("ioc.log");
    // 日志文件最大大小,单位MB
    cb.getIoc().setLogMaxSize("5");
    // 添加一个hello-ioc.xml
    cb.getIoc().getIocXmlFiles().getPath().add("hello-ioc.xml");
    // ------------------------------------------------------------

    // -----------ORM相关的配置-------------------------------------
    // ORM开关,开启了之后,框架在启动的时候会尝试去连接数据库
    cb.getOrm().setOpen("true");
    cb.getOrm().setDebug("true");
    cb.getOrm().setLogFile("orm.log");
    cb.getOrm().setLogMaxSize("5");
    // 设置数据源
    cb.getOrm().setDataSource("com.mchange.v2.c3p0.ComboPooledDataSource");
    // 设置扫描的包名,框架会扫描该包及其子包中所有的类,发现实体类后会加载配置信息,可以填写 "." 表示当前类路径
    cb.getOrm().getScanPojoPackage().getPath().add("org.eweb4j");
    // 设置数据库连接信息配置的文件
    cb.getOrm().getDbInfoXmlFiles().getPath().add("mysql.xml");
    // ------------------------------------------------------

    // ----------MVC相关的配置--------------------------------
    // MVC开关,开启之后,要在WEB-INF/web.xml中配置EWebFilter或EWebServlet才能使用MVC的所有功能
    cb.getMvc().setOpen("true");
    cb.getMvc().setDebug("true");
    cb.getMvc().setLogFile("mvc.log");
    cb.getMvc().setLogMaxSize("5");
    // 设置Action的配置文件,跟Struts类似
    cb.getMvc().getScanActionPackage().getPath()
        .add("hello-world-action.xml");
    // 设置Action的拦截器配置文件
    cb.getMvc().getInterXmlFiles().getPath().add("interceptor.xml");
    // ------------------------------------------------------

    // 默认的start.xml文件名:eweb4j-start-config.xml
    String path = ConfigConstant.START_FILE_PATH();
    // 生成 start.xml
View Full Code Here

   * @param ioc
   * @return
   */
  public static String checkIOC(IOCConfigBean ioc, String xmlFile) {
    String error = null;
    ConfigBean cb = (ConfigBean) SingleBeanCache.get(ConfigBean.class);
    if ("true".equalsIgnoreCase(cb.getIoc().getOpen())
        || "1".equals(cb.getIoc().getOpen())) {
      StringBuilder sb = new StringBuilder();
      if (ioc.getScope() == null)
        ioc.setScope("");
      if (!"prototype".equalsIgnoreCase(ioc.getScope())
          && !"singleton".equalsIgnoreCase(ioc.getScope())
View Full Code Here

  }

  public static String checkMVCInterceptor(InterConfigBean inter,
      String xmlFile) {
    String error = null;
    ConfigBean cb = (ConfigBean) SingleBeanCache.get(ConfigBean.class);
    if ("true".equalsIgnoreCase(cb.getMvc().getOpen())
        || "1".equals(cb.getMvc().getOpen())) {
      StringBuilder sb = new StringBuilder();
      if (!"".equals(inter.getClazz())) {
        try {
          if (Class.forName(inter.getClazz()) == null) {
            sb.append("当前您填写的( class=").append(inter.getClazz())
View Full Code Here

   * @return
   */
  public static String checkIOCJnject(List<Injection> inject,
      List<IOCConfigBean> iocList, String beanID, String xmlFile) {
    String error = null;
    ConfigBean cb = (ConfigBean) SingleBeanCache.get(ConfigBean.class);
    if ("true".equalsIgnoreCase(cb.getIoc().getOpen())
        || "1".equals(cb.getIoc().getOpen())) {
      StringBuilder sb = new StringBuilder();
      for (Injection inj : inject) {
        if (inj.getRef() != null && !"".equals(inj.getRef())) {
          boolean flag = false;
          for (IOCConfigBean iocBean : iocList) {
View Full Code Here

   * @param dcb
   * @return
   */
  public static String checkORMDBInfo(DBInfoConfigBean dcb, String filePath) {
    String error = null;
    ConfigBean cb = (ConfigBean) SingleBeanCache.get(ConfigBean.class);
    if ("true".equals(cb.getOrm().getOpen())
        || "1".equals(cb.getOrm().getOpen())) {
      StringBuilder sb = new StringBuilder();
      if (!DBType.MYSQL_DB.equalsIgnoreCase(dcb.getDataBaseType())
          && !DBType.MSSQL2000_DB.equalsIgnoreCase(dcb
              .getDataBaseType())
          && !DBType.MSSQL2005_DB.equalsIgnoreCase(dcb
View Full Code Here

   * @param orm
   * @return
   */
  public static String checkORM(ORMConfigBean orm, String xmlFile) {
    String error = null;
    ConfigBean cb = (ConfigBean) SingleBeanCache.get(ConfigBean.class);
    if ("true".equalsIgnoreCase(cb.getOrm().getOpen())
        || "1".equals(cb.getOrm().getOpen())) {
      StringBuilder sb = new StringBuilder();
      if (!"".equals(orm.getClazz())) {
        try {
          if (Class.forName(orm.getClazz()) == null) {
            sb.append("当前您填写的( class=").append(orm.getClazz())
View Full Code Here

TOP

Related Classes of org.eweb4j.config.bean.ConfigBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.