2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.config.spi;
10 import javax.annotation.concurrent.NotThreadSafe;
11 import org.opendaylight.controller.config.api.ModuleIdentifier;
12 import org.opendaylight.yangtools.concepts.Identifiable;
16 * Represents one service that is to be configured. These methods need to be
17 * implemented in addition to the usual attribute getters/setters. Dependencies
18 * should always be injected as ObjectName references to the corresponding
21 * In order to guide dependency resolution, the setter method should be
22 * annotated with {@link org.opendaylight.controller.config.api.annotations.RequireInterface}.
25 * Thread safety note: implementations of this interface are not required to be
26 * thread safe as thread safety is enforced by configuration manager.
30 public interface Module extends Identifiable<ModuleIdentifier>{
32 * This method will be called as first phase in two phase commit. Instance
33 * can check attributes, but is not allowed to do any kind of work that
34 * could leave any resources open. It is prohibited to call
35 * {@link #getInstance()} on dependent {@link Module} because it would
36 * destroy separation between validation and commit phase.
42 * Returns 'live' object that was configured using this object. It is
43 * allowed to call this method only after all ConfigBeans were validated. In
44 * this method new resources might be opened or old instance might be
45 * modified. This method must be implemented so that it returns same
46 * result for a single transaction. Since Module is created per transaction
47 * this means that it must be safe to cache result of first call.
50 * @return closeable instance: After bundle update the factory might be able
51 * to copy old configuration into new one without being able to cast
52 * Module or the instance. Thus to clean up old instance, it will
55 AutoCloseable getInstance();
59 * Compare current module with oldModule and if the instance/live object
60 * produced by the old module can be reused in this module as well return true.
61 * Typically true should be returned if the old module had the same configuration.
64 * @param oldModule old instance of Module
65 * @return true if the instance produced by oldModule can be reused with current instance as well.
67 public boolean canReuse(Module oldModule);