Brian O'Connor | d087dd2 | 2015-05-21 12:15:29 -0700 | [diff] [blame^] | 1 | package org.onosproject.flowruletest.impl; |
| 2 | |
| 3 | import static org.slf4j.LoggerFactory.getLogger; |
| 4 | |
| 5 | import org.apache.felix.scr.annotations.Activate; |
| 6 | import org.apache.felix.scr.annotations.Component; |
| 7 | import org.apache.felix.scr.annotations.Deactivate; |
| 8 | import org.apache.felix.scr.annotations.Reference; |
| 9 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 10 | import org.apache.felix.scr.annotations.Service; |
| 11 | import org.onosproject.core.ApplicationId; |
| 12 | import org.onosproject.core.CoreService; |
| 13 | import org.onosproject.flowruletest.AppTestService; |
| 14 | import org.onosproject.flowruletest.dispatch.FlowRuleTest; |
| 15 | import org.onosproject.net.device.DeviceService; |
| 16 | import org.onosproject.net.flow.FlowRuleService; |
| 17 | import org.slf4j.Logger; |
| 18 | |
| 19 | /** |
| 20 | * Test for a application. |
| 21 | */ |
| 22 | @Component(immediate = true) |
| 23 | @Service |
| 24 | public class AppTestManager implements AppTestService { |
| 25 | |
| 26 | private static final String APP_TEST = "org.onosproject.apptest"; |
| 27 | private final Logger log = getLogger(getClass()); |
| 28 | |
| 29 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 30 | protected CoreService coreService; |
| 31 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 32 | protected FlowRuleService flowRuleService; |
| 33 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 34 | protected DeviceService deviceService; |
| 35 | private ApplicationId appId; |
| 36 | FlowRuleTest flowRule; |
| 37 | |
| 38 | @Activate |
| 39 | protected void activate() { |
| 40 | log.info("APP-TEST started"); |
| 41 | appId = coreService.registerApplication(APP_TEST); |
| 42 | flowRule = new FlowRuleTest(flowRuleService, deviceService, appId); |
| 43 | flowRule.applyFlowRules(); |
| 44 | } |
| 45 | |
| 46 | @Deactivate |
| 47 | protected void deactivate() { |
| 48 | flowRule.removeFlowRules(); |
| 49 | log.info("APP-TEST Stopped"); |
| 50 | } |
| 51 | } |