Hongtao Yin | 36f79aa | 2015-02-14 03:51:39 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Hongtao Yin | 36f79aa | 2015-02-14 03:51:39 -0800 | [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 | */ |
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; |
Hongtao Yin | 36f79aa | 2015-02-14 03:51:39 -0800 | [diff] [blame] | 25 | |
| 26 | import java.util.List; |
Hongtao Yin | 36f79aa | 2015-02-14 03:51:39 -0800 | [diff] [blame] | 27 | |
| 28 | /** |
| 29 | * A intent compiler for {@link org.onosproject.net.intent.TwoWayP2PIntent}. |
| 30 | */ |
| 31 | @Component(immediate = true) |
| 32 | public class TwoWayP2PIntentCompiler |
| 33 | extends ConnectivityIntentCompiler<TwoWayP2PIntent> { |
| 34 | |
| 35 | @Activate |
| 36 | public void activate() { |
| 37 | intentManager.registerCompiler(TwoWayP2PIntent.class, this); |
| 38 | } |
| 39 | |
| 40 | @Deactivate |
| 41 | public void deactivate() { |
| 42 | intentManager.unregisterCompiler(TwoWayP2PIntent.class); |
| 43 | } |
| 44 | |
| 45 | @Override |
Sho SHIMIZU | ec07ffd | 2016-02-22 20:45:21 -0800 | [diff] [blame] | 46 | public List<Intent> compile(TwoWayP2PIntent intent, List<Intent> installable) { |
Hongtao Yin | 36f79aa | 2015-02-14 03:51:39 -0800 | [diff] [blame] | 47 | return Lists.newArrayList( |
Ray Milkey | 3e3ec5f | 2015-03-17 17:00:38 -0700 | [diff] [blame] | 48 | PointToPointIntent.builder() |
| 49 | .appId(intent.appId()) |
| 50 | .key(intent.key()) |
| 51 | .selector(intent.selector()) |
| 52 | .treatment(intent.treatment()) |
| 53 | .ingressPoint(intent.one()) |
| 54 | .egressPoint(intent.two()) |
| 55 | .constraints(intent.constraints()) |
| 56 | .priority(intent.priority()) |
| 57 | .build(), |
| 58 | PointToPointIntent.builder() |
| 59 | .appId(intent.appId()) |
| 60 | .key(intent.key()) |
| 61 | .selector(intent.selector()) |
| 62 | .treatment(intent.treatment()) |
| 63 | .ingressPoint(intent.two()) |
| 64 | .egressPoint(intent.one()) |
| 65 | .constraints(intent.constraints()) |
| 66 | .priority(intent.priority()) |
| 67 | .build()); |
Hongtao Yin | 36f79aa | 2015-02-14 03:51:39 -0800 | [diff] [blame] | 68 | } |
| 69 | } |