package com.vci.client.omd.lifecycle.pubimpl;
|
|
import java.io.FileInputStream;
|
import java.io.FileNotFoundException;
|
import java.io.IOException;
|
import java.io.InputStream;
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.Iterator;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.Properties;
|
import java.util.Set;
|
|
import com.vci.client.omd.lifecycle.LifeCycleStart;
|
import com.vci.corba.common.VCIError;
|
|
|
public class LifeCycleTransitionEvents {
|
static String lifecycle_path = null;
|
|
/**
|
* 获取生命周期事件处理基类
|
*/
|
|
public Object getLifeCycleBaseClass(){
|
try {
|
lifecycle_path = LifeCycleStart.getService().getLifeCycleEventPath();
|
InputStream is = null;
|
Properties p = null;
|
is = new FileInputStream(lifecycle_path);
|
p = new Properties();
|
p.load(is);
|
String lifeCycleEventBaseClass = p.getProperty("lifeCycleEventBaseClass");
|
return Class.forName(lifeCycleEventBaseClass).newInstance();
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
|
}
|
|
/**
|
* 获取生命周期事件模板处理类
|
*/
|
|
public static List<String> getLifeCycleModelClass(){
|
try {
|
lifecycle_path = LifeCycleStart.getService().getLifeCycleEventPath();
|
List<String> lifecycleEventModelClasses = new ArrayList<String>();
|
InputStream is = null;
|
Properties p = null;
|
is = new FileInputStream(lifecycle_path);
|
p = new Properties();
|
p.load(is);
|
String[] lifecycleEvents = getLifeCycleEventsViewKeys();
|
for(String lifecycleEvent:lifecycleEvents){
|
String lifeCycleEventModelClass = p.getProperty(lifecycleEvent);
|
lifecycleEventModelClasses.add(lifeCycleEventModelClass);
|
}
|
|
return lifecycleEventModelClasses;
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
|
}
|
|
/**
|
* 通过生命周期跃迁事件,获取生命周期事件模板处理类
|
*/
|
|
public static List<String> getLifeCycleModelClass(String[] lifecycleEvents){
|
try {
|
lifecycle_path = LifeCycleStart.getService().getLifeCycleEventPath();
|
List<String> lifecycleEventModelClasses = new ArrayList<String>();
|
InputStream is = null;
|
Properties p = null;
|
is = new FileInputStream(lifecycle_path);
|
p = new Properties();
|
p.load(is);
|
for(String lifecycleEvent:lifecycleEvents){
|
String lifeCycleEventModelClass = p.getProperty(lifecycleEvent);
|
lifecycleEventModelClasses.add(lifeCycleEventModelClass);
|
}
|
|
return lifecycleEventModelClasses;
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
|
}
|
|
|
|
/**
|
* 获取lce_view.properties keys
|
* @author liwei
|
* @return String[]
|
*/
|
public static String[] getLifeCycleEventsViewKeys() {
|
InputStream is = null;
|
Properties p = null;
|
List<String> lifeCycleEventsViewKeys = null;
|
lifeCycleEventsViewKeys = new ArrayList<String>();
|
try {
|
lifecycle_path = LifeCycleStart.getService()
|
.getLifeCycleEventViewPath();
|
is = new FileInputStream(lifecycle_path);
|
p = new Properties();
|
p.load(is);
|
|
Set keys = p.keySet();
|
Iterator iterator = keys.iterator();
|
while (iterator.hasNext()) {
|
String lifecycleEvent = (String) iterator.next();
|
lifeCycleEventsViewKeys.add(lifecycleEvent);
|
}
|
|
return lifeCycleEventsViewKeys.toArray(new String[0]);
|
|
} catch (Exception e) {
|
e.printStackTrace();
|
} finally {
|
if (is != null)
|
try {
|
is.close();
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
}
|
return null;
|
|
}
|
|
/**
|
* 获取lce_view.properties values
|
* @return
|
*/
|
public String[] getLifeCycleEventsViewValues() {
|
InputStream is = null;
|
Properties p = null;
|
List<String> lifeCycleEventsViewValues = null;
|
lifeCycleEventsViewValues = new ArrayList<String>();
|
try {
|
lifecycle_path = LifeCycleStart.getService()
|
.getLifeCycleEventViewPath();
|
is = new FileInputStream(lifecycle_path);
|
p = new Properties();
|
p.load(is);
|
|
Iterator iterator = p.values().iterator();
|
while (iterator.hasNext()) {
|
String lifecycleEvent = (String) iterator.next();
|
lifeCycleEventsViewValues.add(lifecycleEvent);
|
}
|
|
return lifeCycleEventsViewValues.toArray(new String[0]);
|
|
} catch (Exception e) {
|
e.printStackTrace();
|
} finally {
|
if (is != null)
|
try {
|
is.close();
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
}
|
return null;
|
|
}
|
|
/***
|
* 获取lce_view.properties映射集合
|
* @param args
|
*/
|
|
public static List<Map<String, String>> getlce_view_maps(){
|
try {
|
InputStream is = null;
|
Properties p = null;
|
List<Map<String, String>> lifeCycleEventsViewMaps = null;
|
lifeCycleEventsViewMaps = new ArrayList<Map<String,String>>();
|
|
lifecycle_path = LifeCycleStart.getService().getLifeCycleEventViewPath();
|
is = new FileInputStream(lifecycle_path);
|
p = new Properties();
|
p.load(is);
|
Set keys = p.keySet();
|
Iterator iterator = keys.iterator();
|
while (iterator.hasNext()) {
|
Map<String, String> map = new HashMap<String, String>();
|
String key = (String) iterator.next();
|
String value = p.getProperty(key);
|
map.put(key, value);
|
lifeCycleEventsViewMaps.add(map);
|
}
|
return lifeCycleEventsViewMaps;
|
} catch (VCIError e) {
|
e.printStackTrace();
|
} catch (FileNotFoundException e) {
|
e.printStackTrace();
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
return null;
|
|
}
|
|
|
/***
|
* 通过key值获取lce_view.properties的value值
|
* @param args
|
*/
|
|
public static String getValueBykey(String key){
|
try {
|
InputStream is = null;
|
Properties p = null;
|
lifecycle_path = LifeCycleStart.getService().getLifeCycleEventViewPath();
|
is = new FileInputStream(lifecycle_path);
|
p = new Properties();
|
p.load(is);
|
return p.getProperty(key);
|
} catch (VCIError e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
} catch (FileNotFoundException e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
} catch (IOException e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
return null;
|
|
}
|
|
|
/***
|
* 通过key值获取lce_view.properties的value值
|
* @param args
|
*/
|
|
public static String getKeyByValue(String value){
|
try {
|
InputStream is = null;
|
Properties p = null;
|
lifecycle_path = LifeCycleStart.getService().getLifeCycleEventViewSavePath();
|
is = new FileInputStream(lifecycle_path);
|
p = new Properties();
|
p.load(is);
|
return p.getProperty(value);
|
} catch (VCIError e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
} catch (FileNotFoundException e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
} catch (IOException e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
return null;
|
|
}
|
|
/**
|
* 获取lce_events.properties的keys
|
* @param args
|
*
|
*/
|
public static String[] get_lce_events_keys(){
|
String[] keys = null;
|
try {
|
keys = LifeCycleStart.getService().getLCEventKeys();
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
return keys;
|
}
|
|
|
/***
|
* 通过key值获取lce_events.properties的value值
|
* @param args
|
*/
|
|
public static String getlce_events_valuebykey(String key){
|
String value = "";
|
try {
|
value = LifeCycleStart.getService().getLCEventValueByKey(key);
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
return value;
|
}
|
|
|
public static void main(String[] args) {
|
// getLifeCycleEvents();
|
|
String value = getValueBykey("初始化");
|
//System.out.println(value);
|
}
|
|
}
|