<usermanager.version>0.5.0-SNAPSHOT</usermanager.version>
<nsf.version>0.5.0-SNAPSHOT</nsf.version>
<web.version>0.5.0-SNAPSHOT</web.version>
- <xtend.dstdir>src/main/xtend-gen</xtend.dstdir>
<yang-ext.version>2013.09.07.7-SNAPSHOT</yang-ext.version>
<yang-jmx-generator.version>1.1.0-SNAPSHOT</yang-jmx-generator.version>
<yangtools.version>0.7.0-SNAPSHOT</yangtools.version>
<type>pom</type>
<scope>import</scope>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>mdsal-artifacts</artifactId>
+ <version>${mdsal.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>netconf-artifacts</artifactId>
</dependency>
<!-- md-sal -->
- <dependency>
- <groupId>org.eclipse.xtend</groupId>
- <artifactId>org.eclipse.xtend.lib</artifactId>
- <version>${xtend.version}</version>
- </dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-grizzly2</artifactId>
<artifactId>sal</artifactId>
<version>${sal.version}</version>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-api</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-broker-impl</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-config</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-util</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-broker-impl</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-api</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-impl</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-util</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-inmemory-datastore</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-compatibility</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-connector-api</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-dom-xsql</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-karaf-xsql</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-dom-xsql-config</artifactId>
- <version>${mdsal.version}</version>
- <classifier>config</classifier>
- <type>xml</type>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-core-api</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-core-spi</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-netconf-connector</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-remote</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-rest-connector</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-rest-connector-config</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>md-sal-config</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-rest-docgen</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-restconf-broker</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-test-model</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-distributed-datastore</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-clustering-commons</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-clustering-config</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-remoterpc-connector</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
-
<!-- SAL Extension bundles -->
<dependency>
<artifactId>web</artifactId>
<version>${web.version}</version>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller.md</groupId>
- <artifactId>forwardingrules-manager</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller.md</groupId>
- <artifactId>inventory-manager</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller.md</groupId>
- <artifactId>statistics-manager</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller.md</groupId>
- <artifactId>topology-lldp-discovery</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller.md</groupId>
- <artifactId>topology-manager</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller.model</groupId>
- <artifactId>model-flow-base</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller.model</groupId>
- <artifactId>model-flow-service</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller.model</groupId>
- <artifactId>model-flow-statistics</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller.model</groupId>
- <artifactId>model-inventory</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller.model</groupId>
- <artifactId>model-topology</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller.samples</groupId>
- <artifactId>sample-toaster</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller.samples</groupId>
- <artifactId>sample-toaster-consumer</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller.samples</groupId>
- <artifactId>sample-toaster-provider</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller.samples</groupId>
- <artifactId>toaster-config</artifactId>
- <version>${mdsal.version}</version>
- </dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>features-test</artifactId>
<type>xml</type>
<scope>runtime</scope>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller.samples</groupId>
- <artifactId>features-toaster</artifactId>
- <version>${mdsal.version}</version>
- <classifier>features</classifier>
- <type>xml</type>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>features-flow</artifactId>
- <version>${mdsal.version}</version>
- <classifier>features</classifier>
- <type>xml</type>
- <scope>runtime</scope>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller.thirdparty</groupId>
<artifactId>com.sun.jersey.jersey-servlet</artifactId>
<version>0.1.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-broker-impl</artifactId>
- <version>${mdsal.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-it</artifactId>
- <version>${mdsal.version}</version>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>features-protocol-framework</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>features-mdsal</artifactId>
- <version>${mdsal.version}</version>
- <classifier>features</classifier>
- <type>xml</type>
- <scope>runtime</scope>
- </dependency>
- <dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>features-netconf-connector</artifactId>
<version>${mdsal.version}</version>
<classifier>features</classifier>
<type>xml</type>
<scope>runtime</scope>
- </dependency>
+ </dependency>
+
<!-- JMH Benchmark dependencies -->
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets>
- <fileset>
- <directory>${xtend.dstdir}</directory>
- <includes>
- <include>**</include>
- </includes>
- </fileset>
<fileset>
<directory>${jmxGeneratorPath}</directory>
<includes>
<source>src/main/yang</source>
<source>${jmxGeneratorPath}</source>
<source>${salGeneratorPath}</source>
- <source>${xtend.dstdir}</source>
</sources>
</configuration>
</execution>
</lifecycleMappingMetadata>
</configuration>
</plugin>
- <plugin>
- <groupId>org.eclipse.xtend</groupId>
- <artifactId>xtend-maven-plugin</artifactId>
- <version>${xtend.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>compile</goal>
- </goals>
- <configuration>
- <outputDirectory>${xtend.dstdir}</outputDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<sourceDirectory>${project.basedir}</sourceDirectory>
<includes>**\/*.java,**\/*.xml,**\/*.ini,**\/*.sh,**\/*.bat</includes>
- <excludes>**\/target\/,**\/bin\/,**\/target-ide\/,**\/${jmxGeneratorPath}\/,**\/${salGeneratorPath}\/,**\/xtend-gen\/,**\/protobuff\/</excludes>
+ <excludes>**\/target\/,**\/bin\/,**\/target-ide\/,**\/${jmxGeneratorPath}\/,**\/${salGeneratorPath}\/,**\/protobuff\/</excludes>
</configuration>
<dependencies>
<dependency>
createInstance();
final ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
assertBeanCount(1, FACTORY_NAME);
- final NeverReconnectStrategyFactoryModuleMXBean mxBean = transaction.newMBeanProxy(
+ final NeverReconnectStrategyFactoryModuleMXBean mxBean = transaction.newMXBeanProxy(
transaction.lookupConfigBean(FACTORY_NAME, INSTANCE_NAME), NeverReconnectStrategyFactoryModuleMXBean.class);
mxBean.setTimeout(200);
final CommitStatus status = transaction.commit();
private static ObjectName createInstance(final ConfigTransactionJMXClient transaction, final Integer timeout)
throws InstanceAlreadyExistsException {
final ObjectName nameCreated = transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
- final NeverReconnectStrategyFactoryModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated,
+ final NeverReconnectStrategyFactoryModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated,
NeverReconnectStrategyFactoryModuleMXBean.class);
mxBean.setTimeout(timeout);
mxBean.setExecutor(GlobalEventExecutorUtil.create(transaction));
createInstance();
final ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
assertBeanCount(1, FACTORY_NAME);
- final ReconnectImmediatelyStrategyFactoryModuleMXBean mxBean = transaction.newMBeanProxy(
+ final ReconnectImmediatelyStrategyFactoryModuleMXBean mxBean = transaction.newMXBeanProxy(
transaction.lookupConfigBean(FACTORY_NAME, INSTANCE_NAME),
ReconnectImmediatelyStrategyFactoryModuleMXBean.class);
mxBean.setReconnectTimeout(200);
private static ObjectName createInstance(final ConfigTransactionJMXClient transaction, final Integer timeout)
throws InstanceAlreadyExistsException {
final ObjectName nameCreated = transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
- final ReconnectImmediatelyStrategyFactoryModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated,
+ final ReconnectImmediatelyStrategyFactoryModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated,
ReconnectImmediatelyStrategyFactoryModuleMXBean.class);
mxBean.setReconnectTimeout(timeout);
mxBean.setReconnectExecutor(GlobalEventExecutorUtil.create(transaction));
createInstance();
final ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
assertBeanCount(1, FACTORY_NAME);
- final TimedReconnectStrategyFactoryModuleMXBean mxBean = transaction.newMBeanProxy(
+ final TimedReconnectStrategyFactoryModuleMXBean mxBean = transaction.newMXBeanProxy(
transaction.lookupConfigBean(FACTORY_NAME, INSTANCE_NAME), TimedReconnectStrategyFactoryModuleMXBean.class);
assertEquals(mxBean.getMinSleep(), new Long(100));
mxBean.setMinSleep(200L);
final Integer connectTime, final Long minSleep, final BigDecimal sleepFactor, final Long maxSleep,
final Long maxAttempts, final Long deadline) throws InstanceAlreadyExistsException {
final ObjectName nameCreated = transaction.createModule(FACTORY_NAME, instanceName);
- final TimedReconnectStrategyFactoryModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated,
+ final TimedReconnectStrategyFactoryModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated,
TimedReconnectStrategyFactoryModuleMXBean.class);
mxBean.setConnectTime(connectTime);
mxBean.setDeadline(deadline);
// test reported apsp number of threads
TestingParallelAPSPConfigMXBean parallelAPSPRuntimeProxy = configRegistryClient
- .newMBeanProxy(apspON, TestingParallelAPSPConfigMXBean.class);
+ .newMXBeanProxy(apspON, TestingParallelAPSPConfigMXBean.class);
assertEquals(
(Integer) TestingParallelAPSPImpl.MINIMAL_NUMBER_OF_THREADS,
parallelAPSPRuntimeProxy.getMaxNumberOfThreads());
import static org.junit.Assert.fail;
import javax.annotation.Nullable;
-import javax.management.DynamicMBean;
import javax.management.InstanceAlreadyExistsException;
import javax.management.InstanceNotFoundException;
+import javax.management.IntrospectionException;
import javax.management.ObjectName;
+import javax.management.ReflectionException;
import org.junit.Test;
import org.opendaylight.controller.config.api.ValidationException;
import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
private void assertExists(@Nullable final ConfigTransactionJMXClient transaction,
final String moduleName, final String instanceName)
- throws InstanceNotFoundException {
+ throws InstanceNotFoundException, IntrospectionException, ReflectionException {
if (transaction != null) {
transaction.lookupConfigBean(moduleName, instanceName);
// make a dummy call
- configRegistryClient.newMBeanProxy(
- ObjectNameUtil.createTransactionModuleON(
- transaction.getTransactionName(), moduleName,
- instanceName), DynamicMBean.class).getMBeanInfo();
+ platformMBeanServer.getMBeanInfo(ObjectNameUtil.createTransactionModuleON(
+ transaction.getTransactionName(), moduleName, instanceName));
} else {
configRegistryClient.lookupConfigBean(moduleName, instanceName);
// make a dummy call
- configRegistryClient.newMBeanProxy(
- ObjectNameUtil.createReadOnlyModuleON(moduleName,
- instanceName), DynamicMBean.class).getMBeanInfo();
+ platformMBeanServer.getMBeanInfo(ObjectNameUtil.createReadOnlyModuleON(moduleName,
+ instanceName));
}
}
ObjectName apspName = transaction.createModule(
TestingParallelAPSPModuleFactory.NAME, "apsp1");
- TestingParallelAPSPConfigMXBean apspProxy = transaction.newMBeanProxy(
+ TestingParallelAPSPConfigMXBean apspProxy = transaction.newMXBeanProxy(
apspName, TestingParallelAPSPConfigMXBean.class);
apspProxy.setThreadPool(scheduledName);
apspProxy.setSomeParam("someParam");
ObjectName apspName = transaction.createModule(
TestingParallelAPSPModuleFactory.NAME, "apsp1");
- TestingParallelAPSPConfigMXBean apspProxy = transaction.newMBeanProxy(
+ TestingParallelAPSPConfigMXBean apspProxy = transaction.newMXBeanProxy(
apspName, TestingParallelAPSPConfigMXBean.class);
apspProxy.setThreadPool(ObjectNameUtil.createReadOnlyModuleON(
TestingScheduledThreadPoolModuleFactory.NAME, scheduled1));
ObjectName fixed1name = firstCommit();
// 2, check that configuration was copied to platform
- DynamicMBean dynamicMBean = configRegistryClient.newMBeanProxy(
- ObjectNameUtil.withoutTransactionName(fixed1name),
- DynamicMBean.class);
- dynamicMBean.getMBeanInfo();
- assertEquals(numberOfThreads, dynamicMBean.getAttribute("ThreadCount"));
+ ObjectName on = ObjectNameUtil.withoutTransactionName(fixed1name);
+ platformMBeanServer.getMBeanInfo(on);
+ assertEquals(numberOfThreads, platformMBeanServer.getAttribute(on, "ThreadCount"));
// 3, shutdown fixed1 in new transaction
assertFalse(TestingFixedThreadPool.allExecutors.get(0).isShutdown());
// dynamic config should be removed from platform
try {
- dynamicMBean.getMBeanInfo();
+ platformMBeanServer.getMBeanInfo(on);
fail();
} catch (Exception e) {
- assertTrue(e.getCause() instanceof InstanceNotFoundException);
+ assertTrue(e instanceof InstanceNotFoundException);
}
}
public class ContextSetterImpl implements ContextSetter, Closeable {
private final LogbackStatusListener statusListener;
- private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(ContextSetterImpl.class);
+ private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(ContextSetterImpl.class);
public ContextSetterImpl(final LogbackRuntimeRegistrator rootRuntimeBeanRegistratorWrapper) {
statusListener = new LogbackStatusListener(rootRuntimeBeanRegistratorWrapper);
Map<String, Appender<ILoggingEvent>> appendersMap = getAppenders(module, context);
for (LoggerTO logger : module.getLoggerTO()) {
- LOGGER.trace("Setting configuration for logger {}", logger.getLoggerName());
+ LOG.trace("Setting configuration for logger {}", logger.getLoggerName());
final ch.qos.logback.classic.Logger logbackLogger = context.getLogger(logger.getLoggerName());
Optional<Set<Appender<ILoggingEvent>>> appendersBefore = getAppendersBefore(loggersBefore, logbackLogger);
- LOGGER.trace("Logger {}: Appenders registered before: {}", logger.getLoggerName(),
+ LOG.trace("Logger {}: Appenders registered before: {}", logger.getLoggerName(),
appendersBefore.isPresent() ? appendersBefore.get() : "NO APPENDERS BEFORE");
logbackLogger.setLevel(Level.toLevel(logger.getLevel()));
for (String appenderName : logger.getAppenders()) {
if (appendersMap.containsKey(appenderName)) {
logbackLogger.addAppender(appendersMap.get(appenderName));
- LOGGER.trace("Logger {}: Adding new appender: {}", logger.getLoggerName(), appenderName);
+ LOG.trace("Logger {}: Adding new appender: {}", logger.getLoggerName(), appenderName);
} else {
throw new IllegalStateException("No appender " + appenderName
+ " found. This error should have been discovered by validation");
for (Appender<ILoggingEvent> appenderBefore : appendersBefore.get()) {
logbackLogger.detachAppender(appenderBefore);
appenderBefore.stop();
- LOGGER.trace("Logger {}: Removing old appender: {}", logger.getLoggerName(),
+ LOG.trace("Logger {}: Removing old appender: {}", logger.getLoggerName(),
appenderBefore.getName());
}
loggersBefore.remove(logbackLogger);
*/
package org.opendaylight.controller.config.yang.logback.config;
+import com.google.common.collect.Sets;
import java.util.Set;
-
import org.opendaylight.controller.config.api.JmxAttribute;
import org.opendaylight.controller.config.api.JmxAttributeValidationException;
-import com.google.common.collect.Sets;
-
/**
*
*/
*/
package org.opendaylight.controller.config.yang.logback.config;
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.core.status.StatusBase;
+import ch.qos.logback.core.status.StatusListener;
+import ch.qos.logback.core.status.StatusManager;
import java.io.Closeable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-
import org.slf4j.LoggerFactory;
-import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.core.status.StatusBase;
-import ch.qos.logback.core.status.StatusListener;
-import ch.qos.logback.core.status.StatusManager;
-
public class LogbackStatusListener implements StatusListener, LogbackRuntimeMXBean, Closeable {
private final List<StatusTO> receivedStatuses;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.core.Appender;
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Multimap;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.opendaylight.controller.config.api.ModuleIdentifier;
import org.slf4j.LoggerFactory;
-import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.classic.spi.ILoggingEvent;
-import ch.qos.logback.core.Appender;
-
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Multimap;
-
public class ContextSetterImplTest {
@Mock
a.setEncoderPattern("%-4relative [%thread] %-5level %logger{35} - %msg%n");
return a;
}
+
}
try {
createBeans(
- true, "target/rollingApp", "", "30MB", 1, 5, "target/%i.log", "rolling", "consoleName", "ALL", "logger1",
+ true, "target/rollingApp", "", "30MB", 1, 5, "target/%i.log", "rolling", "consoleName", "ALL", "logger1",
"DEBUG", "FixedWindowRollingPolicy", 0, "FileAppender").commit();
fail();
} catch (ValidationException e) {
*/
package org.opendaylight.controller.config.yang.logback.config;
+import static org.junit.Assert.assertEquals;
+
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.core.rolling.FixedWindowRollingPolicy;
import ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy;
import com.google.common.collect.Lists;
+import java.io.File;
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.JMX;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
import org.apache.commons.io.FileUtils;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
import org.slf4j.LoggerFactory;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.JMX;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import java.io.File;
-import java.io.IOException;
-import java.lang.management.ManagementFactory;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-
public class LogbackModuleWithInitialConfigurationTest extends AbstractConfigTest {
private LogbackModuleFactory factory;
*/
package org.opendaylight.controller.config.yang.logback.config;
+import static org.junit.Assert.assertEquals;
+
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.core.joran.spi.JoranException;
import com.google.common.collect.Lists;
+import java.io.File;
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+import java.util.List;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.JMX;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
import org.apache.commons.io.FileUtils;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
import org.slf4j.LoggerFactory;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.JMX;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import java.io.File;
-import java.io.IOException;
-import java.lang.management.ManagementFactory;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-
public class LogbackWithXmlConfigModuleTest extends AbstractConfigTest {
private LogbackModuleFactory factory;
import com.google.common.reflect.AbstractInvocationHandler;
import com.google.common.reflect.Reflection;
import io.netty.util.concurrent.EventExecutor;
-
import java.lang.reflect.Method;
import java.util.concurrent.TimeUnit;
*/
package org.opendaylight.controller.config.yang.netty.eventexecutor;
+import static com.google.common.base.Preconditions.checkArgument;
+
import org.opendaylight.controller.config.api.DependencyResolver;
import org.osgi.framework.BundleContext;
-import static com.google.common.base.Preconditions.checkArgument;
-
public class GlobalEventExecutorModuleFactory extends org.opendaylight.controller.config.yang.netty.eventexecutor.AbstractGlobalEventExecutorModuleFactory {
public static final String SINGLETON_NAME = "singleton";
*/
package org.opendaylight.controller.config.yang.netty.eventexecutor;
+import static com.google.common.base.Preconditions.checkArgument;
+
import org.opendaylight.controller.config.api.DependencyResolver;
import org.osgi.framework.BundleContext;
-import static com.google.common.base.Preconditions.checkArgument;
-
public class ImmediateEventExecutorModuleFactory extends org.opendaylight.controller.config.yang.netty.eventexecutor.AbstractImmediateEventExecutorModuleFactory {
public static final String SINGLETON_NAME = "singleton";
package org.opendaylight.controller.config.yang.netty.eventexecutor;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+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.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.ObjectName;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
public class GlobalEventExecutorModuleTest extends AbstractConfigTest {
private GlobalEventExecutorModuleFactory factory;
private ObjectName createInstance(ConfigTransactionJMXClient transaction, String instanceName)
throws InstanceAlreadyExistsException {
ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), instanceName);
- transaction.newMBeanProxy(nameCreated, GlobalEventExecutorModuleMXBean.class);
+ transaction.newMXBeanProxy(nameCreated, GlobalEventExecutorModuleMXBean.class);
return nameCreated;
}
private ObjectName createInstance(ConfigTransactionJMXClient transaction, String instanceName)
throws InstanceAlreadyExistsException {
ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), instanceName);
- transaction.newMBeanProxy(nameCreated, ImmediateEventExecutorModuleMXBean.class);
+ transaction.newMXBeanProxy(nameCreated, ImmediateEventExecutorModuleMXBean.class);
return nameCreated;
}
package org.opendaylight.controller.config.yang.netty.threadgroup;
import io.netty.channel.nio.NioEventLoopGroup;
-
-import org.opendaylight.controller.config.api.JmxAttributeValidationException;
-
import java.util.concurrent.TimeUnit;
+import org.opendaylight.controller.config.api.JmxAttributeValidationException;
/**
*
*/
package org.opendaylight.controller.config.yang.netty.threadgroup;
+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.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.ObjectName;
-
public class NettyThreadgroupModuleTest extends AbstractConfigTest {
private NettyThreadgroupModuleFactory factory;
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<sourceDirectory>${project.basedir}</sourceDirectory>
<includes>**\/*.java,**\/*.xml,**\/*.ini,**\/*.sh,**\/*.bat,**\/*.yang</includes>
- <excludes>**\/target\/,**\/bin\/,**\/target-ide\/,**\/${jmxGeneratorPath}\/,**\/${salGeneratorPath}\/</excludes>
+ <!-- excluding logback-config, has several checkstyle warnings
+ regarding Logger/LoggerFactory, which couldn't be removed due necessity/intention
+ to use the particular implementation/library of Logger/LoggerFactory -->
+ <excludes>**\/logback-config\/,**\/target\/,**\/bin\/,**\/target-ide\/,**\/${jmxGeneratorPath}\/,**\/${salGeneratorPath}\/</excludes>
</configuration>
<dependencies>
<dependency>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+ Copyright (c) 2014 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
+ -->
+<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>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>mdsal-artifacts</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <dependencyManagement>
+ <dependencies>
+ <!-- Core API/implementation -->
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-common-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-common-impl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-common-util</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-core-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-core-spi</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-broker-impl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-binding-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-binding-broker-impl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-binding-config</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-binding-util</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-connector-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-inmemory-datastore</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>md-sal-config</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- Test support -->
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-test-model</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-binding-it</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-binding-broker-impl</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- Features -->
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>features-mdsal</artifactId>
+ <version>${project.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- FIXME: move this into netconf-artifacts -->
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-netconf-connector</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- FIXME: These below need splitting up -->
+
+ <!-- AD-SAL compatibility -->
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-compatibility</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- Base model augmentations -->
+ <dependency>
+ <groupId>org.opendaylight.controller.model</groupId>
+ <artifactId>model-inventory</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.model</groupId>
+ <artifactId>model-topology</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- Clustered implementation -->
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-clustering-commons</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-clustering-config</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-distributed-datastore</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-remoterpc-connector</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- OpenFlow stuff -->
+ <dependency>
+ <groupId>org.opendaylight.controller.md</groupId>
+ <artifactId>forwardingrules-manager</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.md</groupId>
+ <artifactId>inventory-manager</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.md</groupId>
+ <artifactId>statistics-manager</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.md</groupId>
+ <artifactId>topology-lldp-discovery</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.md</groupId>
+ <artifactId>topology-manager</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.model</groupId>
+ <artifactId>model-flow-base</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.model</groupId>
+ <artifactId>model-flow-service</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.model</groupId>
+ <artifactId>model-flow-statistics</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>features-flow</artifactId>
+ <version>${project.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- RESTCONF -->
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-remote</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-rest-connector</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-rest-connector-config</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-restconf-broker</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-rest-docgen</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- Toaster -->
+ <dependency>
+ <groupId>org.opendaylight.controller.samples</groupId>
+ <artifactId>sample-toaster</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.samples</groupId>
+ <artifactId>sample-toaster-consumer</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.samples</groupId>
+ <artifactId>sample-toaster-provider</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.samples</groupId>
+ <artifactId>toaster-config</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.samples</groupId>
+ <artifactId>features-toaster</artifactId>
+ <version>${project.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- XSQL support -->
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-dom-xsql</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-karaf-xsql</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sal-dom-xsql-config</artifactId>
+ <version>${project.version}</version>
+ <classifier>config</classifier>
+ <type>xml</type>
+ </dependency>
+
+ </dependencies>
+ </dependencyManagement>
+</project>
+
<packaging>pom</packaging>
<modules>
+ <module>mdsal-artifacts</module>
+
<!-- Common APIs & Implementation -->
<module>sal-common</module>
<module>sal-common-api</module>
</lifecycleMappingMetadata>
</configuration>
</plugin>
- <plugin>
- <groupId>org.eclipse.xtend</groupId>
- <artifactId>xtend-maven-plugin</artifactId>
- <version>${xtend.version}</version>
- </plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
- <dependency>
- <groupId>org.eclipse.xtend</groupId>
- <artifactId>org.eclipse.xtend.lib</artifactId>
- </dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
</execution>
</executions>
</plugin>
- <plugin>
- <groupId>org.eclipse.xtend</groupId>
- <artifactId>xtend-maven-plugin</artifactId>
- </plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
--- /dev/null
+/*
+ * 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.sal.binding.codegen.impl;
+
+import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSet.Builder;
+import java.lang.reflect.Method;
+import java.util.Map;
+import javassist.CannotCompileException;
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.CtMethod;
+import javassist.NotFoundException;
+import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeSpecification;
+import org.opendaylight.yangtools.sal.binding.generator.util.ClassGenerator;
+import org.opendaylight.yangtools.sal.binding.generator.util.MethodGenerator;
+import org.opendaylight.yangtools.util.ClassLoaderUtils;
+import org.opendaylight.yangtools.yang.binding.BaseIdentity;
+import org.opendaylight.yangtools.yang.binding.Notification;
+import org.opendaylight.yangtools.yang.binding.NotificationListener;
+import org.opendaylight.yangtools.yang.binding.RpcImplementation;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
+
+final class DefaultRuntimeCodeGenerator extends AbstractRuntimeCodeGenerator {
+
+ DefaultRuntimeCodeGenerator(final ClassPool pool) {
+ super(pool);
+ }
+
+ @Override
+ protected <T extends RpcService> Supplier<T> directProxySupplier(final Class<T> serviceType) {
+ return new Supplier<T>() {
+ @SuppressWarnings("unchecked")
+ @Override
+ public T get() {
+ final String proxyName = RuntimeCodeSpecification.getDirectProxyName(serviceType);
+
+ final Class<?> potentialClass = ClassLoaderUtils.tryToLoadClassWithTCCL(proxyName);
+ if (potentialClass != null) {
+ try {
+ return (T)potentialClass.newInstance();
+ } catch (InstantiationException | IllegalAccessException e) {
+ throw new IllegalStateException("Failed to instantiate class " + potentialClass.getName(), e);
+ }
+ }
+
+ final CtClass supertype = utils.asCtClass(serviceType);
+ final String directProxyName = RuntimeCodeSpecification.getDirectProxyName(serviceType);
+
+ final CtClass createdCls;
+ try {
+ createdCls = utils.createClass(directProxyName, supertype, new ClassGenerator() {
+ @Override
+ public void process(final CtClass cls) throws CannotCompileException {
+ utils.field(cls, RuntimeCodeSpecification.DELEGATE_FIELD, serviceType);
+ utils.implementsType(cls, utils.asCtClass(RpcImplementation.class));
+ utils.implementMethodsFrom(cls, supertype, new MethodGenerator() {
+ @Override
+ public void process(final CtMethod method) throws CannotCompileException {
+ final StringBuilder sb = new StringBuilder("\n");
+ sb.append("{\n");
+ sb.append(" if (").append(RuntimeCodeSpecification.DELEGATE_FIELD).append(" == null) {\n");
+ sb.append(" throw new java.lang.IllegalStateException(\"No default provider is available\");\n");
+ sb.append(" }\n");
+ sb.append(" return ($r) ").append(RuntimeCodeSpecification.DELEGATE_FIELD).append('.').append(method.getName()).append("($$);\n");
+ sb.append("}\n");
+ method.setBody(sb.toString());
+ }
+ });
+
+ // FIXME: copy this one...
+ utils.implementMethodsFrom(cls, utils.asCtClass(RpcImplementation.class), new MethodGenerator() {
+ @Override
+ public void process(final CtMethod method) throws CannotCompileException {
+ final StringBuilder sb = new StringBuilder("\n");
+ sb.append("{\n");
+ sb.append(" throw new java.lang.IllegalStateException(\"No provider is processing supplied message\");\n");
+ sb.append(" return ($r) null;\n");
+ sb.append("}\n");
+ method.setBody(sb.toString());
+ }
+ });
+ }
+ });
+ } catch (CannotCompileException e) {
+ throw new IllegalStateException("Failed to create class " + directProxyName, e);
+ }
+
+ final Class<?> c;
+ try {
+ c = createdCls.toClass(serviceType.getClassLoader(), serviceType.getProtectionDomain());
+ } catch (CannotCompileException e) {
+ throw new IllegalStateException(String.format("Failed to create class %s", createdCls), e);
+ }
+
+ try {
+ return (T) c.newInstance();
+ } catch (InstantiationException | IllegalAccessException e) {
+ throw new IllegalStateException(String.format("Failed to instantiated class %s", c), e);
+ }
+ }
+ };
+ }
+
+ @Override
+ protected <T extends RpcService> Supplier<T> routerSupplier(final Class<T> serviceType, final RpcServiceMetadata metadata) {
+ return new Supplier<T>() {
+ @SuppressWarnings("unchecked")
+ @Override
+ public T get() {
+ final CtClass supertype = utils.asCtClass(serviceType);
+ final String routerName = RuntimeCodeSpecification.getRouterName(serviceType);
+ final Class<?> potentialClass = ClassLoaderUtils.tryToLoadClassWithTCCL(routerName);
+ if (potentialClass != null) {
+ try {
+ return (T)potentialClass.newInstance();
+ } catch (InstantiationException | IllegalAccessException e) {
+ throw new IllegalStateException("Failed to instantiate class", e);
+ }
+ }
+
+ final CtClass targetCls;
+ try {
+ targetCls = utils.createClass(routerName, supertype, new ClassGenerator() {
+ @Override
+ public void process(final CtClass cls) throws CannotCompileException {
+ utils.field(cls, RuntimeCodeSpecification.DELEGATE_FIELD, serviceType);
+ //utils.field(cls, REMOTE_INVOKER_FIELD,iface);
+ utils.implementsType(cls, utils.asCtClass(RpcImplementation.class));
+
+ for (final Class<? extends BaseIdentity> ctx : metadata.getContexts()) {
+ utils.field(cls, RuntimeCodeSpecification.getRoutingTableField(ctx), Map.class);
+ }
+
+ utils.implementMethodsFrom(cls, supertype, new MethodGenerator() {
+ @Override
+ public void process(final CtMethod method) throws CannotCompileException {
+ final int ptl;
+ try {
+ ptl = method.getParameterTypes().length;
+ } catch (NotFoundException e) {
+ throw new CannotCompileException(e);
+ }
+ final StringBuilder sb = new StringBuilder();
+
+ switch (ptl) {
+ case 0:
+ sb.append("return ($r) ").append(RuntimeCodeSpecification.DELEGATE_FIELD).append('.').append(method.getName()).append("($$);");
+ break;
+ case 1:
+ final RpcMetadata rpcMeta = metadata.getRpcMethod(method.getName());
+ final String rtGetter = rpcMeta.getInputRouteGetter().getName();
+ final String stName = supertype.getName();
+
+ sb.append('\n');
+ sb.append("{\n");
+ sb.append(" if ($1 == null) {\n");
+ sb.append(" throw new IllegalArgumentException(\"RPC input must not be null and must contain a value for field ").append(rtGetter).append("\");\n");
+ sb.append(" }\n");
+ sb.append(" if ($1.").append(rtGetter).append("() == null) {\n");
+ sb.append(" throw new IllegalArgumentException(\"Field ").append(rtGetter).append(" must not be null\");\n");
+ sb.append(" }\n");
+
+ sb.append(" final org.opendaylight.yangtools.yang.binding.InstanceIdentifier identifier = $1.").append(rtGetter).append("()");
+ if (rpcMeta.isRouteEncapsulated()) {
+ sb.append(".getValue()");
+ }
+ sb.append(";\n");
+
+ sb.append(" ").append(supertype.getName()).append(" instance = (").append(stName).append(") ").append(RuntimeCodeSpecification.getRoutingTableField(rpcMeta.getContext())).append(".get(identifier);\n");
+ sb.append(" if (instance == null) {\n");
+ sb.append(" instance = ").append(RuntimeCodeSpecification.DELEGATE_FIELD).append(";\n");
+ sb.append(" }\n");
+
+ sb.append(" if (instance == null) {\n");
+ sb.append(" throw new java.lang.IllegalStateException(\"No routable provider is processing routed message for \" + String.valueOf(identifier));\n");
+ sb.append(" }\n");
+ sb.append(" return ($r) instance.").append(method.getName()).append("($$);\n");
+ sb.append('}');
+ break;
+ default:
+ throw new CannotCompileException(String.format("Unsupported parameters length %s", ptl));
+ }
+
+ method.setBody(sb.toString());
+ }
+ });
+
+ // FIXME: move this into a template class
+ utils.implementMethodsFrom(cls, utils.asCtClass(RpcImplementation.class), new MethodGenerator() {
+ @Override
+ public void process(final CtMethod method) throws CannotCompileException {
+ final StringBuilder sb = new StringBuilder("\n");
+ sb.append("{\n");
+ sb.append(" throw new java.lang.IllegalStateException(\"No provider is processing supplied message\");\n");
+ sb.append(" return ($r) null;\n");
+ sb.append("}\n");
+
+ method.setBody(sb.toString());
+ }
+ });
+ }
+ });
+ } catch (CannotCompileException e) {
+ throw new IllegalStateException("Failed to create class " + routerName, e);
+ }
+
+ final Class<?> c;
+ try {
+ c = targetCls.toClass(serviceType.getClassLoader(), serviceType.getProtectionDomain());
+ } catch (CannotCompileException e) {
+ throw new IllegalStateException(String.format("Failed to compile class %s", targetCls), e);
+ }
+
+ try {
+ return (T)c.newInstance();
+ } catch (InstantiationException | IllegalAccessException e) {
+ throw new IllegalStateException(String.format("Failed to instantiate class %s", c), e);
+ }
+ }
+ };
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected RuntimeGeneratedInvokerPrototype generateListenerInvoker(final Class<? extends NotificationListener> listenerType) {
+ final String invokerName = RuntimeCodeSpecification.getInvokerName(listenerType);
+ final CtClass targetCls;
+
+ // Builder for a set of supported types. Filled while the target class is being generated
+ final Builder<Class<? extends Notification>> b = ImmutableSet.builder();
+
+ try {
+ targetCls = utils.createClass(invokerName, getBrokerNotificationListener(), new ClassGenerator() {
+ @Override
+ public void process(final CtClass cls) throws CannotCompileException {
+ utils.field(cls, RuntimeCodeSpecification.DELEGATE_FIELD, listenerType);
+ utils.implementMethodsFrom(cls, getBrokerNotificationListener(), new MethodGenerator() {
+ @Override
+ public void process(final CtMethod method) throws CannotCompileException {
+ final StringBuilder sb = new StringBuilder("\n");
+
+ sb.append("{\n");
+
+ for (Method m : listenerType.getMethods()) {
+ if (BindingReflections.isNotificationCallback(m)) {
+ final Class<?> argType = m.getParameterTypes()[0];
+
+ // populates builder above
+ b.add((Class<? extends Notification>) argType);
+
+ sb.append(" if ($1 instanceof ").append(argType.getName()).append(") {\n");
+ sb.append(" ").append(RuntimeCodeSpecification.DELEGATE_FIELD).append('.').append(m.getName()).append("((").append(argType.getName()).append(") $1);\n");
+ sb.append(" return null;\n");
+ sb.append(" } else ");
+ }
+ }
+
+ sb.append(" return null;\n");
+ sb.append("}\n");
+ method.setBody(sb.toString());
+ }
+ });
+ }
+ });
+ } catch (CannotCompileException e) {
+ throw new IllegalStateException("Failed to create class " + invokerName, e);
+ }
+
+ final Class<?> finalClass;
+ try {
+ finalClass = targetCls.toClass(listenerType.getClassLoader(), listenerType.getProtectionDomain());
+ } catch (CannotCompileException e) {
+ throw new IllegalStateException(String.format("Failed to compile class %s", targetCls), e);
+ }
+
+ return new RuntimeGeneratedInvokerPrototype(b.build(), (Class<? extends org.opendaylight.controller.sal.binding.api.NotificationListener<?>>) finalClass);
+ }
+}
+++ /dev/null
-/*
- * 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.sal.binding.codegen.impl
-
-import java.util.Map
-import javassist.ClassPool
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
-import org.opendaylight.yangtools.yang.binding.Notification
-import org.opendaylight.yangtools.yang.binding.RpcImplementation
-import org.opendaylight.yangtools.yang.binding.util.BindingReflections
-import org.opendaylight.yangtools.yang.binding.util.ClassLoaderUtils
-
-import static extension org.opendaylight.controller.sal.binding.codegen.RuntimeCodeSpecification.*
-import org.opendaylight.yangtools.yang.binding.RpcService
-
-class RuntimeCodeGenerator extends AbstractRuntimeCodeGenerator {
-
- new(ClassPool pool) {
- super(pool)
- }
-
- override directProxySupplier(Class iface) {
- return [|
- val proxyName = iface.directProxyName;
- val potentialClass = ClassLoaderUtils.tryToLoadClassWithTCCL(proxyName)
- if(potentialClass != null) {
- return potentialClass.newInstance as RpcService;
- }
- val supertype = iface.asCtClass
- val createdCls = createClass(iface.directProxyName, supertype) [
- field(DELEGATE_FIELD, iface);
- implementsType(RpcImplementation.asCtClass)
- implementMethodsFrom(supertype) [
- body = '''
- {
- if(«DELEGATE_FIELD» == null) {
- throw new java.lang.IllegalStateException("No default provider is available");
- }
- return ($r) «DELEGATE_FIELD».«it.name»($$);
- }
- '''
- ]
- implementMethodsFrom(RpcImplementation.asCtClass) [
- body = '''
- {
- throw new java.lang.IllegalStateException("No provider is processing supplied message");
- return ($r) null;
- }
- '''
- ]
- ]
- return createdCls.toClass(iface.classLoader).newInstance as RpcService
- ]
- }
-
- override routerSupplier(Class iface, RpcServiceMetadata metadata) {
- return [ |
- val supertype = iface.asCtClass
- val routerName = iface.routerName;
- val potentialClass = ClassLoaderUtils.tryToLoadClassWithTCCL(routerName)
- if(potentialClass != null) {
- return potentialClass.newInstance as RpcService;
- }
-
- val targetCls = createClass(iface.routerName, supertype) [
-
-
- field(DELEGATE_FIELD, iface)
- //field(REMOTE_INVOKER_FIELD,iface);
- implementsType(RpcImplementation.asCtClass)
-
- for (ctx : metadata.contexts) {
- field(ctx.routingTableField, Map)
- }
- implementMethodsFrom(supertype) [
- if (parameterTypes.size === 1) {
- val rpcMeta = metadata.getRpcMethod(name);
- val bodyTmp = '''
- {
- if($1 == null) {
- throw new IllegalArgumentException("RPC input must not be null and must contain a value for field «rpcMeta.inputRouteGetter.name»");
- }
- if($1.«rpcMeta.inputRouteGetter.name»() == null) {
- throw new IllegalArgumentException("Field «rpcMeta.inputRouteGetter.name» must not be null");
- }
- final «InstanceIdentifier.name» identifier = $1.«rpcMeta.inputRouteGetter.name»()«IF rpcMeta.
- routeEncapsulated».getValue()«ENDIF»;
- «supertype.name» instance = («supertype.name») «rpcMeta.context.routingTableField».get(identifier);
- if(instance == null) {
- instance = «DELEGATE_FIELD»;
- }
- if(instance == null) {
- throw new java.lang.IllegalStateException("No routable provider is processing routed message for " + String.valueOf(identifier));
- }
- return ($r) instance.«it.name»($$);
- }'''
- body = bodyTmp
- } else if (parameterTypes.size === 0) {
- body = '''return ($r) «DELEGATE_FIELD».«it.name»($$);'''
- }
- ]
- implementMethodsFrom(RpcImplementation.asCtClass) [
- body = '''
- {
- throw new java.lang.IllegalStateException("No provider is processing supplied message");
- return ($r) null;
- }
- '''
- ]
- ]
- return targetCls.toClass(iface.classLoader,iface.protectionDomain).newInstance as RpcService
- ];
- }
-
- override generateListenerInvoker(Class iface) {
- val callbacks = iface.methods.filter[BindingReflections.isNotificationCallback(it)]
-
- val supportedNotification = callbacks.map[parameterTypes.get(0) as Class<? extends Notification>].toSet;
-
- val targetCls = createClass(iface.invokerName, brokerNotificationListener) [
- field(DELEGATE_FIELD, iface)
- implementMethodsFrom(brokerNotificationListener) [
- body = '''
- {
- «FOR callback : callbacks SEPARATOR " else "»
- «val cls = callback.parameterTypes.get(0).name»
- if($1 instanceof «cls») {
- «DELEGATE_FIELD».«callback.name»((«cls») $1);
- return null;
- }
- «ENDFOR»
- return null;
- }
- '''
- ]
- ]
- val finalClass = targetCls.toClass(iface.classLoader, iface.protectionDomain)
- return new RuntimeGeneratedInvokerPrototype(supportedNotification,
- finalClass as Class<? extends org.opendaylight.controller.sal.binding.api.NotificationListener<?>>);
- }
-}
public static final ClassPool CLASS_POOL = ClassPool.getDefault();
public static final JavassistUtils JAVASSIST = JavassistUtils.forClassPool(CLASS_POOL);
- public static final org.opendaylight.controller.sal.binding.codegen.impl.RuntimeCodeGenerator RPC_GENERATOR_IMPL = new org.opendaylight.controller.sal.binding.codegen.impl.RuntimeCodeGenerator(
+ public static final org.opendaylight.controller.sal.binding.codegen.impl.DefaultRuntimeCodeGenerator RPC_GENERATOR_IMPL = new org.opendaylight.controller.sal.binding.codegen.impl.DefaultRuntimeCodeGenerator(
CLASS_POOL);
public static final RuntimeCodeGenerator RPC_GENERATOR = RPC_GENERATOR_IMPL;
public static final NotificationInvokerFactory INVOKER_FACTORY = RPC_GENERATOR_IMPL.getInvokerFactory();
* 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.sal.binding.test;
+package org.opendaylight.controller.sal.binding.codegen.impl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
-
import java.util.ArrayList;
import java.util.List;
-
import javassist.ClassPool;
-
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.sal.binding.api.rpc.RpcRouter;
import org.opendaylight.controller.sal.binding.api.rpc.RpcRoutingTable;
-import org.opendaylight.controller.sal.binding.codegen.impl.RuntimeCodeGenerator;
+import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeGenerator;
import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory;
import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory.NotificationInvoker;
import org.opendaylight.controller.sal.binding.test.mock.BarListener;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class RuntimeCodeGeneratorTest {
+public class DefaultRuntimeCodeGeneratorTest {
private RuntimeCodeGenerator codeGenerator;
private NotificationInvokerFactory invokerFactory;
@Before
public void initialize() {
- this.codeGenerator = new RuntimeCodeGenerator(ClassPool.getDefault());
+ this.codeGenerator = new DefaultRuntimeCodeGenerator(ClassPool.getDefault());
this.invokerFactory = codeGenerator.getInvokerFactory();
}
<bundle.plugin.version>2.4.0</bundle.plugin.version>
<guava.version>14.0.1</guava.version>
<maven.clean.plugin.version>2.5</maven.clean.plugin.version>
- <xtend.version>2.4.3</xtend.version>
</properties>
<dependencies>
<dependency>
package org.opendaylight.controller.netconf.util;
import com.google.common.base.Preconditions;
-
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.controller.netconf.util.xml.XmlElement;
public final class NetconfUtil {
- private static final Logger logger = LoggerFactory.getLogger(NetconfUtil.class);
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfUtil.class);
private NetconfUtil() {}
if (element.getName().equals(XmlNetconfConstants.OK)) {
return response;
}
- logger.warn("Can not load last configuration. Operation failed.");
+ LOG.warn("Can not load last configuration. Operation failed.");
throw new IllegalStateException("Can not load last configuration. Operation failed: "
+ XmlUtil.toString(response));
}
import java.util.Collections;
import java.util.Map;
-
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
public class MissingNameSpaceException extends NetconfDocumentedException {
import java.util.Collections;
import java.util.Map;
-
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
public class UnexpectedElementException extends NetconfDocumentedException {
import java.util.Collections;
import java.util.Map;
-
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
public class UnexpectedNamespaceException extends NetconfDocumentedException {
package org.opendaylight.controller.netconf.util.messages;
-import org.opendaylight.controller.netconf.api.NetconfMessage;
-
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Sets;
import java.util.Set;
-
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
+import org.opendaylight.controller.netconf.api.NetconfMessage;
import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.controller.netconf.util.exception.MissingNameSpaceException;
import org.opendaylight.controller.netconf.util.xml.XmlElement;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Sets;
-
/**
* NetconfMessage that can carry additional header with session metadata. See {@link org.opendaylight.controller.netconf.util.messages.NetconfHelloMessageAdditionalHeader}
*/
package org.opendaylight.controller.netconf.util.messages;
import com.google.common.base.Preconditions;
-
import java.util.regex.Matcher;
import java.util.regex.Pattern;
package org.opendaylight.controller.netconf.util.messages;
-import java.nio.ByteBuffer;
-
import com.google.common.base.Charsets;
import com.google.common.base.Preconditions;
+import java.nio.ByteBuffer;
/**
* Netconf message header is used only when chunked framing mechanism is
public final class NetconfMessageUtil {
- private static final Logger logger = LoggerFactory.getLogger(NetconfMessageUtil.class);
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfMessageUtil.class);
private NetconfMessageUtil() {}
try {
return input.getTextContent().trim();
} catch (NetconfDocumentedException e) {
- logger.trace("Error fetching inpit text content becauese {}",e);
+ LOG.trace("Error fetching input text content",e);
return null;
}
}
package org.opendaylight.controller.netconf.util.messages;
import com.google.common.base.Preconditions;
-
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
-
-import org.opendaylight.controller.netconf.api.NetconfSession;
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.opendaylight.controller.netconf.api.NetconfMessage;
+import org.opendaylight.controller.netconf.api.NetconfSession;
import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.controller.netconf.util.xml.XmlUtil;
import org.slf4j.Logger;
import org.w3c.dom.NamedNodeMap;
public final class SendErrorExceptionUtil {
- private static final Logger logger = LoggerFactory.getLogger(SendErrorExceptionUtil.class);
+ private static final Logger LOG = LoggerFactory.getLogger(SendErrorExceptionUtil.class);
private SendErrorExceptionUtil() {}
public static void sendErrorMessage(final NetconfSession session,
final NetconfDocumentedException sendErrorException) {
- logger.trace("Sending error {}", sendErrorException.getMessage(), sendErrorException);
+ LOG.trace("Sending error {}", sendErrorException.getMessage(), sendErrorException);
final Document errorDocument = createDocument(sendErrorException);
ChannelFuture f = session.sendMessage(new NetconfMessage(errorDocument));
f.addListener(new SendErrorVerifyingListener(sendErrorException));
}
public static void sendErrorMessage(Channel channel, NetconfDocumentedException sendErrorException) {
- logger.trace("Sending error {}", sendErrorException.getMessage(), sendErrorException);
+ LOG.trace("Sending error {}", sendErrorException.getMessage(), sendErrorException);
final Document errorDocument = createDocument(sendErrorException);
ChannelFuture f = channel.writeAndFlush(new NetconfMessage(errorDocument));
f.addListener(new SendErrorVerifyingListener(sendErrorException));
public static void sendErrorMessage(NetconfSession session, NetconfDocumentedException sendErrorException,
NetconfMessage incommingMessage) {
final Document errorDocument = createDocument(sendErrorException);
- logger.trace("Sending error {}", XmlUtil.toString(errorDocument));
+ LOG.trace("Sending error {}", XmlUtil.toString(errorDocument));
tryToCopyAttributes(incommingMessage.getDocument(), errorDocument, sendErrorException);
ChannelFuture f = session.sendMessage(new NetconfMessage(errorDocument));
f.addListener(new SendErrorVerifyingListener(sendErrorException));
rpcReply.setAttributeNode((Attr) errorDocument.importNode(attr, true));
}
} catch (final Exception e) {
- logger.warn("Unable to copy incomming attributes to {}, returned rpc-error might be invalid for client",
+ LOG.warn("Unable to copy incomming attributes to {}, returned rpc-error might be invalid for client",
sendErrorException, e);
}
}
import org.slf4j.LoggerFactory;
public final class NetconfConfigUtil {
- private static final Logger logger = LoggerFactory.getLogger(NetconfConfigUtil.class);
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfConfigUtil.class);
private static final String PREFIX_PROP = "netconf.";
try {
return Long.parseLong(timeoutString);
} catch (final NumberFormatException e) {
- logger.warn("Cannot parse {} property: {}, using defaults", key, timeoutString, e);
+ LOG.warn("Cannot parse {} property: {}, using defaults", key, timeoutString, e);
return DEFAULT_TIMEOUT_MILLIS;
}
}
try {
return Optional.of(parseAddress(address, port));
} catch (final RuntimeException e) {
- logger.warn("Unable to parse {} netconf address from {}:{}, fallback to default",
+ LOG.warn("Unable to parse {} netconf address from {}:{}, fallback to default",
infixProp, address, port, e);
}
}
package org.opendaylight.controller.netconf.util.xml;
+import com.google.common.collect.ImmutableMap;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
-
import javax.xml.namespace.NamespaceContext;
-import com.google.common.collect.ImmutableMap;
-
// http://www.ibm.com/developerworks/library/x-nmspccontext/
public class HardcodedNamespaceResolver implements NamespaceContext {
private final Map<String/* prefix */, String/* namespace */> prefixesToNamespaces;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
-
import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
public final class XMLNetconfUtil {
public static final String DEFAULT_NAMESPACE_PREFIX = "";
private final Element element;
- private static final Logger logger = LoggerFactory.getLogger(XmlElement.class);
+ private static final Logger LOG = LoggerFactory.getLogger(XmlElement.class);
private XmlElement(Element element) {
this.element = element;
public void checkNamespace(String expectedNamespace) throws UnexpectedNamespaceException, MissingNameSpaceException {
if (!getNamespace().equals(expectedNamespace))
- {
+ {
throw new UnexpectedNamespaceException(String.format("Unexpected namespace %s should be %s",
getNamespace(),
expectedNamespace),
try {
sb.append(", namespace='").append(getNamespace()).append('\'');
} catch (MissingNameSpaceException e) {
- logger.trace("Missing namespace for element.");
+ LOG.trace("Missing namespace for element.");
}
}
sb.append('}');
package org.opendaylight.controller.netconf.util.xml;
+import com.google.common.base.Preconditions;
import java.io.IOException;
import java.io.InputStream;
-
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import javax.xml.validation.Schema;
import javax.xml.validation.Validator;
-
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
-import com.google.common.base.Preconditions;
-
public final class XmlNetconfValidator {
private static final Schema SCHEMA;
import com.google.common.base.Charsets;
import com.google.common.base.Optional;
-
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
-
import javax.xml.XMLConstants;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.validation.SchemaFactory;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
-
import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
public static Element createTextElementWithNamespacedContent(Document document, String qName, String prefix,
String namespace, String contentWithoutPrefix) {
- return createTextElementWithNamespacedContent(document, qName, prefix, namespace, contentWithoutPrefix, Optional.<String>absent());
+ return createTextElementWithNamespacedContent(document, qName, prefix, namespace, contentWithoutPrefix, Optional.<String>absent());
}
public static Element createTextElementWithNamespacedContent(Document document, String qName, String prefix,
*/
package org.opendaylight.controller.netconf.util;
-import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
+import static org.hamcrest.CoreMatchers.containsString;
+
import org.junit.Test;
import org.opendaylight.controller.netconf.util.xml.XmlUtil;
import org.w3c.dom.Document;
package org.opendaylight.controller.netconf.util.mapping;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-
public class AbstractLastNetconfOperationTest {
class LastNetconfOperationImplTest extends AbstractLastNetconfOperation {
package org.opendaylight.controller.netconf.util.mapping;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+
import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-
public class AbstractNetconfOperationTest {
class NetconfOperationImpl extends AbstractNetconfOperation {
package org.opendaylight.controller.netconf.util.mapping;
+import static org.junit.Assert.assertEquals;
+
import org.junit.Test;
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.opendaylight.controller.netconf.mapping.api.HandlingPriority;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import static org.junit.Assert.assertEquals;
-
public class AbstractSingletonNetconfOperationTest {
class SingletonNCOperationImpl extends AbstractSingletonNetconfOperation {
package org.opendaylight.controller.netconf.util.messages;
+import static org.junit.Assert.assertEquals;
+
import org.junit.Before;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-
public class NetconfHelloMessageAdditionalHeaderTest {
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+
import com.google.common.base.Optional;
import java.util.Set;
import org.junit.Before;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+
import com.google.common.base.Charsets;
import org.junit.Test;
package org.opendaylight.controller.netconf.util.messages;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.util.Collection;
import org.junit.Test;
import org.opendaylight.controller.netconf.api.NetconfMessage;
import org.opendaylight.controller.netconf.util.test.XmlFileLoader;
import org.w3c.dom.Document;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
public class NetconfMessageUtilTest {
@Test
public void testNetconfMessageUtil() throws Exception {
package org.opendaylight.controller.netconf.util.messages;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.util.concurrent.GenericFutureListener;
import org.opendaylight.controller.netconf.util.test.XmlFileLoader;
import org.w3c.dom.Document;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.*;
-
public class SendErrorExceptionUtilTest {
NetconfSession netconfSession;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
+
import com.google.common.base.Optional;
import io.netty.channel.local.LocalAddress;
import java.net.InetSocketAddress;
package org.opendaylight.controller.netconf.util.test;
+import com.google.common.base.Charsets;
+import com.google.common.base.Preconditions;
+import com.google.common.io.CharStreams;
+import com.google.common.io.InputSupplier;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-
import javax.xml.parsers.ParserConfigurationException;
-
import org.opendaylight.controller.netconf.api.NetconfMessage;
import org.opendaylight.controller.netconf.util.xml.XmlUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
-import com.google.common.base.Charsets;
-import com.google.common.base.Preconditions;
-import com.google.common.io.CharStreams;
-import com.google.common.io.InputSupplier;
-
public class XmlFileLoader {
public static NetconfMessage xmlFileToNetconfMessage(final String fileName) throws IOException, SAXException,
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import com.google.common.base.Optional;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import com.google.common.base.Optional;
-
public class XmlElementTest {
private final String elementAsString = "<top xmlns=\"namespace\" xmlns:a=\"attrNamespace\" a:attr1=\"value1\" attr2=\"value2\">" +
<lexical-values/>
</fidelity>
</start-exi>
-</rpc>
+</rpc>
\ No newline at end of file
<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<stop-exi xmlns="urn:ietf:params:xml:ns:netconf:exi:1.0"/>
-</rpc>
+</rpc>
\ No newline at end of file