Switch to MD-SAL APIs
[openflowplugin.git] / test-provider / src / main / java / org / opendaylight / openflowplugin / test / OpenflowpluginGroupTestServiceProvider.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.openflowplugin.test;
9
10 import com.google.common.collect.ImmutableSet;
11 import com.google.common.util.concurrent.ListenableFuture;
12 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
13 import org.opendaylight.mdsal.binding.api.RpcProviderService;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutput;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
25 import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
26 import org.opendaylight.yangtools.concepts.ObjectRegistration;
27 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
28 import org.opendaylight.yangtools.yang.common.RpcResult;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
31
32 public class OpenflowpluginGroupTestServiceProvider implements AutoCloseable,
33         SalGroupService {
34
35     private static final Logger LOG = LoggerFactory
36             .getLogger(OpenflowpluginGroupTestServiceProvider.class);
37     private ObjectRegistration<SalGroupService> groupRegistration;
38     private NotificationPublishService notificationService;
39
40     /**
41      * Get group registration.
42      *
43      * @return {@link #groupRegistration}
44      */
45     public ObjectRegistration<SalGroupService> getGroupRegistration() {
46         return groupRegistration;
47     }
48
49     /**
50      * Set {@link #groupRegistration}.
51      */
52     public void setGroupRegistration(final ObjectRegistration<SalGroupService> groupRegistration) {
53         this.groupRegistration = groupRegistration;
54     }
55
56     /**
57      * Get notification service.
58      *
59      * @return {@link #notificationService}
60      */
61     public NotificationPublishService getNotificationService() {
62         return notificationService;
63     }
64
65     /**
66      * Set {@link #notificationService}.
67      */
68     public void setNotificationService(final NotificationPublishService notificationService) {
69         this.notificationService = notificationService;
70     }
71
72     public void start() {
73         OpenflowpluginGroupTestServiceProvider.LOG
74                 .info("SalGroupServiceProvider Started.");
75     }
76
77     /*
78      * (non-Javadoc)
79      *
80      * @see java.lang.AutoCloseable#close()
81      */
82     @Override
83     public void close() throws Exception {
84         OpenflowpluginGroupTestServiceProvider.LOG
85                 .info("SalGroupServiceProvide stopped.");
86         groupRegistration.close();
87     }
88
89     /*
90      * (non-Javadoc)
91      *
92      * @see
93      * org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918
94      * .SalGroupService
95      * #addGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.group
96      * .service.rev130918.AddGroupInput)
97      */
98     @Override
99     public ListenableFuture<RpcResult<AddGroupOutput>> addGroup(AddGroupInput input) {
100         OpenflowpluginGroupTestServiceProvider.LOG.info("addGroup - {}", input);
101         return null;
102     }
103
104     /*
105      * (non-Javadoc)
106      *
107      * @see
108      * org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918
109      * .SalGroupService
110      * #removeGroup(org.opendaylight.yang.gen.v1.urn.opendaylight
111      * .group.service.rev130918.RemoveGroupInput)
112      */
113     @Override
114     public ListenableFuture<RpcResult<RemoveGroupOutput>> removeGroup(
115             RemoveGroupInput input) {
116         OpenflowpluginGroupTestServiceProvider.LOG.info("removeGroup - {}", input);
117         return null;
118     }
119
120     /*
121      * (non-Javadoc)
122      *
123      * @see
124      * org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918
125      * .SalGroupService
126      * #updateGroup(org.opendaylight.yang.gen.v1.urn.opendaylight
127      * .group.service.rev130918.UpdateGroupInput)
128      */
129     @Override
130     public ListenableFuture<RpcResult<UpdateGroupOutput>> updateGroup(
131             UpdateGroupInput input) {
132         OpenflowpluginGroupTestServiceProvider.LOG.info("updateGroup - {}", input);
133         return null;
134     }
135
136     public ObjectRegistration<OpenflowpluginGroupTestServiceProvider> register(final RpcProviderService rpcRegistry) {
137         setGroupRegistration(rpcRegistry.registerRpcImplementation(SalGroupService.class, this, ImmutableSet.of(
138             InstanceIdentifier.create(Nodes.class)
139             .child(Node.class, new NodeKey(new NodeId(OpenflowpluginTestActivator.NODE_ID))))));
140
141         return new AbstractObjectRegistration<OpenflowpluginGroupTestServiceProvider>(this) {
142             @Override
143             protected void removeRegistration() {
144                 groupRegistration.close();
145             }
146         };
147     }
148 }