/*******************************************************************************
* 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.hprof.image;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
import javax.tools.diagnostics.image.CorruptDataException;
import javax.tools.diagnostics.image.DataUnavailable;
import javax.tools.diagnostics.image.ImageAddressSpace;
import javax.tools.diagnostics.image.ImageModule;
import javax.tools.diagnostics.image.ImageProcess;
import javax.tools.diagnostics.image.ImageThread;
import org.apache.kato.common.IViewMonitor;
import org.apache.kato.hprof.HProfView;
import org.apache.kato.hprof.java.JavaRuntimeImpl;
public class ImageProcessImpl implements ImageProcess {
/**
*
*/
private final ImageImpl imageImpl;
private JavaRuntimeImpl javaRuntime=null;
private HProfView view;
/**
* @param imageImpl
*/
ImageProcessImpl(ImageImpl imageImpl) {
this.imageImpl = imageImpl;
// Make sure view is open before we query it.
this.view=new HProfView(imageImpl.file);
view.open(new IViewMonitor(){
@Override
public void error(IOException e) {
// TODO Auto-generated method stub
}});
}
@Override
public String getCommandLine() throws DataUnavailable,
CorruptDataException {
throw new DataUnavailable();
}
@Override
public ImageThread getCurrentThread() throws CorruptDataException {
// There are no current threads in hprof.
// null is a valid value.
return null;
}
@Override
public Properties getEnvironment() throws DataUnavailable,
CorruptDataException {
throw new DataUnavailable();
}
@Override
public ImageModule getExecutable() throws DataUnavailable,
CorruptDataException {
throw new DataUnavailable();
}
@Override
public String getID() throws DataUnavailable, CorruptDataException {
throw new DataUnavailable();
}
@Override
public List getLibraries() throws DataUnavailable,
CorruptDataException {
throw new DataUnavailable();
}
@Override
public int getPointerSize() {
return this.imageImpl.file.getIdentifierSize();
}
@Override
public List getRuntimes() {
if(javaRuntime==null) {
javaRuntime=new JavaRuntimeImpl(this.view, (ImageAddressSpace) imageImpl.getAddressSpaces().get(0));
}
List list=new LinkedList();
list.add(javaRuntime);
return list;
}
@Override
public String getSignalName() throws DataUnavailable,
CorruptDataException {
throw new DataUnavailable();
}
@Override
public int getSignalNumber() throws DataUnavailable,
CorruptDataException {
throw new DataUnavailable();
}
@Override
public List getThreads() {
// There will never be any native threads.
return new LinkedList();
}
}