blob: f6dbc603b020a4e00bd3eff501f734a85de60a5a [file] [log] [blame]
Marc De Leenheer1afa2a02015-05-13 09:18:07 -07001/*
2 * Copyright 2015 Open Networking Laboratory
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 */
16package org.onosproject.net.resource.impl;
17
18import org.apache.felix.scr.annotations.Activate;
19import org.apache.felix.scr.annotations.Component;
20import org.apache.felix.scr.annotations.Deactivate;
21import org.apache.felix.scr.annotations.Reference;
22import org.apache.felix.scr.annotations.ReferenceCardinality;
23import org.apache.felix.scr.annotations.Service;
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070024import org.onosproject.net.intent.IntentId;
Brian O'Connor6de2e202015-05-21 14:30:41 -070025import org.onosproject.net.resource.device.DeviceResourceService;
26import org.onosproject.net.resource.device.DeviceResourceStore;
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070027import org.slf4j.Logger;
28
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070029import java.util.Set;
30
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070031import static org.slf4j.LoggerFactory.getLogger;
32
33/**
34 * Provides basic implementation of device resources allocation.
35 */
36@Component(immediate = true)
37@Service
38public class DeviceResourceManager implements DeviceResourceService {
39
40 private final Logger log = getLogger(getClass());
41
42 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
43 private DeviceResourceStore store;
44
45 @Activate
46 public void activate() {
47 log.info("Started");
48 }
49
50 @Deactivate
51 public void deactivate() {
52 log.info("Stopped");
53 }
54
55 @Override
Marc De Leenheer9f7d1892015-05-30 13:22:24 -070056 public void releaseMapping(IntentId intentId) {
57 store.releaseMapping(intentId);
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070058 }
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070059
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070060 @Override
61 public boolean requestMapping(IntentId keyIntentId, IntentId valIntentId) {
62 return store.allocateMapping(keyIntentId, valIntentId);
63 }
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070064
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070065 @Override
66 public Set<IntentId> getMapping(IntentId intentId) {
67 return store.getMapping(intentId);
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070068 }
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070069}