Merge "Bug 509: Fixed incorrect merging of Data Store Writes / Events"
authorEd Warnicke <eaw@cisco.com>
Wed, 16 Apr 2014 16:44:35 +0000 (16:44 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 16 Apr 2014 16:44:35 +0000 (16:44 +0000)
312 files changed:
opendaylight/commons/opendaylight/pom.xml
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ConfigRegistryImpl.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ConfigTransactionControllerImpl.java
opendaylight/config/config-persister-directory-xml-adapter/pom.xml
opendaylight/config/config-persister-directory-xml-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/directory/xml/DirectoryStorageAdapterTest.java
opendaylight/config/config-persister-file-xml-adapter/pom.xml
opendaylight/config/config-persister-file-xml-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/file/xml/FileStorageAdapterTest.java
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/async/AsyncEventBusConfigBeanTest.java
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/eventbus/TestingEventBusModule.java
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/fixed/FixedThreadPoolConfigBeanTest.java
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/fixed/TestingFixedThreadPoolModule.java
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/flexible/FlexibleThreadPoolConfigBeanTest.java
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/naming/NamingThreadPoolFactoryConfigBeanTest.java
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/naming/TestingNamingThreadPoolFactoryModule.java
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/scheduled/ScheduledThreadPoolConfigBeanTest.java
opendaylight/config/threadpool-config-impl/src/test/java/org/opendaylight/controller/config/threadpool/scheduled/TestingScheduledThreadPoolModule.java
opendaylight/config/yang-jmx-generator-plugin/pom.xml
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/CodeWriter.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/FreeMarkerCodeWriterImpl.java [deleted file]
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/JMXGenerator.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/AbstractFactoryTemplate.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/AbstractFtlTemplate.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/AbstractModuleTemplate.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/FtlFilePersister.java [deleted file]
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/FtlTemplate.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/StubFactoryTemplate.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/StubModuleTemplate.java [deleted file]
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/TemplateFactory.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/directives/AnnotationsDirective.java [deleted file]
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/directives/ConstructorsDirective.java [deleted file]
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/directives/FieldsDirectiveProg.java [deleted file]
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/directives/FieldsDirectiveTemplate.java [deleted file]
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/directives/HeaderDirective.java [deleted file]
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/directives/JavadocDirective.java [deleted file]
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/directives/MethodsDirective.java [deleted file]
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/directives/ModuleFieldsDirective.java [deleted file]
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/directives/TypeDeclarationDirective.java [deleted file]
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/directives/UnimplementedExceptionDirective.java [deleted file]
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/Annotation.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/AnnotationSerializer.java [new file with mode: 0644]
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/Constructor.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/ConstructorSerializer.java [new file with mode: 0644]
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/Field.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/FieldSerializer.java [new file with mode: 0644]
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/Header.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/HeaderSerializer.java [new file with mode: 0644]
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/MethodDeclaration.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/MethodDefinition.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/MethodSerializer.java [new file with mode: 0644]
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/ModuleField.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/ModuleFieldSerializer.java [new file with mode: 0644]
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/TypeDeclaration.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/gofactory/AbsFactoryGeneratedObjectFactory.groovy [new file with mode: 0644]
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/gofactory/AbsModuleGeneratedObjectFactory.groovy [new file with mode: 0644]
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/gofactory/ConcreteModuleGeneratedObjectFactory.java [new file with mode: 0644]
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/gofactory/GenericGeneratedObjectFactory.groovy [new file with mode: 0644]
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/java/FullyQualifiedName.java [new file with mode: 0644]
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/java/GeneratedObject.java [new file with mode: 0644]
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/java/GeneratedObjectBuilder.java [new file with mode: 0644]
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/java/JavaFileInput.java [new file with mode: 0644]
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/java/JavaFileInputBuilder.java [new file with mode: 0644]
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/java/TypeName.java [new file with mode: 0644]
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/util/StringUtil.java [new file with mode: 0644]
opendaylight/config/yang-jmx-generator-plugin/src/main/resources/copyright.txt [new file with mode: 0644]
opendaylight/config/yang-jmx-generator-plugin/src/main/resources/freeMarker/abstract_ftl_file.ftl [deleted file]
opendaylight/config/yang-jmx-generator-plugin/src/main/resources/freeMarker/factory_abs_template.ftl [deleted file]
opendaylight/config/yang-jmx-generator-plugin/src/main/resources/freeMarker/module_abs_template_new.ftl [deleted file]
opendaylight/config/yang-jmx-generator-plugin/src/main/resources/freeMarker/module_stub_template.ftl [deleted file]
opendaylight/config/yang-jmx-generator-plugin/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/AbstractGeneratorTest.java
opendaylight/config/yang-jmx-generator-plugin/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/JMXGeneratorTest.java
opendaylight/config/yang-jmx-generator-plugin/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ModuleMXBeanEntryTemplatesTest.java
opendaylight/config/yang-jmx-generator-plugin/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/RuntimeRegistratorFtlFileTest.java
opendaylight/config/yang-jmx-generator-plugin/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/FtlFilePersisterTest.java [deleted file]
opendaylight/config/yang-jmx-generator-plugin/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/module/AbstractGeneratedObjectTest.java [new file with mode: 0644]
opendaylight/config/yang-jmx-generator-plugin/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/module/abs/AbsModuleGeneratedObjectFactoryTest.java [new file with mode: 0644]
opendaylight/config/yang-jmx-generator-plugin/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/module/concrete/ConcreteModuleGeneratedObjectFactoryTest.java [new file with mode: 0644]
opendaylight/config/yang-jmx-generator-plugin/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/util/FormattingUtil.java [deleted file]
opendaylight/config/yang-jmx-generator-plugin/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/util/StringUtilTest.java [new file with mode: 0644]
opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/AbstractYangTest.java
opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/ModuleMXBeanEntryTest.java
opendaylight/config/yang-test-plugin/pom.xml
opendaylight/config/yang-test-plugin/src/main/java/org/opendaylight/controller/config/yang/test/plugin/ProcessSources.java
opendaylight/config/yang-test-plugin/src/main/java/org/opendaylight/controller/config/yang/test/plugin/Util.java
opendaylight/config/yang-test/pom.xml
opendaylight/config/yang-test/src/main/java/org/opendaylight/controller/config/yang/test/impl/DepTestImplModule.java
opendaylight/config/yang-test/src/main/java/org/opendaylight/controller/config/yang/test/impl/DepTestImplModuleFactory.java
opendaylight/config/yang-test/src/main/java/org/opendaylight/controller/config/yang/test/impl/IdentityTestModule.java
opendaylight/config/yang-test/src/main/java/org/opendaylight/controller/config/yang/test/impl/IdentityTestModuleFactory.java
opendaylight/config/yang-test/src/main/java/org/opendaylight/controller/config/yang/test/impl/NetconfTestImplModule.java
opendaylight/config/yang-test/src/main/java/org/opendaylight/controller/config/yang/test/impl/NetconfTestImplModuleFactory.java
opendaylight/config/yang-test/src/main/java/org/opendaylight/controller/config/yang/test/impl/TestImplModule.java
opendaylight/config/yang-test/src/main/java/org/opendaylight/controller/config/yang/test/impl/TestImplModuleFactory.java
opendaylight/distribution/opendaylight/pom.xml
opendaylight/md-sal/pom.xml
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeHelper.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeHelper.xtend [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/YangtoolsMappingHelper.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/YangtoolsMappingHelper.xtend [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/BrokerImplClassLoader.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/BrokerImplClassLoader.xtend [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RpcProxyContext.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RpcProxyContext.xtend [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentConnector.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/util/BindingAwareDataReaderRouter.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/util/BindingAwareDataReaderRouter.xtend [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/util/MapUtils.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/util/MapUtils.xtend [deleted file]
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java
opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/md/sal/binding/data/WildcardedDataChangeListenerTest.java
opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/CrossBrokerRpcTest.java
opendaylight/md-sal/sal-binding-it/pom.xml
opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/AbstractTest.java
opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RoutedRpcDefaultImplementation.java
opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcImplementation.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeEventsTask.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerImpl.xtend
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/MountPointImpl.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaAwareRpcBroker.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/RpcProvisionRegistryProxy.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/spi/RoutedRpcProcessor.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/spi/RpcRouter.java
opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/InventoryUtils.java
opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfDevice.xtend
opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfDeviceListener.java
opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfDeviceTwoPhaseCommitTransaction.java
opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfInventoryUtils.java
opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfMapping.xtend
opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfRemoteSchemaSourceProvider.java
opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/UncancellableFuture.java [new file with mode: 0644]
opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/YangModelInputStreamAdapter.java [deleted file]
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/ClientImpl.java
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/RemoteRpcProvider.java
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/ServerImpl.java
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/ClientImplTest.java
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend
opendaylight/md-sal/samples/toaster-it/pom.xml
opendaylight/md-sal/samples/toaster-it/src/test/java/org/opendaylight/controller/sample/toaster/it/ToasterTest.java
opendaylight/netconf/config-netconf-connector/pom.xml
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/toxml/CompositeAttributeWritingStrategy.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/toxml/ObjectNameAttributeWritingStrategy.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/toxml/RuntimeBeanEntryWritingStrategy.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/toxml/SimpleAttributeWritingStrategy.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/toxml/SimpleIdentityRefAttributeWritingStrategy.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/config/Config.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/config/ModuleConfig.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/config/Services.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/runtime/InstanceRuntime.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/runtime/Runtime.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/Commit.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/DiscardChanges.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/Validate.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/editconfig/EditConfig.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/getconfig/GetConfig.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/runtimerpc/RuntimeRpc.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationServiceImpl.java
opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/NetconfMappingTest.java
opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterActivator.java
opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterTest.java
opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/osgi/MockedBundleContext.java
opendaylight/netconf/netconf-api/src/main/java/org/opendaylight/controller/netconf/api/AbstractNetconfSession.java [deleted file]
opendaylight/netconf/netconf-api/src/main/java/org/opendaylight/controller/netconf/api/NetconfClientSessionPreferences.java [new file with mode: 0644]
opendaylight/netconf/netconf-api/src/main/java/org/opendaylight/controller/netconf/api/NetconfServerSessionPreferences.java
opendaylight/netconf/netconf-api/src/main/java/org/opendaylight/controller/netconf/api/NetconfSession.java
opendaylight/netconf/netconf-api/src/main/java/org/opendaylight/controller/netconf/api/NetconfSessionPreferences.java
opendaylight/netconf/netconf-api/src/main/java/org/opendaylight/controller/netconf/api/NetconfTerminationReason.java
opendaylight/netconf/netconf-client/pom.xml
opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/AbstractNetconfClientNotifySessionListener.java [deleted file]
opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClient.java [deleted file]
opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClientDispatcher.java
opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClientSession.java
opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClientSessionNegotiator.java
opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClientSessionNegotiatorFactory.java
opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/SimpleNetconfClientSessionListener.java
opendaylight/netconf/netconf-client/src/main/resources/client_hello.xml [deleted file]
opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/SSHNetconfClientLiveTest.java [deleted file]
opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/test/TestingNetconfClient.java [new file with mode: 0644]
opendaylight/netconf/netconf-impl/pom.xml
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/CapabilityProviderImpl.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerDispatcher.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSession.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSessionListener.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSessionListenerFactory.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSessionNegotiator.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSessionNegotiatorFactory.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultCloseSession.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultCommit.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultGetSchema.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultNetconfOperation.java [moved from opendaylight/config/yang-test-plugin/src/main/resources/Header.txt with 54% similarity]
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultStartExi.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultStopExi.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfImplActivator.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfMonitoringServiceImpl.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfOperationRouter.java [moved from opendaylight/netconf/netconf-api/src/main/java/org/opendaylight/controller/netconf/api/NetconfOperationRouter.java with 62% similarity]
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfOperationRouterImpl.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfOperationServiceFactoryListener.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfOperationServiceFactoryListenerImpl.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfOperationServiceSnapshotImpl.java [moved from opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfOperationServiceSnapshot.java with 51% similarity]
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/util/DeserializerExceptionHandler.java
opendaylight/netconf/netconf-impl/src/main/resources/server_hello.xml [deleted file]
opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/ConcurrentClientsTest.java
opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/ExiEncodeDecodeTest.java
opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/MessageParserTest.java
opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/NetconfDispatcherImplTest.java
opendaylight/netconf/netconf-impl/src/test/resources/testConfigs/input.json
opendaylight/netconf/netconf-impl/src/test/resources/testConfigs/input.xml
opendaylight/netconf/netconf-impl/src/test/resources/testConfigs/inputList.xml
opendaylight/netconf/netconf-impl/src/test/resources/testConfigs/inputMap.xml
opendaylight/netconf/netconf-impl/src/test/resources/testConfigs/inputMultiple.xml
opendaylight/netconf/netconf-impl/src/test/resources/testConfigs/inputSetter.xml
opendaylight/netconf/netconf-impl/src/test/resources/testConfigs/inputSetterList.xml
opendaylight/netconf/netconf-impl/src/test/resources/testConfigs/inputSetterMap.xml
opendaylight/netconf/netconf-impl/src/test/resources/testConfigs/map.json
opendaylight/netconf/netconf-it/pom.xml
opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/AbstractNetconfConfigTest.java
opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfConfigPersisterITTest.java
opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITSecureTest.java
opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITTest.java
opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfMonitoringITTest.java
opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/pax/IdentityRefNetconfTest.java
opendaylight/netconf/netconf-it/src/test/resources/controller.xml
opendaylight/netconf/netconf-mapping-api/src/main/java/org/opendaylight/controller/netconf/mapping/api/NetconfOperationProvider.java [new file with mode: 0644]
opendaylight/netconf/netconf-mapping-api/src/main/java/org/opendaylight/controller/netconf/mapping/api/NetconfOperationServiceSnapshot.java [moved from opendaylight/netconf/netconf-mapping-api/src/main/java/org/opendaylight/controller/netconf/mapping/api/DefaultNetconfOperation.java with 65% similarity]
opendaylight/netconf/netconf-util/pom.xml
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/AbstractNetconfSession.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/AbstractNetconfSessionNegotiator.java
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/CloseableUtil.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/NetconfExiSession.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/NetconfEXICodec.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/NetconfEXIToMessageDecoder.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/NetconfMessageToEXIEncoder.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/NetconfMessageToXMLEncoder.java
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/mapping/AbstractNetconfOperation.java
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/messages/NetconfHelloMessage.java
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/messages/NetconfMessageUtil.java
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/messages/NetconfStartExiMessage.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/EXIParameters.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XmlNetconfConstants.java
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XmlUtil.java
opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/EXILibTest.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/test/XmlUnitUtil.java [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/test/resources/netconfMessages/rpc-reply_ok.xml [new file with mode: 0644]
opendaylight/netconf/netconf-util/src/test/resources/netconfMessages/startExi.xml
opendaylight/netconf/netconf-util/src/test/resources/netconfMessages/stopExi.xml
opendaylight/netconf/pom.xml
third-party/org.openexi/nagasena-rta/nagasena-rta-0000.0002.0035.0.jar [new file with mode: 0644]
third-party/org.openexi/nagasena-rta/pom.xml [new file with mode: 0644]
third-party/org.openexi/nagasena/nagasena-0000.0002.0035.0.jar [new file with mode: 0644]
third-party/org.openexi/nagasena/pom.xml [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/allclasses-frame.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/allclasses-noframe.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/constant-values.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/deprecated-list.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/help-doc.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/index-all.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/index.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/EXIDecoder.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/EXISchemaResolver.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/HeaderOptionsOutputType.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/AlignmentType.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/BinaryDataSource.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/EXIOptions.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/EventDescription.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/EventType.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/GrammarOptions.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/QName.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/package-frame.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/package-summary.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/common/package-tree.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/grammars/GrammarCache.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/grammars/package-frame.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/grammars/package-summary.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/grammars/package-tree.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/io/BinaryDataSink.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/io/CharacterBuffer.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/io/Scanner.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/io/package-frame.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/io/package-summary.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/io/package-tree.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/package-frame.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/package-summary.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/proc/package-tree.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/BinaryDataHandler.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/EXIReader.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/ReaderSupport.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/SAXTransmogrifier.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/Transmogrifier.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/TransmogrifierException.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/package-frame.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/package-summary.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/sax/package-tree.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/schema/Characters.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/schema/EXISchema.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/schema/EmptySchema.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/schema/package-frame.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/schema/package-summary.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/schema/package-tree.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/EXISchemaFactory.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/EXISchemaFactoryErrorHandler.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/EXISchemaFactoryException.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/EXISchemaReader.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/EntityResolverEx.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/package-frame.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/package-summary.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/org/openexi/scomp/package-tree.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/overview-frame.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/overview-summary.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/overview-tree.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/package-list [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/resources/inherit.gif [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/serialized-form.html [new file with mode: 0644]
third-party/org.openexi/nagasena/src/main/resources/doc/stylesheet.css [new file with mode: 0644]
third-party/org.openexi/pom.xml [new file with mode: 0644]

index d5d7e8e..f4b2dee 100644 (file)
     <xtend.dstdir>src/main/xtend-gen</xtend.dstdir>
     <jmxGeneratorPath>src/main/yang-gen-config</jmxGeneratorPath>
     <salGeneratorPath>src/main/yang-gen-sal</salGeneratorPath>
+
+    <!-- OpenEXI third party lib for netconf-->
+    <exi.nagasena.version>0000.0002.0035.0-SNAPSHOT</exi.nagasena.version>
   </properties>
 
   <dependencyManagement>
         <artifactId>org.eclipse.equinox.launcher</artifactId>
         <version>1.3.0.v20120522-1813</version>
       </dependency>
+      <dependency>
+        <groupId>xmlunit</groupId>
+        <artifactId>xmlunit</artifactId>
+        <version>1.5</version>
+        <scope>test</scope>
+      </dependency>
       <!-- Gemini Web -->
       <dependency>
         <groupId>geminiweb</groupId>
         <artifactId>ganymed</artifactId>
         <version>1.1-SNAPSHOT</version>
       </dependency>
+      <dependency>
+        <groupId>org.opendaylight.controller.thirdparty</groupId>
+        <artifactId>nagasena</artifactId>
+        <version>${exi.nagasena.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.opendaylight.controller.thirdparty</groupId>
+        <artifactId>nagasena-rta</artifactId>
+        <version>${exi.nagasena.version}</version>
+      </dependency>
       <dependency>
         <groupId>com.google.code.findbugs</groupId>
         <artifactId>jsr305</artifactId>
index fb0718a..e914162 100644 (file)
@@ -283,6 +283,7 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
 
         int orderingIdx = 0;
         for (ModuleIdentifier moduleIdentifier : orderedModuleIdentifiers) {
+            logger.trace("Registering {}", moduleIdentifier);
             ModuleInternalTransactionalInfo entry = commitInfo.getCommitted()
                     .get(moduleIdentifier);
             if (entry == null) {
index 6b7251c..bc4de5c 100644 (file)
@@ -44,6 +44,7 @@ import java.util.Map.Entry;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicBoolean;
 
+import static com.google.common.base.Preconditions.checkNotNull;
 import static java.lang.String.format;
 
 /**
@@ -380,7 +381,8 @@ class ConfigTransactionControllerImpl implements
             try {
                 logger.debug("About to commit {} in transaction {}",
                         name, getTransactionIdentifier());
-                module.getInstance();
+                AutoCloseable instance = module.getInstance();
+                checkNotNull(instance, "Instance is null:{} in transaction {}", name, getTransactionIdentifier());
             } catch (Exception e) {
                 logger.error("Commit failed on {} in transaction {}", name,
                         getTransactionIdentifier(), e);
index 75188fe..2b98f41 100644 (file)
             <type>test-jar</type>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>xmlunit</groupId>
+            <artifactId>xmlunit</artifactId>
+        </dependency>
 
     </dependencies>
 
     <build>
         <plugins>
-            <!-- workaround for creating version according to OSGi specification (major.minor.micro[.qualifier] -->
-            <plugin>
-                <groupId>org.codehaus.groovy.maven</groupId>
-                <artifactId>gmaven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <phase>generate-sources</phase>
-                        <goals>
-                            <goal>execute</goal>
-                        </goals>
-                        <configuration>
-                            <source>
-                                System.setProperty("osgiversion", "${project.version}".replace('-', '.'))
-                            </source>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
             <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <configuration>
                     <instructions>
-                        <Fragment-Host>${project.groupId}.config-persister-impl;bundle-version=${osgiversion}
+                        <Fragment-Host>${project.groupId}.config-persister-impl
                         </Fragment-Host>
                         <Provide-Capability>org.opendaylight.controller.config.persister.storage.adapter
                         </Provide-Capability>
             </plugin>
         </plugins>
     </build>
-
 </project>
index da442ef..7af06bd 100644 (file)
@@ -8,21 +8,26 @@
 
 package org.opendaylight.controller.config.persist.storage.directory.xml;
 
+import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.io.File;
+import java.io.IOException;
 import java.util.Collections;
 import java.util.List;
 import java.util.SortedSet;
 
-import com.google.common.base.Optional;
 import org.junit.Test;
 import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
 import org.opendaylight.controller.config.persist.api.Persister;
 import org.opendaylight.controller.config.persist.test.PropertiesProviderTest;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import org.xml.sax.SAXException;
+
+import com.google.common.base.Optional;
 
 public class DirectoryStorageAdapterTest {
     Persister tested;
@@ -95,8 +100,8 @@ public class DirectoryStorageAdapterTest {
         logger.info("Testing : " + tested.toString());
     }
 
-    private void assertResult(ConfigSnapshotHolder result, String s, String... caps) {
-        assertEquals(s, result.getConfigSnapshot().replaceAll("\\s", ""));
+    private void assertResult(ConfigSnapshotHolder result, String s, String... caps) throws SAXException, IOException {
+        assertXMLEqual(s, result.getConfigSnapshot());
         int i = 0;
         for (String capFromSnapshot : result.getCapabilities()) {
             assertEquals(capFromSnapshot, caps[i++]);
index dd20795..a5010f0 100644 (file)
             <type>test-jar</type>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>xmlunit</groupId>
+            <artifactId>xmlunit</artifactId>
+        </dependency>
     </dependencies>
 
     <build>
         <plugins>
-            <!-- workaround for creating version according to OSGi specification (major.minor.micro[.qualifier] -->
-            <plugin>
-                <groupId>org.codehaus.groovy.maven</groupId>
-                <artifactId>gmaven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <phase>generate-sources</phase>
-                        <goals>
-                            <goal>execute</goal>
-                        </goals>
-                        <configuration>
-                            <source>
-                                System.setProperty("osgiversion", "${project.version}".replace('-', '.'))
-                            </source>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
             <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <configuration>
                     <instructions>
-                        <Fragment-Host>${project.groupId}.config-persister-impl;bundle-version=${osgiversion}
+                        <Fragment-Host>${project.groupId}.config-persister-impl
                         </Fragment-Host>
-                        <Provide-Capability>org.opendaylight.controller.config.persister.storage.adapter
-                        </Provide-Capability>
+                        <Provide-Capability>org.opendaylight.controller.config.persister.storage.adapter</Provide-Capability>
                     </instructions>
                 </configuration>
             </plugin>
index 5322f63..2bfe70a 100644 (file)
@@ -8,7 +8,12 @@
 
 package org.opendaylight.controller.config.persist.storage.file.xml;
 
-import com.google.common.base.Charsets;
+import static junit.framework.Assert.assertFalse;
+import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
@@ -16,16 +21,16 @@ import java.nio.file.Files;
 import java.util.List;
 import java.util.SortedSet;
 import java.util.TreeSet;
+
 import junit.framework.Assert;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
 import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
 import org.opendaylight.controller.config.persist.test.PropertiesProviderTest;
-import static junit.framework.Assert.assertFalse;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
+
+import com.google.common.base.Charsets;
 
 public class FileStorageAdapterTest {
 
@@ -96,8 +101,7 @@ public class FileStorageAdapterTest {
         List<ConfigSnapshotHolder> lastConf = storage.loadLastConfigs();
         assertEquals(1, lastConf.size());
         ConfigSnapshotHolder configSnapshotHolder = lastConf.get(0);
-        assertEquals("<config>2</config>",
-                configSnapshotHolder.getConfigSnapshot().replaceAll("\\s", ""));
+        assertXMLEqual("<config>2</config>", configSnapshotHolder.getConfigSnapshot());
         assertEquals(createCaps(), configSnapshotHolder.getCapabilities());
 
         storage = new XmlFileStorageAdapter();
@@ -147,8 +151,7 @@ public class FileStorageAdapterTest {
         List<ConfigSnapshotHolder> lastConf = storage.loadLastConfigs();
         assertEquals(1, lastConf.size());
         ConfigSnapshotHolder configSnapshotHolder = lastConf.get(0);
-        assertEquals("<config>2</config>",
-                configSnapshotHolder.getConfigSnapshot().replaceAll("\\s", ""));
+        assertXMLEqual("<config>2</config>", configSnapshotHolder.getConfigSnapshot());
     }
 
     @Test
@@ -178,8 +181,7 @@ public class FileStorageAdapterTest {
         List<ConfigSnapshotHolder> lastConf = storage.loadLastConfigs();
         assertEquals(1, lastConf.size());
         ConfigSnapshotHolder configSnapshotHolder = lastConf.get(0);
-        assertEquals("<config>3</config>",
-                configSnapshotHolder.getConfigSnapshot().replaceAll("\\s", ""));
+        assertXMLEqual("<config>3</config>", configSnapshotHolder.getConfigSnapshot());
         assertFalse(readLines.contains(holder.getConfigSnapshot()));
     }
 
index b9731cd..177adc1 100644 (file)
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.config.threadpool.async;\r
-\r
-import static org.junit.Assert.assertThat;\r
-import static org.junit.Assert.fail;\r
-import static org.junit.matchers.JUnitMatchers.containsString;\r
-\r
-import javax.management.InstanceAlreadyExistsException;\r
-import javax.management.ObjectName;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.opendaylight.controller.config.api.ConflictingVersionException;\r
-import org.opendaylight.controller.config.api.ValidationException;\r
-import org.opendaylight.controller.config.api.jmx.CommitStatus;\r
-import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;\r
-import org.opendaylight.controller.config.manager.impl.ClassBasedModuleFactory;\r
-import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;\r
-import org.opendaylight.controller.config.threadpool.scheduled.TestingScheduledThreadPoolModule;\r
-import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;\r
-import org.opendaylight.controller.config.yang.threadpool.impl.AsyncEventBusModuleFactory;\r
-import org.opendaylight.controller.config.yang.threadpool.impl.AsyncEventBusModuleMXBean;\r
-\r
-public class AsyncEventBusConfigBeanTest extends AbstractConfigTest {\r
-\r
-    private AsyncEventBusModuleFactory factory;\r
-    private final String instanceName = "async1";\r
-    private final String poolImplName = "fixed1";\r
-\r
-    @Before\r
-    public void setUp() {\r
-\r
-        ClassBasedModuleFactory scheduledThreadPoolConfigFactory = createClassBasedCBF(\r
-                TestingScheduledThreadPoolModule.class, poolImplName);\r
-\r
-        factory = new AsyncEventBusModuleFactory();\r
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory,\r
-                scheduledThreadPoolConfigFactory));\r
-    }\r
-\r
-    @Test\r
-    public void testCreateBean() throws InstanceAlreadyExistsException, ValidationException,\r
-            ConflictingVersionException {\r
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
-\r
-        createAsynced(transaction, instanceName, transaction.createModule(poolImplName, "pool-test"));\r
-        transaction.validateConfig();\r
-        CommitStatus status = transaction.commit();\r
-\r
-        assertBeanCount(1, factory.getImplementationName());\r
-        assertStatus(status, 2, 0, 0);\r
-    }\r
-\r
-    @Test\r
-    public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException,\r
-            ValidationException {\r
-\r
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
-        createAsynced(transaction, instanceName, transaction.createModule(poolImplName, "pool-test"));\r
-\r
-        transaction.commit();\r
-\r
-        assertBeanCount(1, factory.getImplementationName());\r
-\r
-        transaction = configRegistryClient.createTransaction();\r
-        CommitStatus status = transaction.commit();\r
-\r
-        assertBeanCount(1, factory.getImplementationName());\r
-        assertStatus(status, 0, 0, 2);\r
-\r
-    }\r
-\r
-    @Test\r
-    public void testInstanceAlreadyExistsException() throws ConflictingVersionException, ValidationException,\r
-            InstanceAlreadyExistsException {\r
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
-\r
-        ObjectName poolCB = transaction.createModule(poolImplName, "pool-test");\r
-        createAsynced(transaction, instanceName, poolCB);\r
-        transaction.commit();\r
-\r
-        transaction = configRegistryClient.createTransaction();\r
-        try {\r
-            createAsynced(transaction, instanceName, poolCB);\r
-            fail();\r
-        } catch (InstanceAlreadyExistsException e) {\r
-            assertThat(\r
-                    e.getMessage(),\r
-                    containsString("There is an instance registered with name ModuleIdentifier{factoryName='async-eventbus', instanceName='async1'}"));\r
-        }\r
-    }\r
-\r
-    private ObjectName createAsynced(ConfigTransactionJMXClient transaction, String instanceName, ObjectName threadPool)\r
-            throws InstanceAlreadyExistsException {\r
-        ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), instanceName);\r
-        AsyncEventBusModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated, AsyncEventBusModuleMXBean.class);\r
-        mxBean.setThreadpool(threadPool);\r
-        return nameCreated;\r
-    }\r
-\r
-}\r
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.config.threadpool.async;
+
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+import static org.junit.matchers.JUnitMatchers.containsString;
+
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.ObjectName;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.config.api.ConflictingVersionException;
+import org.opendaylight.controller.config.api.ValidationException;
+import org.opendaylight.controller.config.api.jmx.CommitStatus;
+import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
+import org.opendaylight.controller.config.manager.impl.ClassBasedModuleFactory;
+import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
+import org.opendaylight.controller.config.threadpool.scheduled.TestingScheduledThreadPoolModule;
+import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
+import org.opendaylight.controller.config.yang.threadpool.impl.AsyncEventBusModuleFactory;
+import org.opendaylight.controller.config.yang.threadpool.impl.AsyncEventBusModuleMXBean;
+
+public class AsyncEventBusConfigBeanTest extends AbstractConfigTest {
+
+    private AsyncEventBusModuleFactory factory;
+    private final String instanceName = "async1";
+    private final String poolImplName = "fixed1";
+
+    @Before
+    public void setUp() {
+
+        ClassBasedModuleFactory scheduledThreadPoolConfigFactory = createClassBasedCBF(
+                TestingScheduledThreadPoolModule.class, poolImplName);
+
+        factory = new AsyncEventBusModuleFactory();
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory,
+                scheduledThreadPoolConfigFactory));
+    }
+
+    @Test
+    public void testCreateBean() throws InstanceAlreadyExistsException, ValidationException,
+            ConflictingVersionException {
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+
+        createAsynced(transaction, instanceName, transaction.createModule(poolImplName, "pool-test"));
+        transaction.validateConfig();
+        CommitStatus status = transaction.commit();
+
+        assertBeanCount(1, factory.getImplementationName());
+        assertStatus(status, 2, 0, 0);
+    }
+
+    @Test
+    public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException,
+            ValidationException {
+
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+        createAsynced(transaction, instanceName, transaction.createModule(poolImplName, "pool-test"));
+
+        transaction.commit();
+
+        assertBeanCount(1, factory.getImplementationName());
+
+        transaction = configRegistryClient.createTransaction();
+        CommitStatus status = transaction.commit();
+
+        assertBeanCount(1, factory.getImplementationName());
+        assertStatus(status, 0, 0, 2);
+
+    }
+
+    @Test
+    public void testInstanceAlreadyExistsException() throws ConflictingVersionException, ValidationException,
+            InstanceAlreadyExistsException {
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+
+        ObjectName poolCB = transaction.createModule(poolImplName, "pool-test");
+        createAsynced(transaction, instanceName, poolCB);
+        transaction.commit();
+
+        transaction = configRegistryClient.createTransaction();
+        try {
+            createAsynced(transaction, instanceName, poolCB);
+            fail();
+        } catch (InstanceAlreadyExistsException e) {
+            assertThat(
+                    e.getMessage(),
+                    containsString("There is an instance registered with name ModuleIdentifier{factoryName='async-eventbus', instanceName='async1'}"));
+        }
+    }
+
+    private ObjectName createAsynced(ConfigTransactionJMXClient transaction, String instanceName, ObjectName threadPool)
+            throws InstanceAlreadyExistsException {
+        ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), instanceName);
+        AsyncEventBusModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated, AsyncEventBusModuleMXBean.class);
+        mxBean.setThreadpool(threadPool);
+        return nameCreated;
+    }
+
+}
index 01a89a9..4431f78 100644 (file)
@@ -1,35 +1,35 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.config.threadpool.eventbus;\r
-\r
-import static org.mockito.Mockito.doNothing;\r
-import static org.mockito.Mockito.mock;\r
-\r
-import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;\r
-import org.opendaylight.controller.config.api.ModuleIdentifier;\r
-import org.opendaylight.controller.config.manager.impl.AbstractMockedModule;\r
-import org.opendaylight.controller.config.spi.Module;\r
-import org.opendaylight.controller.config.threadpool.util.CloseableEventBus;\r
-import org.opendaylight.controller.config.yang.threadpool.EventBusServiceInterface;\r
-import org.opendaylight.controller.config.yang.threadpool.impl.EventBusModuleMXBean;\r
-\r
-public class TestingEventBusModule extends AbstractMockedModule implements Module, EventBusServiceInterface,\r
-        EventBusModuleMXBean {\r
-\r
-    public TestingEventBusModule(DynamicMBeanWithInstance old, ModuleIdentifier id) {\r
-        super(old, id);\r
-    }\r
-\r
-    @Override\r
-    protected AutoCloseable prepareMockedInstance() throws Exception {\r
-        CloseableEventBus bus = mock(CloseableEventBus.class);\r
-        doNothing().when(bus).close();\r
-        return bus;\r
-    }\r
-\r
-}\r
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.config.threadpool.eventbus;
+
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.mock;
+
+import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.opendaylight.controller.config.manager.impl.AbstractMockedModule;
+import org.opendaylight.controller.config.spi.Module;
+import org.opendaylight.controller.config.threadpool.util.CloseableEventBus;
+import org.opendaylight.controller.config.yang.threadpool.EventBusServiceInterface;
+import org.opendaylight.controller.config.yang.threadpool.impl.EventBusModuleMXBean;
+
+public class TestingEventBusModule extends AbstractMockedModule implements Module, EventBusServiceInterface,
+        EventBusModuleMXBean {
+
+    public TestingEventBusModule(DynamicMBeanWithInstance old, ModuleIdentifier id) {
+        super(old, id);
+    }
+
+    @Override
+    protected AutoCloseable prepareMockedInstance() throws Exception {
+        CloseableEventBus bus = mock(CloseableEventBus.class);
+        doNothing().when(bus).close();
+        return bus;
+    }
+
+}
index 8bfd049..781215d 100644 (file)
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.config.threadpool.fixed;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.opendaylight.controller.config.api.ConflictingVersionException;\r
-import org.opendaylight.controller.config.api.ValidationException;\r
-import org.opendaylight.controller.config.api.jmx.CommitStatus;\r
-import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;\r
-import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;\r
-import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;\r
-import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleFactory;\r
-import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleMXBean;\r
-import org.opendaylight.controller.config.yang.threadpool.impl.fixed.FixedThreadPoolModuleFactory;\r
-import org.opendaylight.controller.config.yang.threadpool.impl.fixed.FixedThreadPoolModuleMXBean;\r
-\r
-import javax.management.InstanceAlreadyExistsException;\r
-import javax.management.InstanceNotFoundException;\r
-import javax.management.ObjectName;\r
-\r
-import static org.junit.Assert.assertThat;\r
-import static org.junit.Assert.fail;\r
-import static org.junit.matchers.JUnitMatchers.containsString;\r
-\r
-public class FixedThreadPoolConfigBeanTest extends AbstractConfigTest {\r
-\r
-    private FixedThreadPoolModuleFactory factory;\r
-    private final String nameInstance = "fixedInstance";\r
-\r
-    @Before\r
-    public void setUp() {\r
-        factory = new FixedThreadPoolModuleFactory();\r
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory,\r
-                new NamingThreadFactoryModuleFactory()));\r
-    }\r
-\r
-    @Test\r
-    public void testCreateBean() throws InstanceAlreadyExistsException, ValidationException,\r
-            ConflictingVersionException {\r
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
-        createFixed(transaction, nameInstance, 2);\r
-\r
-        transaction.validateConfig();\r
-        CommitStatus status = transaction.commit();\r
-\r
-        assertBeanCount(1, factory.getImplementationName());\r
-        assertStatus(status, 2, 0, 0);\r
-    }\r
-\r
-    @Test\r
-    public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException,\r
-            ValidationException {\r
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
-        createFixed(transaction, nameInstance, 4);\r
-\r
-        transaction.validateConfig();\r
-        transaction.commit();\r
-\r
-        assertBeanCount(1, factory.getImplementationName());\r
-\r
-        transaction = configRegistryClient.createTransaction();\r
-        CommitStatus status = transaction.commit();\r
-\r
-        assertBeanCount(1, factory.getImplementationName());\r
-        assertStatus(status, 0, 0, 2);\r
-    }\r
-\r
-    @Test\r
-    public void testNegative() throws ConflictingVersionException, ValidationException, InstanceAlreadyExistsException {\r
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
-\r
-        createFixed(transaction, nameInstance, 5);\r
-        transaction.commit();\r
-\r
-        transaction = configRegistryClient.createTransaction();\r
-        try {\r
-            createFixed(transaction, nameInstance, 0);\r
-            fail();\r
-        } catch (InstanceAlreadyExistsException e) {\r
-            assertThat(\r
-                    e.getMessage(),\r
-                    containsString("There is an instance registered with name ModuleIdentifier{factoryName='threadpool-fixed', instanceName='fixedInstance'}"));\r
-        }\r
-    }\r
-\r
-    @Test\r
-    public void testDestroy() throws InstanceAlreadyExistsException, ValidationException, ConflictingVersionException,\r
-            InstanceNotFoundException {\r
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
-        createFixed(transaction, nameInstance, 1);\r
-\r
-        transaction.commit();\r
-\r
-        transaction = configRegistryClient.createTransaction();\r
-        transaction.destroyConfigBean(factory.getImplementationName(), nameInstance);\r
-        CommitStatus status = transaction.commit();\r
-\r
-        assertBeanCount(0, factory.getImplementationName());\r
-        assertStatus(status, 0, 0, 1);\r
-    }\r
-\r
-    @Test\r
-    public void testValidationException() throws InstanceAlreadyExistsException {\r
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
-        createFixed(transaction, nameInstance, -1);\r
-        try {\r
-            transaction.validateConfig();\r
-            fail();\r
-        } catch (ValidationException e) {\r
-            assertThat(e.getMessage(), containsString("MaxThreadCount must be greater than zero"));\r
-        }\r
-    }\r
-\r
-    private ObjectName createFixed(ConfigTransactionJMXClient transaction, String name, int numberOfThreads)\r
-            throws InstanceAlreadyExistsException {\r
-        ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), name);\r
-        FixedThreadPoolModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated, FixedThreadPoolModuleMXBean.class);\r
-        mxBean.setMaxThreadCount(numberOfThreads);\r
-\r
-        ObjectName threadFactoryON = transaction.createModule(NamingThreadFactoryModuleFactory.NAME, "naming");\r
-        NamingThreadFactoryModuleMXBean namingThreadFactoryModuleMXBean = transaction.newMXBeanProxy(threadFactoryON,\r
-                NamingThreadFactoryModuleMXBean.class);\r
-        namingThreadFactoryModuleMXBean.setNamePrefix("prefix");\r
-\r
-        mxBean.setThreadFactory(threadFactoryON);\r
-\r
-        return nameCreated;\r
-    }\r
-\r
-}\r
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.config.threadpool.fixed;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.config.api.ConflictingVersionException;
+import org.opendaylight.controller.config.api.ValidationException;
+import org.opendaylight.controller.config.api.jmx.CommitStatus;
+import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
+import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
+import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
+import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleFactory;
+import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleMXBean;
+import org.opendaylight.controller.config.yang.threadpool.impl.fixed.FixedThreadPoolModuleFactory;
+import org.opendaylight.controller.config.yang.threadpool.impl.fixed.FixedThreadPoolModuleMXBean;
+
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.ObjectName;
+
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+import static org.junit.matchers.JUnitMatchers.containsString;
+
+public class FixedThreadPoolConfigBeanTest extends AbstractConfigTest {
+
+    private FixedThreadPoolModuleFactory factory;
+    private final String nameInstance = "fixedInstance";
+
+    @Before
+    public void setUp() {
+        factory = new FixedThreadPoolModuleFactory();
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory,
+                new NamingThreadFactoryModuleFactory()));
+    }
+
+    @Test
+    public void testCreateBean() throws InstanceAlreadyExistsException, ValidationException,
+            ConflictingVersionException {
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+        createFixed(transaction, nameInstance, 2);
+
+        transaction.validateConfig();
+        CommitStatus status = transaction.commit();
+
+        assertBeanCount(1, factory.getImplementationName());
+        assertStatus(status, 2, 0, 0);
+    }
+
+    @Test
+    public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException,
+            ValidationException {
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+        createFixed(transaction, nameInstance, 4);
+
+        transaction.validateConfig();
+        transaction.commit();
+
+        assertBeanCount(1, factory.getImplementationName());
+
+        transaction = configRegistryClient.createTransaction();
+        CommitStatus status = transaction.commit();
+
+        assertBeanCount(1, factory.getImplementationName());
+        assertStatus(status, 0, 0, 2);
+    }
+
+    @Test
+    public void testNegative() throws ConflictingVersionException, ValidationException, InstanceAlreadyExistsException {
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+
+        createFixed(transaction, nameInstance, 5);
+        transaction.commit();
+
+        transaction = configRegistryClient.createTransaction();
+        try {
+            createFixed(transaction, nameInstance, 0);
+            fail();
+        } catch (InstanceAlreadyExistsException e) {
+            assertThat(
+                    e.getMessage(),
+                    containsString("There is an instance registered with name ModuleIdentifier{factoryName='threadpool-fixed', instanceName='fixedInstance'}"));
+        }
+    }
+
+    @Test
+    public void testDestroy() throws InstanceAlreadyExistsException, ValidationException, ConflictingVersionException,
+            InstanceNotFoundException {
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+        createFixed(transaction, nameInstance, 1);
+
+        transaction.commit();
+
+        transaction = configRegistryClient.createTransaction();
+        transaction.destroyConfigBean(factory.getImplementationName(), nameInstance);
+        CommitStatus status = transaction.commit();
+
+        assertBeanCount(0, factory.getImplementationName());
+        assertStatus(status, 0, 0, 1);
+    }
+
+    @Test
+    public void testValidationException() throws InstanceAlreadyExistsException {
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+        createFixed(transaction, nameInstance, -1);
+        try {
+            transaction.validateConfig();
+            fail();
+        } catch (ValidationException e) {
+            assertThat(e.getMessage(), containsString("MaxThreadCount must be greater than zero"));
+        }
+    }
+
+    private ObjectName createFixed(ConfigTransactionJMXClient transaction, String name, int numberOfThreads)
+            throws InstanceAlreadyExistsException {
+        ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), name);
+        FixedThreadPoolModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated, FixedThreadPoolModuleMXBean.class);
+        mxBean.setMaxThreadCount(numberOfThreads);
+
+        ObjectName threadFactoryON = transaction.createModule(NamingThreadFactoryModuleFactory.NAME, "naming");
+        NamingThreadFactoryModuleMXBean namingThreadFactoryModuleMXBean = transaction.newMXBeanProxy(threadFactoryON,
+                NamingThreadFactoryModuleMXBean.class);
+        namingThreadFactoryModuleMXBean.setNamePrefix("prefix");
+
+        mxBean.setThreadFactory(threadFactoryON);
+
+        return nameCreated;
+    }
+
+}
index 1fc0821..03cf9d6 100644 (file)
@@ -1,37 +1,37 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.config.threadpool.fixed;\r
-\r
-import static org.mockito.Mockito.doNothing;\r
-import static org.mockito.Mockito.doReturn;\r
-import static org.mockito.Mockito.mock;\r
-\r
-import java.util.concurrent.ExecutorService;\r
-\r
-import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;\r
-import org.opendaylight.controller.config.api.ModuleIdentifier;\r
-import org.opendaylight.controller.config.manager.impl.AbstractMockedModule;\r
-import org.opendaylight.controller.config.spi.Module;\r
-import org.opendaylight.controller.config.threadpool.util.FixedThreadPoolWrapper;\r
-import org.opendaylight.controller.config.yang.threadpool.ThreadPoolServiceInterface;\r
-\r
-public class TestingFixedThreadPoolModule extends AbstractMockedModule implements ThreadPoolServiceInterface, Module {\r
-\r
-    public TestingFixedThreadPoolModule(DynamicMBeanWithInstance old, ModuleIdentifier id) {\r
-        super(old, id);\r
-    }\r
-\r
-    @Override\r
-    protected AutoCloseable prepareMockedInstance() throws Exception {\r
-        FixedThreadPoolWrapper pool = mock(FixedThreadPoolWrapper.class);\r
-        doNothing().when(pool).close();\r
-        doReturn(mock(ExecutorService.class)).when(pool).getExecutor();\r
-        return pool;\r
-    }\r
-\r
-}\r
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.config.threadpool.fixed;
+
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+
+import java.util.concurrent.ExecutorService;
+
+import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.opendaylight.controller.config.manager.impl.AbstractMockedModule;
+import org.opendaylight.controller.config.spi.Module;
+import org.opendaylight.controller.config.threadpool.util.FixedThreadPoolWrapper;
+import org.opendaylight.controller.config.yang.threadpool.ThreadPoolServiceInterface;
+
+public class TestingFixedThreadPoolModule extends AbstractMockedModule implements ThreadPoolServiceInterface, Module {
+
+    public TestingFixedThreadPoolModule(DynamicMBeanWithInstance old, ModuleIdentifier id) {
+        super(old, id);
+    }
+
+    @Override
+    protected AutoCloseable prepareMockedInstance() throws Exception {
+        FixedThreadPoolWrapper pool = mock(FixedThreadPoolWrapper.class);
+        doNothing().when(pool).close();
+        doReturn(mock(ExecutorService.class)).when(pool).getExecutor();
+        return pool;
+    }
+
+}
index 43cb7e1..f0e8a10 100644 (file)
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.config.threadpool.flexible;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.opendaylight.controller.config.api.ConflictingVersionException;\r
-import org.opendaylight.controller.config.api.ValidationException;\r
-import org.opendaylight.controller.config.api.jmx.CommitStatus;\r
-import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;\r
-import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;\r
-import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;\r
-import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleFactory;\r
-import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleMXBean;\r
-import org.opendaylight.controller.config.yang.threadpool.impl.flexible.FlexibleThreadPoolModuleFactory;\r
-import org.opendaylight.controller.config.yang.threadpool.impl.flexible.FlexibleThreadPoolModuleMXBean;\r
-\r
-import javax.management.InstanceAlreadyExistsException;\r
-import javax.management.InstanceNotFoundException;\r
-import javax.management.ObjectName;\r
-\r
-import static org.junit.Assert.assertThat;\r
-import static org.junit.Assert.fail;\r
-import static org.junit.matchers.JUnitMatchers.containsString;\r
-\r
-public class FlexibleThreadPoolConfigBeanTest extends AbstractConfigTest {\r
-\r
-    private FlexibleThreadPoolModuleFactory flexibleFactory;\r
-    private final String instanceName = "flexible1";\r
-    private final String threadFactoryName = "threadFactoryName";\r
-\r
-    @Before\r
-    public void setUp() {\r
-\r
-        flexibleFactory = new FlexibleThreadPoolModuleFactory();\r
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(flexibleFactory,\r
-                new NamingThreadFactoryModuleFactory()));\r
-    }\r
-\r
-    @Test\r
-    public void testCreateBean() throws InstanceAlreadyExistsException, ValidationException,\r
-            ConflictingVersionException {\r
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
-\r
-        createFlexible(transaction, instanceName, threadFactoryName, 1, 20, 20);\r
-        transaction.validateConfig();\r
-        CommitStatus status = transaction.commit();\r
-\r
-        assertBeanCount(1, flexibleFactory.getImplementationName());\r
-        assertStatus(status, 2, 0, 0);\r
-    }\r
-\r
-    @Test\r
-    public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException,\r
-            ValidationException {\r
-\r
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
-        createFlexible(transaction, instanceName, threadFactoryName, 1, 20, 10);\r
-\r
-        transaction.commit();\r
-\r
-        assertBeanCount(1, flexibleFactory.getImplementationName());\r
-\r
-        transaction = configRegistryClient.createTransaction();\r
-        CommitStatus status = transaction.commit();\r
-\r
-        assertBeanCount(1, flexibleFactory.getImplementationName());\r
-        assertStatus(status, 0, 0, 2);\r
-\r
-    }\r
-\r
-    @Test\r
-    public void testInstanceAlreadyExistsException() throws ConflictingVersionException, ValidationException {\r
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
-\r
-        try {\r
-            createFlexible(transaction, instanceName, threadFactoryName, 1, 1, 2);\r
-            transaction.commit();\r
-        } catch (InstanceAlreadyExistsException e1) {\r
-            fail();\r
-        }\r
-\r
-        transaction = configRegistryClient.createTransaction();\r
-        try {\r
-            createFlexible(transaction, instanceName, "threadFactoryName1", 2, 2, 2);\r
-            fail();\r
-        } catch (InstanceAlreadyExistsException e) {\r
-            assertThat(\r
-                    e.getMessage(),\r
-                    containsString("There is an instance registered with name ModuleIdentifier{factoryName='threadpool-flexible', instanceName='flexible1'}"));\r
-        }\r
-    }\r
-\r
-    @Test\r
-    public void testValidationException() throws InstanceAlreadyExistsException {\r
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
-\r
-        createFlexible(transaction, instanceName, threadFactoryName, 0, 10, 10);\r
-\r
-        try {\r
-            transaction.validateConfig();\r
-            fail();\r
-        } catch (ValidationException e) {\r
-            assertThat(e.getMessage(), containsString("MinThreadCount must be greater than zero"));\r
-        }\r
-    }\r
-\r
-    @Test\r
-    public void testValidationException2() throws InstanceAlreadyExistsException {\r
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
-\r
-        createFlexible(transaction, instanceName, threadFactoryName, 0, 0, 10);\r
-\r
-        try {\r
-            transaction.validateConfig();\r
-            fail();\r
-        } catch (ValidationException e) {\r
-            assertThat(e.getMessage(), containsString("KeepAliveMillis must be greater than zero"));\r
-        }\r
-    }\r
-\r
-    @Test\r
-    public void testValidationException3() throws InstanceAlreadyExistsException {\r
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
-\r
-        createFlexible(transaction, instanceName, threadFactoryName, 10, 50, 0);\r
-\r
-        try {\r
-            transaction.validateConfig();\r
-            fail();\r
-        } catch (ValidationException e) {\r
-            assertThat(e.getMessage(), containsString("MaxThreadCount must be greater than zero"));\r
-        }\r
-    }\r
-\r
-    private ObjectName createFlexible(ConfigTransactionJMXClient transaction, String instanceName,\r
-            String threadFactoryName, int minThreadCount, long keepAliveMillis, int maxThreadCount)\r
-            throws InstanceAlreadyExistsException {\r
-\r
-        ObjectName threadFactoryON = transaction.createModule(NamingThreadFactoryModuleFactory.NAME, threadFactoryName);\r
-        NamingThreadFactoryModuleMXBean namingThreadFactoryModuleMXBean = transaction.newMXBeanProxy(threadFactoryON,\r
-                NamingThreadFactoryModuleMXBean.class);\r
-        namingThreadFactoryModuleMXBean.setNamePrefix("prefix");\r
-\r
-        ObjectName flexibleON = transaction.createModule(flexibleFactory.getImplementationName(), instanceName);\r
-        FlexibleThreadPoolModuleMXBean mxBean = transaction.newMBeanProxy(flexibleON,\r
-                FlexibleThreadPoolModuleMXBean.class);\r
-        mxBean.setKeepAliveMillis(keepAliveMillis);\r
-        mxBean.setMaxThreadCount(maxThreadCount);\r
-        mxBean.setMinThreadCount(minThreadCount);\r
-        mxBean.setThreadFactory(threadFactoryON);\r
-        return flexibleON;\r
-    }\r
-\r
-    @Test\r
-    public void testReconfigurationInstance() throws InstanceAlreadyExistsException, ValidationException,\r
-            ConflictingVersionException, InstanceNotFoundException {\r
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
-        createFlexible(transaction, instanceName, threadFactoryName, 2, 2, 2);\r
-\r
-        transaction.commit();\r
-\r
-        transaction = configRegistryClient.createTransaction();\r
-        ObjectName databaseNew = transaction.lookupConfigBean(flexibleFactory.getImplementationName(), instanceName);\r
-        FlexibleThreadPoolModuleMXBean proxy = transaction.newMXBeanProxy(databaseNew,\r
-                FlexibleThreadPoolModuleMXBean.class);\r
-        proxy.setMaxThreadCount(99);\r
-\r
-        CommitStatus status = transaction.commit();\r
-\r
-        assertBeanCount(1, flexibleFactory.getImplementationName());\r
-        assertStatus(status, 0, 1, 1);\r
-    }\r
-\r
-}\r
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.config.threadpool.flexible;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.config.api.ConflictingVersionException;
+import org.opendaylight.controller.config.api.ValidationException;
+import org.opendaylight.controller.config.api.jmx.CommitStatus;
+import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
+import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
+import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
+import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleFactory;
+import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleMXBean;
+import org.opendaylight.controller.config.yang.threadpool.impl.flexible.FlexibleThreadPoolModuleFactory;
+import org.opendaylight.controller.config.yang.threadpool.impl.flexible.FlexibleThreadPoolModuleMXBean;
+
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.ObjectName;
+
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+import static org.junit.matchers.JUnitMatchers.containsString;
+
+public class FlexibleThreadPoolConfigBeanTest extends AbstractConfigTest {
+
+    private FlexibleThreadPoolModuleFactory flexibleFactory;
+    private final String instanceName = "flexible1";
+    private final String threadFactoryName = "threadFactoryName";
+
+    @Before
+    public void setUp() {
+
+        flexibleFactory = new FlexibleThreadPoolModuleFactory();
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(flexibleFactory,
+                new NamingThreadFactoryModuleFactory()));
+    }
+
+    @Test
+    public void testCreateBean() throws InstanceAlreadyExistsException, ValidationException,
+            ConflictingVersionException {
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+
+        createFlexible(transaction, instanceName, threadFactoryName, 1, 20, 20);
+        transaction.validateConfig();
+        CommitStatus status = transaction.commit();
+
+        assertBeanCount(1, flexibleFactory.getImplementationName());
+        assertStatus(status, 2, 0, 0);
+    }
+
+    @Test
+    public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException,
+            ValidationException {
+
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+        createFlexible(transaction, instanceName, threadFactoryName, 1, 20, 10);
+
+        transaction.commit();
+
+        assertBeanCount(1, flexibleFactory.getImplementationName());
+
+        transaction = configRegistryClient.createTransaction();
+        CommitStatus status = transaction.commit();
+
+        assertBeanCount(1, flexibleFactory.getImplementationName());
+        assertStatus(status, 0, 0, 2);
+
+    }
+
+    @Test
+    public void testInstanceAlreadyExistsException() throws ConflictingVersionException, ValidationException {
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+
+        try {
+            createFlexible(transaction, instanceName, threadFactoryName, 1, 1, 2);
+            transaction.commit();
+        } catch (InstanceAlreadyExistsException e1) {
+            fail();
+        }
+
+        transaction = configRegistryClient.createTransaction();
+        try {
+            createFlexible(transaction, instanceName, "threadFactoryName1", 2, 2, 2);
+            fail();
+        } catch (InstanceAlreadyExistsException e) {
+            assertThat(
+                    e.getMessage(),
+                    containsString("There is an instance registered with name ModuleIdentifier{factoryName='threadpool-flexible', instanceName='flexible1'}"));
+        }
+    }
+
+    @Test
+    public void testValidationException() throws InstanceAlreadyExistsException {
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+
+        createFlexible(transaction, instanceName, threadFactoryName, 0, 10, 10);
+
+        try {
+            transaction.validateConfig();
+            fail();
+        } catch (ValidationException e) {
+            assertThat(e.getMessage(), containsString("MinThreadCount must be greater than zero"));
+        }
+    }
+
+    @Test
+    public void testValidationException2() throws InstanceAlreadyExistsException {
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+
+        createFlexible(transaction, instanceName, threadFactoryName, 0, 0, 10);
+
+        try {
+            transaction.validateConfig();
+            fail();
+        } catch (ValidationException e) {
+            assertThat(e.getMessage(), containsString("KeepAliveMillis must be greater than zero"));
+        }
+    }
+
+    @Test
+    public void testValidationException3() throws InstanceAlreadyExistsException {
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+
+        createFlexible(transaction, instanceName, threadFactoryName, 10, 50, 0);
+
+        try {
+            transaction.validateConfig();
+            fail();
+        } catch (ValidationException e) {
+            assertThat(e.getMessage(), containsString("MaxThreadCount must be greater than zero"));
+        }
+    }
+
+    private ObjectName createFlexible(ConfigTransactionJMXClient transaction, String instanceName,
+            String threadFactoryName, int minThreadCount, long keepAliveMillis, int maxThreadCount)
+            throws InstanceAlreadyExistsException {
+
+        ObjectName threadFactoryON = transaction.createModule(NamingThreadFactoryModuleFactory.NAME, threadFactoryName);
+        NamingThreadFactoryModuleMXBean namingThreadFactoryModuleMXBean = transaction.newMXBeanProxy(threadFactoryON,
+                NamingThreadFactoryModuleMXBean.class);
+        namingThreadFactoryModuleMXBean.setNamePrefix("prefix");
+
+        ObjectName flexibleON = transaction.createModule(flexibleFactory.getImplementationName(), instanceName);
+        FlexibleThreadPoolModuleMXBean mxBean = transaction.newMBeanProxy(flexibleON,
+                FlexibleThreadPoolModuleMXBean.class);
+        mxBean.setKeepAliveMillis(keepAliveMillis);
+        mxBean.setMaxThreadCount(maxThreadCount);
+        mxBean.setMinThreadCount(minThreadCount);
+        mxBean.setThreadFactory(threadFactoryON);
+        return flexibleON;
+    }
+
+    @Test
+    public void testReconfigurationInstance() throws InstanceAlreadyExistsException, ValidationException,
+            ConflictingVersionException, InstanceNotFoundException {
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+        createFlexible(transaction, instanceName, threadFactoryName, 2, 2, 2);
+
+        transaction.commit();
+
+        transaction = configRegistryClient.createTransaction();
+        ObjectName databaseNew = transaction.lookupConfigBean(flexibleFactory.getImplementationName(), instanceName);
+        FlexibleThreadPoolModuleMXBean proxy = transaction.newMXBeanProxy(databaseNew,
+                FlexibleThreadPoolModuleMXBean.class);
+        proxy.setMaxThreadCount(99);
+
+        CommitStatus status = transaction.commit();
+
+        assertBeanCount(1, flexibleFactory.getImplementationName());
+        assertStatus(status, 0, 1, 1);
+    }
+
+}
index 7280b04..6dea96e 100644 (file)
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.config.threadpool.naming;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-import static org.junit.Assert.assertThat;\r
-import static org.junit.Assert.assertTrue;\r
-import static org.junit.Assert.fail;\r
-import static org.junit.matchers.JUnitMatchers.containsString;\r
-\r
-import javax.management.InstanceAlreadyExistsException;\r
-import javax.management.InstanceNotFoundException;\r
-import javax.management.ObjectName;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.opendaylight.controller.config.api.ConflictingVersionException;\r
-import org.opendaylight.controller.config.api.ValidationException;\r
-import org.opendaylight.controller.config.api.jmx.CommitStatus;\r
-import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;\r
-import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;\r
-import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;\r
-import org.opendaylight.controller.config.yang.threadpool.ThreadFactoryServiceInterface;\r
-import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleFactory;\r
-import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleMXBean;\r
-\r
-public class NamingThreadPoolFactoryConfigBeanTest extends AbstractConfigTest {\r
-\r
-    private NamingThreadFactoryModuleFactory factory;\r
-    private final String instanceName = "named";\r
-\r
-    @Before\r
-    public void setUp() {\r
-\r
-        factory = new NamingThreadFactoryModuleFactory();\r
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory));\r
-    }\r
-\r
-    @Test\r
-    public void testCreateBean() throws InstanceAlreadyExistsException, ValidationException,\r
-            ConflictingVersionException {\r
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
-\r
-        createNamed(transaction, instanceName, "prefixes");\r
-        transaction.validateConfig();\r
-        CommitStatus status = transaction.commit();\r
-\r
-        assertEquals(1, configRegistry.lookupConfigBeans(factory.getImplementationName()).size());\r
-        assertEquals(1, status.getNewInstances().size());\r
-        assertEquals(0, status.getRecreatedInstances().size());\r
-        assertEquals(0, status.getReusedInstances().size());\r
-    }\r
-\r
-    @Test\r
-    public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException,\r
-            ValidationException {\r
-\r
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
-        createNamed(transaction, instanceName, "prefixes");\r
-\r
-        transaction.commit();\r
-\r
-        assertEquals(1, configRegistry.lookupConfigBeans(factory.getImplementationName()).size());\r
-\r
-        transaction = configRegistryClient.createTransaction();\r
-        CommitStatus status = transaction.commit();\r
-\r
-        assertEquals(1, configRegistry.lookupConfigBeans(factory.getImplementationName()).size());\r
-        assertEquals(0, status.getNewInstances().size());\r
-        assertEquals(0, status.getRecreatedInstances().size());\r
-        assertEquals(1, status.getReusedInstances().size());\r
-\r
-    }\r
-\r
-    @Test\r
-    public void testInstanceAlreadyExistsException() throws ConflictingVersionException, ValidationException,\r
-            InstanceAlreadyExistsException {\r
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
-\r
-        createNamed(transaction, instanceName, "prefixes");\r
-        transaction.commit();\r
-\r
-        transaction = configRegistryClient.createTransaction();\r
-        try {\r
-            createNamed(transaction, instanceName, "prefixes1");\r
-            fail();\r
-        } catch (InstanceAlreadyExistsException e) {\r
-            assertThat(\r
-                    e.getMessage(),\r
-                    containsString("There is an instance registered with name ModuleIdentifier{factoryName='threadfactory-naming', instanceName='named'}"));\r
-        }\r
-    }\r
-\r
-    @Test\r
-    public void testValidationException() throws InstanceAlreadyExistsException {\r
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
-\r
-        ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), instanceName);\r
-        transaction.newMXBeanProxy(nameCreated, ThreadFactoryServiceInterface.class);\r
-        try {\r
-            transaction.validateConfig();\r
-            fail();\r
-        } catch (ValidationException e) {\r
-            assertTrue(e.getFailedValidations().containsKey(factory.getImplementationName()));\r
-            assertEquals(1, e.getFailedValidations().get(factory.getImplementationName()).keySet().size());\r
-        }\r
-    }\r
-\r
-    @Test\r
-    public void testReconfigurationInstance() throws InstanceAlreadyExistsException, ValidationException,\r
-            ConflictingVersionException, InstanceNotFoundException {\r
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
-        createNamed(transaction, instanceName, "pref");\r
-\r
-        transaction.commit();\r
-\r
-        transaction = configRegistryClient.createTransaction();\r
-        ObjectName databaseNew = transaction.lookupConfigBean(factory.getImplementationName(), instanceName);\r
-        NamingThreadFactoryModuleMXBean proxy = transaction.newMXBeanProxy(databaseNew,\r
-                NamingThreadFactoryModuleMXBean.class);\r
-        proxy.setNamePrefix("pref1");\r
-\r
-        CommitStatus status = transaction.commit();\r
-\r
-        assertBeanCount(1, factory.getImplementationName());\r
-        assertStatus(status, 0, 1, 0);\r
-    }\r
-\r
-    private ObjectName createNamed(ConfigTransactionJMXClient transaction, String instanceName, String prefixes)\r
-            throws InstanceAlreadyExistsException {\r
-        ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), instanceName);\r
-        NamingThreadFactoryModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated,\r
-                NamingThreadFactoryModuleMXBean.class);\r
-        mxBean.setNamePrefix(prefixes);\r
-        return nameCreated;\r
-    }\r
-\r
-}\r
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.config.threadpool.naming;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.junit.matchers.JUnitMatchers.containsString;
+
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.ObjectName;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.config.api.ConflictingVersionException;
+import org.opendaylight.controller.config.api.ValidationException;
+import org.opendaylight.controller.config.api.jmx.CommitStatus;
+import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
+import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
+import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
+import org.opendaylight.controller.config.yang.threadpool.ThreadFactoryServiceInterface;
+import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleFactory;
+import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleMXBean;
+
+public class NamingThreadPoolFactoryConfigBeanTest extends AbstractConfigTest {
+
+    private NamingThreadFactoryModuleFactory factory;
+    private final String instanceName = "named";
+
+    @Before
+    public void setUp() {
+
+        factory = new NamingThreadFactoryModuleFactory();
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory));
+    }
+
+    @Test
+    public void testCreateBean() throws InstanceAlreadyExistsException, ValidationException,
+            ConflictingVersionException {
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+
+        createNamed(transaction, instanceName, "prefixes");
+        transaction.validateConfig();
+        CommitStatus status = transaction.commit();
+
+        assertEquals(1, configRegistry.lookupConfigBeans(factory.getImplementationName()).size());
+        assertEquals(1, status.getNewInstances().size());
+        assertEquals(0, status.getRecreatedInstances().size());
+        assertEquals(0, status.getReusedInstances().size());
+    }
+
+    @Test
+    public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException,
+            ValidationException {
+
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+        createNamed(transaction, instanceName, "prefixes");
+
+        transaction.commit();
+
+        assertEquals(1, configRegistry.lookupConfigBeans(factory.getImplementationName()).size());
+
+        transaction = configRegistryClient.createTransaction();
+        CommitStatus status = transaction.commit();
+
+        assertEquals(1, configRegistry.lookupConfigBeans(factory.getImplementationName()).size());
+        assertEquals(0, status.getNewInstances().size());
+        assertEquals(0, status.getRecreatedInstances().size());
+        assertEquals(1, status.getReusedInstances().size());
+
+    }
+
+    @Test
+    public void testInstanceAlreadyExistsException() throws ConflictingVersionException, ValidationException,
+            InstanceAlreadyExistsException {
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+
+        createNamed(transaction, instanceName, "prefixes");
+        transaction.commit();
+
+        transaction = configRegistryClient.createTransaction();
+        try {
+            createNamed(transaction, instanceName, "prefixes1");
+            fail();
+        } catch (InstanceAlreadyExistsException e) {
+            assertThat(
+                    e.getMessage(),
+                    containsString("There is an instance registered with name ModuleIdentifier{factoryName='threadfactory-naming', instanceName='named'}"));
+        }
+    }
+
+    @Test
+    public void testValidationException() throws InstanceAlreadyExistsException {
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+
+        ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), instanceName);
+        transaction.newMXBeanProxy(nameCreated, ThreadFactoryServiceInterface.class);
+        try {
+            transaction.validateConfig();
+            fail();
+        } catch (ValidationException e) {
+            assertTrue(e.getFailedValidations().containsKey(factory.getImplementationName()));
+            assertEquals(1, e.getFailedValidations().get(factory.getImplementationName()).keySet().size());
+        }
+    }
+
+    @Test
+    public void testReconfigurationInstance() throws InstanceAlreadyExistsException, ValidationException,
+            ConflictingVersionException, InstanceNotFoundException {
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+        createNamed(transaction, instanceName, "pref");
+
+        transaction.commit();
+
+        transaction = configRegistryClient.createTransaction();
+        ObjectName databaseNew = transaction.lookupConfigBean(factory.getImplementationName(), instanceName);
+        NamingThreadFactoryModuleMXBean proxy = transaction.newMXBeanProxy(databaseNew,
+                NamingThreadFactoryModuleMXBean.class);
+        proxy.setNamePrefix("pref1");
+
+        CommitStatus status = transaction.commit();
+
+        assertBeanCount(1, factory.getImplementationName());
+        assertStatus(status, 0, 1, 0);
+    }
+
+    private ObjectName createNamed(ConfigTransactionJMXClient transaction, String instanceName, String prefixes)
+            throws InstanceAlreadyExistsException {
+        ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), instanceName);
+        NamingThreadFactoryModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated,
+                NamingThreadFactoryModuleMXBean.class);
+        mxBean.setNamePrefix(prefixes);
+        return nameCreated;
+    }
+
+}
index f22da34..47613bf 100644 (file)
@@ -1,66 +1,66 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.config.threadpool.naming;\r
-\r
-import static org.mockito.Matchers.any;\r
-import static org.mockito.Mockito.doNothing;\r
-import static org.mockito.Mockito.doReturn;\r
-import static org.mockito.Mockito.mock;\r
-\r
-import java.io.Closeable;\r
-import java.io.IOException;\r
-\r
-import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;\r
-import org.opendaylight.controller.config.api.ModuleIdentifier;\r
-import org.opendaylight.controller.config.spi.Module;\r
-import org.opendaylight.controller.config.threadpool.util.NamingThreadPoolFactory;\r
-import org.opendaylight.controller.config.yang.threadpool.ThreadFactoryServiceInterface;\r
-import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleMXBean;\r
-\r
-public class TestingNamingThreadPoolFactoryModule implements Module, ThreadFactoryServiceInterface,\r
-        NamingThreadFactoryModuleMXBean {\r
-\r
-    private final NamingThreadPoolFactory fact;\r
-\r
-    public TestingNamingThreadPoolFactoryModule() throws IOException {\r
-        fact = mock(NamingThreadPoolFactory.class);\r
-        Thread thread = mock(Thread.class);\r
-        doNothing().when(thread).start();\r
-        doReturn(thread).when(fact).newThread(any(Runnable.class));\r
-        doNothing().when(fact).close();\r
-    }\r
-\r
-    public TestingNamingThreadPoolFactoryModule(DynamicMBeanWithInstance old) {\r
-        fact = (NamingThreadPoolFactory) old.getInstance();\r
-    }\r
-\r
-    @Override\r
-    public ModuleIdentifier getIdentifier() {\r
-        return new ModuleIdentifier(TestingNamingThreadPoolFactoryModule.class.getCanonicalName(), "mock");\r
-    }\r
-\r
-    @Override\r
-    public String getNamePrefix() {\r
-        return null;\r
-    }\r
-\r
-    @Override\r
-    public void setNamePrefix(String arg) {\r
-        throw new UnsupportedOperationException();\r
-    }\r
-\r
-    @Override\r
-    public void validate() {\r
-    }\r
-\r
-    @Override\r
-    public Closeable getInstance() {\r
-        return fact;\r
-    }\r
-\r
-}\r
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.config.threadpool.naming;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+
+import java.io.Closeable;
+import java.io.IOException;
+
+import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.opendaylight.controller.config.spi.Module;
+import org.opendaylight.controller.config.threadpool.util.NamingThreadPoolFactory;
+import org.opendaylight.controller.config.yang.threadpool.ThreadFactoryServiceInterface;
+import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleMXBean;
+
+public class TestingNamingThreadPoolFactoryModule implements Module, ThreadFactoryServiceInterface,
+        NamingThreadFactoryModuleMXBean {
+
+    private final NamingThreadPoolFactory fact;
+
+    public TestingNamingThreadPoolFactoryModule() throws IOException {
+        fact = mock(NamingThreadPoolFactory.class);
+        Thread thread = mock(Thread.class);
+        doNothing().when(thread).start();
+        doReturn(thread).when(fact).newThread(any(Runnable.class));
+        doNothing().when(fact).close();
+    }
+
+    public TestingNamingThreadPoolFactoryModule(DynamicMBeanWithInstance old) {
+        fact = (NamingThreadPoolFactory) old.getInstance();
+    }
+
+    @Override
+    public ModuleIdentifier getIdentifier() {
+        return new ModuleIdentifier(TestingNamingThreadPoolFactoryModule.class.getCanonicalName(), "mock");
+    }
+
+    @Override
+    public String getNamePrefix() {
+        return null;
+    }
+
+    @Override
+    public void setNamePrefix(String arg) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void validate() {
+    }
+
+    @Override
+    public Closeable getInstance() {
+        return fact;
+    }
+
+}
index 6183cb5..538d437 100644 (file)
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.config.threadpool.scheduled;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.opendaylight.controller.config.api.ConflictingVersionException;\r
-import org.opendaylight.controller.config.api.ValidationException;\r
-import org.opendaylight.controller.config.api.jmx.CommitStatus;\r
-import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;\r
-import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;\r
-import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;\r
-import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleFactory;\r
-import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleMXBean;\r
-import org.opendaylight.controller.config.yang.threadpool.impl.scheduled.ScheduledThreadPoolModuleFactory;\r
-import org.opendaylight.controller.config.yang.threadpool.impl.scheduled.ScheduledThreadPoolModuleMXBean;\r
-\r
-import javax.management.InstanceAlreadyExistsException;\r
-import javax.management.InstanceNotFoundException;\r
-import javax.management.ObjectName;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-import static org.junit.Assert.assertThat;\r
-import static org.junit.Assert.assertTrue;\r
-import static org.junit.Assert.fail;\r
-import static org.junit.matchers.JUnitMatchers.containsString;\r
-\r
-public class ScheduledThreadPoolConfigBeanTest extends AbstractConfigTest {\r
-\r
-    private ScheduledThreadPoolModuleFactory factory;\r
-    private final String instanceName = "scheduled1";\r
-\r
-    @Before\r
-    public void setUp() {\r
-\r
-        factory = new ScheduledThreadPoolModuleFactory();\r
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory,\r
-                new NamingThreadFactoryModuleFactory()));\r
-    }\r
-\r
-    @Test\r
-    public void testCreateBean() throws InstanceAlreadyExistsException, ValidationException,\r
-            ConflictingVersionException {\r
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
-\r
-        createScheduled(transaction, instanceName, 1);\r
-        transaction.validateConfig();\r
-        CommitStatus status = transaction.commit();\r
-\r
-        assertBeanCount(1, factory.getImplementationName());\r
-        assertStatus(status, 2, 0, 0);\r
-    }\r
-\r
-    @Test\r
-    public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException,\r
-            ValidationException {\r
-\r
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
-        createScheduled(transaction, instanceName, 1);\r
-\r
-        transaction.commit();\r
-\r
-        assertBeanCount(1, factory.getImplementationName());\r
-\r
-        transaction = configRegistryClient.createTransaction();\r
-        CommitStatus status = transaction.commit();\r
-\r
-        assertBeanCount(1, factory.getImplementationName());\r
-        assertStatus(status, 0, 0, 2);\r
-    }\r
-\r
-    @Test\r
-    public void testReconfigurationInstance() throws InstanceAlreadyExistsException, ValidationException,\r
-            ConflictingVersionException, InstanceNotFoundException {\r
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
-        createScheduled(transaction, instanceName, 1);\r
-\r
-        transaction.commit();\r
-\r
-        transaction = configRegistryClient.createTransaction();\r
-        ObjectName databaseNew = transaction.lookupConfigBean(factory.getImplementationName(), instanceName);\r
-        ScheduledThreadPoolModuleMXBean proxy = transaction.newMXBeanProxy(databaseNew,\r
-                ScheduledThreadPoolModuleMXBean.class);\r
-        proxy.setMaxThreadCount(99);\r
-\r
-        CommitStatus status = transaction.commit();\r
-\r
-        assertBeanCount(1, factory.getImplementationName());\r
-        assertStatus(status, 0, 1, 1);\r
-    }\r
-\r
-    @Test\r
-    public void testDestroy() throws InstanceAlreadyExistsException, ValidationException, ConflictingVersionException,\r
-            InstanceNotFoundException {\r
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
-        createScheduled(transaction, instanceName, 1);\r
-\r
-        transaction.commit();\r
-\r
-        transaction = configRegistryClient.createTransaction();\r
-        transaction.destroyConfigBean(factory.getImplementationName(), instanceName);\r
-        CommitStatus status = transaction.commit();\r
-\r
-        assertBeanCount(0, factory.getImplementationName());\r
-        assertStatus(status, 0, 0, 1);\r
-    }\r
-\r
-    @Test\r
-    public void testInstanceAlreadyExistsException() throws ConflictingVersionException, ValidationException,\r
-            InstanceAlreadyExistsException {\r
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
-        createScheduled(transaction, instanceName, 1);\r
-        transaction.commit();\r
-        transaction = configRegistryClient.createTransaction();\r
-        try {\r
-            createScheduled(transaction, instanceName, 2);\r
-            fail();\r
-        } catch (InstanceAlreadyExistsException e) {\r
-            assertThat(\r
-                    e.getMessage(),\r
-                    containsString("There is an instance registered with name ModuleIdentifier{factoryName='threadpool-scheduled', instanceName='scheduled1'}"));\r
-        }\r
-    }\r
-\r
-    @Test\r
-    public void testValidationException() throws InstanceAlreadyExistsException {\r
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();\r
-        createScheduled(transaction, instanceName, 0);\r
-\r
-        try {\r
-            transaction.validateConfig();\r
-            fail();\r
-        } catch (ValidationException e) {\r
-            assertTrue(e.getFailedValidations().containsKey(factory.getImplementationName()));\r
-            assertEquals(1, e.getFailedValidations().get(factory.getImplementationName()).keySet().size());\r
-        }\r
-    }\r
-\r
-    private ObjectName createScheduled(ConfigTransactionJMXClient transaction, String instanceName, int maxThreadCount)\r
-            throws InstanceAlreadyExistsException {\r
-        ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), instanceName);\r
-        ScheduledThreadPoolModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated,\r
-                ScheduledThreadPoolModuleMXBean.class);\r
-        mxBean.setMaxThreadCount(maxThreadCount);\r
-\r
-        ObjectName threadFactoryON = transaction.createModule(NamingThreadFactoryModuleFactory.NAME, "naming");\r
-        NamingThreadFactoryModuleMXBean namingThreadFactoryModuleMXBean = transaction.newMXBeanProxy(threadFactoryON,\r
-                NamingThreadFactoryModuleMXBean.class);\r
-        namingThreadFactoryModuleMXBean.setNamePrefix("prefix");\r
-\r
-        mxBean.setThreadFactory(threadFactoryON);\r
-\r
-        return nameCreated;\r
-    }\r
-\r
-}\r
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.config.threadpool.scheduled;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.config.api.ConflictingVersionException;
+import org.opendaylight.controller.config.api.ValidationException;
+import org.opendaylight.controller.config.api.jmx.CommitStatus;
+import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
+import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
+import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
+import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleFactory;
+import org.opendaylight.controller.config.yang.threadpool.impl.NamingThreadFactoryModuleMXBean;
+import org.opendaylight.controller.config.yang.threadpool.impl.scheduled.ScheduledThreadPoolModuleFactory;
+import org.opendaylight.controller.config.yang.threadpool.impl.scheduled.ScheduledThreadPoolModuleMXBean;
+
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.ObjectName;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.junit.matchers.JUnitMatchers.containsString;
+
+public class ScheduledThreadPoolConfigBeanTest extends AbstractConfigTest {
+
+    private ScheduledThreadPoolModuleFactory factory;
+    private final String instanceName = "scheduled1";
+
+    @Before
+    public void setUp() {
+
+        factory = new ScheduledThreadPoolModuleFactory();
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory,
+                new NamingThreadFactoryModuleFactory()));
+    }
+
+    @Test
+    public void testCreateBean() throws InstanceAlreadyExistsException, ValidationException,
+            ConflictingVersionException {
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+
+        createScheduled(transaction, instanceName, 1);
+        transaction.validateConfig();
+        CommitStatus status = transaction.commit();
+
+        assertBeanCount(1, factory.getImplementationName());
+        assertStatus(status, 2, 0, 0);
+    }
+
+    @Test
+    public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException,
+            ValidationException {
+
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+        createScheduled(transaction, instanceName, 1);
+
+        transaction.commit();
+
+        assertBeanCount(1, factory.getImplementationName());
+
+        transaction = configRegistryClient.createTransaction();
+        CommitStatus status = transaction.commit();
+
+        assertBeanCount(1, factory.getImplementationName());
+        assertStatus(status, 0, 0, 2);
+    }
+
+    @Test
+    public void testReconfigurationInstance() throws InstanceAlreadyExistsException, ValidationException,
+            ConflictingVersionException, InstanceNotFoundException {
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+        createScheduled(transaction, instanceName, 1);
+
+        transaction.commit();
+
+        transaction = configRegistryClient.createTransaction();
+        ObjectName databaseNew = transaction.lookupConfigBean(factory.getImplementationName(), instanceName);
+        ScheduledThreadPoolModuleMXBean proxy = transaction.newMXBeanProxy(databaseNew,
+                ScheduledThreadPoolModuleMXBean.class);
+        proxy.setMaxThreadCount(99);
+
+        CommitStatus status = transaction.commit();
+
+        assertBeanCount(1, factory.getImplementationName());
+        assertStatus(status, 0, 1, 1);
+    }
+
+    @Test
+    public void testDestroy() throws InstanceAlreadyExistsException, ValidationException, ConflictingVersionException,
+            InstanceNotFoundException {
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+        createScheduled(transaction, instanceName, 1);
+
+        transaction.commit();
+
+        transaction = configRegistryClient.createTransaction();
+        transaction.destroyConfigBean(factory.getImplementationName(), instanceName);
+        CommitStatus status = transaction.commit();
+
+        assertBeanCount(0, factory.getImplementationName());
+        assertStatus(status, 0, 0, 1);
+    }
+
+    @Test
+    public void testInstanceAlreadyExistsException() throws ConflictingVersionException, ValidationException,
+            InstanceAlreadyExistsException {
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+        createScheduled(transaction, instanceName, 1);
+        transaction.commit();
+        transaction = configRegistryClient.createTransaction();
+        try {
+            createScheduled(transaction, instanceName, 2);
+            fail();
+        } catch (InstanceAlreadyExistsException e) {
+            assertThat(
+                    e.getMessage(),
+                    containsString("There is an instance registered with name ModuleIdentifier{factoryName='threadpool-scheduled', instanceName='scheduled1'}"));
+        }
+    }
+
+    @Test
+    public void testValidationException() throws InstanceAlreadyExistsException {
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+        createScheduled(transaction, instanceName, 0);
+
+        try {
+            transaction.validateConfig();
+            fail();
+        } catch (ValidationException e) {
+            assertTrue(e.getFailedValidations().containsKey(factory.getImplementationName()));
+            assertEquals(1, e.getFailedValidations().get(factory.getImplementationName()).keySet().size());
+        }
+    }
+
+    private ObjectName createScheduled(ConfigTransactionJMXClient transaction, String instanceName, int maxThreadCount)
+            throws InstanceAlreadyExistsException {
+        ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), instanceName);
+        ScheduledThreadPoolModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated,
+                ScheduledThreadPoolModuleMXBean.class);
+        mxBean.setMaxThreadCount(maxThreadCount);
+
+        ObjectName threadFactoryON = transaction.createModule(NamingThreadFactoryModuleFactory.NAME, "naming");
+        NamingThreadFactoryModuleMXBean namingThreadFactoryModuleMXBean = transaction.newMXBeanProxy(threadFactoryON,
+                NamingThreadFactoryModuleMXBean.class);
+        namingThreadFactoryModuleMXBean.setNamePrefix("prefix");
+
+        mxBean.setThreadFactory(threadFactoryON);
+
+        return nameCreated;
+    }
+
+}
index 0fe5b0d..2ba1b3b 100644 (file)
@@ -1,82 +1,82 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.config.threadpool.scheduled;\r
-\r
-import com.google.common.util.concurrent.ListenableFutureTask;\r
-import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;\r
-import org.opendaylight.controller.config.api.ModuleIdentifier;\r
-import org.opendaylight.controller.config.manager.impl.AbstractMockedModule;\r
-import org.opendaylight.controller.config.spi.Module;\r
-import org.opendaylight.controller.config.threadpool.util.ScheduledThreadPoolWrapper;\r
-import org.opendaylight.controller.config.yang.threadpool.ScheduledThreadPoolServiceInterface;\r
-import org.opendaylight.controller.config.yang.threadpool.impl.scheduled.ScheduledThreadPoolModuleMXBean;\r
-\r
-import javax.management.ObjectName;\r
-import java.util.concurrent.ScheduledExecutorService;\r
-import java.util.concurrent.ScheduledFuture;\r
-import java.util.concurrent.TimeUnit;\r
-\r
-import static org.mockito.Matchers.any;\r
-import static org.mockito.Matchers.anyBoolean;\r
-import static org.mockito.Matchers.anyLong;\r
-import static org.mockito.Mockito.doNothing;\r
-import static org.mockito.Mockito.doReturn;\r
-import static org.mockito.Mockito.mock;\r
-\r
-public class TestingScheduledThreadPoolModule extends AbstractMockedModule implements\r
-        ScheduledThreadPoolServiceInterface, Module, ScheduledThreadPoolModuleMXBean {\r
-\r
-    public TestingScheduledThreadPoolModule(DynamicMBeanWithInstance old, ModuleIdentifier id) {\r
-        super(old, id);\r
-    }\r
-\r
-    @Override\r
-    protected AutoCloseable prepareMockedInstance() throws Exception {\r
-        ScheduledThreadPoolWrapper instance = mock(ScheduledThreadPoolWrapper.class);\r
-        ScheduledExecutorService ses = mock(ScheduledExecutorService.class);\r
-        {// mockFuture\r
-            ScheduledFuture<?> future = mock(ScheduledFuture.class);\r
-            doReturn(false).when(future).cancel(anyBoolean());\r
-            try {\r
-                doReturn(mock(Object.class)).when(future).get();\r
-            } catch (Exception e) {\r
-                throw new RuntimeException(e);\r
-            }\r
-            doReturn(future).when(ses).schedule(any(Runnable.class), any(Long.class), any(TimeUnit.class));\r
-            doReturn(future).when(ses).scheduleWithFixedDelay(any(Runnable.class), anyLong(), anyLong(),\r
-                    any(TimeUnit.class));\r
-\r
-        }\r
-        doNothing().when(ses).execute(any(Runnable.class));\r
-        doNothing().when(ses).execute(any(ListenableFutureTask.class));\r
-        doReturn(ses).when(instance).getExecutor();\r
-        doNothing().when(instance).close();\r
-\r
-        doReturn(1).when(instance).getMaxThreadCount();\r
-        return instance;\r
-    }\r
-\r
-    @Override\r
-    public ObjectName getThreadFactory() {\r
-        return any(ObjectName.class);\r
-    }\r
-\r
-    @Override\r
-    public void setThreadFactory(ObjectName threadFactory) {\r
-    }\r
-\r
-    @Override\r
-    public Integer getMaxThreadCount() {\r
-        return 1;\r
-    }\r
-\r
-    @Override\r
-    public void setMaxThreadCount(Integer maxThreadCount) {\r
-    }\r
-\r
-}\r
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.config.threadpool.scheduled;
+
+import com.google.common.util.concurrent.ListenableFutureTask;
+import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.opendaylight.controller.config.manager.impl.AbstractMockedModule;
+import org.opendaylight.controller.config.spi.Module;
+import org.opendaylight.controller.config.threadpool.util.ScheduledThreadPoolWrapper;
+import org.opendaylight.controller.config.yang.threadpool.ScheduledThreadPoolServiceInterface;
+import org.opendaylight.controller.config.yang.threadpool.impl.scheduled.ScheduledThreadPoolModuleMXBean;
+
+import javax.management.ObjectName;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyBoolean;
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+
+public class TestingScheduledThreadPoolModule extends AbstractMockedModule implements
+        ScheduledThreadPoolServiceInterface, Module, ScheduledThreadPoolModuleMXBean {
+
+    public TestingScheduledThreadPoolModule(DynamicMBeanWithInstance old, ModuleIdentifier id) {
+        super(old, id);
+    }
+
+    @Override
+    protected AutoCloseable prepareMockedInstance() throws Exception {
+        ScheduledThreadPoolWrapper instance = mock(ScheduledThreadPoolWrapper.class);
+        ScheduledExecutorService ses = mock(ScheduledExecutorService.class);
+        {// mockFuture
+            ScheduledFuture<?> future = mock(ScheduledFuture.class);
+            doReturn(false).when(future).cancel(anyBoolean());
+            try {
+                doReturn(mock(Object.class)).when(future).get();
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+            doReturn(future).when(ses).schedule(any(Runnable.class), any(Long.class), any(TimeUnit.class));
+            doReturn(future).when(ses).scheduleWithFixedDelay(any(Runnable.class), anyLong(), anyLong(),
+                    any(TimeUnit.class));
+
+        }
+        doNothing().when(ses).execute(any(Runnable.class));
+        doNothing().when(ses).execute(any(ListenableFutureTask.class));
+        doReturn(ses).when(instance).getExecutor();
+        doNothing().when(instance).close();
+
+        doReturn(1).when(instance).getMaxThreadCount();
+        return instance;
+    }
+
+    @Override
+    public ObjectName getThreadFactory() {
+        return any(ObjectName.class);
+    }
+
+    @Override
+    public void setThreadFactory(ObjectName threadFactory) {
+    }
+
+    @Override
+    public Integer getMaxThreadCount() {
+        return 1;
+    }
+
+    @Override
+    public void setMaxThreadCount(Integer maxThreadCount) {
+    }
+
+}
index a8119b8..c934530 100644 (file)
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <artifactId>config-subsystem</artifactId>
             <artifactId>binding-type-provider</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>net.sourceforge.pmd</groupId>
+            <artifactId>pmd</artifactId>
+            <version>5.1.0</version>
+            <scope>test</scope>
+        </dependency>
+
+
         <dependency>
             <groupId>org.eclipse.jdt</groupId>
             <artifactId>core</artifactId>
         </dependency>
 
 
-        <dependency>
-            <groupId>org.freemarker</groupId>
-            <artifactId>freemarker</artifactId>
-            <version>2.3.20</version>
-        </dependency>
-
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>config-api</artifactId>
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-lang3</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>org.codehaus.gmaven.runtime</groupId>
+            <artifactId>gmaven-runtime-2.0</artifactId>
+            <version>1.5</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.sonatype.gossip</groupId>
+                    <artifactId>gossip</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
     </dependencies>
 
     <build>
         <plugins>
             <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-jar-plugin</artifactId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.1</version>
+                <configuration>
+                    <compilerId>groovy-eclipse-compiler</compilerId>
+                    <verbose>false</verbose>
+                </configuration>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.codehaus.groovy</groupId>
+                        <artifactId>groovy-eclipse-compiler</artifactId>
+                        <version>2.8.0-01</version>
+                    </dependency>
+
+                    <dependency>
+                        <groupId>org.codehaus.groovy</groupId>
+                        <artifactId>groovy-eclipse-batch</artifactId>
+                        <version>2.1.8-01</version>
+                    </dependency>
+                </dependencies>
             </plugin>
+
         </plugins>
     </build>
 </project>
index 13d828a..dd2b504 100644 (file)
  */
 package org.opendaylight.controller.config.yangjmxgenerator.plugin;
 
+import com.google.common.base.Optional;
+import com.google.common.collect.Lists;
+import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry;
+import org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry;
+import org.opendaylight.controller.config.yangjmxgenerator.ServiceInterfaceEntry;
+import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.FtlTemplate;
+import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.GeneralClassTemplate;
+import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.GeneralInterfaceTemplate;
+import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.RuntimeRegistratorFtlTemplate;
+import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.StubFactoryTemplate;
+import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.TemplateFactory;
+import org.opendaylight.controller.config.yangjmxgenerator.plugin.gofactory.AbsFactoryGeneratedObjectFactory;
+import org.opendaylight.controller.config.yangjmxgenerator.plugin.gofactory.AbsModuleGeneratedObjectFactory;
+import org.opendaylight.controller.config.yangjmxgenerator.plugin.gofactory.ConcreteModuleGeneratedObjectFactory;
+import org.opendaylight.controller.config.yangjmxgenerator.plugin.gofactory.GenericGeneratedObjectFactory;
+import org.opendaylight.controller.config.yangjmxgenerator.plugin.java.FullyQualifiedName;
+import org.opendaylight.controller.config.yangjmxgenerator.plugin.java.GeneratedObject;
+import org.opendaylight.controller.config.yangjmxgenerator.plugin.util.StringUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
 
-import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry;
-import org.opendaylight.controller.config.yangjmxgenerator.ServiceInterfaceEntry;
+final class CodeWriter {
+
+    private static final Logger logger = LoggerFactory.getLogger(CodeWriter.class);
+    private static final Optional<String> copyright = StringUtil.loadCopyright();
+
+    public File writeSie(ServiceInterfaceEntry sie, File outputBaseDir) {
+        try {
+            GeneralInterfaceTemplate generalInterfaceTemplate = TemplateFactory.serviceInterfaceFromSie(sie);
+            GeneratedObject go = new GenericGeneratedObjectFactory().toGeneratedObject(generalInterfaceTemplate, copyright);
+            return go.persist(outputBaseDir).get().getValue();
+        } catch (Exception e) {
+            String message = "An error occurred during Service interface generating, sie:"
+                    + sie.getTypeName() + ", " + sie.getFullyQualifiedName();
+            logger.error(message, e);
+            throw new RuntimeException(message, e);
+        }
+    }
+
+    public List<File> writeMbe(ModuleMXBeanEntry mbe, File targetBaseDir,
+                               File mainBaseDir) {
+        try {
+            List<File> generatedFiles = Lists.newArrayList();
+
+
+            Map<GeneratedObject, Boolean /*overwrite*/> gos = new HashMap<>();
+
+            // generate mx interface and abstract factory
+
+            // TOs
+            Map<String,GeneralClassTemplate> tosFromMbe = TemplateFactory.tOsFromMbe(mbe);
+            for(GeneralClassTemplate template: tosFromMbe.values()) {
+                gos.put(new GenericGeneratedObjectFactory().toGeneratedObject(template, copyright), true);
+            }
+
+            // MXBean interface
+            GeneralInterfaceTemplate ifcTemplate = TemplateFactory.mXBeanInterfaceTemplateFromMbe(mbe);
+            gos.put(new GenericGeneratedObjectFactory().toGeneratedObject(ifcTemplate, copyright), true);
+
+
+            // generate abstract factory
+            gos.put(new AbsFactoryGeneratedObjectFactory().toGeneratedObject(mbe, copyright), true);
+
+            // generate abstract module
+            gos.put(new AbsModuleGeneratedObjectFactory().toGeneratedObject(mbe, copyright), true);
+
+            // generate concrete factory
+            StubFactoryTemplate concreteFactory = TemplateFactory.stubFactoryTemplateFromMbe(mbe);
+            gos.put(new GenericGeneratedObjectFactory().toGeneratedObject(concreteFactory, copyright), false);
+
+
+            // generate concrete module
+
+            gos.put(new ConcreteModuleGeneratedObjectFactory().toGeneratedObject(mbe, copyright, Optional.<String>absent()), false);
+
+            // write runtime bean MXBeans and registrators
+            List<FtlTemplate> allFtlFiles = getRuntimeBeanFtlTemplates(mbe.getRuntimeBeans());
+            for(FtlTemplate template: allFtlFiles) {
+                gos.put(new GenericGeneratedObjectFactory().toGeneratedObject(template, copyright), true);
+            }
+
+            generatedFiles.addAll(persistGeneratedObjects(targetBaseDir, mainBaseDir, gos));
+
+            // purge nulls
+            for (Iterator<File> it = generatedFiles.iterator(); it.hasNext(); ) {
+                if (it.next() == null) {
+                    it.remove();
+                }
+            }
+
+            return generatedFiles;
+
+        } catch (Exception e) {
+            String message = "An error occurred during Module generating, mbe:"
+                    + mbe.getJavaNamePrefix();
+            logger.error(message, e);
+            throw new RuntimeException(message, e);
+        }
+    }
 
-public interface CodeWriter {
+    private List<File> persistGeneratedObjects(File targetBaseDir, File mainBaseDir, Map<GeneratedObject, Boolean> gos) throws IOException {
+        List<File> generatedFiles = new ArrayList<>();
+        for (Entry<GeneratedObject, Boolean> entry : gos.entrySet()) {
+            boolean overwrite = entry.getValue();
+            File dst;
+            if (overwrite) {
+                dst = targetBaseDir;
+            } else {
+                dst = mainBaseDir;
+            }
+            Optional<Entry<FullyQualifiedName, File>> maybePersistEntry = entry.getKey().persist(dst, overwrite);
 
-    File writeSie(ServiceInterfaceEntry sie, File targetBaseDir);
+            if (maybePersistEntry.isPresent()) {
+                generatedFiles.add(maybePersistEntry.get().getValue());
+            }
+        }
+        return generatedFiles;
+    }
 
-    List<File> writeMbe(ModuleMXBeanEntry mbe, File targetBaseDir,
-            File mainBaseDir, File resourceBaseDir);
+    private List<FtlTemplate> getRuntimeBeanFtlTemplates(Collection<RuntimeBeanEntry> runtimeBeans) {
+        if (runtimeBeans.isEmpty()) {
+            return Collections.emptyList();
+        }
+        List<FtlTemplate> allFtlFiles = new ArrayList<>();
+        { // registrators
+            Map<String, FtlTemplate> registratorNamesToFtls = RuntimeRegistratorFtlTemplate
+                    .create(RuntimeRegistratorFtlTemplate.findRoot(runtimeBeans));
 
+            allFtlFiles.addAll(registratorNamesToFtls.values());
+        }
+        { // TOs, MXBean interfaces
+            for (RuntimeBeanEntry runtimeBeanEntry : runtimeBeans) {
+                Collection<FtlTemplate> ftlFiles = TemplateFactory
+                        .getTOAndMXInterfaceFtlFiles(runtimeBeanEntry)
+                        .values();
+                allFtlFiles.addAll(ftlFiles);
+            }
+        }
+        return allFtlFiles;
+    }
 }
diff --git a/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/FreeMarkerCodeWriterImpl.java b/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/FreeMarkerCodeWriterImpl.java
deleted file mode 100644 (file)
index 2b84ed1..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.yangjmxgenerator.plugin;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry;
-import org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry;
-import org.opendaylight.controller.config.yangjmxgenerator.ServiceInterfaceEntry;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.FtlFilePersister;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.FtlTemplate;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.RuntimeRegistratorFtlTemplate;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.TemplateFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.Lists;
-
-final class FreeMarkerCodeWriterImpl implements CodeWriter {
-
-    private static final Logger logger = LoggerFactory
-            .getLogger(FreeMarkerCodeWriterImpl.class);
-
-    private final FtlFilePersister ftlFilePersister = new FtlFilePersister();
-
-    public FreeMarkerCodeWriterImpl() {
-    }
-
-    @Override
-    public File writeSie(ServiceInterfaceEntry sie, File outputBaseDir) {
-        try {
-            Collection<FtlTemplate> values = TemplateFactory.getFtlTemplates(
-                    sie).values();
-            return ftlFilePersister.persist(values, outputBaseDir, true).get(0);
-        } catch (Exception e) {
-            String message = "An error occurred during Service interface generating, sie:"
-                    + sie.getTypeName() + ", " + sie.getFullyQualifiedName();
-            logger.error(message, e);
-            throw new RuntimeException(message, e);
-        }
-    }
-
-    @Override
-    public List<File> writeMbe(ModuleMXBeanEntry mbe, File targetBaseDir,
-            File mainBaseDir, File resourceBaseDir) {
-        try {
-            List<File> generatedFiles = Lists.newArrayList();
-
-            generatedFiles.addAll(ftlFilePersister.persist(TemplateFactory
-                    .getFtlTemplates(mbe).values(), targetBaseDir, true));
-            generatedFiles.addAll(ftlFilePersister.persist(TemplateFactory
-                    .getFtlStubTemplates(mbe).values(), mainBaseDir, false));
-
-            // write runtime bean MXBeans and registrators
-            Collection<RuntimeBeanEntry> runtimeBeans = mbe.getRuntimeBeans();
-            if (runtimeBeans.size() > 0) {
-                List<FtlTemplate> allFtlFiles = new ArrayList<>();
-                { // registrators
-                    Map<String, FtlTemplate> registratorNamesToFtls = RuntimeRegistratorFtlTemplate
-                            .create(RuntimeRegistratorFtlTemplate.findRoot(runtimeBeans));
-
-                    allFtlFiles.addAll(registratorNamesToFtls.values());
-                }
-                { // TOs, MXBean interfaces
-                    for (RuntimeBeanEntry runtimeBeanEntry : runtimeBeans) {
-                        Collection<FtlTemplate> ftlFiles = TemplateFactory
-                                .getTOAndMXInterfaceFtlFiles(runtimeBeanEntry)
-                                .values();
-                        allFtlFiles.addAll(ftlFiles);
-                    }
-                }
-                boolean overwrite = true;
-
-                FtlFilePersister ftlFilePersister = new FtlFilePersister();
-                List<File> persisted = ftlFilePersister.persist(allFtlFiles,
-                        targetBaseDir, overwrite);
-                // FIXME: check for intersection
-                generatedFiles.addAll(persisted);
-            }
-
-            // purge nulls
-            for (Iterator<File> it = generatedFiles.iterator(); it.hasNext();) {
-                if (it.next() == null) {
-                    it.remove();
-                }
-            }
-
-            return generatedFiles;
-
-        } catch (Exception e) {
-            String message = "An error occurred during Module generating, mbe:"
-                    + mbe.getJavaNamePrefix();
-            logger.error(message, e);
-            throw new RuntimeException(message, e);
-        }
-    }
-
-}
index e41ac66..1b8905b 100644 (file)
@@ -12,16 +12,6 @@ import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
-import java.io.File;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 import org.apache.commons.io.FileUtils;
 import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.project.MavenProject;
@@ -40,6 +30,17 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.impl.StaticLoggerBinder;
 
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
 /**
  * This class interfaces with yang-maven-plugin. Gets parsed yang modules in
  * {@link SchemaContext}, and parameters form the plugin configuration, and
@@ -61,7 +62,7 @@ public class JMXGenerator implements CodeGenerator {
     private boolean generateModuleFactoryFile = true;
 
     public JMXGenerator() {
-        this.codeWriter = new FreeMarkerCodeWriterImpl();
+        this.codeWriter = new CodeWriter();
     }
 
     public JMXGenerator(CodeWriter codeWriter) {
@@ -139,7 +140,7 @@ public class JMXGenerator implements CodeGenerator {
                 ModuleMXBeanEntry mbe = mbeEntry.getValue();
                 try {
                     List<File> files1 = codeWriter.writeMbe(mbe, outputBaseDir,
-                            mainBaseDir, resourceBaseDir);
+                            mainBaseDir);
                     generatedFiles.addFile(files1);
                 } catch (Exception e) {
                     throw new RuntimeException(
index 35dc7a3..c3e51d6 100644 (file)
@@ -8,94 +8,26 @@
 package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl;
 
 import com.google.common.collect.Lists;
-import org.opendaylight.controller.config.api.DependencyResolver;
-import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
-import org.opendaylight.controller.config.api.ModuleIdentifier;
-import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
-import org.opendaylight.controller.config.spi.Module;
 import org.opendaylight.controller.config.spi.ModuleFactory;
-import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Constructor;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Field;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Header;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.MethodDefinition;
-import org.osgi.framework.BundleContext;
 
 import java.util.Collections;
 import java.util.List;
 
-/**
- *
- */
 public class AbstractFactoryTemplate extends GeneralClassTemplate {
 
     private static final List<String> implementedIfcs = Lists
             .newArrayList(ModuleFactory.class.getCanonicalName());
 
-    private final String globallyUniqueName, moduleInstanceType;
-    private final List<String> providedServices;
-    private final ModuleMXBeanEntry mbe;
-
     public AbstractFactoryTemplate(Header header, String packageName,
-                                   String abstractFactoryName, String globallyUniqueName,
-                                   String moduleInstanceType, List<Field> fields,
-                                   List<String> providedServices, ModuleMXBeanEntry mbe) {
+                                   String abstractFactoryName,
+                                   List<Field> fields) {
         super(header, packageName, abstractFactoryName, Collections
                 .<String> emptyList(), implementedIfcs, fields, Collections
                 .<MethodDefinition> emptyList(), true, false, Collections
                 .<Constructor> emptyList());
-        this.globallyUniqueName = globallyUniqueName;
-        this.moduleInstanceType = moduleInstanceType;
-        this.providedServices = providedServices;
-        this.mbe = mbe;
-    }
-
-    public String getGloballyUniqueName() {
-        return globallyUniqueName;
-    }
-
-    public String getInstanceType() {
-        return AutoCloseable.class.getCanonicalName();
-    }
-
-    public String getModuleNameType() {
-        return ModuleIdentifier.class.getCanonicalName();
-    }
-
-    public String getModuleInstanceType() {
-        return moduleInstanceType;
-    }
-
-    public String getAbstractServiceInterfaceType() {
-        return AbstractServiceInterface.class.getCanonicalName();
-    }
-
-    public List<String> getProvidedServices() {
-        return providedServices;
-    }
-
-    public String getModuleType() {
-        return Module.class.getCanonicalName();
-    }
-
-    public String getDependencyResolverType() {
-        return DependencyResolver.class.getCanonicalName();
-    }
-
-    public String getDynamicMBeanWithInstanceType() {
-        return DynamicMBeanWithInstance.class.getCanonicalName();
-    }
-
-    public String getBundleContextType() {
-        return BundleContext.class.getCanonicalName();
-    }
-
-    @Override
-    public String getFtlTempleteLocation() {
-        return "factory_abs_template.ftl";
-    }
-
-    public ModuleMXBeanEntry getMbe() {
-        return mbe;
     }
 }
index 7f80299..a959978 100644 (file)
@@ -7,17 +7,18 @@
  */
 package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl;
 
-import java.io.File;
-import java.util.List;
-
+import com.google.common.base.Optional;
+import com.google.common.collect.Lists;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Annotation;
+import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Constructor;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Field;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Header;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Method;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.TypeDeclaration;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.util.FullyQualifiedNameHelper;
 
-import com.google.common.collect.Lists;
+import java.util.Collections;
+import java.util.List;
 
 public abstract class AbstractFtlTemplate implements FtlTemplate {
     private final String packageName;
@@ -44,6 +45,15 @@ public abstract class AbstractFtlTemplate implements FtlTemplate {
         return header;
     }
 
+    @Override
+    public Optional<String> getHeaderString() {
+        if (header == null) {
+            return Optional.absent();
+        } else {
+            return Optional.of(header.toString());
+        }
+    }
+
     @Override
     public String getFullyQualifiedName() {
         return FullyQualifiedNameHelper.getFullyQualifiedName(getPackageName(),
@@ -60,9 +70,14 @@ public abstract class AbstractFtlTemplate implements FtlTemplate {
         return typeDeclaration;
     }
 
+
     @Override
-    public String getJavadoc() {
-        return javadoc;
+    public Optional<String> getMaybeJavadoc() {
+        if (javadoc == null) {
+            return Optional.absent();
+        } else {
+            return Optional.of(javadoc);
+        }
     }
 
     public void setJavadoc(String javadoc) {
@@ -84,15 +99,10 @@ public abstract class AbstractFtlTemplate implements FtlTemplate {
         return methods;
     }
 
-    @Override
-    public File getRelativeFile() {
-        return new File(packageName.replace(".", File.separator),
-                getTypeDeclaration().getName() + ".java");
-    }
 
     @Override
-    public String getFtlTempleteLocation() {
-        return "abstract_ftl_file.ftl";
+    public List<Constructor> getConstructors() {
+        return Collections.emptyList();
     }
 
     @Override
index c40bfdf..92a71c2 100644 (file)
@@ -7,26 +7,15 @@
  */
 package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl;
 
-import java.util.Collections;
-import java.util.List;
-
-import org.opendaylight.controller.config.api.DependencyResolver;
-import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
-import org.opendaylight.controller.config.api.ModuleIdentifier;
-import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
-import org.opendaylight.controller.config.api.runtime.RootRuntimeBeanRegistrator;
-import org.opendaylight.controller.config.spi.Module;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Constructor;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Field;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Header;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.MethodDefinition;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.ModuleField;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
-/**
- *
- */
+import java.util.Collections;
+import java.util.List;
+
 public class AbstractModuleTemplate extends GeneralClassTemplate {
 
     private final List<ModuleField> moduleFields;
@@ -50,22 +39,6 @@ public class AbstractModuleTemplate extends GeneralClassTemplate {
         return moduleFields;
     }
 
-    public String getInstanceType() {
-        return AutoCloseable.class.getCanonicalName();
-    }
-
-    public String getModuleNameType() {
-        return ModuleIdentifier.class.getCanonicalName();
-    }
-
-    public String getAbstractServiceInterfaceType() {
-        return AbstractServiceInterface.class.getCanonicalName();
-    }
-
-    public String getModuleType() {
-        return Module.class.getCanonicalName();
-    }
-
     public String getRegistratorType() {
         return registratorType;
     }
@@ -74,29 +47,4 @@ public class AbstractModuleTemplate extends GeneralClassTemplate {
         return runtime;
     }
 
-    public String getDependencyResolverType() {
-        return DependencyResolver.class.getCanonicalName();
-    }
-
-    public String getDynamicMBeanWithInstanceType() {
-        return DynamicMBeanWithInstance.class.getCanonicalName();
-    }
-
-    public String getRootRuntimeRegistratorType() {
-        return RootRuntimeBeanRegistrator.class.getCanonicalName();
-    }
-
-    @Override
-    public String getFtlTempleteLocation() {
-        return "module_abs_template_new.ftl";
-    }
-
-    public String getLoggerType() {
-        return Logger.class.getCanonicalName();
-    }
-
-    public String getLoggerFactoryType() {
-        return LoggerFactory.class.getCanonicalName();
-    }
-
 }
diff --git a/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/FtlFilePersister.java b/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/FtlFilePersister.java
deleted file mode 100644 (file)
index 37d5e6b..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl;
-
-import com.google.common.annotations.VisibleForTesting;
-import freemarker.template.Configuration;
-import freemarker.template.Template;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.directives.AnnotationsDirective;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.directives.ConstructorsDirective;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.directives.FieldsDirectiveProg;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.directives.HeaderDirective;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.directives.JavadocDirective;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.directives.MethodsDirective;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.directives.ModuleFieldsDirective;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.directives.TypeDeclarationDirective;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.directives.UnimplementedExceptionDirective;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.regex.Pattern;
-
-public class FtlFilePersister {
-    private static final Logger logger = LoggerFactory
-            .getLogger(FtlFilePersister.class);
-
-    private static final Pattern TRAILING_WHITESPACES = Pattern.compile(" +$", Pattern.MULTILINE);
-
-    @VisibleForTesting
-    public Map<FtlTemplate, String> serializeFtls(
-            Collection<? extends FtlTemplate> ftlFiles) {
-        Map<FtlTemplate, String> result = new HashMap<>();
-        for (FtlTemplate ftlFile : ftlFiles) {
-
-            try (Writer writer = new StringWriter()) {
-                Template template = getCfg().getTemplate(
-                        ftlFile.getFtlTempleteLocation());
-                try {
-                    template.process(ftlFile, writer);
-                } catch (Exception e) {
-                    throw new IllegalStateException(
-                            "Template error while generating " + ftlFile, e);
-                }
-                String fileContent = writer.toString();
-                // remove trailing spaces
-                fileContent = TRAILING_WHITESPACES.matcher(fileContent).replaceAll("");
-                result.put(ftlFile, fileContent);
-            } catch (IOException e) {
-                throw new IllegalStateException(
-                        "Exception while processing template", e);
-            }
-        }
-
-        return result;
-    }
-
-    public List<File> persist(Collection<? extends FtlTemplate> ftlFiles,
-            File dstFolder, boolean overwrite) throws IOException {
-        Map<FtlTemplate, String> ftlFileStringMap = serializeFtls(ftlFiles);
-        List<File> result = new ArrayList<>();
-        for (Entry<FtlTemplate, String> entry : ftlFileStringMap.entrySet()) {
-            FtlTemplate ftlFile = entry.getKey();
-            File targetFile = new File(dstFolder, ftlFile.getRelativeFile()
-                    .getPath());
-            File pathToFile = targetFile.getParentFile();
-            if (pathToFile.exists() == false) {
-                pathToFile.mkdirs();
-            }
-            if (targetFile.exists() && overwrite == false) {
-                logger.trace("Skipping {} since it already exists", targetFile);
-            } else {
-                try (Writer fileWriter = new FileWriter(targetFile)) {
-                    fileWriter.write(entry.getValue());
-                }
-                logger.trace("{}: File {} generated successfully",
-                        JMXGenerator.class.getCanonicalName(), targetFile);
-                result.add(targetFile);
-            }
-        }
-        return result;
-    }
-
-    private Configuration getCfg() {
-        Configuration cfg = new Configuration();
-        cfg.setClassForTemplateLoading(getClass(), "/freeMarker/");
-        cfg.setSharedVariable("javadocD", new JavadocDirective());
-        cfg.setSharedVariable("annotationsD", new AnnotationsDirective());
-        cfg.setSharedVariable("typeDeclarationD",
-                new TypeDeclarationDirective());
-        cfg.setSharedVariable("constructorsD", new ConstructorsDirective());
-        cfg.setSharedVariable("fieldsD", new FieldsDirectiveProg());
-        cfg.setSharedVariable("moduleFieldsD", new ModuleFieldsDirective());
-        cfg.setSharedVariable("methodsD", new MethodsDirective());
-        cfg.setSharedVariable("headerD", new HeaderDirective());
-        cfg.setSharedVariable("unimplementedExceptionD",
-                new UnimplementedExceptionDirective());
-        return cfg;
-    }
-
-}
index 8172a58..d01f3f9 100644 (file)
@@ -7,22 +7,24 @@
  */
 package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl;
 
-import java.io.File;
-import java.util.List;
-
+import com.google.common.base.Optional;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Annotation;
+import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Constructor;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Field;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Header;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Method;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.TypeDeclaration;
 
+import java.util.List;
+
 public interface FtlTemplate {
 
     Header getHeader();
+    Optional<String> getHeaderString();
 
     String getPackageName();
 
-    String getJavadoc();
+    Optional<String> getMaybeJavadoc();
 
     public List<Annotation> getAnnotations();
 
@@ -34,14 +36,5 @@ public interface FtlTemplate {
 
     List<? extends Method> getMethods();
 
-    /**
-     * @return relative path to file to be created.
-     */
-    public File getRelativeFile();
-
-    /**
-     *
-     * @return ftl template location
-     */
-    public String getFtlTempleteLocation();
+    List<Constructor> getConstructors();
 }
index be49f93..5d2d664 100644 (file)
@@ -7,33 +7,21 @@
  */
 package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl;
 
-import java.util.Collections;
-
-import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
+import com.google.common.collect.Lists;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Field;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Header;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.MethodDefinition;
 
-import com.google.common.collect.Lists;
+import java.util.Collections;
 
 public class StubFactoryTemplate extends GeneralClassTemplate {
 
-    private final String moduleInstanceType;
-
     public StubFactoryTemplate(Header header, String packageName, String name,
-            String extendedClass, String moduleInstanceType) {
+                               String extendedClass) {
         super(header, packageName, name, Lists.newArrayList(extendedClass),
                 Collections.<String> emptyList(), Collections
                         .<Field> emptyList(), Collections
                         .<MethodDefinition> emptyList());
-        this.moduleInstanceType = moduleInstanceType;
-    }
-
-    public String getModuleInstanceType() {
-        return moduleInstanceType;
     }
 
-    public String getDynamicMBeanWithInstanceType() {
-        return DynamicMBeanWithInstance.class.getCanonicalName();
-    }
 }
diff --git a/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/StubModuleTemplate.java b/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/StubModuleTemplate.java
deleted file mode 100644 (file)
index f49bbba..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl;
-
-import java.util.Collections;
-
-import org.opendaylight.controller.config.api.DependencyResolver;
-import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
-import org.opendaylight.controller.config.api.ModuleIdentifier;
-import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
-import org.opendaylight.controller.config.spi.Module;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Constructor;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Field;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Header;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.MethodDefinition;
-
-import com.google.common.collect.Lists;
-
-/**
- *
- */
-public class StubModuleTemplate extends GeneralClassTemplate {
-
-    private final String extendedClass;
-
-    public StubModuleTemplate(Header header, String packageName,
-            String stubModuleName, String extendedClass) {
-        super(header, packageName, stubModuleName, Lists
-                .newArrayList(extendedClass), Collections.<String> emptyList(),
-                Collections.<Field> emptyList(), Collections
-                        .<MethodDefinition> emptyList(), false, true,
-                Collections.<Constructor> emptyList());
-        this.extendedClass = extendedClass;
-    }
-
-    public String getExtendedClass() {
-        return extendedClass;
-    }
-
-    public String getInstanceType() {
-        return AutoCloseable.class.getCanonicalName();
-    }
-
-    public String getModuleNameType() {
-        return ModuleIdentifier.class.getCanonicalName();
-    }
-
-    public String getAbstractServiceInterfaceType() {
-        return AbstractServiceInterface.class.getCanonicalName();
-    }
-
-    public String getModuleType() {
-        return Module.class.getCanonicalName();
-    }
-
-    public String getDependencyResolverType() {
-        return DependencyResolver.class.getCanonicalName();
-    }
-
-    public String getDynamicMBeanWithInstanceType() {
-        return DynamicMBeanWithInstance.class.getCanonicalName();
-    }
-
-    @Override
-    public String getFtlTempleteLocation() {
-        return "module_stub_template.ftl";
-    }
-}
index fea9a79..7b7aab8 100644 (file)
@@ -7,9 +7,7 @@
  */
 package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl;
 
-import com.google.common.base.Function;
 import com.google.common.base.Preconditions;
-import com.google.common.collect.Collections2;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import org.opendaylight.controller.config.api.DependencyResolver;
@@ -45,12 +43,10 @@ import org.opendaylight.controller.config.yangjmxgenerator.plugin.util.FullyQual
 import org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil;
 import org.opendaylight.yangtools.sal.binding.model.api.ParameterizedType;
 import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
 
 import javax.management.openmbean.SimpleType;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -59,49 +55,6 @@ import java.util.Map.Entry;
 
 public class TemplateFactory {
 
-    public static Map<String, FtlTemplate> getFtlTemplates(
-            ModuleMXBeanEntry entry) {
-        Map<String, FtlTemplate> result = new HashMap<>();
-
-        result.putAll(TemplateFactory.tOsFromMbe(entry));
-
-        // IFC
-        result.put(entry.getMXBeanInterfaceName() + ".java",
-                TemplateFactory.mXBeanInterfaceTemplateFromMbe(entry));
-
-        // ABS fact
-        result.put(entry.getAbstractFactoryName() + ".java",
-                TemplateFactory.abstractFactoryTemplateFromMbe(entry));
-
-        // ABS module
-        result.put(entry.getAbstractModuleName() + ".java",
-                TemplateFactory.abstractModuleTemplateFromMbe(entry));
-
-        return result;
-    }
-
-    public static Map<String, FtlTemplate> getFtlStubTemplates(
-            ModuleMXBeanEntry entry) {
-        Map<String, FtlTemplate> result = new HashMap<>();
-        // STUB fact
-        result.put(entry.getStubFactoryName() + ".java",
-                TemplateFactory.stubFactoryTemplateFromMbe(entry));
-
-        result.put(entry.getStubModuleName() + ".java",
-                TemplateFactory.stubModuleTemplateFromMbe(entry));
-        return result;
-    }
-
-    public static Map<String, FtlTemplate> getFtlTemplates(
-            ServiceInterfaceEntry entry) {
-
-        Map<String, FtlTemplate> result = new HashMap<>();
-        result.put(entry.getTypeName() + ".java",
-                TemplateFactory.serviceInterfaceFromSie(entry));
-
-        return result;
-    }
-
     /**
      * Get map of file name as key, FtlFile instance representing runtime mx
      * bean as value that should be persisted from this instance.
@@ -183,11 +136,6 @@ public class TemplateFactory {
         return serializeType(type, false);
     }
 
-    private static boolean isIdentityRefType(Type type) {
-        return type instanceof IdentityrefTypeDefinition;
-    }
-
-
     private static String getReturnType(AttributeIfc attributeIfc) {
         String returnType;
         if (attributeIfc instanceof TypedAttribute) {
@@ -234,28 +182,17 @@ public class TemplateFactory {
         attrProcessor.processAttributes(mbe.getAttributes(),
                 mbe.getPackageName());
 
-        Collection<String> transformed = Collections2.transform(mbe
-                .getProvidedServices().keySet(),
-                new Function<String, String>() {
 
-                    @Override
-                    public String apply(String input) {
-                        return input + ".class";
-                    }
-                });
 
         return new AbstractFactoryTemplate(getHeaderFromEntry(mbe),
                 mbe.getPackageName(), mbe.getAbstractFactoryName(),
-                mbe.getGloballyUniqueName(), mbe.getFullyQualifiedName(mbe
-                        .getStubModuleName()), attrProcessor.getFields(),
-                Lists.newArrayList(transformed), mbe);
+                attrProcessor.getFields()
+        );
     }
 
     public static AbstractModuleTemplate abstractModuleTemplateFromMbe(
             ModuleMXBeanEntry mbe) {
-        AbstractModuleAttributesProcessor attrProcessor = new AbstractModuleAttributesProcessor();
-        attrProcessor.processAttributes(mbe.getAttributes(),
-                mbe.getPackageName());
+        AbstractModuleAttributesProcessor attrProcessor = new AbstractModuleAttributesProcessor(mbe.getAttributes());
 
         List<ModuleField> moduleFields = attrProcessor.getModuleFields();
         List<String> implementedIfcs = Lists.newArrayList(
@@ -298,15 +235,8 @@ public class TemplateFactory {
             ModuleMXBeanEntry mbe) {
         return new StubFactoryTemplate(getHeaderFromEntry(mbe),
                 mbe.getPackageName(), mbe.getStubFactoryName(),
-                mbe.getFullyQualifiedName(mbe.getAbstractFactoryName()),
-                mbe.getStubModuleName());
-    }
-
-    public static StubModuleTemplate stubModuleTemplateFromMbe(
-            ModuleMXBeanEntry mbe) {
-        return new StubModuleTemplate(getHeaderFromEntry(mbe),
-                mbe.getPackageName(), mbe.getStubModuleName(),
-                mbe.getFullyQualifiedName(mbe.getAbstractModuleName()));
+                mbe.getFullyQualifiedName(mbe.getAbstractFactoryName())
+        );
     }
 
     public static GeneralInterfaceTemplate mXBeanInterfaceTemplateFromMbe(
@@ -612,12 +542,26 @@ public class TemplateFactory {
     }
 
     private static class AbstractModuleAttributesProcessor {
+        private static class Holder {
+            private final List<ModuleField> moduleFields;
+            private final List<MethodDefinition> methods;
+
+            private Holder(List<ModuleField> moduleFields, List<MethodDefinition> methods) {
+                this.moduleFields = Collections.unmodifiableList(moduleFields);
+                this.methods = Collections.unmodifiableList(methods);
+            }
+        }
 
-        private final List<ModuleField> moduleFields = Lists.newArrayList();
-        private final List<MethodDefinition> methods = Lists.newArrayList();
+        private final Holder holder;
 
-        void processAttributes(Map<String, AttributeIfc> attributes,
-                String packageName) {
+
+        private AbstractModuleAttributesProcessor(Map<String, AttributeIfc> attributes) {
+            this.holder = processAttributes(attributes);
+        }
+
+        private static Holder processAttributes(Map<String, AttributeIfc> attributes) {
+            List<ModuleField> moduleFields = new ArrayList<>();
+            List<MethodDefinition> methods = new ArrayList<>();
             for (Entry<String, AttributeIfc> attrEntry : attributes.entrySet()) {
                 String type, nullableDefaultWrapped = null;
                 AttributeIfc attributeIfc = attrEntry.getValue();
@@ -661,7 +605,7 @@ public class TemplateFactory {
 
                 String varName = BindingGeneratorUtil
                         .parseToValidParamName(attrEntry.getKey());
-
+                {
                 ModuleField field;
 
                 if (isIdentity) {
@@ -695,7 +639,7 @@ public class TemplateFactory {
                             nullableDefaultWrapped, isDependency, dependency, isListOfDependencies, needsDepResolver);
                 }
                 moduleFields.add(field);
-
+                }
                 String getterName = "get"
                         + attributeIfc.getUpperCaseCammelCase();
                 MethodDefinition getter = new MethodDefinition(type,
@@ -727,14 +671,15 @@ public class TemplateFactory {
 
                 methods.add(setter);
             }
+            return new Holder(moduleFields, methods);
         }
 
         List<ModuleField> getModuleFields() {
-            return moduleFields;
+            return holder.moduleFields;
         }
 
         List<MethodDefinition> getMethods() {
-            return methods;
+            return holder.methods;
         }
 
     }
diff --git a/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/directives/AnnotationsDirective.java b/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/directives/AnnotationsDirective.java
deleted file mode 100644 (file)
index 4a34a1f..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.directives;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.List;
-import java.util.Map;
-
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.FtlTemplate;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Annotation;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Annotation.Parameter;
-
-import com.google.common.collect.Lists;
-
-import freemarker.core.Environment;
-import freemarker.template.SimpleSequence;
-import freemarker.template.TemplateDirectiveBody;
-import freemarker.template.TemplateDirectiveModel;
-import freemarker.template.TemplateException;
-import freemarker.template.TemplateModel;
-
-/**
- * Add annotations to freemarker template.
- */
-public class AnnotationsDirective implements TemplateDirectiveModel {
-
-    private static final String OBJECT = "object";
-
-    @Override
-    public void execute(Environment env, Map params, TemplateModel[] loopVars,
-            TemplateDirectiveBody body) throws TemplateException, IOException {
-        Object object = params.get(OBJECT);
-        List<Annotation> annotations = Lists.newArrayList();
-
-        if (object != null) {
-            if (object instanceof SimpleSequence)
-                annotations = ((SimpleSequence) object).toList();
-            else if (object instanceof FtlTemplate) {
-                annotations = ((FtlTemplate) object).getAnnotations();
-            } else
-                throw new IllegalArgumentException(
-                        "Object must be a SimpleSequence or instance of "
-                                + FtlTemplate.class + "but was "
-                                + object.getClass());
-        }
-
-        Writer out = env.getOut();
-        StringBuilder build = new StringBuilder();
-        writeAnnotations(annotations, build, "");
-
-        if (!annotations.isEmpty())
-            out.write(build.toString().toCharArray());
-    }
-
-    static void writeAnnotations(List<Annotation> annotations,
-            StringBuilder build, String linePrefix) {
-        for (Annotation annotation : annotations) {
-            build.append(linePrefix + "@");
-            build.append(annotation.getName());
-            if (!annotation.getParams().isEmpty()) {
-                build.append("(");
-                for (Parameter param : annotation.getParams()) {
-                    build.append(param.getKey());
-                    build.append(" = ");
-                    build.append(fixString(param.getValue()));
-                    build.append(", ");
-                }
-                build.setCharAt(build.length() - 2, ')');
-            }
-            build.append(System.lineSeparator());
-        }
-    }
-
-    private static String fixString(String value) {
-        // TODO replace with compress single line if possible
-        return value.replaceAll("\\r\\n|\\r|\\n", " ").replaceAll(" +", " ");
-    }
-
-}
diff --git a/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/directives/ConstructorsDirective.java b/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/directives/ConstructorsDirective.java
deleted file mode 100644 (file)
index 56b7286..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.directives;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.List;
-import java.util.Map;
-
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.GeneralClassTemplate;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Constructor;
-
-import com.google.common.collect.Lists;
-
-import freemarker.core.Environment;
-import freemarker.template.SimpleSequence;
-import freemarker.template.TemplateDirectiveBody;
-import freemarker.template.TemplateDirectiveModel;
-import freemarker.template.TemplateException;
-import freemarker.template.TemplateModel;
-
-/**
- * Add annotations to freemarker template.
- */
-public class ConstructorsDirective implements TemplateDirectiveModel {
-
-    private static final String OBJECT = "object";
-
-    @Override
-    public void execute(Environment env, Map params, TemplateModel[] loopVars,
-            TemplateDirectiveBody body) throws TemplateException, IOException {
-        Object object = params.get(OBJECT);
-        List<Constructor> constructors = Lists.newArrayList();
-
-        if (object != null) {
-            if (object instanceof SimpleSequence)
-                constructors = ((SimpleSequence) object).toList();
-            else if (object instanceof GeneralClassTemplate) {
-                constructors = ((GeneralClassTemplate) object)
-                        .getConstructors();
-            } else
-                throw new IllegalArgumentException(
-                        "Object must be a SimpleSequence or instance of "
-                                + GeneralClassTemplate.class + "but was "
-                                + object.getClass());
-        }
-
-        Writer out = env.getOut();
-        StringBuilder build = new StringBuilder();
-        for (Constructor constr : constructors) {
-            build.append("    ");
-            if (constr.isPublic())
-                build.append("public ");
-            build.append(constr.getTypeName() + " ");
-            build.append("() {");
-            build.append(System.lineSeparator());
-            build.append("    ");
-            build.append("    ");
-            build.append(constr.getBody());
-            build.append(System.lineSeparator());
-            build.append("    ");
-            build.append("}");
-            build.append(System.lineSeparator());
-            build.append(System.lineSeparator());
-        }
-
-        if (!constructors.isEmpty())
-            out.write(build.toString().toCharArray());
-    }
-
-}
diff --git a/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/directives/FieldsDirectiveProg.java b/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/directives/FieldsDirectiveProg.java
deleted file mode 100644 (file)
index 7dd0f8e..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.directives;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.List;
-import java.util.Map;
-
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.FtlTemplate;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Field;
-
-import com.google.common.collect.Lists;
-
-import freemarker.core.Environment;
-import freemarker.template.SimpleSequence;
-import freemarker.template.TemplateDirectiveBody;
-import freemarker.template.TemplateDirectiveModel;
-import freemarker.template.TemplateException;
-import freemarker.template.TemplateModel;
-
-/**
- * Add fields to freemarker template.
- */
-public class FieldsDirectiveProg implements TemplateDirectiveModel {
-
-    private static final String OBJECT = "object";
-
-    @Override
-    public void execute(Environment env, Map params, TemplateModel[] loopVars,
-            TemplateDirectiveBody body) throws TemplateException, IOException {
-        Object object = params.get(OBJECT);
-        List<Field> fields = Lists.newArrayList();
-
-        if (object != null) {
-            if (object instanceof SimpleSequence)
-                fields = ((SimpleSequence) object).toList();
-            else if (object instanceof FtlTemplate) {
-                fields = ((FtlTemplate) object).getFields();
-            } else
-                throw new IllegalArgumentException(
-                        "Object must be a SimpleSequence or instance of "
-                                + FtlTemplate.class + "but was "
-                                + object.getClass());
-        }
-
-        Writer out = env.getOut();
-        StringBuilder build = new StringBuilder();
-        for (Field field : fields) {
-            build.append("     private ");
-            for (String mod : field.getModifiers()) {
-                build.append(mod + " ");
-            }
-            build.append(field.getType() + " ");
-            build.append(field.getName());
-            if (field.getDefinition() != null)
-                build.append(" = " + field.getDefinition());
-            build.append(";");
-            build.append(System.lineSeparator());
-        }
-
-        if (!fields.isEmpty())
-            out.write(build.toString().toCharArray());
-    }
-
-    // String templateStr = "Hello ${user}";
-    // Template t = new Template("name", new StringReader(templateStr), new
-    // Configuration());
-}
diff --git a/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/directives/FieldsDirectiveTemplate.java b/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/directives/FieldsDirectiveTemplate.java
deleted file mode 100644 (file)
index 268d898..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.directives;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.Writer;
-import java.util.Map;
-
-import com.google.common.collect.Maps;
-
-import freemarker.core.Environment;
-import freemarker.template.Configuration;
-import freemarker.template.Template;
-import freemarker.template.TemplateDirectiveBody;
-import freemarker.template.TemplateDirectiveModel;
-import freemarker.template.TemplateException;
-import freemarker.template.TemplateModel;
-
-/**
- * Add fields to freemarker template.
- */
-public class FieldsDirectiveTemplate implements TemplateDirectiveModel {
-
-    private static final String OBJECT = "object";
-
-    @Override
-    public void execute(Environment env, Map params, TemplateModel[] loopVars,
-            TemplateDirectiveBody body) throws TemplateException, IOException {
-        Object object = params.get(OBJECT);
-
-        // TODO check type
-
-        String templateStr = "    <#list fields as field>"
-                + "private <#if field.final==true>final </#if> <#if field.static==true>static </#if>"
-                + "${field.type} ${field.name}<#if field.definition??> = ${field.definition}</#if>;"
-                + System.lineSeparator() + " </#list>";
-        Template t = new Template("name", new StringReader(templateStr),
-                new Configuration());
-
-        try {
-            Map<String, Object> map = Maps.newHashMap();
-            map.put("fields", object);
-            Writer out = env.getOut();
-            t.process(map, out);
-        } catch (TemplateException e) {
-            throw new IllegalStateException(
-                    "Template error while generating fields" + e);
-        }
-    }
-
-}
diff --git a/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/directives/HeaderDirective.java b/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/directives/HeaderDirective.java
deleted file mode 100644 (file)
index 93fde59..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.directives;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.Date;
-import java.util.Map;
-
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Header;
-
-import com.google.common.base.Preconditions;
-
-import freemarker.core.Environment;
-import freemarker.ext.beans.StringModel;
-import freemarker.template.TemplateDirectiveBody;
-import freemarker.template.TemplateDirectiveModel;
-import freemarker.template.TemplateException;
-import freemarker.template.TemplateModel;
-
-/**
- * Add annotations to freemarker template.
- */
-public class HeaderDirective implements TemplateDirectiveModel {
-
-    private static final String GENERATOR_CLASS = JMXGenerator.class
-            .getCanonicalName();
-    private static final String OBJECT = "header";
-
-    @Override
-    public void execute(Environment env, Map params, TemplateModel[] loopVars,
-            TemplateDirectiveBody body) throws TemplateException, IOException {
-
-        // FIXME do not allow null header
-        // Preconditions.checkNotNull(object, "Null type declaration");
-        Object object = params.get(OBJECT);
-        Header header = null;
-        if (object != null) {
-            object = ((StringModel) object).getWrappedObject();
-            Preconditions.checkArgument(object instanceof Header,
-                    "Template header should be instance of " + Header.class
-                            + " but was " + object.getClass());
-
-            header = (Header) object;
-        }
-
-        Writer out = env.getOut();
-        StringBuilder build = new StringBuilder();
-        build.append("/**");
-        build.append(System.lineSeparator());
-        build.append("* ");
-        build.append("Generated file");
-        build.append(System.lineSeparator());
-        build.append(System.lineSeparator());
-        build.append("* ");
-        build.append("Generated from: ");
-        build.append(header != null ? header.toString() : "");
-        build.append(System.lineSeparator());
-        build.append("* ");
-        build.append("Generated by: " + GENERATOR_CLASS);
-        build.append(System.lineSeparator());
-        build.append("* ");
-        build.append("Generated at: " + new Date());
-        build.append(System.lineSeparator());
-        build.append("* ");
-        build.append(System.lineSeparator());
-        build.append("* ");
-        build.append("Do not modify this file unless it is present under src/main directory ");
-        build.append(System.lineSeparator());
-        build.append("*/");
-        build.append(System.lineSeparator());
-
-        out.write(build.toString().toCharArray());
-    }
-}
diff --git a/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/directives/JavadocDirective.java b/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/directives/JavadocDirective.java
deleted file mode 100644 (file)
index 9817be3..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.directives;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.Map;
-
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.FtlTemplate;
-
-import freemarker.core.Environment;
-import freemarker.template.SimpleScalar;
-import freemarker.template.TemplateDirectiveBody;
-import freemarker.template.TemplateDirectiveModel;
-import freemarker.template.TemplateException;
-import freemarker.template.TemplateModel;
-
-/**
- * Add javadoc to freemarker template as String.
- */
-public class JavadocDirective implements TemplateDirectiveModel {
-
-    private static final String OBJECT = "object";
-
-    @Override
-    public void execute(Environment env, Map params, TemplateModel[] loopVars,
-            TemplateDirectiveBody body) throws TemplateException, IOException {
-        Object object = params.get(OBJECT);
-        String javadoc = "";
-
-        if (object != null) {
-            if (object instanceof SimpleScalar)
-                javadoc = ((SimpleScalar) object).getAsString();
-            else if (object instanceof FtlTemplate) {
-                javadoc = ((FtlTemplate) object).getJavadoc();
-            } else
-                throw new IllegalArgumentException(
-                        "Object must be a String or instance of "
-                                + FtlTemplate.class + "but was "
-                                + object.getClass());
-        }
-
-        Writer out = env.getOut();
-        StringBuilder build = new StringBuilder();
-        writeJavadoc(build, javadoc, "");
-        out.write(build.toString().toCharArray());
-    }
-
-    static void writeJavadoc(StringBuilder build, String javadoc,
-            String linePrefix) {
-        build.append(linePrefix + "/**");
-        build.append(System.lineSeparator());
-        build.append(linePrefix + "* ");
-        build.append(javadoc == null ? "" : javadoc);
-        build.append(System.lineSeparator());
-        build.append(linePrefix + "*/");
-        build.append(System.lineSeparator());
-    }
-
-}
diff --git a/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/directives/MethodsDirective.java b/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/directives/MethodsDirective.java
deleted file mode 100644 (file)
index 975d8fd..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.directives;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.List;
-import java.util.Map;
-
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.FtlTemplate;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Field;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Method;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.MethodDeclaration;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.MethodDefinition;
-
-import com.google.common.collect.Lists;
-
-import freemarker.core.Environment;
-import freemarker.template.SimpleSequence;
-import freemarker.template.TemplateDirectiveBody;
-import freemarker.template.TemplateDirectiveModel;
-import freemarker.template.TemplateException;
-import freemarker.template.TemplateModel;
-
-/**
- * Add annotations to freemarker template.
- */
-public class MethodsDirective implements TemplateDirectiveModel {
-
-    private static final String OBJECT = "object";
-
-    @Override
-    public void execute(Environment env, Map params, TemplateModel[] loopVars,
-            TemplateDirectiveBody body) throws TemplateException, IOException {
-        Object object = params.get(OBJECT);
-        List<? extends Method> methods = Lists.newArrayList();
-
-        if (object != null) {
-            if (object instanceof SimpleSequence)
-                methods = ((SimpleSequence) object).toList();
-            else if (object instanceof FtlTemplate) {
-                methods = ((FtlTemplate) object).getMethods();
-            } else
-                throw new IllegalArgumentException(
-                        "Object must be a SimpleSequence or instance of "
-                                + FtlTemplate.class + "but was "
-                                + object.getClass());
-        }
-
-        Writer out = env.getOut();
-        StringBuilder build = new StringBuilder();
-        for (Method method : methods) {
-            if (method.getJavadoc() != null)
-                JavadocDirective.writeJavadoc(build, method.getJavadoc(), "    ");
-
-            if (!method.getAnnotations().isEmpty()) {
-                AnnotationsDirective.writeAnnotations(method.getAnnotations(),
-                        build, "    ");
-            }
-
-            build.append("    " + "public ");
-            for (String mod : method.getModifiers()) {
-                build.append(mod + " ");
-            }
-            build.append(method.getReturnType() + " ");
-
-            build.append(method.getName() + "(");
-            for (Field param : method.getParameters()) {
-                for (String mod : param.getModifiers()) {
-                    build.append(mod + " ");
-                }
-                build.append(param.getType() + " ");
-                build.append(param.getName() + ", ");
-            }
-            if (method.getParameters().isEmpty())
-                build.append(")");
-            else {
-                build.deleteCharAt(build.length() - 1);
-                build.deleteCharAt(build.length() - 1);
-                build.append(')');
-            }
-
-            if (method instanceof MethodDeclaration) {
-                build.append(";");
-                build.append(System.lineSeparator());
-            } else if (method instanceof MethodDefinition) {
-                if (!((MethodDefinition) method).getThrowsExceptions()
-                        .isEmpty())
-                    build.append(" throws ");
-                for (String ex : ((MethodDefinition) method)
-                        .getThrowsExceptions()) {
-                    build.append(ex + " ");
-                }
-                build.append(" {");
-                build.append(System.lineSeparator());
-                build.append("        ");
-                build.append(((MethodDefinition) method).getBody());
-                build.append(System.lineSeparator());
-                build.append("    ");
-                build.append("}");
-                build.append(System.lineSeparator());
-            }
-            build.append(System.lineSeparator());
-
-        }
-
-        if (!methods.isEmpty())
-            out.write(build.toString().toCharArray());
-    }
-}
diff --git a/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/directives/ModuleFieldsDirective.java b/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/directives/ModuleFieldsDirective.java
deleted file mode 100644 (file)
index 144419e..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.directives;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.List;
-import java.util.Map;
-
-import org.opendaylight.controller.config.api.JmxAttribute;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.AbstractModuleTemplate;
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.ModuleField;
-
-import com.google.common.collect.Lists;
-
-import freemarker.core.Environment;
-import freemarker.template.SimpleSequence;
-import freemarker.template.TemplateDirectiveBody;
-import freemarker.template.TemplateDirectiveModel;
-import freemarker.template.TemplateException;
-import freemarker.template.TemplateModel;
-
-/**
- * Add annotations to freemarker template.
- */
-public class ModuleFieldsDirective implements TemplateDirectiveModel {
-
-    private static final String OBJECT = "moduleFields";
-
-    @Override
-    public void execute(Environment env, Map params, TemplateModel[] loopVars,
-            TemplateDirectiveBody body) throws TemplateException, IOException {
-        Object object = params.get(OBJECT);
-        List<ModuleField> fields = Lists.newArrayList();
-
-        if (object != null) {
-            if (object instanceof SimpleSequence)
-                fields = ((SimpleSequence) object).toList();
-            else if (object instanceof AbstractModuleTemplate) {
-                fields = ((AbstractModuleTemplate) object).getModuleFields();
-            } else
-                throw new IllegalArgumentException(
-                        "Object must be a SimpleSequence or instance of "
-                                + AbstractModuleTemplate.class + "but was "
-                                + object.getClass());
-        }
-
-        Writer out = env.getOut();
-        StringBuilder build = new StringBuilder();
-        for (ModuleField field : fields) {
-            build.append("    ");
-            build.append("protected final "
-                    + JmxAttribute.class.getCanonicalName() + " "
-                    + field.getName() + "JmxAttribute = new "
-                    + JmxAttribute.class.getCanonicalName() + "(\""
-                    + field.getAttributeName() + "\");");
-            build.append(System.lineSeparator());
-
-            build.append("     private ");
-            for (String mod : field.getModifiers()) {
-                build.append(mod + " ");
-            }
-            build.append(field.getType() + " ");
-            build.append(field.getName());
-            if (field.getNullableDefault() != null)
-                build.append(" = " + field.getNullableDefault());
-            build.append(";");
-
-            if (field.isDependent()) {
-                String comment = field.getDependency().isMandatory() ? "mandatory"
-                        : "optional";
-                build.append(" // " + comment);
-            }
-            build.append(System.lineSeparator());
-
-            build.append(System.lineSeparator());
-
-        }
-
-        if (!fields.isEmpty())
-            out.write(build.toString().toCharArray());
-    }
-}
diff --git a/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/directives/TypeDeclarationDirective.java b/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/directives/TypeDeclarationDirective.java
deleted file mode 100644 (file)
index 42556c2..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.directives;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.Collection;
-import java.util.Map;
-
-import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.TypeDeclaration;
-
-import com.google.common.base.Preconditions;
-
-import freemarker.core.Environment;
-import freemarker.ext.beans.StringModel;
-import freemarker.template.TemplateDirectiveBody;
-import freemarker.template.TemplateDirectiveModel;
-import freemarker.template.TemplateException;
-import freemarker.template.TemplateModel;
-
-/**
- * Add type declaration to freemarker template.
- */
-public class TypeDeclarationDirective implements TemplateDirectiveModel {
-
-    private static final String OBJECT = "object";
-
-    @Override
-    public void execute(Environment env, Map params, TemplateModel[] loopVars,
-            TemplateDirectiveBody body) throws TemplateException, IOException {
-        Object object = params.get(OBJECT);
-        Preconditions.checkNotNull(object, "Null type declaration");
-
-        object = ((StringModel) object).getWrappedObject();
-        Preconditions.checkArgument(
-                object instanceof TypeDeclaration,
-                "Type declaration should be instance of "
-                        + TypeDeclaration.class + " but was "
-                        + object.getClass());
-
-        TypeDeclaration type = (TypeDeclaration) object;
-
-        Writer out = env.getOut();
-        StringBuilder build = new StringBuilder("public ");
-        if (type.isAbstract())
-            build.append("abstract ");
-        if (type.isFinal())
-            build.append("final ");
-        build.append(type.getType() + " ");
-        build.append(type.getName() + " ");
-
-        generateExtendOrImplement(build, "extends", type.getExtended());
-
-        generateExtendOrImplement(build, "implements", type.getImplemented());
-
-        build.append(System.lineSeparator());
-        out.write(build.toString().toCharArray());
-    }
-
-    private void generateExtendOrImplement(StringBuilder build, String prefix,
-            Collection<String> elements) {
-        if (elements.isEmpty())
-            return;
-
-        build.append(prefix + " ");
-
-        for (String extended : elements) {
-            build.append(extended);
-            build.append(", ");
-        }
-        build.deleteCharAt(build.length() - 1);
-        build.deleteCharAt(build.length() - 1);
-    }
-
-}
diff --git a/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/directives/UnimplementedExceptionDirective.java b/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/directives/UnimplementedExceptionDirective.java
deleted file mode 100644 (file)
index 5175ade..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.directives;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.Map;
-
-import freemarker.core.Environment;
-import freemarker.template.TemplateDirectiveBody;
-import freemarker.template.TemplateDirectiveModel;
-import freemarker.template.TemplateException;
-import freemarker.template.TemplateModel;
-
-/**
- * Add annotations to freemarker template.
- */
-public class UnimplementedExceptionDirective implements TemplateDirectiveModel {
-
-    @Override
-    public void execute(Environment env, Map params, TemplateModel[] loopVars,
-            TemplateDirectiveBody body) throws TemplateException, IOException {
-
-        Writer out = env.getOut();
-        StringBuilder build = new StringBuilder();
-        build.append("        ");
-        build.append("throw new "
-                + UnsupportedOperationException.class.getCanonicalName()
-                + "(\"Unimplemented stub method\");");
-        build.append(System.lineSeparator());
-
-        out.write(build.toString().toCharArray());
-    }
-}
index 7cf2417..a8ddabc 100644 (file)
@@ -7,18 +7,21 @@
  */
 package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
 import org.opendaylight.controller.config.api.annotations.Description;
 import org.opendaylight.controller.config.api.annotations.RequireInterface;
 import org.opendaylight.controller.config.api.annotations.ServiceInterfaceAnnotation;
-import org.opendaylight.yangtools.yang.binding.annotations.ModuleQName;
 import org.opendaylight.controller.config.yangjmxgenerator.ServiceInterfaceEntry;
+import org.opendaylight.yangtools.yang.binding.annotations.ModuleQName;
+import org.opendaylight.yangtools.yang.common.QName;
 
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
 
 public class Annotation {
     final String name;
@@ -37,6 +40,14 @@ public class Annotation {
         return params;
     }
 
+    public static Annotation createFromMap(Class<?> annotationClass, Map<String, String> parameters) {
+        List<Parameter> parameterList = new ArrayList<>();
+        for(Entry<String, String> entry: parameters.entrySet()) {
+            parameterList.add(new Parameter(entry.getKey(), entry.getValue()));
+        }
+        return new Annotation(annotationClass.getCanonicalName(), parameterList);
+    }
+
     public static Annotation createDescriptionAnnotation(String description) {
         Preconditions.checkNotNull(description,
                 "Cannot create annotation from null description");
@@ -44,6 +55,14 @@ public class Annotation {
                 Lists.newArrayList(new Parameter("value", q(description))));
     }
 
+    public static Annotation createModuleQNameANnotation(QName qName) {
+        Map<String, String> parameters = new HashMap<>();
+        parameters.put("namespace", q(qName.getNamespace().toString()));
+        parameters.put("revision", q(qName.getFormattedRevision()));
+        parameters.put("name", q(qName.getLocalName()));
+        return Annotation.createFromMap(ModuleQName.class, parameters);
+    }
+
     public static Collection<Annotation> createSieAnnotations(ServiceInterfaceEntry sie){
 
         String exportedClassName = sie.getExportedOsgiClassName();
@@ -85,7 +104,7 @@ public class Annotation {
 
     private static final String quote = "\"";
 
-    private static String q(String nullableDescription) {
+    public static String q(String nullableDescription) {
         return nullableDescription == null ? null : quote + nullableDescription
                 + quote;
     }
@@ -107,4 +126,8 @@ public class Annotation {
         }
     }
 
+    @Override
+    public String toString() {
+        return AnnotationSerializer.toString(this);
+    }
 }
diff --git a/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/AnnotationSerializer.java b/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/AnnotationSerializer.java
new file mode 100644 (file)
index 0000000..6b4ce38
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model;
+
+import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Annotation.Parameter;
+
+class AnnotationSerializer {
+
+    static String toString(Annotation annotation) {
+        StringBuilder builder = new StringBuilder();
+        builder.append("@");
+        builder.append(annotation.getName());
+        if (!annotation.getParams().isEmpty()) {
+            builder.append("(");
+            for (Parameter param : annotation.getParams()) {
+                builder.append(param.getKey());
+                builder.append(" = ");
+                builder.append(fixString(param.getValue()));
+                builder.append(", ");
+            }
+            builder.setCharAt(builder.length() - 2, ')');
+        }
+        builder.append("\n");
+        return builder.toString();
+    }
+
+    private static String fixString(String value) {
+        // TODO replace with compress single line if possible
+        return value.replaceAll("\\r\\n|\\r|\\n", " ").replaceAll(" +", " ");
+    }
+
+}
diff --git a/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/ConstructorSerializer.java b/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/ConstructorSerializer.java
new file mode 100644 (file)
index 0000000..c257aa6
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model;
+
+public class ConstructorSerializer {
+
+    public static String toString(Constructor constr) {
+        StringBuilder build = new StringBuilder();
+        build.append("    ");
+        if (constr.isPublic()) {
+            build.append("public ");
+        }
+        build.append(constr.getTypeName() + " ");
+        build.append("() {");
+        build.append("\n");
+        build.append("    ");
+        build.append("    ");
+        build.append(constr.getBody());
+        build.append("\n");
+        build.append("    ");
+        build.append("}");
+        build.append("\n");
+        build.append("\n");
+        return build.toString();
+    }
+}
index ad5cbb2..3639b6d 100644 (file)
@@ -11,6 +11,8 @@ import com.google.common.collect.Lists;
 
 import java.util.List;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 public class Field {
     private final String type;
     private final String name;
@@ -36,11 +38,11 @@ public class Field {
     }
 
     public Field(List<String> modifiers, String type, String name,
-            String definition, boolean needsDepResolver) {
-        this.modifiers = modifiers;
-        this.type = type;
-        this.name = name;
-        this.definition = definition;
+            String nullableDefinition, boolean needsDepResolver) {
+        this.modifiers = checkNotNull(modifiers);
+        this.type = checkNotNull(type);
+        this.name = checkNotNull(name);
+        this.definition = nullableDefinition;
         this.needsDepResolver = needsDepResolver;
     }
 
@@ -56,6 +58,10 @@ public class Field {
         return type;
     }
 
+    public String getGenericInnerType() {
+        return type.substring(type.indexOf("<") + 1, type.indexOf(">"));
+    }
+
     public List<String> getModifiers() {
         return modifiers;
     }
@@ -71,4 +77,9 @@ public class Field {
     public boolean isArray() {
         return type.endsWith("[]");
     }
+
+    @Override
+    public String toString() {
+        return FieldSerializer.toString(this);
+    }
 }
diff --git a/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/FieldSerializer.java b/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/FieldSerializer.java
new file mode 100644 (file)
index 0000000..90a2b56
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model;
+
+public class FieldSerializer {
+
+    public static String toString(Field field) {
+        StringBuilder build = new StringBuilder();
+        build.append("private ");
+        for (String mod : field.getModifiers()) {
+            build.append(mod + " ");
+        }
+        build.append(field.getType() + " ");
+        build.append(field.getName());
+        if (field.getDefinition() != null) {
+            build.append(" = " + field.getDefinition());
+        }
+        build.append(";");
+        build.append("\n");
+        return build.toString();
+    }
+}
index 047e87a..b9a6284 100644 (file)
@@ -26,8 +26,7 @@ public class Header {
 
     @Override
     public String toString() {
-        return "yang module name: " + yangModuleName + " "
-                + " yang module local name: " + yangModuleLocalName;
+        return HeaderSerializer.toString(this);
     }
 
 }
diff --git a/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/HeaderSerializer.java b/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/HeaderSerializer.java
new file mode 100644 (file)
index 0000000..eb07c80
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model;
+
+import org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator;
+
+import java.util.Date;
+
+public class HeaderSerializer {
+    private static final String GENERATOR_CLASS = JMXGenerator.class.getCanonicalName();
+
+    public static String toString(Header header) {
+        StringBuilder build = new StringBuilder();
+
+
+        build.append("Generated file");
+        build.append("\n");
+        build.append("\n");
+        build.append("Generated from: ");
+        //build.append(header.toString());
+
+        build.append("yang module name: ");
+        build.append(header.getYangModuleName());
+        build.append(" yang module local name: ");
+        build.append(header.getYangModuleLocalName());
+
+        build.append("\n");
+        build.append("Generated by: " + GENERATOR_CLASS);
+        build.append("\n");
+        build.append("Generated at: " + new Date());
+        build.append("\n");
+        build.append("\n");
+        build.append("Do not modify this file unless it is present under src/main directory ");
+
+        return build.toString();
+    }
+
+}
diff --git a/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/MethodSerializer.java b/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/MethodSerializer.java
new file mode 100644 (file)
index 0000000..7d2b9fc
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model;
+
+import org.opendaylight.controller.config.yangjmxgenerator.plugin.util.StringUtil;
+
+class MethodSerializer {
+
+    static String toString(Method method) {
+        StringBuilder build = new StringBuilder();
+        if (method.getJavadoc() != null) {
+            build.append(StringUtil.writeComment(method.getJavadoc(), true));
+        }
+
+        for(Annotation a: method.getAnnotations()) {
+            build.append(a);
+        }
+
+        build.append("    " + "public ");
+        for (String mod : method.getModifiers()) {
+            build.append(mod + " ");
+        }
+        build.append(method.getReturnType() + " ");
+
+        build.append(method.getName() + "(");
+        for (Field param : method.getParameters()) {
+            for (String mod : param.getModifiers()) {
+                build.append(mod + " ");
+            }
+            build.append(param.getType() + " ");
+            build.append(param.getName() + ", ");
+        }
+        if (method.getParameters().isEmpty()) {
+            build.append(")");
+        } else {
+            build.deleteCharAt(build.length() - 1);
+            build.deleteCharAt(build.length() - 1);
+            build.append(')');
+        }
+
+        if (method instanceof MethodDeclaration) {
+            build.append(";");
+            build.append("\n");
+        } else if (method instanceof MethodDefinition) {
+            if (!((MethodDefinition) method).getThrowsExceptions()
+                    .isEmpty()) {
+                build.append(" throws ");
+            }
+            for (String ex : ((MethodDefinition) method)
+                    .getThrowsExceptions()) {
+                build.append(ex + " ");
+            }
+            build.append(" {");
+            build.append("\n");
+            build.append("        ");
+            build.append(((MethodDefinition) method).getBody());
+            build.append("\n");
+            build.append("    ");
+            build.append("}");
+            build.append("\n");
+        }
+        build.append("\n");
+        return build.toString();
+    }
+}
index 74e5bb0..37d6603 100644 (file)
@@ -44,6 +44,11 @@ public class ModuleField extends Field {
         return false;
     }
 
+    @Override
+    public String toString() {
+        return ModuleFieldSerializer.toString(this);
+    }
+
     public Dependency getDependency() {
         return dependency;
     }
@@ -64,4 +69,9 @@ public class ModuleField extends Field {
         return attributeName;
     }
 
+
+    public boolean isList() {
+        return getType().startsWith("java.util.List");
+    }
+
 }
diff --git a/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/ModuleFieldSerializer.java b/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/ModuleFieldSerializer.java
new file mode 100644 (file)
index 0000000..c0e3bc1
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model;
+
+import org.opendaylight.controller.config.api.JmxAttribute;
+
+public class ModuleFieldSerializer {
+
+
+    public static String toString(ModuleField moduleField) {
+        StringBuilder builder = new StringBuilder();
+        builder.append("    ");
+        builder.append("protected final "
+                + JmxAttribute.class.getCanonicalName() + " "
+                + moduleField.getName() + "JmxAttribute = new "
+                + JmxAttribute.class.getCanonicalName() + "(\""
+                + moduleField.getAttributeName() + "\");");
+        builder.append("\n");
+
+        builder.append("     private ");
+        for (String mod : moduleField.getModifiers()) {
+            builder.append(mod + " ");
+        }
+        builder.append(moduleField.getType() + " ");
+        builder.append(moduleField.getName());
+        if (moduleField.getNullableDefault() != null) {
+            builder.append(" = " + moduleField.getNullableDefault());
+        }
+        builder.append(";");
+
+        if (moduleField.isDependent()) {
+            String comment = moduleField.getDependency().isMandatory() ? "mandatory"
+                    : "optional";
+            builder.append(" // " + comment);
+        }
+        builder.append("\n");
+
+        builder.append("\n");
+
+        return builder.toString();
+    }
+}
index ee0aa2f..a5bb987 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model;
 
+import org.opendaylight.controller.config.yangjmxgenerator.plugin.java.TypeName;
+
 import java.util.List;
 
 public class TypeDeclaration {
@@ -54,6 +56,24 @@ public class TypeDeclaration {
         return implemented;
     }
 
+    public TypeName toTypeName() {
+        if ("interface".equals(type)) {
+            return TypeName.interfaceType;
+        } else if ("class".equals(type)) {
+            if (isAbstract) {
+                return TypeName.absClassType;
+            } else if (isFinal) {
+                return TypeName.finalClassType;
+            } else {
+                return TypeName.classType;
+            }
+        } else if ("enum".equals(type)) {
+            return TypeName.enumType;
+        } else {
+            throw new IllegalStateException("Type not supported: " + type);
+        }
+    }
+
     @Override
     public String toString() {
         return "TypeDeclaration{" + "type='" + type + '\'' + ", name='" + name
diff --git a/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/gofactory/AbsFactoryGeneratedObjectFactory.groovy b/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/gofactory/AbsFactoryGeneratedObjectFactory.groovy
new file mode 100644 (file)
index 0000000..baff88c
--- /dev/null
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.config.yangjmxgenerator.plugin.gofactory
+import com.google.common.base.Optional
+import org.opendaylight.controller.config.api.DependencyResolver
+import org.opendaylight.controller.config.api.DynamicMBeanWithInstance
+import org.opendaylight.controller.config.api.ModuleIdentifier
+import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface
+import org.opendaylight.controller.config.api.annotations.Description
+import org.opendaylight.controller.config.spi.Module
+import org.opendaylight.controller.config.spi.ModuleFactory
+import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry
+import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.AbstractFactoryTemplate
+import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.TemplateFactory
+import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Annotation
+import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Field
+import org.opendaylight.controller.config.yangjmxgenerator.plugin.java.*
+import org.opendaylight.yangtools.yang.common.QName
+import org.osgi.framework.BundleContext
+
+public class AbsFactoryGeneratedObjectFactory {
+
+    public GeneratedObject toGeneratedObject(ModuleMXBeanEntry mbe, Optional<String> copyright) {
+        FullyQualifiedName absFactoryFQN = new FullyQualifiedName(mbe.packageName, mbe.abstractFactoryName)
+        FullyQualifiedName moduleFQN = new FullyQualifiedName(mbe.packageName, mbe.stubModuleName)
+        Optional<String> classJavaDoc = Optional.fromNullable(mbe.getNullableDescription())
+
+        AbstractFactoryTemplate abstractFactoryTemplate = TemplateFactory.abstractFactoryTemplateFromMbe(mbe)
+        Optional<String> header = abstractFactoryTemplate.headerString;
+        List<FullyQualifiedName> providedServices = mbe.providedServices.keySet().collect {
+            FullyQualifiedName.fromString(it)
+        }
+
+
+        return toGeneratedObject(absFactoryFQN, copyright,
+                header, classJavaDoc, mbe.yangModuleQName,
+                mbe.globallyUniqueName,
+                providedServices,
+                moduleFQN,
+                abstractFactoryTemplate.fields)
+    }
+
+    public GeneratedObject toGeneratedObject(FullyQualifiedName absFactoryFQN, Optional<String> copyright,
+                                             Optional<String> header, Optional<String> classJavaDoc, QName yangModuleQName,
+                                             String globallyUniqueName,
+                                     &nbs