Thomas Vachuska | 7d693f5 | 2014-10-21 19:17:57 -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 | 7d693f5 | 2014-10-21 19:17:57 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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 |
Thomas Vachuska | 7d693f5 | 2014-10-21 19:17:57 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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. |
Thomas Vachuska | 7d693f5 | 2014-10-21 19:17:57 -0700 | [diff] [blame] | 15 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.cli.net; |
Ray Milkey | 9fdf1ea | 2014-10-21 09:48:02 -0700 | [diff] [blame] | 17 | |
Jonathan Hart | 6e94828 | 2014-11-17 22:50:42 -0800 | [diff] [blame] | 18 | import static com.google.common.base.Strings.isNullOrEmpty; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 19 | import static org.onosproject.net.flow.DefaultTrafficTreatment.builder; |
Jonathan Hart | 6e94828 | 2014-11-17 22:50:42 -0800 | [diff] [blame] | 20 | |
Ray Milkey | 460f402 | 2014-11-05 15:41:43 -0800 | [diff] [blame] | 21 | import java.util.LinkedList; |
| 22 | import java.util.List; |
| 23 | |
Ray Milkey | 9fdf1ea | 2014-10-21 09:48:02 -0700 | [diff] [blame] | 24 | import org.apache.karaf.shell.commands.Option; |
Charles M.C. Chan | e9c8bbc | 2015-04-24 05:03:02 +0800 | [diff] [blame^] | 25 | import org.onlab.packet.Ip6Address; |
| 26 | import org.onlab.packet.IpAddress; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 27 | import org.onosproject.cli.AbstractShellCommand; |
Ray Milkey | 95c5087 | 2015-04-14 14:32:31 -0700 | [diff] [blame] | 28 | import org.onosproject.core.ApplicationId; |
| 29 | import org.onosproject.core.CoreService; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 30 | import org.onosproject.net.Link; |
| 31 | import org.onosproject.net.flow.DefaultTrafficSelector; |
| 32 | import org.onosproject.net.flow.TrafficSelector; |
| 33 | import org.onosproject.net.flow.TrafficTreatment; |
| 34 | import org.onosproject.net.intent.Constraint; |
Ray Milkey | c24cde3 | 2015-03-10 18:20:18 -0700 | [diff] [blame] | 35 | import org.onosproject.net.intent.Intent; |
Ray Milkey | 5b3717e | 2015-02-05 11:44:08 -0800 | [diff] [blame] | 36 | import org.onosproject.net.intent.Key; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 37 | import org.onosproject.net.intent.constraint.BandwidthConstraint; |
| 38 | import org.onosproject.net.intent.constraint.LambdaConstraint; |
| 39 | import org.onosproject.net.intent.constraint.LinkTypeConstraint; |
| 40 | import org.onosproject.net.resource.Bandwidth; |
Jonathan Hart | 5f7097e | 2014-11-11 11:50:28 -0800 | [diff] [blame] | 41 | import org.onlab.packet.IpPrefix; |
Ray Milkey | 9fdf1ea | 2014-10-21 09:48:02 -0700 | [diff] [blame] | 42 | import org.onlab.packet.MacAddress; |
| 43 | |
Ray Milkey | 9fdf1ea | 2014-10-21 09:48:02 -0700 | [diff] [blame] | 44 | /** |
| 45 | * Base class for command line operations for connectivity based intents. |
| 46 | */ |
| 47 | public abstract class ConnectivityIntentCommand extends AbstractShellCommand { |
| 48 | |
Jonathan Hart | 2c25e36 | 2014-11-17 18:14:19 -0800 | [diff] [blame] | 49 | // Selectors |
Ray Milkey | 9fdf1ea | 2014-10-21 09:48:02 -0700 | [diff] [blame] | 50 | @Option(name = "-s", aliases = "--ethSrc", description = "Source MAC Address", |
| 51 | required = false, multiValued = false) |
| 52 | private String srcMacString = null; |
| 53 | |
| 54 | @Option(name = "-d", aliases = "--ethDst", description = "Destination MAC Address", |
| 55 | required = false, multiValued = false) |
| 56 | private String dstMacString = null; |
| 57 | |
| 58 | @Option(name = "-t", aliases = "--ethType", description = "Ethernet Type", |
| 59 | required = false, multiValued = false) |
Ray Milkey | 04c7832 | 2015-01-21 14:57:58 -0800 | [diff] [blame] | 60 | private String ethTypeString = null; |
Ray Milkey | 9fdf1ea | 2014-10-21 09:48:02 -0700 | [diff] [blame] | 61 | |
Jonathan Hart | 5f7097e | 2014-11-11 11:50:28 -0800 | [diff] [blame] | 62 | @Option(name = "--ipProto", description = "IP Protocol", |
| 63 | required = false, multiValued = false) |
| 64 | private String ipProtoString = null; |
| 65 | |
Pavlin Radoslavov | 6ba7efc | 2015-03-20 16:26:10 -0700 | [diff] [blame] | 66 | @Option(name = "--ipSrc", description = "Source IP Prefix", |
Jonathan Hart | 5f7097e | 2014-11-11 11:50:28 -0800 | [diff] [blame] | 67 | required = false, multiValued = false) |
| 68 | private String srcIpString = null; |
| 69 | |
Pavlin Radoslavov | 6ba7efc | 2015-03-20 16:26:10 -0700 | [diff] [blame] | 70 | @Option(name = "--ipDst", description = "Destination IP Prefix", |
Jonathan Hart | 5f7097e | 2014-11-11 11:50:28 -0800 | [diff] [blame] | 71 | required = false, multiValued = false) |
| 72 | private String dstIpString = null; |
| 73 | |
Charles M.C. Chan | e9c8bbc | 2015-04-24 05:03:02 +0800 | [diff] [blame^] | 74 | @Option(name = "--fLabel", description = "IPv6 Flow Label", |
| 75 | required = false, multiValued = false) |
| 76 | private String fLabelString = null; |
| 77 | |
| 78 | @Option(name = "--icmp6Type", description = "ICMPv6 Type", |
| 79 | required = false, multiValued = false) |
| 80 | private String icmp6TypeString = null; |
| 81 | |
| 82 | @Option(name = "--icmp6Code", description = "ICMPv6 Code", |
| 83 | required = false, multiValued = false) |
| 84 | private String icmp6CodeString = null; |
| 85 | |
| 86 | @Option(name = "--ndTarget", description = "IPv6 Neighbor Discovery Target Address", |
| 87 | required = false, multiValued = false) |
| 88 | private String ndTargetString = null; |
| 89 | |
| 90 | @Option(name = "--ndSLL", description = "IPv6 Neighbor Discovery Source Link-Layer", |
| 91 | required = false, multiValued = false) |
| 92 | private String ndSLLString = null; |
| 93 | |
| 94 | @Option(name = "--ndTLL", description = "IPv6 Neighbor Discovery Target Link-Layer", |
| 95 | required = false, multiValued = false) |
| 96 | private String ndTLLString = null; |
| 97 | |
Jonathan Hart | 5f7097e | 2014-11-11 11:50:28 -0800 | [diff] [blame] | 98 | @Option(name = "--tcpSrc", description = "Source TCP Port", |
| 99 | required = false, multiValued = false) |
| 100 | private String srcTcpString = null; |
| 101 | |
| 102 | @Option(name = "--tcpDst", description = "Destination TCP Port", |
| 103 | required = false, multiValued = false) |
| 104 | private String dstTcpString = null; |
| 105 | |
Charles M.C. Chan | e9c8bbc | 2015-04-24 05:03:02 +0800 | [diff] [blame^] | 106 | @Option(name = "--extHdr", description = "IPv6 Extension Header Pseudo-field", |
| 107 | required = false, multiValued = false) |
| 108 | private String extHdrString = null; |
| 109 | |
Ray Milkey | 460f402 | 2014-11-05 15:41:43 -0800 | [diff] [blame] | 110 | @Option(name = "-b", aliases = "--bandwidth", description = "Bandwidth", |
| 111 | required = false, multiValued = false) |
Ray Milkey | 04c7832 | 2015-01-21 14:57:58 -0800 | [diff] [blame] | 112 | private String bandwidthString = null; |
Ray Milkey | 460f402 | 2014-11-05 15:41:43 -0800 | [diff] [blame] | 113 | |
| 114 | @Option(name = "-l", aliases = "--lambda", description = "Lambda", |
| 115 | required = false, multiValued = false) |
| 116 | private boolean lambda = false; |
| 117 | |
Ray Milkey | 95c5087 | 2015-04-14 14:32:31 -0700 | [diff] [blame] | 118 | @Option(name = "-a", aliases = "--appId", description = "Application Id", |
| 119 | required = false, multiValued = false) |
| 120 | private String appId = null; |
| 121 | |
Ray Milkey | 5b3717e | 2015-02-05 11:44:08 -0800 | [diff] [blame] | 122 | @Option(name = "-k", aliases = "--key", description = "Intent Key", |
| 123 | required = false, multiValued = false) |
| 124 | private String intentKey = null; |
| 125 | |
Jonathan Hart | 2c25e36 | 2014-11-17 18:14:19 -0800 | [diff] [blame] | 126 | |
| 127 | // Treatments |
| 128 | @Option(name = "--setEthSrc", description = "Rewrite Source MAC Address", |
| 129 | required = false, multiValued = false) |
| 130 | private String setEthSrcString = null; |
| 131 | |
| 132 | @Option(name = "--setEthDst", description = "Rewrite Destination MAC Address", |
| 133 | required = false, multiValued = false) |
| 134 | private String setEthDstString = null; |
| 135 | |
Charles M.C. Chan | e9c8bbc | 2015-04-24 05:03:02 +0800 | [diff] [blame^] | 136 | @Option(name = "--setIpSrc", description = "Rewrite Source IP Address", |
| 137 | required = false, multiValued = false) |
| 138 | private String setIpSrcString = null; |
| 139 | |
| 140 | @Option(name = "--setIpDst", description = "Rewrite Destination IP Address", |
| 141 | required = false, multiValued = false) |
| 142 | private String setIpDstString = null; |
| 143 | |
| 144 | |
Ray Milkey | c24cde3 | 2015-03-10 18:20:18 -0700 | [diff] [blame] | 145 | // Priorities |
| 146 | @Option(name = "-p", aliases = "--priority", description = "Priority", |
| 147 | required = false, multiValued = false) |
| 148 | private int priority = Intent.DEFAULT_INTENT_PRIORITY; |
| 149 | |
Ray Milkey | 9fdf1ea | 2014-10-21 09:48:02 -0700 | [diff] [blame] | 150 | /** |
| 151 | * Constructs a traffic selector based on the command line arguments |
| 152 | * presented to the command. |
Yuta HIGUCHI | 5c94727 | 2014-11-03 21:39:21 -0800 | [diff] [blame] | 153 | * @return traffic selector |
Ray Milkey | 9fdf1ea | 2014-10-21 09:48:02 -0700 | [diff] [blame] | 154 | */ |
| 155 | protected TrafficSelector buildTrafficSelector() { |
Pavlin Radoslavov | 6ba7efc | 2015-03-20 16:26:10 -0700 | [diff] [blame] | 156 | IpPrefix srcIpPrefix = null; |
| 157 | IpPrefix dstIpPrefix = null; |
Ray Milkey | caa450b | 2014-10-29 15:54:24 -0700 | [diff] [blame] | 158 | |
Pavlin Radoslavov | 6ba7efc | 2015-03-20 16:26:10 -0700 | [diff] [blame] | 159 | TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder(); |
| 160 | |
| 161 | if (!isNullOrEmpty(srcIpString)) { |
| 162 | srcIpPrefix = IpPrefix.valueOf(srcIpString); |
| 163 | if (srcIpPrefix.isIp4()) { |
| 164 | selectorBuilder.matchIPSrc(srcIpPrefix); |
| 165 | } else { |
| 166 | selectorBuilder.matchIPv6Src(srcIpPrefix); |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | if (!isNullOrEmpty(dstIpString)) { |
| 171 | dstIpPrefix = IpPrefix.valueOf(dstIpString); |
| 172 | if (dstIpPrefix.isIp4()) { |
| 173 | selectorBuilder.matchIPDst(dstIpPrefix); |
| 174 | } else { |
| 175 | selectorBuilder.matchIPv6Dst(dstIpPrefix); |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | if ((srcIpPrefix != null) && (dstIpPrefix != null) && |
| 180 | (srcIpPrefix.version() != dstIpPrefix.version())) { |
| 181 | // ERROR: IP src/dst version mismatch |
| 182 | throw new IllegalArgumentException( |
| 183 | "IP source and destination version mismatch"); |
| 184 | } |
| 185 | |
| 186 | // |
| 187 | // Set the default EthType based on the IP version if the matching |
| 188 | // source or destination IP prefixes. |
| 189 | // |
| 190 | short ethType = EthType.IPV4.value(); |
| 191 | if ((srcIpPrefix != null) && srcIpPrefix.isIp6()) { |
| 192 | ethType = EthType.IPV6.value(); |
| 193 | } |
| 194 | if ((dstIpPrefix != null) && dstIpPrefix.isIp6()) { |
| 195 | ethType = EthType.IPV6.value(); |
| 196 | } |
Ray Milkey | 460f402 | 2014-11-05 15:41:43 -0800 | [diff] [blame] | 197 | if (!isNullOrEmpty(ethTypeString)) { |
Jonathan Hart | 6e94828 | 2014-11-17 22:50:42 -0800 | [diff] [blame] | 198 | ethType = EthType.parseFromString(ethTypeString); |
Ray Milkey | 9fdf1ea | 2014-10-21 09:48:02 -0700 | [diff] [blame] | 199 | } |
| 200 | selectorBuilder.matchEthType(ethType); |
| 201 | |
Ray Milkey | 460f402 | 2014-11-05 15:41:43 -0800 | [diff] [blame] | 202 | if (!isNullOrEmpty(srcMacString)) { |
Ray Milkey | 9fdf1ea | 2014-10-21 09:48:02 -0700 | [diff] [blame] | 203 | selectorBuilder.matchEthSrc(MacAddress.valueOf(srcMacString)); |
| 204 | } |
| 205 | |
Ray Milkey | 460f402 | 2014-11-05 15:41:43 -0800 | [diff] [blame] | 206 | if (!isNullOrEmpty(dstMacString)) { |
Ray Milkey | 9fdf1ea | 2014-10-21 09:48:02 -0700 | [diff] [blame] | 207 | selectorBuilder.matchEthDst(MacAddress.valueOf(dstMacString)); |
| 208 | } |
| 209 | |
Jonathan Hart | 5f7097e | 2014-11-11 11:50:28 -0800 | [diff] [blame] | 210 | if (!isNullOrEmpty(ipProtoString)) { |
Jonathan Hart | 6e94828 | 2014-11-17 22:50:42 -0800 | [diff] [blame] | 211 | short ipProtoShort = IpProtocol.parseFromString(ipProtoString); |
| 212 | selectorBuilder.matchIPProtocol((byte) ipProtoShort); |
Jonathan Hart | 5f7097e | 2014-11-11 11:50:28 -0800 | [diff] [blame] | 213 | } |
| 214 | |
Charles M.C. Chan | e9c8bbc | 2015-04-24 05:03:02 +0800 | [diff] [blame^] | 215 | if (!isNullOrEmpty(fLabelString)) { |
| 216 | selectorBuilder.matchIPv6FlowLabel(Integer.parseInt(fLabelString)); |
| 217 | } |
| 218 | |
| 219 | if (!isNullOrEmpty(icmp6TypeString)) { |
| 220 | selectorBuilder.matchIcmpv6Type((byte) Integer.parseInt(icmp6TypeString)); |
| 221 | } |
| 222 | |
| 223 | if (!isNullOrEmpty(icmp6CodeString)) { |
| 224 | selectorBuilder.matchIcmpv6Code((byte) Integer.parseInt(icmp6CodeString)); |
| 225 | } |
| 226 | |
| 227 | if (!isNullOrEmpty(ndTargetString)) { |
| 228 | selectorBuilder.matchIPv6NDTargetAddress(Ip6Address.valueOf(ndTargetString)); |
| 229 | } |
| 230 | |
| 231 | if (!isNullOrEmpty(ndSLLString)) { |
| 232 | selectorBuilder.matchIPv6NDSourceLinkLayerAddress(MacAddress.valueOf(ndSLLString)); |
| 233 | } |
| 234 | |
| 235 | if (!isNullOrEmpty(ndTLLString)) { |
| 236 | selectorBuilder.matchIPv6NDTargetLinkLayerAddress(MacAddress.valueOf(ndTLLString)); |
| 237 | } |
| 238 | |
Jonathan Hart | 5f7097e | 2014-11-11 11:50:28 -0800 | [diff] [blame] | 239 | if (!isNullOrEmpty(srcTcpString)) { |
| 240 | selectorBuilder.matchTcpSrc((short) Integer.parseInt(srcTcpString)); |
| 241 | } |
| 242 | |
| 243 | if (!isNullOrEmpty(dstTcpString)) { |
Jonathan Hart | 5dfa43f | 2014-11-17 15:35:54 -0800 | [diff] [blame] | 244 | selectorBuilder.matchTcpDst((short) Integer.parseInt(dstTcpString)); |
Jonathan Hart | 5f7097e | 2014-11-11 11:50:28 -0800 | [diff] [blame] | 245 | } |
| 246 | |
Charles M.C. Chan | e9c8bbc | 2015-04-24 05:03:02 +0800 | [diff] [blame^] | 247 | if (!isNullOrEmpty(extHdrString)) { |
| 248 | selectorBuilder.matchIPv6ExthdrFlags(Integer.parseInt(extHdrString)); |
| 249 | } |
| 250 | |
Ray Milkey | 9fdf1ea | 2014-10-21 09:48:02 -0700 | [diff] [blame] | 251 | return selectorBuilder.build(); |
| 252 | } |
| 253 | |
Ray Milkey | 460f402 | 2014-11-05 15:41:43 -0800 | [diff] [blame] | 254 | /** |
Jonathan Hart | 2c25e36 | 2014-11-17 18:14:19 -0800 | [diff] [blame] | 255 | * Generates a traffic treatment for this intent based on command line |
| 256 | * arguments presented to the command. |
| 257 | * |
| 258 | * @return traffic treatment |
| 259 | */ |
| 260 | protected TrafficTreatment buildTrafficTreatment() { |
Charles M.C. Chan | e9c8bbc | 2015-04-24 05:03:02 +0800 | [diff] [blame^] | 261 | final TrafficTreatment.Builder treatmentBuilder = builder(); |
Jonathan Hart | 2c25e36 | 2014-11-17 18:14:19 -0800 | [diff] [blame] | 262 | |
Charles M.C. Chan | e9c8bbc | 2015-04-24 05:03:02 +0800 | [diff] [blame^] | 263 | if (!isNullOrEmpty(setEthSrcString)) { |
| 264 | treatmentBuilder.setEthSrc(MacAddress.valueOf(setEthSrcString)); |
Brian O'Connor | 4f5a98a | 2015-03-14 19:50:09 -0700 | [diff] [blame] | 265 | } |
| 266 | |
Charles M.C. Chan | e9c8bbc | 2015-04-24 05:03:02 +0800 | [diff] [blame^] | 267 | if (!isNullOrEmpty(setEthDstString)) { |
| 268 | treatmentBuilder.setEthDst(MacAddress.valueOf(setEthDstString)); |
Jonathan Hart | 2c25e36 | 2014-11-17 18:14:19 -0800 | [diff] [blame] | 269 | } |
Charles M.C. Chan | e9c8bbc | 2015-04-24 05:03:02 +0800 | [diff] [blame^] | 270 | |
| 271 | if (!isNullOrEmpty(setIpSrcString)) { |
| 272 | treatmentBuilder.setIpSrc(IpAddress.valueOf(setIpSrcString)); |
Jonathan Hart | 2c25e36 | 2014-11-17 18:14:19 -0800 | [diff] [blame] | 273 | } |
Charles M.C. Chan | e9c8bbc | 2015-04-24 05:03:02 +0800 | [diff] [blame^] | 274 | |
| 275 | if (!isNullOrEmpty(setIpDstString)) { |
| 276 | treatmentBuilder.setIpSrc(IpAddress.valueOf(setIpDstString)); |
| 277 | } |
| 278 | |
| 279 | return treatmentBuilder.build(); |
Jonathan Hart | 2c25e36 | 2014-11-17 18:14:19 -0800 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | /** |
Ray Milkey | 460f402 | 2014-11-05 15:41:43 -0800 | [diff] [blame] | 283 | * Builds the constraint list for this command based on the command line |
| 284 | * parameters. |
| 285 | * |
| 286 | * @return List of constraint objects describing the constraints requested |
| 287 | */ |
| 288 | protected List<Constraint> buildConstraints() { |
| 289 | final List<Constraint> constraints = new LinkedList<>(); |
| 290 | |
| 291 | // Check for a bandwidth specification |
| 292 | if (!isNullOrEmpty(bandwidthString)) { |
| 293 | final double bandwidthValue = Double.parseDouble(bandwidthString); |
Sho SHIMIZU | 0ce220a | 2015-01-23 15:54:47 -0800 | [diff] [blame] | 294 | constraints.add(new BandwidthConstraint(Bandwidth.bps(bandwidthValue))); |
Ray Milkey | 460f402 | 2014-11-05 15:41:43 -0800 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | // Check for a lambda specification |
| 298 | if (lambda) { |
| 299 | constraints.add(new LambdaConstraint(null)); |
| 300 | } |
Thomas Vachuska | dea45ff | 2014-11-12 18:35:46 -0800 | [diff] [blame] | 301 | constraints.add(new LinkTypeConstraint(lambda, Link.Type.OPTICAL)); |
Ray Milkey | 460f402 | 2014-11-05 15:41:43 -0800 | [diff] [blame] | 302 | |
| 303 | return constraints; |
| 304 | } |
Ray Milkey | 5b3717e | 2015-02-05 11:44:08 -0800 | [diff] [blame] | 305 | |
Ray Milkey | 95c5087 | 2015-04-14 14:32:31 -0700 | [diff] [blame] | 306 | @Override |
| 307 | protected ApplicationId appId() { |
| 308 | ApplicationId appIdForIntent; |
| 309 | if (appId == null) { |
| 310 | appIdForIntent = super.appId(); |
| 311 | } else { |
| 312 | CoreService service = get(CoreService.class); |
| 313 | appIdForIntent = service.getAppId(appId); |
| 314 | } |
| 315 | return appIdForIntent; |
| 316 | } |
| 317 | |
Ray Milkey | 5b3717e | 2015-02-05 11:44:08 -0800 | [diff] [blame] | 318 | /** |
| 319 | * Creates a key for an intent based on command line arguments. If a key |
| 320 | * has been specified, it is returned. If no key is specified, null |
| 321 | * is returned. |
| 322 | * |
| 323 | * @return intent key if specified, null otherwise |
| 324 | */ |
| 325 | protected Key key() { |
| 326 | Key key = null; |
Ray Milkey | 95c5087 | 2015-04-14 14:32:31 -0700 | [diff] [blame] | 327 | ApplicationId appIdForIntent; |
| 328 | |
Ray Milkey | 5b3717e | 2015-02-05 11:44:08 -0800 | [diff] [blame] | 329 | if (intentKey != null) { |
| 330 | key = Key.of(intentKey, appId()); |
| 331 | } |
| 332 | return key; |
| 333 | } |
Ray Milkey | c24cde3 | 2015-03-10 18:20:18 -0700 | [diff] [blame] | 334 | |
| 335 | /** |
| 336 | * Gets the priority to use for the intent. |
| 337 | * |
| 338 | * @return priority |
| 339 | */ |
| 340 | protected int priority() { |
| 341 | return priority; |
| 342 | } |
Ray Milkey | 9fdf1ea | 2014-10-21 09:48:02 -0700 | [diff] [blame] | 343 | } |