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