Hongtao Yin | 36f79aa | 2015-02-14 03:51:39 -0800 | [diff] [blame] | 1 | /* |
| 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 | */ |
Sho SHIMIZU | 6c28f83 | 2015-02-20 16:12:19 -0800 | [diff] [blame] | 16 | package org.onosproject.net.intent.impl.compiler; |
Hongtao Yin | 36f79aa | 2015-02-14 03:51:39 -0800 | [diff] [blame] | 17 | |
| 18 | import com.google.common.collect.Lists; |
| 19 | import org.apache.felix.scr.annotations.Activate; |
| 20 | import org.apache.felix.scr.annotations.Component; |
| 21 | import org.apache.felix.scr.annotations.Deactivate; |
| 22 | import org.onosproject.net.intent.Intent; |
| 23 | import org.onosproject.net.intent.PointToPointIntent; |
| 24 | import org.onosproject.net.intent.TwoWayP2PIntent; |
Brian O'Connor | 6de2e20 | 2015-05-21 14:30:41 -0700 | [diff] [blame] | 25 | import org.onosproject.net.resource.link.LinkResourceAllocations; |
Hongtao Yin | 36f79aa | 2015-02-14 03:51:39 -0800 | [diff] [blame] | 26 | |
| 27 | import java.util.List; |
| 28 | import java.util.Set; |
| 29 | |
| 30 | /** |
| 31 | * A intent compiler for {@link org.onosproject.net.intent.TwoWayP2PIntent}. |
| 32 | */ |
| 33 | @Component(immediate = true) |
| 34 | public class TwoWayP2PIntentCompiler |
| 35 | extends ConnectivityIntentCompiler<TwoWayP2PIntent> { |
| 36 | |
| 37 | @Activate |
| 38 | public void activate() { |
| 39 | intentManager.registerCompiler(TwoWayP2PIntent.class, this); |
| 40 | } |
| 41 | |
| 42 | @Deactivate |
| 43 | public void deactivate() { |
| 44 | intentManager.unregisterCompiler(TwoWayP2PIntent.class); |
| 45 | } |
| 46 | |
| 47 | @Override |
| 48 | public List<Intent> compile(TwoWayP2PIntent intent, List<Intent> installable, |
| 49 | Set<LinkResourceAllocations> resources) { |
| 50 | return Lists.newArrayList( |
Ray Milkey | 3e3ec5f | 2015-03-17 17:00:38 -0700 | [diff] [blame] | 51 | PointToPointIntent.builder() |
| 52 | .appId(intent.appId()) |
| 53 | .key(intent.key()) |
| 54 | .selector(intent.selector()) |
| 55 | .treatment(intent.treatment()) |
| 56 | .ingressPoint(intent.one()) |
| 57 | .egressPoint(intent.two()) |
| 58 | .constraints(intent.constraints()) |
| 59 | .priority(intent.priority()) |
| 60 | .build(), |
| 61 | PointToPointIntent.builder() |
| 62 | .appId(intent.appId()) |
| 63 | .key(intent.key()) |
| 64 | .selector(intent.selector()) |
| 65 | .treatment(intent.treatment()) |
| 66 | .ingressPoint(intent.two()) |
| 67 | .egressPoint(intent.one()) |
| 68 | .constraints(intent.constraints()) |
| 69 | .priority(intent.priority()) |
| 70 | .build()); |
Hongtao Yin | 36f79aa | 2015-02-14 03:51:39 -0800 | [diff] [blame] | 71 | } |
| 72 | } |