-
Notifications
You must be signed in to change notification settings - Fork 408
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1000: Add a BootstrapConsistencyChecker to Leshan Client.
- Loading branch information
1 parent
e0919c3
commit 0d24d6d
Showing
12 changed files
with
382 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...t-core/src/main/java/org/eclipse/leshan/client/bootstrap/BootstrapConsistencyChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 Sierra Wireless and others. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* and Eclipse Distribution License v1.0 which accompany this distribution. | ||
* | ||
* The Eclipse Public License is available at | ||
* http://www.eclipse.org/legal/epl-v20.html | ||
* and the Eclipse Distribution License is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.html. | ||
* | ||
* Contributors: | ||
* Sierra Wireless - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.leshan.client.bootstrap; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.eclipse.leshan.client.resource.LwM2mObjectEnabler; | ||
|
||
/** | ||
* This class is responsible to check the consistency state of the client after at the end of a bootstrap session. | ||
*/ | ||
public interface BootstrapConsistencyChecker { | ||
|
||
/** | ||
* check if current state of the client is consistent | ||
* | ||
* @param objectEnablers all objects supported by the client. | ||
* @return <code>null</code> if the current state is consistent or a list of issues | ||
*/ | ||
List<String> checkconfig(Map<Integer, LwM2mObjectEnabler> objectEnablers); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...src/main/java/org/eclipse/leshan/client/bootstrap/DefaultBootstrapConsistencyChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 Sierra Wireless and others. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* and Eclipse Distribution License v1.0 which accompany this distribution. | ||
* | ||
* The Eclipse Public License is available at | ||
* http://www.eclipse.org/legal/epl-v20.html | ||
* and the Eclipse Distribution License is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.html. | ||
* | ||
* Contributors: | ||
* Sierra Wireless - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.leshan.client.bootstrap; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.eclipse.leshan.client.resource.LwM2mObjectEnabler; | ||
import org.eclipse.leshan.client.servers.ServersInfoExtractor; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* A default implementation of {@link BootstrapConsistencyChecker} | ||
*/ | ||
public class DefaultBootstrapConsistencyChecker implements BootstrapConsistencyChecker { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(DefaultBootstrapConsistencyChecker.class); | ||
|
||
@Override | ||
public List<String> checkconfig(Map<Integer, LwM2mObjectEnabler> objectEnablers) { | ||
try { | ||
ServersInfoExtractor.getInfo(objectEnablers, true); | ||
} catch (RuntimeException e) { | ||
LOG.debug(e.getMessage()); | ||
return Arrays.asList(e.getMessage()); | ||
} | ||
return null; | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
...-client-core/src/main/java/org/eclipse/leshan/client/bootstrap/InvalidStateException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 Sierra Wireless and others. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* and Eclipse Distribution License v1.0 which accompany this distribution. | ||
* | ||
* The Eclipse Public License is available at | ||
* http://www.eclipse.org/legal/epl-v20.html | ||
* and the Eclipse Distribution License is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.html. | ||
* | ||
* Contributors: | ||
* Sierra Wireless - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.leshan.client.bootstrap; | ||
|
||
/** | ||
* Raised if LWM2M client is in an invalid or inconsistent state. | ||
* | ||
*/ | ||
public class InvalidStateException extends Exception { | ||
private static final long serialVersionUID = 1L; | ||
|
||
public InvalidStateException() { | ||
} | ||
|
||
public InvalidStateException(String m) { | ||
super(m); | ||
} | ||
|
||
public InvalidStateException(String m, Object... args) { | ||
super(String.format(m, args)); | ||
} | ||
|
||
public InvalidStateException(Throwable e) { | ||
super(e); | ||
} | ||
|
||
public InvalidStateException(String m, Throwable e) { | ||
super(m, e); | ||
} | ||
|
||
public InvalidStateException(Throwable e, String m, Object... args) { | ||
super(String.format(m, args), e); | ||
} | ||
} |
Oops, something went wrong.