Below is the code to get all faults given the filter criteria in the entire soa infra.
Libraries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.raylabs.bpel; | |
import java.util.Calendar; | |
import java.util.Hashtable; | |
import java.util.Iterator; | |
import java.util.List; | |
import javax.naming.Context; | |
import oracle.soa.management.facade.Fault; | |
import oracle.soa.management.facade.Locator; | |
import oracle.soa.management.facade.LocatorFactory; | |
import oracle.soa.management.util.FaultFilter; | |
public class Class1 { | |
public Class1() { | |
super(); | |
} | |
public static void main(String[] args) { | |
Locator locator = null; | |
try{ | |
locator = LocatorFactory.createLocator(getConnectionForLocator()); | |
FaultFilter faultFilter = new FaultFilter(); | |
Calendar cal = Calendar.getInstance(); | |
cal.add(Calendar.DATE, -30); | |
faultFilter.setMinCreationDate(cal.getTime()); | |
//faultFilter.setRecoverable(true); | |
faultFilter.setPageSize(10); | |
List<Fault> list = locator.getFaults(faultFilter); | |
Iterator<Fault> faults = list.iterator(); | |
while (faults.hasNext()) { | |
Fault fault = faults.next(); | |
//if(fault.isRecoverable()){ | |
System.out.println("Composite :" + | |
fault.getCompositeDN().getCompositeName()); | |
System.out.println("Fault Description :" + fault.getName()); | |
System.out.println("Fault ECID:" + fault.getECID()); | |
System.out.println("Fault Composite instance id :" + | |
fault.getCompositeInstanceId()); | |
if (fault.getType() == Fault.TYPE_BUSINESS_FAULT) { | |
System.out.println("BUSINESS_FAULT"); | |
} else if (fault.getType() == Fault.TYPE_SYSTEM_FAULT) { | |
System.out.println("SYSTEM_FAULT"); | |
} else if (fault.getType() == Fault.TYPE_POLICY_FAULT) { | |
System.out.println("POLICY_FAULT"); | |
} else { | |
System.out.println("Unknown fault :" + fault.getType()); | |
} | |
System.out.println("Message :" + fault.getMessage()); | |
System.out.println("Created on :" + fault.getCreationDate()); | |
if (fault.isRecoverable()) { | |
System.out.println("Recoverable"); | |
} else { | |
System.out.println("Non Recoverable"); | |
} | |
if (fault.isRejectedMessage()) { | |
System.out.println("Rejected Message"); | |
} | |
System.out.println("--------------------------------------------"); | |
// } | |
} | |
} catch (Exception e) { | |
System.out.println("Unknown Exception "); | |
e.printStackTrace(); | |
} finally { | |
try { | |
locator.close(); | |
System.out.println("Locator closed successfully"); | |
} catch (Exception e) { | |
System.out.println("Exception while closing Locator handle"); | |
e.printStackTrace(); | |
} | |
} | |
} | |
public static Hashtable getConnectionForLocator() { | |
Hashtable jndiProps = new Hashtable(); | |
jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, | |
"weblogic.jndi.WLInitialContextFactory"); | |
jndiProps.put(Context.PROVIDER_URL, | |
"t3://xxx:123123/soa-infra"); | |
jndiProps.put(Context.SECURITY_PRINCIPAL, "xxx"); | |
jndiProps.put(Context.SECURITY_CREDENTIALS, "xxxx"); | |
jndiProps.put("dedicated.connection", "true"); | |
return jndiProps; | |
} | |
} |
Libraries
No comments:
Post a Comment