Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
Ray Milkey | 34c9590 | 2015-04-15 09:47:53 -0700 | [diff] [blame] | 2 | * Copyright 2014-2015 Open Networking Laboratory |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.resource.impl; |
Toshio Koide | 50df38d | 2014-10-23 10:36:51 -0700 | [diff] [blame] | 17 | |
Sho SHIMIZU | 716c8e9 | 2015-07-02 11:35:34 -0700 | [diff] [blame] | 18 | import com.google.common.collect.Sets; |
Toshio Koide | 50df38d | 2014-10-23 10:36:51 -0700 | [diff] [blame] | 19 | import org.apache.felix.scr.annotations.Activate; |
| 20 | import org.apache.felix.scr.annotations.Component; |
| 21 | import org.apache.felix.scr.annotations.Deactivate; |
Toshio Koide | 106d449 | 2014-10-28 11:22:02 -0700 | [diff] [blame] | 22 | import org.apache.felix.scr.annotations.Reference; |
| 23 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
Toshio Koide | 50df38d | 2014-10-23 10:36:51 -0700 | [diff] [blame] | 24 | import org.apache.felix.scr.annotations.Service; |
Changhoon Yoon | 541ef71 | 2015-05-23 17:18:34 +0900 | [diff] [blame] | 25 | import org.onosproject.core.Permission; |
Simon Hunt | ff66374 | 2015-05-14 13:33:05 -0700 | [diff] [blame] | 26 | import org.onosproject.event.ListenerRegistry; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 27 | import org.onosproject.event.EventDeliveryService; |
| 28 | import org.onosproject.net.Link; |
| 29 | import org.onosproject.net.intent.IntentId; |
Brian O'Connor | 6de2e20 | 2015-05-21 14:30:41 -0700 | [diff] [blame] | 30 | import org.onosproject.net.resource.link.BandwidthResourceAllocation; |
| 31 | import org.onosproject.net.resource.link.BandwidthResourceRequest; |
| 32 | import org.onosproject.net.resource.link.DefaultLinkResourceAllocations; |
| 33 | import org.onosproject.net.resource.link.LambdaResource; |
| 34 | import org.onosproject.net.resource.link.LambdaResourceAllocation; |
| 35 | import org.onosproject.net.resource.link.LambdaResourceRequest; |
| 36 | import org.onosproject.net.resource.link.LinkResourceAllocations; |
| 37 | import org.onosproject.net.resource.link.LinkResourceEvent; |
| 38 | import org.onosproject.net.resource.link.LinkResourceListener; |
| 39 | import org.onosproject.net.resource.link.LinkResourceRequest; |
| 40 | import org.onosproject.net.resource.link.LinkResourceService; |
| 41 | import org.onosproject.net.resource.link.LinkResourceStore; |
| 42 | import org.onosproject.net.resource.link.LinkResourceStoreDelegate; |
| 43 | import org.onosproject.net.resource.link.MplsLabel; |
| 44 | import org.onosproject.net.resource.link.MplsLabelResourceAllocation; |
| 45 | import org.onosproject.net.resource.link.MplsLabelResourceRequest; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 46 | import org.onosproject.net.resource.ResourceAllocation; |
| 47 | import org.onosproject.net.resource.ResourceRequest; |
| 48 | import org.onosproject.net.resource.ResourceType; |
Toshio Koide | 50df38d | 2014-10-23 10:36:51 -0700 | [diff] [blame] | 49 | import org.slf4j.Logger; |
| 50 | |
Marc De Leenheer | 8b3e80b | 2015-03-06 14:27:03 -0800 | [diff] [blame] | 51 | import java.util.Collections; |
| 52 | import java.util.HashMap; |
| 53 | import java.util.HashSet; |
| 54 | import java.util.Iterator; |
| 55 | import java.util.Map; |
| 56 | import java.util.Set; |
| 57 | |
| 58 | import static com.google.common.base.Preconditions.checkArgument; |
| 59 | import static com.google.common.base.Preconditions.checkNotNull; |
| 60 | import static org.slf4j.LoggerFactory.getLogger; |
Changhoon Yoon | 541ef71 | 2015-05-23 17:18:34 +0900 | [diff] [blame] | 61 | import static org.onosproject.security.AppGuard.checkPermission; |
| 62 | |
Marc De Leenheer | 8b3e80b | 2015-03-06 14:27:03 -0800 | [diff] [blame] | 63 | |
Toshio Koide | 50df38d | 2014-10-23 10:36:51 -0700 | [diff] [blame] | 64 | /** |
| 65 | * Provides basic implementation of link resources allocation. |
| 66 | */ |
| 67 | @Component(immediate = true) |
| 68 | @Service |
| 69 | public class LinkResourceManager implements LinkResourceService { |
| 70 | |
| 71 | private final Logger log = getLogger(getClass()); |
| 72 | |
Simon Hunt | ff66374 | 2015-05-14 13:33:05 -0700 | [diff] [blame] | 73 | protected final ListenerRegistry<LinkResourceEvent, LinkResourceListener> |
| 74 | listenerRegistry = new ListenerRegistry<>(); |
Ray Milkey | e97ede9 | 2014-11-20 10:43:12 -0800 | [diff] [blame] | 75 | |
Toshio Koide | 106d449 | 2014-10-28 11:22:02 -0700 | [diff] [blame] | 76 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 77 | private LinkResourceStore store; |
Ray Milkey | caa450b | 2014-10-29 15:54:24 -0700 | [diff] [blame] | 78 | |
Ray Milkey | e97ede9 | 2014-11-20 10:43:12 -0800 | [diff] [blame] | 79 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 80 | protected EventDeliveryService eventDispatcher; |
| 81 | |
Toshio Koide | 50df38d | 2014-10-23 10:36:51 -0700 | [diff] [blame] | 82 | @Activate |
| 83 | public void activate() { |
Ray Milkey | e97ede9 | 2014-11-20 10:43:12 -0800 | [diff] [blame] | 84 | eventDispatcher.addSink(LinkResourceEvent.class, listenerRegistry); |
Toshio Koide | 50df38d | 2014-10-23 10:36:51 -0700 | [diff] [blame] | 85 | log.info("Started"); |
| 86 | } |
| 87 | |
| 88 | @Deactivate |
| 89 | public void deactivate() { |
| 90 | log.info("Stopped"); |
| 91 | } |
| 92 | |
Toshio Koide | 106d449 | 2014-10-28 11:22:02 -0700 | [diff] [blame] | 93 | /** |
| 94 | * Returns available lambdas on specified link. |
| 95 | * |
| 96 | * @param link the link |
| 97 | * @return available lambdas on specified link |
| 98 | */ |
Sho SHIMIZU | 94b7ff4 | 2015-05-06 17:51:49 -0700 | [diff] [blame] | 99 | private Set<LambdaResource> getAvailableLambdas(Link link) { |
Toshio Koide | 106d449 | 2014-10-28 11:22:02 -0700 | [diff] [blame] | 100 | checkNotNull(link); |
| 101 | Set<ResourceAllocation> resAllocs = store.getFreeResources(link); |
| 102 | if (resAllocs == null) { |
| 103 | return Collections.emptySet(); |
| 104 | } |
Sho SHIMIZU | 94b7ff4 | 2015-05-06 17:51:49 -0700 | [diff] [blame] | 105 | Set<LambdaResource> lambdas = new HashSet<>(); |
Toshio Koide | 106d449 | 2014-10-28 11:22:02 -0700 | [diff] [blame] | 106 | for (ResourceAllocation res : resAllocs) { |
| 107 | if (res.type() == ResourceType.LAMBDA) { |
| 108 | lambdas.add(((LambdaResourceAllocation) res).lambda()); |
| 109 | } |
| 110 | } |
| 111 | return lambdas; |
Toshio Koide | 9be539e | 2014-10-23 18:43:30 -0700 | [diff] [blame] | 112 | } |
| 113 | |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 114 | |
Toshio Koide | 106d449 | 2014-10-28 11:22:02 -0700 | [diff] [blame] | 115 | /** |
| 116 | * Returns available lambdas on specified links. |
| 117 | * |
| 118 | * @param links the links |
| 119 | * @return available lambdas on specified links |
| 120 | */ |
Sho SHIMIZU | 94b7ff4 | 2015-05-06 17:51:49 -0700 | [diff] [blame] | 121 | private Iterable<LambdaResource> getAvailableLambdas(Iterable<Link> links) { |
Toshio Koide | 106d449 | 2014-10-28 11:22:02 -0700 | [diff] [blame] | 122 | checkNotNull(links); |
| 123 | Iterator<Link> i = links.iterator(); |
| 124 | checkArgument(i.hasNext()); |
Sho SHIMIZU | 94b7ff4 | 2015-05-06 17:51:49 -0700 | [diff] [blame] | 125 | Set<LambdaResource> lambdas = new HashSet<>(getAvailableLambdas(i.next())); |
Toshio Koide | 106d449 | 2014-10-28 11:22:02 -0700 | [diff] [blame] | 126 | while (i.hasNext()) { |
| 127 | lambdas.retainAll(getAvailableLambdas(i.next())); |
| 128 | } |
| 129 | return lambdas; |
| 130 | } |
Ray Milkey | caa450b | 2014-10-29 15:54:24 -0700 | [diff] [blame] | 131 | |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 132 | |
| 133 | /** |
| 134 | * Returns available MPLS label on specified link. |
| 135 | * |
| 136 | * @param link the link |
| 137 | * @return available MPLS labels on specified link |
| 138 | */ |
| 139 | private Iterable<MplsLabel> getAvailableMplsLabels(Link link) { |
| 140 | Set<ResourceAllocation> resAllocs = store.getFreeResources(link); |
| 141 | if (resAllocs == null) { |
| 142 | return Collections.emptySet(); |
| 143 | } |
| 144 | Set<MplsLabel> mplsLabels = new HashSet<>(); |
| 145 | for (ResourceAllocation res : resAllocs) { |
| 146 | if (res.type() == ResourceType.MPLS_LABEL) { |
| 147 | |
| 148 | mplsLabels.add(((MplsLabelResourceAllocation) res).mplsLabel()); |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | return mplsLabels; |
| 153 | } |
| 154 | |
Toshio Koide | 50df38d | 2014-10-23 10:36:51 -0700 | [diff] [blame] | 155 | @Override |
| 156 | public LinkResourceAllocations requestResources(LinkResourceRequest req) { |
Changhoon Yoon | 541ef71 | 2015-05-23 17:18:34 +0900 | [diff] [blame] | 157 | checkPermission(Permission.LINK_WRITE); |
| 158 | |
Toshio Koide | 106d449 | 2014-10-28 11:22:02 -0700 | [diff] [blame] | 159 | // TODO Concatenate multiple bandwidth requests. |
| 160 | // TODO Support multiple lambda resource requests. |
| 161 | // TODO Throw appropriate exception. |
Toshio Koide | 106d449 | 2014-10-28 11:22:02 -0700 | [diff] [blame] | 162 | Set<ResourceAllocation> allocs = new HashSet<>(); |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 163 | Map<Link, Set<ResourceAllocation>> allocsPerLink = new HashMap<>(); |
Toshio Koide | 9be539e | 2014-10-23 18:43:30 -0700 | [diff] [blame] | 164 | for (ResourceRequest r : req.resources()) { |
Toshio Koide | ca0fcff | 2014-10-23 14:08:36 -0700 | [diff] [blame] | 165 | switch (r.type()) { |
| 166 | case BANDWIDTH: |
Toshio Koide | ca0fcff | 2014-10-23 14:08:36 -0700 | [diff] [blame] | 167 | BandwidthResourceRequest br = (BandwidthResourceRequest) r; |
Toshio Koide | 106d449 | 2014-10-28 11:22:02 -0700 | [diff] [blame] | 168 | allocs.add(new BandwidthResourceAllocation(br.bandwidth())); |
Toshio Koide | ca0fcff | 2014-10-23 14:08:36 -0700 | [diff] [blame] | 169 | break; |
| 170 | case LAMBDA: |
Sho SHIMIZU | 94b7ff4 | 2015-05-06 17:51:49 -0700 | [diff] [blame] | 171 | Iterator<LambdaResource> lambdaIterator = |
Toshio Koide | 106d449 | 2014-10-28 11:22:02 -0700 | [diff] [blame] | 172 | getAvailableLambdas(req.links()).iterator(); |
Toshio Koide | 9be539e | 2014-10-23 18:43:30 -0700 | [diff] [blame] | 173 | if (lambdaIterator.hasNext()) { |
Toshio Koide | 106d449 | 2014-10-28 11:22:02 -0700 | [diff] [blame] | 174 | allocs.add(new LambdaResourceAllocation(lambdaIterator.next())); |
| 175 | } else { |
| 176 | log.info("Failed to allocate lambda resource."); |
| 177 | return null; |
Toshio Koide | 9be539e | 2014-10-23 18:43:30 -0700 | [diff] [blame] | 178 | } |
Toshio Koide | ca0fcff | 2014-10-23 14:08:36 -0700 | [diff] [blame] | 179 | break; |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 180 | case MPLS_LABEL: |
| 181 | for (Link link : req.links()) { |
| 182 | if (allocsPerLink.get(link) == null) { |
| 183 | allocsPerLink.put(link, |
| 184 | new HashSet<ResourceAllocation>()); |
| 185 | } |
| 186 | Iterator<MplsLabel> mplsIter = getAvailableMplsLabels(link) |
| 187 | .iterator(); |
| 188 | if (mplsIter.hasNext()) { |
| 189 | allocsPerLink.get(link) |
| 190 | .add(new MplsLabelResourceAllocation(mplsIter |
| 191 | .next())); |
| 192 | } else { |
| 193 | log.info("Failed to allocate MPLS resource."); |
| 194 | break; |
| 195 | } |
| 196 | } |
| 197 | break; |
Toshio Koide | ca0fcff | 2014-10-23 14:08:36 -0700 | [diff] [blame] | 198 | default: |
| 199 | break; |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | Map<Link, Set<ResourceAllocation>> allocations = new HashMap<>(); |
Toshio Koide | 9be539e | 2014-10-23 18:43:30 -0700 | [diff] [blame] | 204 | for (Link link : req.links()) { |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 205 | allocations.put(link, new HashSet<ResourceAllocation>(allocs)); |
Marc De Leenheer | 8b3e80b | 2015-03-06 14:27:03 -0800 | [diff] [blame] | 206 | Set<ResourceAllocation> linkAllocs = allocsPerLink.get(link); |
| 207 | if (linkAllocs != null) { |
| 208 | allocations.get(link).addAll(linkAllocs); |
| 209 | } |
Toshio Koide | ca0fcff | 2014-10-23 14:08:36 -0700 | [diff] [blame] | 210 | } |
Toshio Koide | 106d449 | 2014-10-28 11:22:02 -0700 | [diff] [blame] | 211 | LinkResourceAllocations result = |
| 212 | new DefaultLinkResourceAllocations(req, allocations); |
| 213 | store.allocateResources(result); |
| 214 | return result; |
| 215 | |
Toshio Koide | 50df38d | 2014-10-23 10:36:51 -0700 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | @Override |
| 219 | public void releaseResources(LinkResourceAllocations allocations) { |
Changhoon Yoon | 541ef71 | 2015-05-23 17:18:34 +0900 | [diff] [blame] | 220 | checkPermission(Permission.LINK_WRITE); |
| 221 | |
Ray Milkey | e97ede9 | 2014-11-20 10:43:12 -0800 | [diff] [blame] | 222 | final LinkResourceEvent event = store.releaseResources(allocations); |
| 223 | if (event != null) { |
| 224 | post(event); |
| 225 | } |
Toshio Koide | 50df38d | 2014-10-23 10:36:51 -0700 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | @Override |
Thomas Vachuska | f997695 | 2014-10-24 11:55:05 -0700 | [diff] [blame] | 229 | public LinkResourceAllocations updateResources(LinkResourceRequest req, |
Toshio Koide | 106d449 | 2014-10-28 11:22:02 -0700 | [diff] [blame] | 230 | LinkResourceAllocations oldAllocations) { |
Changhoon Yoon | 541ef71 | 2015-05-23 17:18:34 +0900 | [diff] [blame] | 231 | checkPermission(Permission.LINK_WRITE); |
| 232 | |
| 233 | releaseResources(oldAllocations); |
weibit | 00c94f5 | 2014-11-16 07:09:05 -0800 | [diff] [blame] | 234 | return requestResources(req); |
Thomas Vachuska | f997695 | 2014-10-24 11:55:05 -0700 | [diff] [blame] | 235 | } |
| 236 | |
| 237 | @Override |
Toshio Koide | 50df38d | 2014-10-23 10:36:51 -0700 | [diff] [blame] | 238 | public Iterable<LinkResourceAllocations> getAllocations() { |
Changhoon Yoon | 541ef71 | 2015-05-23 17:18:34 +0900 | [diff] [blame] | 239 | checkPermission(Permission.LINK_READ); |
| 240 | |
Toshio Koide | 106d449 | 2014-10-28 11:22:02 -0700 | [diff] [blame] | 241 | return store.getAllocations(); |
Toshio Koide | 50df38d | 2014-10-23 10:36:51 -0700 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | @Override |
Toshio Koide | 50df38d | 2014-10-23 10:36:51 -0700 | [diff] [blame] | 245 | public Iterable<LinkResourceAllocations> getAllocations(Link link) { |
Changhoon Yoon | 541ef71 | 2015-05-23 17:18:34 +0900 | [diff] [blame] | 246 | checkPermission(Permission.LINK_READ); |
| 247 | |
Toshio Koide | 106d449 | 2014-10-28 11:22:02 -0700 | [diff] [blame] | 248 | return store.getAllocations(link); |
Toshio Koide | 50df38d | 2014-10-23 10:36:51 -0700 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | @Override |
Toshio Koide | 9be539e | 2014-10-23 18:43:30 -0700 | [diff] [blame] | 252 | public LinkResourceAllocations getAllocations(IntentId intentId) { |
Changhoon Yoon | 541ef71 | 2015-05-23 17:18:34 +0900 | [diff] [blame] | 253 | checkPermission(Permission.LINK_READ); |
| 254 | |
Toshio Koide | 106d449 | 2014-10-28 11:22:02 -0700 | [diff] [blame] | 255 | return store.getAllocations(intentId); |
Toshio Koide | 50df38d | 2014-10-23 10:36:51 -0700 | [diff] [blame] | 256 | } |
| 257 | |
| 258 | @Override |
Toshio Koide | 9be539e | 2014-10-23 18:43:30 -0700 | [diff] [blame] | 259 | public Iterable<ResourceRequest> getAvailableResources(Link link) { |
Changhoon Yoon | 541ef71 | 2015-05-23 17:18:34 +0900 | [diff] [blame] | 260 | checkPermission(Permission.LINK_READ); |
| 261 | |
Toshio Koide | 106d449 | 2014-10-28 11:22:02 -0700 | [diff] [blame] | 262 | Set<ResourceAllocation> freeRes = store.getFreeResources(link); |
| 263 | Set<ResourceRequest> result = new HashSet<>(); |
| 264 | for (ResourceAllocation alloc : freeRes) { |
| 265 | switch (alloc.type()) { |
| 266 | case BANDWIDTH: |
| 267 | result.add(new BandwidthResourceRequest( |
| 268 | ((BandwidthResourceAllocation) alloc).bandwidth())); |
| 269 | break; |
| 270 | case LAMBDA: |
| 271 | result.add(new LambdaResourceRequest()); |
| 272 | break; |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 273 | case MPLS_LABEL: |
| 274 | result.add(new MplsLabelResourceRequest()); |
Sho SHIMIZU | 3fa9e8d | 2015-05-05 11:40:04 -0700 | [diff] [blame] | 275 | break; |
Toshio Koide | 106d449 | 2014-10-28 11:22:02 -0700 | [diff] [blame] | 276 | default: |
| 277 | break; |
| 278 | } |
| 279 | } |
Ray Milkey | caa450b | 2014-10-29 15:54:24 -0700 | [diff] [blame] | 280 | return result; |
Toshio Koide | 50df38d | 2014-10-23 10:36:51 -0700 | [diff] [blame] | 281 | } |
| 282 | |
Thomas Vachuska | f997695 | 2014-10-24 11:55:05 -0700 | [diff] [blame] | 283 | @Override |
weibit | 00c94f5 | 2014-11-16 07:09:05 -0800 | [diff] [blame] | 284 | public Iterable<ResourceRequest> getAvailableResources(Link link, |
Toshio Koide | 106d449 | 2014-10-28 11:22:02 -0700 | [diff] [blame] | 285 | LinkResourceAllocations allocations) { |
Changhoon Yoon | 541ef71 | 2015-05-23 17:18:34 +0900 | [diff] [blame] | 286 | checkPermission(Permission.LINK_READ); |
| 287 | |
weibit | 00c94f5 | 2014-11-16 07:09:05 -0800 | [diff] [blame] | 288 | Set<ResourceAllocation> allocatedRes = allocations.getResourceAllocation(link); |
Sho SHIMIZU | 716c8e9 | 2015-07-02 11:35:34 -0700 | [diff] [blame] | 289 | Set<ResourceRequest> result = Sets.newHashSet(getAvailableResources(link)); |
weibit | 00c94f5 | 2014-11-16 07:09:05 -0800 | [diff] [blame] | 290 | result.addAll(allocatedRes); |
| 291 | return result; |
Thomas Vachuska | f997695 | 2014-10-24 11:55:05 -0700 | [diff] [blame] | 292 | } |
| 293 | |
Ray Milkey | e97ede9 | 2014-11-20 10:43:12 -0800 | [diff] [blame] | 294 | @Override |
| 295 | public void addListener(LinkResourceListener listener) { |
Changhoon Yoon | 541ef71 | 2015-05-23 17:18:34 +0900 | [diff] [blame] | 296 | checkPermission(Permission.LINK_EVENT); |
| 297 | |
Ray Milkey | e97ede9 | 2014-11-20 10:43:12 -0800 | [diff] [blame] | 298 | listenerRegistry.addListener(listener); |
| 299 | } |
| 300 | |
| 301 | @Override |
| 302 | public void removeListener(LinkResourceListener listener) { |
Changhoon Yoon | 541ef71 | 2015-05-23 17:18:34 +0900 | [diff] [blame] | 303 | checkPermission(Permission.LINK_EVENT); |
| 304 | |
Ray Milkey | e97ede9 | 2014-11-20 10:43:12 -0800 | [diff] [blame] | 305 | listenerRegistry.removeListener(listener); |
| 306 | } |
| 307 | |
| 308 | /** |
| 309 | * Posts the specified event to the local event dispatcher. |
| 310 | */ |
| 311 | private void post(LinkResourceEvent event) { |
| 312 | if (event != null) { |
| 313 | eventDispatcher.post(event); |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | /** |
| 318 | * Store delegate to re-post events emitted from the store. |
| 319 | */ |
| 320 | private class InternalStoreDelegate implements LinkResourceStoreDelegate { |
| 321 | @Override |
| 322 | public void notify(LinkResourceEvent event) { |
| 323 | post(event); |
| 324 | } |
| 325 | } |
Toshio Koide | 50df38d | 2014-10-23 10:36:51 -0700 | [diff] [blame] | 326 | } |