//
// RemoteServerImpl.java
//
/*
VisAD system for interactive analysis and visualization of numerical
data. Copyright (C) 1996 - 2017 Bill Hibbard, Curtis Rueden, Tom
Rink, Dave Glowacki, Steve Emmerson, Tom Whittaker, Don Murray, and
Tommy Jasmin.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA
*/
package visad;
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
public class RemoteServerImpl extends UnicastRemoteObject
implements RemoteServer
{
private RemoteDataReferenceImpl[] refs;
private RemoteDisplayImpl[] dpys;
public RemoteServerImpl()
throws RemoteException {
this(null, null);
}
public RemoteServerImpl(RemoteDataReferenceImpl[] rs)
throws RemoteException {
this(rs, null);
}
public RemoteServerImpl(RemoteDisplayImpl[] rd)
throws RemoteException {
this(null, rd);
}
/** construct a RemoteServerImpl and initialize it with
an array of RemoteDataReferenceImpls */
public RemoteServerImpl(RemoteDataReferenceImpl[] rs, RemoteDisplayImpl[] rd)
throws RemoteException {
super();
refs = rs;
dpys = rd;
}
/** get a RemoteDataReference by index */
public synchronized RemoteDataReference getDataReference(int index)
throws RemoteException {
if (refs != null && 0 <= index && index < refs.length) return refs[index];
else return null;
}
/** get a RemoteDataReference by name */
public synchronized RemoteDataReference getDataReference(String name)
throws VisADException, RemoteException {
if (name != null && refs != null) {
for (int i=0; i= refs.length) {
RemoteDataReferenceImpl[] rs = new RemoteDataReferenceImpl[index + 1];
for (int i=0; i 0) System.arraycopy(refs, 0, nr, 0, len);
nr[len] = ref;
refs = nr;
}
/** set array of all RemoteDataReferences on this RemoteServer */
public synchronized void setDataReferences(RemoteDataReferenceImpl[] rs) {
if (rs == null) {
refs = null;
return;
}
refs = new RemoteDataReferenceImpl[rs.length];
for (int i=0; i 0) System.arraycopy(refs, 0, nr, 0, index);
if (index < len - 1) {
System.arraycopy(refs, index + 1, nr, index, len - index - 1);
}
refs = nr;
}
/** return array of all RemoteDisplays in this RemoteServer */
public RemoteDisplay[] getDisplays()
throws RemoteException
{
if (dpys == null || dpys.length == 0) return null;
// is this copy necessary?
RemoteDisplay[] rd =
new RemoteDisplay[dpys.length];
for (int i=0; i= 0 && index < dpys.length) {
return dpys[index];
}
return null;
}
/** get a RemoteDisplay by name */
public RemoteDisplay getDisplay(String name)
throws VisADException, RemoteException
{
if (dpys == null) {
throw new RemoteException("No displays associated with this server");
}
for (int i=0; i 0) System.arraycopy(dpys, 0, nd, 0, len);
nd[len] = rd;
dpys = nd;
}
/** set all RemoteDisplayImpls to serve */
public synchronized void setDisplays(RemoteDisplayImpl[] rd) {
if (rd == null) {
dpys = null;
return;
}
dpys = new RemoteDisplayImpl[rd.length];
for (int i=0; i 0) System.arraycopy(dpys, 0, nd, 0, index);
if (index < len - 1) {
System.arraycopy(dpys, index + 1, nd, index, len - index - 1);
}
dpys = nd;
}
}
Ads help maintain this website.