diff options
| author | abranson <andrew.branson@cern.ch> | 2011-08-02 22:10:28 +0200 |
|---|---|---|
| committer | abranson <andrew.branson@cern.ch> | 2011-08-02 22:10:28 +0200 |
| commit | 5664fd4644c78f4571a1a72e6b9f0511fb10720a (patch) | |
| tree | 7be1c346d1d001bf6b079089f995a60c52b955c1 /source/com/c2kernel/entity/proxy | |
| parent | 29bbf451a22916d39017ec1a3f53f4e0f0e65ee0 (diff) | |
Finished move to generics. Enforced 1.6 compliance for now. No errors or
warnings :)
Diffstat (limited to 'source/com/c2kernel/entity/proxy')
| -rw-r--r--[-rwxr-xr-x] | source/com/c2kernel/entity/proxy/EntityProxy.java | 4 | ||||
| -rw-r--r--[-rwxr-xr-x] | source/com/c2kernel/entity/proxy/EntityProxyManager.java | 8 | ||||
| -rw-r--r--[-rwxr-xr-x] | source/com/c2kernel/entity/proxy/ItemProxy.java | 14 | ||||
| -rw-r--r--[-rwxr-xr-x] | source/com/c2kernel/entity/proxy/MemberSubscription.java | 15 | ||||
| -rw-r--r--[-rwxr-xr-x] | source/com/c2kernel/entity/proxy/ProxyClientConnection.java | 4 |
5 files changed, 20 insertions, 25 deletions
diff --git a/source/com/c2kernel/entity/proxy/EntityProxy.java b/source/com/c2kernel/entity/proxy/EntityProxy.java index a5b6822..b34653f 100755..100644 --- a/source/com/c2kernel/entity/proxy/EntityProxy.java +++ b/source/com/c2kernel/entity/proxy/EntityProxy.java @@ -35,7 +35,7 @@ abstract public class EntityProxy implements ManageableEntity protected ManageableEntity mEntity = null;
protected org.omg.CORBA.Object mIOR;
protected int mSystemKey;
- private HashMap mSubscriptions;
+ private HashMap<MemberSubscription, EntityProxyObserver> mSubscriptions;
/**************************************************************************
*
@@ -60,7 +60,7 @@ abstract public class EntityProxy implements ManageableEntity mIOR = ior;
mSystemKey = systemKey;
- mSubscriptions = new HashMap();
+ mSubscriptions = new HashMap<MemberSubscription, EntityProxyObserver>();
}
diff --git a/source/com/c2kernel/entity/proxy/EntityProxyManager.java b/source/com/c2kernel/entity/proxy/EntityProxyManager.java index 386bc2c..3224da7 100755..100644 --- a/source/com/c2kernel/entity/proxy/EntityProxyManager.java +++ b/source/com/c2kernel/entity/proxy/EntityProxyManager.java @@ -27,12 +27,12 @@ import com.c2kernel.utils.server.SimpleTCPIPServer; public class EntityProxyManager
{
- SoftCache proxyPool = new SoftCache(50);
- HashMap treeSubscribers = new HashMap();
- HashMap connections = new HashMap();
+ SoftCache<Integer, EntityProxy> proxyPool = new SoftCache<Integer, EntityProxy>(50);
+ HashMap<DomainPathSubscriber, DomainPath> treeSubscribers = new HashMap<DomainPathSubscriber, DomainPath>();
+ HashMap<String, ProxyServerConnection> connections = new HashMap<String, ProxyServerConnection>();
// server objects
- static ArrayList proxyClients = new ArrayList();
+ static ArrayList<ProxyClientConnection> proxyClients = new ArrayList<ProxyClientConnection>();
static SimpleTCPIPServer proxyServer = null;
static String serverName = null;
diff --git a/source/com/c2kernel/entity/proxy/ItemProxy.java b/source/com/c2kernel/entity/proxy/ItemProxy.java index e816a53..702dd26 100755..100644 --- a/source/com/c2kernel/entity/proxy/ItemProxy.java +++ b/source/com/c2kernel/entity/proxy/ItemProxy.java @@ -152,7 +152,7 @@ public class ItemProxy extends EntityProxy /**************************************************************************
*
**************************************************************************/
- private ArrayList getJobList(int agentId, boolean filter)
+ private ArrayList<Job> getJobList(int agentId, boolean filter)
throws AccessRightsException,
ObjectNotFoundException,
PersistencyException
@@ -163,14 +163,13 @@ public class ItemProxy extends EntityProxy thisJobList = (JobArrayList)CastorXMLUtility.unmarshall(jobs);
}
catch (Exception e) {
- Logger.error("Exception::ItemProxy::getJobList() - Cannot unmarshall the jobs");
Logger.error(e);
- return new ArrayList();
+ throw new PersistencyException("Exception::ItemProxy::getJobList() - Cannot unmarshall the jobs", null);
}
return thisJobList.list;
}
- public ArrayList getJobList(AgentProxy agent)
+ public ArrayList<Job> getJobList(AgentProxy agent)
throws AccessRightsException,
ObjectNotFoundException,
PersistencyException
@@ -178,7 +177,7 @@ public class ItemProxy extends EntityProxy return getJobList(agent.getSystemKey());
}
- private ArrayList getJobList(int agentId)
+ private ArrayList<Job> getJobList(int agentId)
throws AccessRightsException,
ObjectNotFoundException,
PersistencyException
@@ -191,9 +190,8 @@ public class ItemProxy extends EntityProxy ObjectNotFoundException,
PersistencyException {
- ArrayList jobList = getJobList(agentId);
- for (Object jobObj : jobList) {
- Job job = (Job)jobObj;
+ ArrayList<Job> jobList = getJobList(agentId);
+ for (Job job : jobList) {
int transition = job.getPossibleTransition();
if (job.getStepName().equals(actName))
if (transition == Transitions.COMPLETE || transition == Transitions.DONE)
diff --git a/source/com/c2kernel/entity/proxy/MemberSubscription.java b/source/com/c2kernel/entity/proxy/MemberSubscription.java index fdd3e96..ba2d725 100755..100644 --- a/source/com/c2kernel/entity/proxy/MemberSubscription.java +++ b/source/com/c2kernel/entity/proxy/MemberSubscription.java @@ -2,7 +2,6 @@ package com.c2kernel.entity.proxy;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.StringTokenizer;
import com.c2kernel.common.ObjectNotFoundException;
@@ -13,8 +12,8 @@ public class MemberSubscription implements Runnable { EntityProxy subject;
String interest;
// keep the subscriber by weak reference, so it is not kept from the garbage collector if no longer used
- WeakReference observerReference;
- ArrayList contents = new ArrayList();
+ WeakReference<EntityProxyObserver> observerReference;
+ ArrayList<String> contents = new ArrayList<String>();
boolean preLoad;
public MemberSubscription(EntityProxy subject, String interest,
@@ -38,13 +37,12 @@ public class MemberSubscription implements Runnable { // fetch contents of path
String children = subject.queryData(interest+"/all");
StringTokenizer tok = new StringTokenizer(children, ",");
- ArrayList newContents = new ArrayList();
+ ArrayList<String> newContents = new ArrayList<String>();
while (tok.hasMoreTokens())
newContents.add(tok.nextToken());
// look to see what's new
- for (Iterator iter = newContents.iterator(); iter.hasNext();) {
- String newChild = (String)iter.next();
+ for (String newChild: newContents) {
// load child object
try {
@@ -61,8 +59,7 @@ public class MemberSubscription implements Runnable { }
}
// report what's left in old contents as deleted
- for (Iterator iter = contents.iterator(); iter.hasNext();) {
- String oldChild = (String)iter.next();
+ for (String oldChild: contents) {
observer.remove(interest+"/"+oldChild);
}
//replace contents arraylist
@@ -110,7 +107,7 @@ public class MemberSubscription implements Runnable { }
public void setObserver(EntityProxyObserver observer) {
- observerReference = new WeakReference(observer);
+ observerReference = new WeakReference<EntityProxyObserver>(observer);
}
public EntityProxyObserver getObserver() {
diff --git a/source/com/c2kernel/entity/proxy/ProxyClientConnection.java b/source/com/c2kernel/entity/proxy/ProxyClientConnection.java index 46f1e3d..f041012 100755..100644 --- a/source/com/c2kernel/entity/proxy/ProxyClientConnection.java +++ b/source/com/c2kernel/entity/proxy/ProxyClientConnection.java @@ -28,7 +28,7 @@ public class ProxyClientConnection implements SocketHandler { Socket clientSocket = null;
static int clientId = -1;
int thisClientId;
- ArrayList sysKeys;
+ ArrayList<Integer> sysKeys;
PrintWriter response;
BufferedReader request;
boolean closing = false;
@@ -55,7 +55,7 @@ public class ProxyClientConnection implements SocketHandler { newSocket.setSoTimeout(500);
clientSocket = newSocket;
response = new PrintWriter(clientSocket.getOutputStream(), true);
- sysKeys = new ArrayList();
+ sysKeys = new ArrayList<Integer>();
} catch (SocketException ex) {
Logger.msg("Could not set socket timeout:");
Logger.error(ex);
|
