Remove yang-test
[controller.git] / opendaylight / config / config-manager-facade-xml / src / main / java / org / opendaylight / controller / config / facade / xml / strategy / AbstractEditConfigStrategy.java
1 /*
2  * Copyright (c) 2015 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
9 package org.opendaylight.controller.config.facade.xml.strategy;
10
11 import java.util.Map;
12 import javax.management.InstanceNotFoundException;
13 import javax.management.ObjectName;
14 import org.opendaylight.controller.config.facade.xml.exception.ConfigHandlingException;
15 import org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml.AttributeConfigElement;
16 import org.opendaylight.controller.config.facade.xml.mapping.config.ServiceRegistryWrapper;
17 import org.opendaylight.controller.config.util.ConfigTransactionClient;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
20
21 public abstract class AbstractEditConfigStrategy implements EditConfigStrategy {
22
23     private static final Logger LOG = LoggerFactory.getLogger(AbstractEditConfigStrategy.class);
24
25     @Override
26     public void executeConfiguration(String module, String instance, Map<String, AttributeConfigElement> configuration,
27                                      ConfigTransactionClient ta, ServiceRegistryWrapper services) throws
28         ConfigHandlingException {
29
30         try {
31             ObjectName on = ta.lookupConfigBean(module, instance);
32             LOG.debug("ServiceInstance for {} {} located successfully under {}", module, instance, on);
33             executeStrategy(configuration, ta, on, services);
34         } catch (InstanceNotFoundException e) {
35             handleMissingInstance(configuration, ta, module, instance, services);
36         }
37
38     }
39
40     // TODO split missing instances handling strategies from edit config strategies in this hierarchy = REFACTOR
41     // edit configs should not handle missing
42
43     abstract void handleMissingInstance(Map<String, AttributeConfigElement> configuration, ConfigTransactionClient ta,
44                                         String module, String instance, ServiceRegistryWrapper services) throws
45         ConfigHandlingException;
46
47     abstract void executeStrategy(Map<String, AttributeConfigElement> configuration, ConfigTransactionClient ta,
48                                   ObjectName objectName, ServiceRegistryWrapper services) throws
49         ConfigHandlingException;
50
51 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.