?? appfwimpl.java.bak
字號:
package samples.fw;
import java.util.*;
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;
import org.omg.CORBA.*;
import org.csapi.*;
import org.csapi.fw.*;
import org.csapi.fw.fw_access.trust_and_security.*;
import org.csapi.fw.fw_application.discovery.*;
import org.csapi.fw.fw_application.service_agreement.*;
import org.csapi.fw.fw_application.notification.*;
import org.csapi.fw.fw_application.integrity.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POA;
public class AppFWImpl
{
static String svcToken;
static String svcAgreementText;
static String svcSigningAlgorithm;
// those from fw server
//
static IpInitial ipInitial;
static IpEventNotification ipEventNotification;
static IpFaultManager ipFaultManager;
static IpHeartBeat ipHeartBeat;
static IpHeartBeatMgmt ipHeartBeatMgmt;
static IpLoadManager ipLoadManager;
static IpOAM ipOAM;
static IpAccess ipAccess;
static IpAPILevelAuthentication ipAPILevelAuthentication;
static IpServiceAgreementManagement ipServiceAgreementManagement;
static IpServiceDiscovery ipServiceDiscovery;
// those are application side
//
static IpClientAccess clientAccess;
static IpClientAPILevelAuthentication clientAPILevelAuthentication;
static IpAppServiceAgreementManagement appServiceAgreementManagement;
static IpAppEventNotification appEventNotification;
static IpAppFaultManager appFaultManager;
static IpAppHeartBeat appHeartBeat;
static IpAppHeartBeatMgmt appHeartBeatMgmt;
static IpAppLoadManager appLoadManager;
static IpAppOAM appOAM;
static Timer timer = null;
public static POA poa = null;
public static initiate(String namesvrHost,
int namesvrPort, String initialPath)
{
Properties props = new Properties();
props.put("org.omg.CORBA.ORBInitialHost", namesvrHost);
props.put("org.omg.CORBA.ORBInitialPort", ""+namesvrPort);
String[] args = null;
NameComponent nc = new NameComponent(initialPath, "");
NameComponent path[] = {nc};
org.omg.CORBA.Object objRef = null;
NamingContextExt ncRef = null;
try {
ORB orb = ORB.init(args, props);
poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
poa.the_POAManager().activate();
objRef = orb.resolve_initial_references("TNameService");
ncRef = NamingContextExtHelper.narrow(objRef);
ipInitial = IpInitialHelper.narrow(ncRef.resolve(path));
}
catch(Exception e) {
}
try {
clientAccess = IpClientAccessHelper.narrow(
poa.servant_to_reference(new ClientAccessImpl()));
clientAPILevelAuthentication = IpClientAPILevelAuthenticationHelper.narrow(
poa.servant_to_reference(new ClientAPILevelAuthenticationImpl()));
appEventNotification = IpAppEventNotificationHelper.narrow(
poa.servant_to_reference(new AppEventNotificationImpl()));
appFaultManager = IpAppFaultManagerHelper.narrow(
poa.servant_to_reference(new AppFaultManagerImpl()));
appHeartBeatMgmt = IpAppHeartBeatMgmtHelper.narrow(
poa.servant_to_reference(new AppHeartBeatMgmtImpl()));
appLoadManager = IpAppLoadManagerHelper.narrow(
poa.servant_to_reference(new AppLoadManagerImpl()));
appOAM = IpAppOAMHelper.narrow(
poa.servant_to_reference(new AppOAMImpl()));
appServiceAgreementManagement = IpAppServiceAgreementManagementHelper.narrow(
poa.servant_to_reference(new AppServiceAgreementManagementImpl()));
}
catch(Exception e) {
}
}
public getAuthenticated(String appID)
{
try {
TpDomainID domainID = new TpDomainID();
domainID.ClientAppID(appID);
TpAuthDomain clientDomain = new TpAuthDomain(domainID,
clientAPILevelAuthentication);
synchronized (this)
{
TpAuthDomain authDomain =
ipInitial.initiateAuthentication(clientDomain,
"P_OSA_AUTHENTICATION");
ipAPILevelAuthentication =
IpAPILevelAuthenticationHelper.narrow(
authDomain.AuthInterface);
wait();
ipAccess = IpAccessHelper.narrow(
ipAPILevelAuthentication.requestAccess("P_OSA_ACCESS",clientAccess));
}
}
catch(Exception ee){
}
}
public org.csapi.IpInterface getServices(String serviceType)
{
try {
//String[] svcTypes = ipServiceDiscovery.listServiceTypes();
ipServiceDiscovery = IpServiceDiscoveryHelper.narrow(
ipAccess.obtainInterface("P_DISCOVERY"))
/* TpServiceTypeDescription
public org.csapi.fw.TpServiceTypeProperty ServiceTypePropertyList[] = null;
public String ServiceTypeNameList[] = null;
public boolean AvailableOrUnavailable = false;
*/
/* TpServiceTypeProperty
public String ServicePropertyName = null;
public org.csapi.fw.TpServiceTypePropertyMode ServiceTypePropertyMode = null;
public String ServicePropertyTypeName = null;
*/
org.csapi.fw.TpServiceTypeDescription desc =
ipServiceDiscovery.describeServiceType(serviceType);
org.csapi.fw.TpService[] services =
ipServiceDiscovery.discoverService(
serviceType,
new org.csapi.fw.TpServiceProperty[0],
1);
if (services==null || services.length==0) {
System.out.println("there is not service instance for "+serviceType);
return null;
}
ipServiceAgreementManagement = IpServiceAgreementManagementHelper.narrow(
ipAccess.obtainInterfaceWithCallback("P_SVC_CONTRACT_MANAGEMENT",
appServiceAgreementManagement));
svcToken = ipServiceAgreementManagement.selectService(services[0].ServiceID);
synchronized (this) {
ipServiceAgreementManagement.initiateSignServiceAgreement(svcToken);
wait();
org.csapi.fw.TpSignatureAndServiceMgr signatureAndServiceMgr =
svcMgrsForApp.ipServiceAgreementManagement.signServiceAgreement(
svcToken, svcAgreementText, svcSigningAlgorithm);
return signatureAndService.ServiceMgrInterface;
}
}
catch(Exception ee){
return null;
}
}
public void startEventNotification(String[] services)
{
try {
if ((services==null) || (services.length==0))
return;
ipEventNotification = IpEventNotificationHelper.narrow(
ipAccess.obtainInterfaceWithCallback("P_EVENT_NOTIFICATION",
appEventNotification));
TpFwEventCriteria criteria = new TpFwEventCriteria();
criteria.UnavailableServiceTypeNameList(services);
ipEventNotification.createNotification(criteria);
criteria = new TpFwEventCriteria();
criteria.ServiceTypeNameList(services);
ipEventNotification.createNotification(criteria);
}
catch (Exception e) {
}
}
public void startHeartbeat(int heartBeatInternal)
{
try {
ipHeartBeatMgmt = IpHeartBeatMgmtHelper.narrow(
ipAccess.obtainInterfaceWithCallback("P_HEARTBEAT_MANAGEMENT",
appHeartBeatMgmt));
appHeartBeat = IpAppHeartBeatHelper.narrow(
poa.servant_to_reference(
new AppHeartBeatImpl(heartBeatInternal)));
ipHeartBeatMgmt.enableHeartBeat(heartBeatInternal, appHeartBeat);
}
catch (Exception e) {
}
}
public void startOtherIntegrity(int heartBeatInternal)
{
try {
ipFaultManager = IpFaultManagerHelper.narrow(
ipAccess.obtainInterfaceWithCallback("P_FAULT_MANAGER",
appFaultManager));
ipLoadManager = IpLoadManagerHelper.narrow(
ipAccess.obtainInterfaceWithCallback("P_LOAD_MANAGER",
appLoadManager));
ipOAM = IpOAMHelper.narrow(
ipAccess.obtainInterfaceWithCallback("P_OAM",appOAM));
}
catch (Exception e) {
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -