📄 webpromanager.java
字号:
// ----------------------------------------------------------------------------
// $Source: /cvs/vas2006/webpro2/webpro_java/src/com/onewaveinc/portalman/webpro/WebProManager.java,v $
// ----------------------------------------------------------------------------
// Copyright (c) 2002 by Onewave Inc.
// ----------------------------------------------------------------------------
// $Id: WebProManager.java,v 1.1.1.1 2006/08/01 05:49:33 zhengx Exp $
// ----------------------------------------------------------------------------
// $Log: WebProManager.java,v $
// Revision 1.1.1.1 2006/08/01 05:49:33 zhengx
// no message
//
// Revision 1.1 2006/06/02 03:33:15 wuyan
// *** empty log message ***
//
// Revision 1.3 2005/12/19 07:33:56 like
// no message
//
// Revision 1.2 2005/12/09 08:53:25 lufang
// no message
//
// Revision 1.1 2005/12/08 10:36:27 like
// no message
//
// Revision 1.1 2003/07/28 06:29:59 zengc
// no message
//
// ----------------------------------------------------------------------------
package com.onewaveinc.portalman.webpro;
/**
* <p>Title: PortalMAN SDK API Documentation</p>
* <p>Description: OneWave Technologies., Inc. PortalMAN Value-add Management Platform 3rd Software Development Kit</p>
* <p>Copyright: Copyright (c) 2002 </p>
* <p>Company: OneWave Technologies., Inc.</p>
* @author 3rd AAA & ICP Integration Developement Team
* @version 1.5
*/
import java.util.*;
import java.io.*;
import java.text.*;
import com.onewaveinc.portalman.webpro.configure.*;
import com.onewaveinc.portalman.webpro.soap.*;
public class WebProManager {
final static String mVersion = "20";
private static Properties mProperties;
private static ConfigureFile mConfigureFile;
private static boolean mDebug;
private static PrintWriter log;
private static String logfilename;
private static WebProManagerDaemon daemon;
static String mRecordType;
static String mICPCode;
static String mICPKey;
static String mICPMode;
static String mRefreshMinute;
static String mAuthenticationJumpURL;
static String mAuthorizationJumpURL;
static String mLogValue;
static String mLogPath;
private static Vector AuthenticationConfig;
private static Vector AccountingConfig;
static{
initialize();
}
private WebProManager() {
}
/**
* 重新读取配置
*/
public static void refresh(){
initialize();
debug("WebPro Manager instance refreshed!");
}
/**
* 处理调试信息
* @param message 调试信息
*/
public static void debug(Object message){
if(mDebug){
System.out.println(message.toString());
}
}
public static void log(Object message){
if(!"false".equalsIgnoreCase(mLogValue)){
//建webprolog目录
File webproroot = new File(mLogPath);
if(!webproroot.exists()){
if(!webproroot.mkdir()){
debug("Can't create log directory:"+webproroot);
return;
}
}
File webprolog = new File(mLogPath+"/webprolog");
if(!webprolog.exists()){
if(!webprolog.mkdir()){
debug("Can't create log directory:"+webproroot);
return;
}
}
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
SimpleDateFormat dateFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
Date now = new Date();
String logpath = mLogPath+"/webprolog/" +dateFormat.format(now)+".log";
File logfile = new File(logpath);
if(!logfile.exists() || log==null || log.checkError()){
try {
log = new PrintWriter(new BufferedWriter(new FileWriter(logpath,true)));
}
catch (IOException ex) {
ex.printStackTrace();
}
}
try {
if(log!=null){
log.print(dateFormat2.format(now)+": ");
log.println(message.toString());
log.println();
log.flush();
}
}
catch (Exception ex) {
ex.printStackTrace();
try {
log = new PrintWriter(new BufferedWriter(new FileWriter(logpath,true)));
log.print(dateFormat2.format(now)+": ");
log.println(message.toString());
log.println();
log.flush();
}
catch (Exception ex2) {
ex.printStackTrace();
}
}
}
}
public static void closelog(){
log.close();
}
/**
* 初始化WebPro管理器
*/
private static void initialize(){
try {
//取得webpro.xml配置文件的路径
//String strPropertiesFilePath = "d:/webpro.xml";//System.getProperty("com.onewaveinc.webpro");
String strPropertiesFilePath = System.getProperty("com.onewaveinc.webpro");
// String strPropertiesFilePath = "d:/webpro.xml";
if(strPropertiesFilePath == null || strPropertiesFilePath.length() == 0){
throw new Exception("Can not find WebPro Configuration File!");
}
mConfigureFile = new ConfigureFile(strPropertiesFilePath);
mProperties = mConfigureFile.getAllProperties();
readparameter();
//取得Authentication配置
AuthenticationConfig = mConfigureFile.getAllAttrsProperties("AuthenticationServer");
if(AuthenticationConfig == null){
throw new Exception("AuthenticationServer Configuration Error !!!");
}
//取得Accounting配置
AccountingConfig = mConfigureFile.getAllAttrsProperties("AccountingServer");
if(AccountingConfig == null){
throw new Exception("AccountingServer Configuration Error !!!");
}
//初始化配置文件更新后台
if(daemon != null){
daemon.stopDaemon();
}
if(mRefreshMinute == null || mRefreshMinute.trim().length() == 0){
mRefreshMinute = "10";
}
long refreshMinute = 0L;
try {
refreshMinute = Long.parseLong(mRefreshMinute);
}catch (NumberFormatException ex) {
refreshMinute = 10L;
}
if(refreshMinute > 0){
daemon = new WebProManagerDaemon(refreshMinute);
}
debug("WebPro Manager initialze finished!\n\n");
}
catch (Exception ex) {
ex.printStackTrace();
}
}
private static void readparameter() {
//debug("WebPro Configure :" + mProperties);
mDebug = Boolean.valueOf(mProperties.getProperty("WebPro.Debug.Value")).booleanValue();
debug("WebPro Manager Verion 21 initialzing ....");
debug("\tWebPro.Debug.Value = " + mDebug);
mICPCode = mProperties.getProperty("WebPro.ICPCode.Value");
debug("\tWebPro.ICPCode.Value = " + mICPCode);
mICPKey = mProperties.getProperty("WebPro.ICPKey.Value");
debug("\tWebPro.ICPKey.Value = " + mICPKey);
mICPMode = mProperties.getProperty("WebPro.ICPMode.Value");
if(mICPMode == null){
mICPMode = "1";
}
debug("\tWebPro.ICPMode.Value = " + mICPMode);
mAuthenticationJumpURL = mProperties.getProperty("WebPro.AuthenticationJumpURL.Value");
debug("\tWebPro.AuthenticationJumpURL.Value = " + mAuthenticationJumpURL);
mAuthorizationJumpURL = mProperties.getProperty("WebPro.AuthorizationJumpURL.Value");
debug("\tWebPro.AuthorizationJumpURL.Value = " + mAuthorizationJumpURL);
mRefreshMinute = mProperties.getProperty("WebPro.RefreshMinute.Value");
debug("\tWebPro.RefreshMinute.Value = " + mRefreshMinute);
mLogValue = mProperties.getProperty("WebPro.Log.Value");
debug("\tWebPro.Log.Value = " + mLogValue);
mLogPath = mProperties.getProperty("WebPro.Log.Path");
if(mLogPath==null || mLogPath.length()==0){
// mLogPath = new File("d://webpro.xml").getParent();
mLogPath = new File(System.getProperty("com.onewaveinc.webpro")).getParent();
// mLogPath = new File("d:/webpro.xml").getParent();
if(mLogPath==null){
mLogPath=".";
}
}
debug("\tWebPro.Log.Path = " + mLogPath);
}
/**
* 得到认证中心接口
* @return com.onewaveinc.portalman.webpro.OWAccounting
*/
public static OWAuthentication getOWAuthentication(){
OWAuthentication auth = new OWAuthentication(AuthenticationConfig);
debug("OWAuthentication object created ...... ");
return auth;
}
/**
* 得到计费中心的接口
* @return com.onewaveinc.portalman.webpro.OWAccounting
*/
public static OWAccounting getOWAccounting(){
OWAccounting accounting = new OWAccounting(AccountingConfig);
debug("OWAccounting object created ......");
return accounting;
}
public static String getAuthorizationJumpURL(){
return mAuthorizationJumpURL;
}
public static String getAuthenticationJumpURL(){
return mAuthenticationJumpURL;
}
public static String getICPCode(){
return mICPCode;
}
public static String getICPKey(){
return mICPKey;
}
public static PrintWriter getLog(){
return log;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -