Vector sources = oldPB.getSources();
newPB.removeSources();
// Create a new RenderableOp on the server
ImageServer remoteImage = getImageServer(rop.getServerName());
ImagingListener listener =
ImageUtil.getImagingListener(rop.getRenderingHints());
Long opID = new Long(0L);
try {
opID = remoteImage.getRemoteID();
remoteImage.createRenderableOp(opID,
rop.getOperationName(),
newPB);
} catch (RemoteException e){
String message = JaiI18N.getString("RMIServerProxy8");
listener.errorOccurred(message,
new RemoteImagingException(message, e),
this, false);
// throw new RemoteImagingException(ImageUtil.getStackTraceString(e));
}
// Now look at the sources of the RenderableOp
if (sources != null) {
for (int i = 0; i < sources.size(); i++) {
Object source = sources.elementAt(i);
if (source instanceof RemoteRenderedOp) {
// If source is a RenderedOp on a remote machine, create
// it on the remote machine.
RMIServerProxy rmisp =
(RMIServerProxy)(((RemoteRenderedOp)source).getRendering());
try {
if (rmisp.getServerName().equalsIgnoreCase(
rop.getServerName())) {
// Both the RenderableOp and this source are on
// the same server.
remoteImage.setRenderedSource(opID,
rmisp.getRMIID(),
i);
newPB.setSource(rmisp, i);
} else {
// The RenderableOp and this source are on
// different servers.
remoteImage.setRenderedSource(
opID,
rmisp.getRMIID(),
rmisp.getServerName(),
rmisp.getOperationName(),
i);
newPB.setSource(rmisp, i);
}
} catch (RemoteException e) {
String message = JaiI18N.getString("RMIServerProxy6");
listener.errorOccurred(message,
new RemoteImagingException(message, e),
this, false);
// throw new RemoteImagingException(ImageUtil.getStackTraceString(e));
}
} else if (source instanceof RenderedOp) {
// If the source is a local RenderedOp, then the only way
// to access it from a remote machine is to render it and
// create a SerializableRenderedImage wrapping the
// rendering, which is set as the source of the remote op.
RenderedImage ri = ((RenderedOp)source).getRendering();
try {
SerializableRenderedImage sri =
new SerializableRenderedImage(ri);
remoteImage.setRenderedSource(opID, sri, i);
newPB.setSource(sri, i);
} catch (RemoteException e) {
String message = JaiI18N.getString("RMIServerProxy6");
listener.errorOccurred(message,
new RemoteImagingException(message, e),
this, false);
// throw new RemoteImagingException(ImageUtil.getStackTraceString(e));
}
} else if (source instanceof RenderedImage) {
// If the source is a local RenderedImage, then the only
// way to access it from a remote machine is by wrapping
// it in SerializableRenderedImage and then setting the
// SRI as the source.
RenderedImage ri = (RenderedImage)source;
try {
SerializableRenderedImage sri =
new SerializableRenderedImage(ri);
remoteImage.setRenderedSource(opID, sri, i);
newPB.setSource(sri, i);
} catch (RemoteException e) {
String message = JaiI18N.getString("RMIServerProxy6");
listener.errorOccurred(message,
new RemoteImagingException(message, e),
this, false);
// throw new RemoteImagingException(ImageUtil.getStackTraceString(e));
}
} else if (source instanceof RemoteRenderableOp) {
// If the source is a RenderableOp on a remote machine,
// cause the RenderableOp to be created on the remote
// machine.
RenderableRMIServerProxy rrmisp =
createProxy((RemoteRenderableOp)source);
try {
// If the source RenderableOp is on the same server
// as the RenderableOp that represents the operation
if (rrmisp.getServerName().equalsIgnoreCase(
rop.getServerName())) {
remoteImage.setRenderableSource(opID,
rrmisp.getRMIID(),
i);
newPB.setSource(rrmisp, i);
} else {
// If the source RenderableOp is on a different
// server than the RenderableOp that represents
// the operation
remoteImage.setRenderableRMIServerProxyAsSource(
opID,
rrmisp.getRMIID(),
rrmisp.getServerName(),
rrmisp.getOperationName(),
i);
newPB.setSource(rrmisp, i);
}
} catch (RemoteException e) {
String message = JaiI18N.getString("RMIServerProxy6");
listener.errorOccurred(message,
new RemoteImagingException(message, e),
this, false);
// throw new RemoteImagingException(ImageUtil.getStackTraceString(e));
}
} else if (source instanceof RenderableImage) {
// If the source is a local RenderableImage, the only way
// to access it from a remote machine is to wrap it in
// a SerializableRenderableImage and then set the SRI as
// the source on the remote operation.
RenderableImage ri = (RenderableImage)source;
try {
SerializableRenderableImage sri =
new SerializableRenderableImage(ri);
remoteImage.setRenderableSource(opID, sri, i);
newPB.setSource(sri, i);
} catch (RemoteException e) {
String message = JaiI18N.getString("RMIServerProxy6");
listener.errorOccurred(message,
new RemoteImagingException(message, e),
this, false);
// throw new RemoteImagingException(ImageUtil.getStackTraceString(e));
}
}