Package org.apache.kato.tck.harness.scenario

Source Code of org.apache.kato.tck.harness.scenario.StandardDumpTrigger

/*******************************************************************************
* 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 org.apache.kato.tck.harness.scenario;

import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;

import javax.tools.diagnostics.vm.DumpFactory;
import javax.tools.diagnostics.vm.DumpHandle;
import javax.tools.diagnostics.vm.DumpInitiatorDelegate;

public class StandardDumpTrigger implements IDumpTrigger {

  private String format=null;
 
  public void dump() throws IOException {
   
    DumpHandle handle=null;
   
    DumpFactory d=DumpFactory.getDefault();
   
    if(format!=null) {
      DumpInitiatorDelegate delegate=d.getInitiator(format);
      if(delegate==null) {
        Collection available=d.getAvailableInitiators();
        if(available==null || available.isEmpty()) {
          System.out.println("!!!No Dump Initiators available");
        }
        else {
          System.out.println("Dump format "+format+" requested but unavailable");
          System.out.println("available formats are:");
          Iterator i=available.iterator();
          while(i.hasNext()) {
            delegate=(DumpInitiatorDelegate) i.next();
            System.out.println(delegate.getDumpType());
          }
        }
       
      }
      else {
        handle=delegate.createDumpHandle();
      }
     
    }
    if(handle==null)handle=d.createDumpHandle();
   
    handle.dump();
   
  }

  public void setDumpFormat(String dumpFormat) {
    this.format=dumpFormat;
   
  }

}
TOP

Related Classes of org.apache.kato.tck.harness.scenario.StandardDumpTrigger

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.