⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 httpserverparamfactory.java

📁 功能完善的java开发框架
💻 JAVA
字号:
/*
 * Copyright 2003-2005 the original author or authors.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */
package com.jdon.remoteClient;

import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;

import com.jdon.bussinessproxy.remote.http.HttpServerParam;
import com.jdon.util.FileLocator;

/**
 * @author <a href="mailto:banqiao@jdon.com">banq</a>
 *
 */
public class HttpServerParamFactory {

 
    private String configFile = "config.properities";
    
    public HttpServerParamFactory(){
        
    }

    public HttpServerParamFactory(String configFile){
        this.configFile = configFile;
    }

    
    public  HttpServerParam getHttpServerParam() {
        HttpServerParam httpServerParam = getHttpServerParamFromFile();
        if (httpServerParam == null){
            System.out.println(" enter  code HttpServerParam");
            httpServerParam = new HttpServerParam(); 
            httpServerParam.setHost("localhost");
            httpServerParam.setPort(8080);
            httpServerParam.setServletPath("/AuthTest/auth/EJBInvokerServlet");
            httpServerParam.setDebug(false);
        }
        return httpServerParam;

    }
    
    private  HttpServerParam getHttpServerParamFromFile() {
        System.out.println(" enter getHttpServerParam");
        HttpServerParam httpServerParam = null;
        InputStream fin = null;
        try {
            Properties p = new Properties();
            FileLocator fileLocator = new FileLocator();
            fin = fileLocator.getConfStream(configFile);
            p.load(fin);

            String host = p.getProperty("httpserver.host").trim();
            String port = p.getProperty("httpserver.port").trim();
            String servletPath = p.getProperty("servlet.path").trim();
            String loginPath = p.getProperty("login.path").trim();
            String debug = p.getProperty("debug").trim();
            httpServerParam = new HttpServerParam();
            httpServerParam.setHost(host);
            httpServerParam.setPort(Integer.parseInt(port));
            httpServerParam.setServletPath(servletPath);
            httpServerParam.setLoginPath(loginPath);
            if ((debug != null) && (debug.equalsIgnoreCase("true")))
                httpServerParam.setDebug(true);
        } catch (Exception e) {
            System.err.println(e);
        } finally {
            try {
                if (fin != null) {
                    fin.close();
                    fin = null;
                }
            } catch (Exception e) {
            }
        }
        return httpServerParam;

    }
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -