本文整理汇总了Java中org.eclipse.leshan.core.node.codec.DefaultLwM2mNodeDecoder类的典型用法代码示例。如果您正苦于以下问题:Java DefaultLwM2mNodeDecoder类的具体用法?Java DefaultLwM2mNodeDecoder怎么用?Java DefaultLwM2mNodeDecoder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultLwM2mNodeDecoder类属于org.eclipse.leshan.core.node.codec包,在下文中一共展示了DefaultLwM2mNodeDecoder类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.eclipse.leshan.core.node.codec.DefaultLwM2mNodeDecoder; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
support.givenASimpleClient();
store = new InMemoryRegistrationStore();
observationService = new ObservationServiceImpl(store, new StandardModelProvider(),
new DefaultLwM2mNodeDecoder());
}
示例2: createAndStartServer
import org.eclipse.leshan.core.node.codec.DefaultLwM2mNodeDecoder; //导入依赖的package包/类
public static void createAndStartServer(String clusterInstanceId, String localAddress, int localPort,
String secureLocalAddress, int secureLocalPort, String modelsFolderPath, String redisUrl) throws Exception {
// Create Redis connector.
// TODO: support sentinel pool and make pool configurable
Pool<Jedis> jedis = new JedisPool(new URI(redisUrl));
// Prepare LWM2M server.
LeshanServerBuilder builder = new LeshanServerBuilder();
builder.setLocalAddress(localAddress, localPort);
builder.setLocalSecureAddress(secureLocalAddress, secureLocalPort);
DefaultLwM2mNodeDecoder decoder = new DefaultLwM2mNodeDecoder();
builder.setDecoder(decoder);
builder.setCoapConfig(NetworkConfig.getStandard());
List<ObjectModel> models = ObjectLoader.loadDefault();
if (modelsFolderPath != null) {
models.addAll(ObjectLoader.loadObjectsFromDir(new File(modelsFolderPath)));
}
LwM2mModelProvider modelProvider = new StaticModelProvider(models);
builder.setObjectModelProvider(modelProvider);
RedisRegistrationStore registrationStore = new RedisRegistrationStore(jedis);
builder.setRegistrationStore(registrationStore);
// TODO add support of public and private server key
builder.setSecurityStore(new RedisSecurityStore(jedis));
// Create and start LWM2M server
LeshanServer lwServer = builder.build();
// Create Clustering support
RedisTokenHandler tokenHandler = new RedisTokenHandler(jedis, clusterInstanceId);
new RedisRequestResponseHandler(jedis, lwServer, lwServer.getRegistrationService(), tokenHandler,
lwServer.getObservationService());
lwServer.getRegistrationService().addListener(tokenHandler);
lwServer.getRegistrationService().addListener(new RedisRegistrationEventPublisher(jedis));
// Start Jetty & Leshan
lwServer.start();
}