The node and field correspond to an object member field that has a @Stateful annotation. This method has to make sense of this and plan out how states should be captured for this field. @param node @param f
(ObjectGraphNode node, Field f)
| 154 | * @param f |
| 155 | */ |
| 156 | private void addStateVariable(ObjectGraphNode node, Field f) { |
| 157 | // if (f == null) { |
| 158 | // System.out.println("State var: "+node.parent.name+"."+node.name+ ">>" + node.index); |
| 159 | // } else { |
| 160 | // System.out.println("State var: "+node.parent.name+"."+node.name+ ">>" + f.getDeclaringClass().getName() + "." + f.getName()); |
| 161 | // } |
| 162 | // For paged memory, video and softswiches we might have to do something |
| 163 | // more sophosticated. |
| 164 | Class type = node.getCurrentValue().getClass(); |
| 165 | if (PagedMemory.class.isAssignableFrom(type)) { |
| 166 | addMemoryPages(node, f); |
| 167 | } else if (Image.class.isAssignableFrom(type)) { |
| 168 | addVideoFrame(node, f); |
| 169 | } else if (List.class.isAssignableFrom(type)) { |
| 170 | List l = (List) node.getCurrentValue(); |
| 171 | Type fieldGenericType = f.getGenericType(); |
| 172 | // Class genericType = Object.class; |
| 173 | // if (fieldGenericType instanceof ParameterizedType) { |
| 174 | // genericType = (Class) ((ParameterizedType) fieldGenericType).getActualTypeArguments()[0]; |
| 175 | // } else { |
| 176 | // System.out.println("NOT PARAMATERIZED!"); |
| 177 | // } |
| 178 | for (int i = 0; i < l.size(); i++) { |
| 179 | if (l.get(i) != null) { |
| 180 | // ObjectGraphNode inode = new ObjectGraphNode(genericType); |
| 181 | Object obj = l.get(i); |
| 182 | if (obj == null) { |
| 183 | continue; |
| 184 | } |
| 185 | ObjectGraphNode inode = new ObjectGraphNode(obj); |
| 186 | // inode.source = new WeakReference(); |
| 187 | inode.parent = node; |
| 188 | inode.name = String.valueOf(i); |
| 189 | inode.index = i; |
| 190 | // Build this recursively because it might be a nested type (e.g. a list of maps) |
| 191 | // If it isn't a nested type then the default case shoud apply. |
| 192 | addStateVariable(inode, null); |
| 193 | } |
| 194 | } |
| 195 | } else if (Map.class.isAssignableFrom(type)) { |
| 196 | // TODO: |
| 197 | // Walk through members of the map, etc. |
| 198 | // This will at least let RamWorks memory pages work with state management |
| 199 | } else { |
| 200 | // This is the default case, just capture the field and move on |
| 201 | allStateVariables.add(node); |
| 202 | node.isPrimitive = f.getType().isPrimitive(); |
| 203 | // Since we can only guess how state changes just assume we have to check for changes every time. |
| 204 | node.forceCheck = true; |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | /** |
| 209 | * Track a stateful video framebuffer. |
no test coverage detected