Java Code Performance Problem

Hi,

I'm running a piece of java code within BW 5.1 which reads an image then writes each page of the image to a new file. The process seems to work ok but once deployed time to complete starts at a few seconds and gradually ramps up to 15mins per image over time. I think the problem maybe related to the initial file read which from some os analysis may be causing the problem.

Any thoughts or comments would be appreciated.

Thanks

package AutomatedProcesses.ManageFax;

import java.util.*;

import java.io.*;

import com.sun.media.jai.codec.FileSeekableStream;

import com.sun.media.jai.codec.SeekableStream;

import com.sun.media.jai.codec.ImageCodec;

import com.sun.media.jai.codec.ImageDecoder;

import com.sun.media.jai.codec.TIFFDecodeParam;

import java.awt.image.*;

import javax.media.jai.*;

import java.awt.*;

import java.awt.image.renderable.ParameterBlock;

public class ManageFaxJavaCode{

/****** START SET/GET METHOD, DO NOT MODIFY *****/

protected String filename = "";

protected String outDir = "";

protected String imageDir = "";

protected int DISPLAY_WIDTH = 0;

protected String outFile = "";

protected int numofpages = 0;

public String getfilename() {

return filename;

}

public void setfilename(String val) {

filename = val;

}

public String getoutDir() {

return outDir;

}

public void setoutDir(String val) {

outDir = val;

}

public String getimageDir() {

return imageDir;

}

public void setimageDir(String val) {

imageDir = val;

}

public int getDISPLAY_WIDTH() {

return DISPLAY_WIDTH;

}

public void setDISPLAY_WIDTH(int val) {

DISPLAY_WIDTH = val;

}

public String getoutFile() {

return outFile;

}

public void setoutFile(String val) {

outFile = val;

}

public int getnumofpages() {

return numofpages;

}

public void setnumofpages(int val) {

numofpages = val;

}

/****** END SET/GET METHOD, DO NOT MODIFY *****/

public ManageFaxJavaCode() {

}

public void invoke() throws Exception {

/* Available Variables: DO NOT MODIFY

In : String filename

In : String outDir

In : String imageDir

In : int DISPLAY_WIDTH

In : String outFile

Out : int numofpages

  • Available Variables: DO NOT MODIFY *****/

File file = new File(imageDir + filename);

SeekableStream s = null;

TIFFDecodeParam param = null;

String simplefilename = filename.substring(0,filename.lastIndexOf("."));

try {

s = new FileSeekableStream(file);

ImageDecoder dec = ImageCodec.createImageDecoder("tiff", s, param);

numofpages = dec.getNumPages();

for (int i=0; i< numofpages; i++) {

RenderedImage op= new NullOpImage(dec.decodeAsRenderedImage(i),null,null,OpImage.OP_COMPUTE_BOUND);

int width = 0;

int height = 0;

height=op.getHeight();

width=op.getWidth();

boolean tall = (height > width);

float modifier = 1184 / (float) (tall ? height : width);

ParameterBlock params = new ParameterBlock();

params.addSource(op);

params.add(modifier); //x scale factor

params.add(modifier); //y scale factor

params.add(0.0F); //x translate

params.add(0.0F); //y translate

params.add(new InterpolationNearest()); //interpolation method

RenderedImage res= JAI.create("scale", params);

JAI.create("filestore", res, outDir + outFile + "_" + i + ".png", "png");

res=null;

op=null;

params=null;

modifier=0;

}

s.close();

} catch (IOException e) {

System.out.println(e.getLocalizedMessage());

}

System.gc();}

}

Login