You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2017/04/12 08:56:01 UTC
[15/18] camel git commit: Apply code formatter
Apply code formatter
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/19db14d7
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/19db14d7
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/19db14d7
Branch: refs/heads/master
Commit: 19db14d76cb74533c06e610c1593c13348bdd9c0
Parents: 0f35f55
Author: Jens Reimann <jr...@redhat.com>
Authored: Wed Apr 12 09:37:23 2017 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Wed Apr 12 10:55:27 2017 +0200
----------------------------------------------------------------------
.../camel/component/milo/KeyStoreLoader.java | 216 +++--
.../apache/camel/component/milo/Messages.java | 26 +-
.../camel/component/milo/NamespaceId.java | 112 +--
.../apache/camel/component/milo/NodeIds.java | 368 ++++---
.../camel/component/milo/PartialNodeId.java | 164 ++--
.../milo/client/MiloClientComponent.java | 290 +++---
.../milo/client/MiloClientConfiguration.java | 486 +++++-----
.../milo/client/MiloClientConnection.java | 178 ++--
.../milo/client/MiloClientConsumer.java | 84 +-
.../milo/client/MiloClientEndpoint.java | 283 +++---
.../client/MiloClientItemConfiguration.java | 6 +-
.../milo/client/MiloClientProducer.java | 41 +-
.../client/internal/SubscriptionManager.java | 957 +++++++++----------
.../milo/converter/ValueConverter.java | 20 +-
.../component/milo/converter/package-info.java | 2 +-
.../milo/server/MiloServerComponent.java | 735 +++++++-------
.../milo/server/MiloServerConsumer.java | 66 +-
.../milo/server/MiloServerEndpoint.java | 104 +-
.../milo/server/MiloServerProducer.java | 20 +-
.../milo/server/internal/CamelNamespace.java | 296 +++---
.../milo/server/internal/CamelServerItem.java | 202 ++--
.../component/milo/AbstractMiloServerTest.java | 101 +-
.../MonitorItemMultiConnectionsCertTest.java | 169 ++--
.../milo/MonitorItemMultiConnectionsTest.java | 97 +-
.../camel/component/milo/MonitorItemTest.java | 87 +-
.../apache/camel/component/milo/NodeIdTest.java | 106 +-
.../camel/component/milo/WriteClientTest.java | 236 ++---
.../component/milo/converter/ConverterTest.java | 38 +-
.../component/milo/server/ServerLocalTest.java | 80 +-
.../server/ServerSetCertificateManagerTest.java | 27 +-
.../server/ServerSetSecurityPoliciesTest.java | 40 +-
.../component/milo/testing/Application.java | 61 +-
.../milo/testing/Application2Client.java | 45 +-
.../milo/testing/Application2Server.java | 63 +-
34 files changed, 2865 insertions(+), 2941 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/19db14d7/components/camel-milo/src/main/java/org/apache/camel/component/milo/KeyStoreLoader.java
----------------------------------------------------------------------
diff --git a/components/camel-milo/src/main/java/org/apache/camel/component/milo/KeyStoreLoader.java b/components/camel-milo/src/main/java/org/apache/camel/component/milo/KeyStoreLoader.java
index fa1f970..b745bb7 100644
--- a/components/camel-milo/src/main/java/org/apache/camel/component/milo/KeyStoreLoader.java
+++ b/components/camel-milo/src/main/java/org/apache/camel/component/milo/KeyStoreLoader.java
@@ -30,116 +30,114 @@ import java.security.cert.X509Certificate;
import java.util.NoSuchElementException;
public class KeyStoreLoader {
- public static final String DEFAULT_KEY_STORE_TYPE = "PKCS12";
+ public static final String DEFAULT_KEY_STORE_TYPE = "PKCS12";
- private String type = DEFAULT_KEY_STORE_TYPE;
- private URL url;
- private String keyStorePassword;
- private String keyPassword;
- private String keyAlias;
-
- public static class Result {
+ private String type = DEFAULT_KEY_STORE_TYPE;
+ private URL url;
+ private String keyStorePassword;
+ private String keyPassword;
+ private String keyAlias;
- private final X509Certificate certificate;
- private final KeyPair keyPair;
-
- public Result(final X509Certificate certificate, final KeyPair keyPair) {
- this.certificate = certificate;
- this.keyPair = keyPair;
- }
-
- public X509Certificate getCertificate() {
- return this.certificate;
- }
-
- public KeyPair getKeyPair() {
- return this.keyPair;
- }
- }
-
- public KeyStoreLoader() {
- }
-
- public void setType(final String type) {
- this.type = type != null ? type : DEFAULT_KEY_STORE_TYPE;
- }
-
- public String getType() {
- return this.type;
- }
-
- public void setUrl(final URL url) {
- this.url = url;
- }
-
- public URL getUrl() {
- return this.url;
- }
-
- public void setUrl(final String url) throws MalformedURLException {
- this.url = new URL(url);
- }
-
- public void setKeyStorePassword(final String keyStorePassword) {
- this.keyStorePassword = keyStorePassword;
- }
-
- public String getKeyStorePassword() {
- return this.keyStorePassword;
- }
-
- public void setKeyPassword(final String keyPassword) {
- this.keyPassword = keyPassword;
- }
-
- public String getKeyPassword() {
- return this.keyPassword;
- }
-
- public void setKeyAlias(final String keyAlias) {
- this.keyAlias = keyAlias;
- }
-
- public String getKeyAlias() {
- return this.keyAlias;
- }
-
- public Result load() throws GeneralSecurityException, IOException {
-
- final KeyStore keyStore = KeyStore.getInstance(this.type);
-
- try (InputStream stream = this.url.openStream()) {
- keyStore.load(stream, this.keyStorePassword != null ? this.keyStorePassword.toCharArray() : null);
- }
-
- String effectiveKeyAlias = this.keyAlias;
-
- if (effectiveKeyAlias == null) {
- if (keyStore.size() != 1) {
- throw new IllegalArgumentException(
- "Key store contains more than one key. The use of the 'keyAlias' parameter is required.");
- }
- try {
- effectiveKeyAlias = keyStore.aliases().nextElement();
- } catch (final NoSuchElementException e) {
- throw new RuntimeException("Failed to enumerate key alias", e);
- }
- }
-
- final Key privateKey = keyStore.getKey(effectiveKeyAlias,
- this.keyPassword != null ? this.keyPassword.toCharArray() : null);
-
- if (privateKey instanceof PrivateKey) {
- final X509Certificate certificate = (X509Certificate) keyStore.getCertificate(effectiveKeyAlias);
- if (certificate == null) {
- return null;
- }
-
- final PublicKey publicKey = certificate.getPublicKey();
- final KeyPair keyPair = new KeyPair(publicKey, (PrivateKey) privateKey);
- return new Result(certificate, keyPair);
- }
+ public static class Result {
- return null;
- }
+ private final X509Certificate certificate;
+ private final KeyPair keyPair;
+
+ public Result(final X509Certificate certificate, final KeyPair keyPair) {
+ this.certificate = certificate;
+ this.keyPair = keyPair;
+ }
+
+ public X509Certificate getCertificate() {
+ return this.certificate;
+ }
+
+ public KeyPair getKeyPair() {
+ return this.keyPair;
+ }
+ }
+
+ public KeyStoreLoader() {
+ }
+
+ public void setType(final String type) {
+ this.type = type != null ? type : DEFAULT_KEY_STORE_TYPE;
+ }
+
+ public String getType() {
+ return this.type;
+ }
+
+ public void setUrl(final URL url) {
+ this.url = url;
+ }
+
+ public URL getUrl() {
+ return this.url;
+ }
+
+ public void setUrl(final String url) throws MalformedURLException {
+ this.url = new URL(url);
+ }
+
+ public void setKeyStorePassword(final String keyStorePassword) {
+ this.keyStorePassword = keyStorePassword;
+ }
+
+ public String getKeyStorePassword() {
+ return this.keyStorePassword;
+ }
+
+ public void setKeyPassword(final String keyPassword) {
+ this.keyPassword = keyPassword;
+ }
+
+ public String getKeyPassword() {
+ return this.keyPassword;
+ }
+
+ public void setKeyAlias(final String keyAlias) {
+ this.keyAlias = keyAlias;
+ }
+
+ public String getKeyAlias() {
+ return this.keyAlias;
+ }
+
+ public Result load() throws GeneralSecurityException, IOException {
+
+ final KeyStore keyStore = KeyStore.getInstance(this.type);
+
+ try (InputStream stream = this.url.openStream()) {
+ keyStore.load(stream, this.keyStorePassword != null ? this.keyStorePassword.toCharArray() : null);
+ }
+
+ String effectiveKeyAlias = this.keyAlias;
+
+ if (effectiveKeyAlias == null) {
+ if (keyStore.size() != 1) {
+ throw new IllegalArgumentException("Key store contains more than one key. The use of the 'keyAlias' parameter is required.");
+ }
+ try {
+ effectiveKeyAlias = keyStore.aliases().nextElement();
+ } catch (final NoSuchElementException e) {
+ throw new RuntimeException("Failed to enumerate key alias", e);
+ }
+ }
+
+ final Key privateKey = keyStore.getKey(effectiveKeyAlias, this.keyPassword != null ? this.keyPassword.toCharArray() : null);
+
+ if (privateKey instanceof PrivateKey) {
+ final X509Certificate certificate = (X509Certificate)keyStore.getCertificate(effectiveKeyAlias);
+ if (certificate == null) {
+ return null;
+ }
+
+ final PublicKey publicKey = certificate.getPublicKey();
+ final KeyPair keyPair = new KeyPair(publicKey, (PrivateKey)privateKey);
+ return new Result(certificate, keyPair);
+ }
+
+ return null;
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/19db14d7/components/camel-milo/src/main/java/org/apache/camel/component/milo/Messages.java
----------------------------------------------------------------------
diff --git a/components/camel-milo/src/main/java/org/apache/camel/component/milo/Messages.java b/components/camel-milo/src/main/java/org/apache/camel/component/milo/Messages.java
index f696fda..5c9be28 100644
--- a/components/camel-milo/src/main/java/org/apache/camel/component/milo/Messages.java
+++ b/components/camel-milo/src/main/java/org/apache/camel/component/milo/Messages.java
@@ -20,19 +20,17 @@ import org.apache.camel.impl.DefaultMessage;
import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue;
public final class Messages {
- private Messages() {
- }
+ private Messages() {
+ }
- /**
- * Fill a Message from a DataValue
- *
- * @param value
- * the value to feed from
- * @param result
- * the result to feed to
- */
- public static void fillFromDataValue(final DataValue value, final DefaultMessage result) {
- result.setBody(value);
- result.setFault(value.getStatusCode().isBad());
- }
+ /**
+ * Fill a Message from a DataValue
+ *
+ * @param value the value to feed from
+ * @param result the result to feed to
+ */
+ public static void fillFromDataValue(final DataValue value, final DefaultMessage result) {
+ result.setBody(value);
+ result.setFault(value.getStatusCode().isBad());
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/19db14d7/components/camel-milo/src/main/java/org/apache/camel/component/milo/NamespaceId.java
----------------------------------------------------------------------
diff --git a/components/camel-milo/src/main/java/org/apache/camel/component/milo/NamespaceId.java b/components/camel-milo/src/main/java/org/apache/camel/component/milo/NamespaceId.java
index 4960b75..ac5bf9f 100644
--- a/components/camel-milo/src/main/java/org/apache/camel/component/milo/NamespaceId.java
+++ b/components/camel-milo/src/main/java/org/apache/camel/component/milo/NamespaceId.java
@@ -24,60 +24,60 @@ import org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId;
import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UShort;
public class NamespaceId {
- private final String uri;
- private final UShort numeric;
-
- public NamespaceId(final String uri) {
- requireNonNull(uri);
-
- this.uri = uri;
- this.numeric = null;
- }
-
- public NamespaceId(final UShort numeric) {
- requireNonNull(numeric);
-
- this.uri = null;
- this.numeric = numeric;
- }
-
- public String getUri() {
- return this.uri;
- }
-
- public UShort getNumeric() {
- return this.numeric;
- }
-
- public boolean isNumeric() {
- return this.numeric != null;
- }
-
- @Override
- public String toString() {
- if (isNumeric()) {
- return String.format("[Namespace - numeric: %s]", this.numeric);
- } else {
- return String.format("[Namespace - URI: %s]", this.uri);
- }
- }
-
- public Serializable getValue() {
- return this.uri != null ? this.uri : this.numeric;
- }
-
- public static NamespaceId fromExpandedNodeId(final ExpandedNodeId id) {
- if (id == null) {
- return null;
- }
-
- if (id.getNamespaceUri() != null) {
- return new NamespaceId(id.getNamespaceUri());
- }
- if (id.getNamespaceIndex() != null) {
- return new NamespaceId(id.getNamespaceIndex());
- }
-
- throw new IllegalStateException(String.format("Unknown namespace type"));
- }
+ private final String uri;
+ private final UShort numeric;
+
+ public NamespaceId(final String uri) {
+ requireNonNull(uri);
+
+ this.uri = uri;
+ this.numeric = null;
+ }
+
+ public NamespaceId(final UShort numeric) {
+ requireNonNull(numeric);
+
+ this.uri = null;
+ this.numeric = numeric;
+ }
+
+ public String getUri() {
+ return this.uri;
+ }
+
+ public UShort getNumeric() {
+ return this.numeric;
+ }
+
+ public boolean isNumeric() {
+ return this.numeric != null;
+ }
+
+ @Override
+ public String toString() {
+ if (isNumeric()) {
+ return String.format("[Namespace - numeric: %s]", this.numeric);
+ } else {
+ return String.format("[Namespace - URI: %s]", this.uri);
+ }
+ }
+
+ public Serializable getValue() {
+ return this.uri != null ? this.uri : this.numeric;
+ }
+
+ public static NamespaceId fromExpandedNodeId(final ExpandedNodeId id) {
+ if (id == null) {
+ return null;
+ }
+
+ if (id.getNamespaceUri() != null) {
+ return new NamespaceId(id.getNamespaceUri());
+ }
+ if (id.getNamespaceIndex() != null) {
+ return new NamespaceId(id.getNamespaceIndex());
+ }
+
+ throw new IllegalStateException(String.format("Unknown namespace type"));
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/19db14d7/components/camel-milo/src/main/java/org/apache/camel/component/milo/NodeIds.java
----------------------------------------------------------------------
diff --git a/components/camel-milo/src/main/java/org/apache/camel/component/milo/NodeIds.java b/components/camel-milo/src/main/java/org/apache/camel/component/milo/NodeIds.java
index 1f61ebb..0dad418 100644
--- a/components/camel-milo/src/main/java/org/apache/camel/component/milo/NodeIds.java
+++ b/components/camel-milo/src/main/java/org/apache/camel/component/milo/NodeIds.java
@@ -26,197 +26,181 @@ import org.eclipse.milo.opcua.stack.core.types.builtin.ByteString;
* Helper class to work with node IDs
*/
public final class NodeIds {
- private NodeIds() {
- }
-
- /**
- * Create an attribute value for the "node" attribute
- *
- * @param namespace
- * the namespace to use
- * @param node
- * the node ID
- * @return the value ready to append to a "node" URI attribute
- */
- public static String nodeValue(final String namespace, final String node) {
- Objects.requireNonNull(namespace);
- Objects.requireNonNull(node);
-
- final StringBuilder builder = new StringBuilder("RAW(");
- appendNamespace(builder, namespace);
- builder.append(';');
- appendNodeId(builder, node);
- builder.append(')');
- return builder.toString();
- }
-
- /**
- * Create an attribute value for the "node" attribute
- *
- * @param namespace
- * the namespace to use
- * @param node
- * the node ID
- * @return the value ready to append to a "node" URI attribute
- */
- public static String nodeValue(final String namespace, final int node) {
- Objects.requireNonNull(namespace);
-
- final StringBuilder builder = new StringBuilder("RAW(");
- appendNamespace(builder, namespace);
- builder.append(';');
- appendNodeId(builder, node);
- builder.append(')');
- return builder.toString();
- }
-
- /**
- * Create an attribute value for the "node" attribute
- *
- * @param namespace
- * the namespace to use
- * @param node
- * the node ID
- * @return the value ready to append to a "node" URI attribute
- */
- public static String nodeValue(final String namespace, final UUID node) {
- Objects.requireNonNull(namespace);
- Objects.requireNonNull(node);
-
- final StringBuilder builder = new StringBuilder("RAW(");
- appendNamespace(builder, namespace);
- builder.append(';');
- appendNodeId(builder, node);
- builder.append(')');
- return builder.toString();
- }
-
- /**
- * Create an attribute value for the "node" attribute
- *
- * @param namespace
- * the namespace to use
- * @param node
- * the node ID
- * @return the value ready to append to a "node" URI attribute
- */
- public static String nodeValue(final String namespace, final ByteString node) {
- Objects.requireNonNull(namespace);
- Objects.requireNonNull(node);
-
- final StringBuilder builder = new StringBuilder("RAW(");
- appendNamespace(builder, namespace);
- builder.append(';');
- appendNodeId(builder, node);
- builder.append(')');
- return builder.toString();
- }
-
- /**
- * Create an attribute value for the "node" attribute
- *
- * @param namespace
- * the namespace to use
- * @param node
- * the node ID
- * @return the value ready to append to a "node" URI attribute
- */
- public static String nodeValue(final int namespace, final String node) {
- Objects.requireNonNull(namespace);
- Objects.requireNonNull(node);
-
- final StringBuilder builder = new StringBuilder("RAW(");
- appendNamespace(builder, namespace);
- builder.append(';');
- appendNodeId(builder, node);
- builder.append(')');
- return builder.toString();
- }
-
- /**
- * Create an attribute value for the "node" attribute
- *
- * @param namespace
- * the namespace to use
- * @param node
- * the node ID
- * @return the value ready to append to a "node" URI attribute
- */
- public static String nodeValue(final int namespace, final int node) {
- Objects.requireNonNull(namespace);
-
- final StringBuilder builder = new StringBuilder("RAW(");
- appendNamespace(builder, namespace);
- builder.append(';');
- appendNodeId(builder, node);
- builder.append(')');
- return builder.toString();
- }
-
- /**
- * Create an attribute value for the "node" attribute
- *
- * @param namespace
- * the namespace to use
- * @param node
- * the node ID
- * @return the value ready to append to a "node" URI attribute
- */
- public static String nodeValue(final int namespace, final UUID node) {
- Objects.requireNonNull(namespace);
- Objects.requireNonNull(node);
-
- final StringBuilder builder = new StringBuilder("RAW(");
- appendNamespace(builder, namespace);
- builder.append(';');
- appendNodeId(builder, node);
- builder.append(')');
- return builder.toString();
- }
-
- /**
- * Create an attribute value for the "node" attribute
- *
- * @param namespace
- * the namespace to use
- * @param node
- * the node ID
- * @return the value ready to append to a "node" URI attribute
- */
- public static String nodeValue(final int namespace, final ByteString node) {
- Objects.requireNonNull(namespace);
- Objects.requireNonNull(node);
-
- final StringBuilder builder = new StringBuilder("RAW(");
- appendNamespace(builder, namespace);
- builder.append(';');
- appendNodeId(builder, node);
- builder.append(')');
- return builder.toString();
- }
-
- private static void appendNamespace(final StringBuilder builder, final String namespace) {
- builder.append("nsu=").append(namespace);
- }
-
- private static void appendNamespace(final StringBuilder builder, final int namespace) {
- builder.append("ns=").append(Integer.toUnsignedString(namespace));
- }
-
- private static void appendNodeId(final StringBuilder builder, final String nodeId) {
- builder.append("s=").append(nodeId);
- }
-
- private static void appendNodeId(final StringBuilder builder, final int nodeId) {
- builder.append("i=").append(Integer.toUnsignedString(nodeId));
- }
-
- private static void appendNodeId(final StringBuilder builder, final UUID nodeId) {
- builder.append("g=").append(nodeId);
- }
-
- private static void appendNodeId(final StringBuilder builder, final ByteString nodeId) {
- builder.append("b=").append(Base64.getEncoder().encodeToString(nodeId.bytes()));
- }
+ private NodeIds() {
+ }
+
+ /**
+ * Create an attribute value for the "node" attribute
+ *
+ * @param namespace the namespace to use
+ * @param node the node ID
+ * @return the value ready to append to a "node" URI attribute
+ */
+ public static String nodeValue(final String namespace, final String node) {
+ Objects.requireNonNull(namespace);
+ Objects.requireNonNull(node);
+
+ final StringBuilder builder = new StringBuilder("RAW(");
+ appendNamespace(builder, namespace);
+ builder.append(';');
+ appendNodeId(builder, node);
+ builder.append(')');
+ return builder.toString();
+ }
+
+ /**
+ * Create an attribute value for the "node" attribute
+ *
+ * @param namespace the namespace to use
+ * @param node the node ID
+ * @return the value ready to append to a "node" URI attribute
+ */
+ public static String nodeValue(final String namespace, final int node) {
+ Objects.requireNonNull(namespace);
+
+ final StringBuilder builder = new StringBuilder("RAW(");
+ appendNamespace(builder, namespace);
+ builder.append(';');
+ appendNodeId(builder, node);
+ builder.append(')');
+ return builder.toString();
+ }
+
+ /**
+ * Create an attribute value for the "node" attribute
+ *
+ * @param namespace the namespace to use
+ * @param node the node ID
+ * @return the value ready to append to a "node" URI attribute
+ */
+ public static String nodeValue(final String namespace, final UUID node) {
+ Objects.requireNonNull(namespace);
+ Objects.requireNonNull(node);
+
+ final StringBuilder builder = new StringBuilder("RAW(");
+ appendNamespace(builder, namespace);
+ builder.append(';');
+ appendNodeId(builder, node);
+ builder.append(')');
+ return builder.toString();
+ }
+
+ /**
+ * Create an attribute value for the "node" attribute
+ *
+ * @param namespace the namespace to use
+ * @param node the node ID
+ * @return the value ready to append to a "node" URI attribute
+ */
+ public static String nodeValue(final String namespace, final ByteString node) {
+ Objects.requireNonNull(namespace);
+ Objects.requireNonNull(node);
+
+ final StringBuilder builder = new StringBuilder("RAW(");
+ appendNamespace(builder, namespace);
+ builder.append(';');
+ appendNodeId(builder, node);
+ builder.append(')');
+ return builder.toString();
+ }
+
+ /**
+ * Create an attribute value for the "node" attribute
+ *
+ * @param namespace the namespace to use
+ * @param node the node ID
+ * @return the value ready to append to a "node" URI attribute
+ */
+ public static String nodeValue(final int namespace, final String node) {
+ Objects.requireNonNull(namespace);
+ Objects.requireNonNull(node);
+
+ final StringBuilder builder = new StringBuilder("RAW(");
+ appendNamespace(builder, namespace);
+ builder.append(';');
+ appendNodeId(builder, node);
+ builder.append(')');
+ return builder.toString();
+ }
+
+ /**
+ * Create an attribute value for the "node" attribute
+ *
+ * @param namespace the namespace to use
+ * @param node the node ID
+ * @return the value ready to append to a "node" URI attribute
+ */
+ public static String nodeValue(final int namespace, final int node) {
+ Objects.requireNonNull(namespace);
+
+ final StringBuilder builder = new StringBuilder("RAW(");
+ appendNamespace(builder, namespace);
+ builder.append(';');
+ appendNodeId(builder, node);
+ builder.append(')');
+ return builder.toString();
+ }
+
+ /**
+ * Create an attribute value for the "node" attribute
+ *
+ * @param namespace the namespace to use
+ * @param node the node ID
+ * @return the value ready to append to a "node" URI attribute
+ */
+ public static String nodeValue(final int namespace, final UUID node) {
+ Objects.requireNonNull(namespace);
+ Objects.requireNonNull(node);
+
+ final StringBuilder builder = new StringBuilder("RAW(");
+ appendNamespace(builder, namespace);
+ builder.append(';');
+ appendNodeId(builder, node);
+ builder.append(')');
+ return builder.toString();
+ }
+
+ /**
+ * Create an attribute value for the "node" attribute
+ *
+ * @param namespace the namespace to use
+ * @param node the node ID
+ * @return the value ready to append to a "node" URI attribute
+ */
+ public static String nodeValue(final int namespace, final ByteString node) {
+ Objects.requireNonNull(namespace);
+ Objects.requireNonNull(node);
+
+ final StringBuilder builder = new StringBuilder("RAW(");
+ appendNamespace(builder, namespace);
+ builder.append(';');
+ appendNodeId(builder, node);
+ builder.append(')');
+ return builder.toString();
+ }
+
+ private static void appendNamespace(final StringBuilder builder, final String namespace) {
+ builder.append("nsu=").append(namespace);
+ }
+
+ private static void appendNamespace(final StringBuilder builder, final int namespace) {
+ builder.append("ns=").append(Integer.toUnsignedString(namespace));
+ }
+
+ private static void appendNodeId(final StringBuilder builder, final String nodeId) {
+ builder.append("s=").append(nodeId);
+ }
+
+ private static void appendNodeId(final StringBuilder builder, final int nodeId) {
+ builder.append("i=").append(Integer.toUnsignedString(nodeId));
+ }
+
+ private static void appendNodeId(final StringBuilder builder, final UUID nodeId) {
+ builder.append("g=").append(nodeId);
+ }
+
+ private static void appendNodeId(final StringBuilder builder, final ByteString nodeId) {
+ builder.append("b=").append(Base64.getEncoder().encodeToString(nodeId.bytes()));
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/19db14d7/components/camel-milo/src/main/java/org/apache/camel/component/milo/PartialNodeId.java
----------------------------------------------------------------------
diff --git a/components/camel-milo/src/main/java/org/apache/camel/component/milo/PartialNodeId.java b/components/camel-milo/src/main/java/org/apache/camel/component/milo/PartialNodeId.java
index 21d2834..172702a 100644
--- a/components/camel-milo/src/main/java/org/apache/camel/component/milo/PartialNodeId.java
+++ b/components/camel-milo/src/main/java/org/apache/camel/component/milo/PartialNodeId.java
@@ -34,86 +34,86 @@ import com.google.common.base.MoreObjects;
public class PartialNodeId {
- private IdType type;
-
- private final Serializable id;
-
- public PartialNodeId(final int id) {
- this(uint(id));
- }
-
- public PartialNodeId(final UInteger id) {
- requireNonNull(id);
- this.id = id;
- }
-
- public PartialNodeId(final String id) {
- requireNonNull(id);
- this.id = id;
- }
-
- public PartialNodeId(final UUID id) {
- requireNonNull(id);
- this.id = id;
- }
-
- public PartialNodeId(final ByteString id) {
- requireNonNull(id);
- this.id = id;
- }
-
- public NodeId toNodeId(final int namespaceIndex) {
- if (this.id instanceof String) {
- return new NodeId(namespaceIndex, (String) this.id);
- } else if (this.id instanceof UInteger) {
- return new NodeId(ushort(namespaceIndex), (UInteger) this.id);
- } else if (this.id instanceof ByteString) {
- return new NodeId(namespaceIndex, (ByteString) this.id);
- } else if (this.id instanceof UUID) {
- return new NodeId(namespaceIndex, (UUID) this.id);
- }
- throw new IllegalStateException("Invalid id type: " + this.id);
- }
-
- public NodeId toNodeId(final UShort namespaceIndex) {
- if (this.id instanceof String) {
- return new NodeId(namespaceIndex, (String) this.id);
- } else if (this.id instanceof UInteger) {
- return new NodeId(namespaceIndex, (UInteger) this.id);
- } else if (this.id instanceof ByteString) {
- return new NodeId(namespaceIndex, (ByteString) this.id);
- } else if (this.id instanceof UUID) {
- return new NodeId(namespaceIndex, (UUID) this.id);
- }
- throw new IllegalStateException("Invalid id type: " + this.id);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this).add("type", this.type).add("id", this.id).toString();
- }
-
- public Serializable getValue() {
- return this.id;
- }
-
- public static PartialNodeId fromExpandedNodeId(final ExpandedNodeId node) {
- if (node == null) {
- return null;
- }
-
- final Object value = node.getIdentifier();
-
- if (value instanceof String) {
- return new PartialNodeId((String) value);
- } else if (value instanceof UInteger) {
- return new PartialNodeId((UInteger) value);
- } else if (value instanceof UUID) {
- return new PartialNodeId((UUID) value);
- } else if (value instanceof ByteString) {
- return new PartialNodeId((ByteString) value);
- }
-
- throw new IllegalStateException(String.format("Unknown node id type: " + value));
- }
+ private IdType type;
+
+ private final Serializable id;
+
+ public PartialNodeId(final int id) {
+ this(uint(id));
+ }
+
+ public PartialNodeId(final UInteger id) {
+ requireNonNull(id);
+ this.id = id;
+ }
+
+ public PartialNodeId(final String id) {
+ requireNonNull(id);
+ this.id = id;
+ }
+
+ public PartialNodeId(final UUID id) {
+ requireNonNull(id);
+ this.id = id;
+ }
+
+ public PartialNodeId(final ByteString id) {
+ requireNonNull(id);
+ this.id = id;
+ }
+
+ public NodeId toNodeId(final int namespaceIndex) {
+ if (this.id instanceof String) {
+ return new NodeId(namespaceIndex, (String)this.id);
+ } else if (this.id instanceof UInteger) {
+ return new NodeId(ushort(namespaceIndex), (UInteger)this.id);
+ } else if (this.id instanceof ByteString) {
+ return new NodeId(namespaceIndex, (ByteString)this.id);
+ } else if (this.id instanceof UUID) {
+ return new NodeId(namespaceIndex, (UUID)this.id);
+ }
+ throw new IllegalStateException("Invalid id type: " + this.id);
+ }
+
+ public NodeId toNodeId(final UShort namespaceIndex) {
+ if (this.id instanceof String) {
+ return new NodeId(namespaceIndex, (String)this.id);
+ } else if (this.id instanceof UInteger) {
+ return new NodeId(namespaceIndex, (UInteger)this.id);
+ } else if (this.id instanceof ByteString) {
+ return new NodeId(namespaceIndex, (ByteString)this.id);
+ } else if (this.id instanceof UUID) {
+ return new NodeId(namespaceIndex, (UUID)this.id);
+ }
+ throw new IllegalStateException("Invalid id type: " + this.id);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this).add("type", this.type).add("id", this.id).toString();
+ }
+
+ public Serializable getValue() {
+ return this.id;
+ }
+
+ public static PartialNodeId fromExpandedNodeId(final ExpandedNodeId node) {
+ if (node == null) {
+ return null;
+ }
+
+ final Object value = node.getIdentifier();
+
+ if (value instanceof String) {
+ return new PartialNodeId((String)value);
+ } else if (value instanceof UInteger) {
+ return new PartialNodeId((UInteger)value);
+ } else if (value instanceof UUID) {
+ return new PartialNodeId((UUID)value);
+ } else if (value instanceof ByteString) {
+ return new PartialNodeId((ByteString)value);
+ }
+
+ throw new IllegalStateException(String.format("Unknown node id type: " + value));
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/19db14d7/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientComponent.java b/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientComponent.java
index 94520e5..580d5e9 100644
--- a/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientComponent.java
+++ b/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientComponent.java
@@ -39,181 +39,177 @@ import com.google.common.collect.Multimap;
public class MiloClientComponent extends DefaultComponent {
- private static final Logger LOG = LoggerFactory.getLogger(MiloClientComponent.class);
+ private static final Logger LOG = LoggerFactory.getLogger(MiloClientComponent.class);
- private final Map<String, MiloClientConnection> cache = new HashMap<>();
- private final Multimap<String, MiloClientEndpoint> connectionMap = HashMultimap.create();
+ private final Map<String, MiloClientConnection> cache = new HashMap<>();
+ private final Multimap<String, MiloClientEndpoint> connectionMap = HashMultimap.create();
- private MiloClientConfiguration defaultConfiguration = new MiloClientConfiguration();
+ private MiloClientConfiguration defaultConfiguration = new MiloClientConfiguration();
- @Override
- protected Endpoint createEndpoint(final String uri, final String remaining, final Map<String, Object> parameters)
- throws Exception {
+ @Override
+ protected Endpoint createEndpoint(final String uri, final String remaining, final Map<String, Object> parameters) throws Exception {
- final MiloClientConfiguration configuration = new MiloClientConfiguration(this.defaultConfiguration);
- configuration.setEndpointUri(remaining);
- setProperties(configuration, parameters);
+ final MiloClientConfiguration configuration = new MiloClientConfiguration(this.defaultConfiguration);
+ configuration.setEndpointUri(remaining);
+ setProperties(configuration, parameters);
- return createEndpoint(uri, configuration, parameters);
- }
+ return createEndpoint(uri, configuration, parameters);
+ }
- private synchronized MiloClientEndpoint createEndpoint(final String uri,
- final MiloClientConfiguration configuration, final Map<String, Object> parameters) throws Exception {
+ private synchronized MiloClientEndpoint createEndpoint(final String uri, final MiloClientConfiguration configuration, final Map<String, Object> parameters) throws Exception {
- MiloClientConnection connection = this.cache.get(configuration.toCacheId());
+ MiloClientConnection connection = this.cache.get(configuration.toCacheId());
- if (connection == null) {
- LOG.info("Cache miss - creating new connection instance: {}", configuration.toCacheId());
+ if (connection == null) {
+ LOG.info("Cache miss - creating new connection instance: {}", configuration.toCacheId());
- connection = new MiloClientConnection(configuration, mapToClientConfiguration(configuration));
- this.cache.put(configuration.toCacheId(), connection);
- }
+ connection = new MiloClientConnection(configuration, mapToClientConfiguration(configuration));
+ this.cache.put(configuration.toCacheId(), connection);
+ }
- final MiloClientEndpoint endpoint = new MiloClientEndpoint(uri, this, connection,
- configuration.getEndpointUri());
+ final MiloClientEndpoint endpoint = new MiloClientEndpoint(uri, this, connection, configuration.getEndpointUri());
- setProperties(endpoint, parameters);
+ setProperties(endpoint, parameters);
- // register connection with endpoint
+ // register connection with endpoint
- this.connectionMap.put(configuration.toCacheId(), endpoint);
+ this.connectionMap.put(configuration.toCacheId(), endpoint);
- return endpoint;
- }
-
- private OpcUaClientConfigBuilder mapToClientConfiguration(final MiloClientConfiguration configuration) {
- final OpcUaClientConfigBuilder builder = new OpcUaClientConfigBuilder();
-
- whenHasText(configuration::getApplicationName,
- value -> builder.setApplicationName(LocalizedText.english(value)));
- whenHasText(configuration::getApplicationUri, builder::setApplicationUri);
- whenHasText(configuration::getProductUri, builder::setProductUri);
-
- if (configuration.getRequestTimeout() != null) {
- builder.setRequestTimeout(Unsigned.uint(configuration.getRequestTimeout()));
- }
- if (configuration.getChannelLifetime() != null) {
- builder.setChannelLifetime(Unsigned.uint(configuration.getChannelLifetime()));
- }
+ return endpoint;
+ }
- whenHasText(configuration::getSessionName, value -> builder.setSessionName(() -> value));
- if (configuration.getSessionTimeout() != null) {
- builder.setSessionTimeout(UInteger.valueOf(configuration.getSessionTimeout()));
- }
+ private OpcUaClientConfigBuilder mapToClientConfiguration(final MiloClientConfiguration configuration) {
+ final OpcUaClientConfigBuilder builder = new OpcUaClientConfigBuilder();
- if (configuration.getMaxPendingPublishRequests() != null) {
- builder.setMaxPendingPublishRequests(UInteger.valueOf(configuration.getMaxPendingPublishRequests()));
- }
+ whenHasText(configuration::getApplicationName, value -> builder.setApplicationName(LocalizedText.english(value)));
+ whenHasText(configuration::getApplicationUri, builder::setApplicationUri);
+ whenHasText(configuration::getProductUri, builder::setProductUri);
- if (configuration.getMaxResponseMessageSize() != null) {
- builder.setMaxResponseMessageSize(UInteger.valueOf(configuration.getMaxPendingPublishRequests()));
- }
+ if (configuration.getRequestTimeout() != null) {
+ builder.setRequestTimeout(Unsigned.uint(configuration.getRequestTimeout()));
+ }
+ if (configuration.getChannelLifetime() != null) {
+ builder.setChannelLifetime(Unsigned.uint(configuration.getChannelLifetime()));
+ }
- if (configuration.getSecureChannelReauthenticationEnabled() != null) {
- builder.setSecureChannelReauthenticationEnabled(configuration.getSecureChannelReauthenticationEnabled());
- }
+ whenHasText(configuration::getSessionName, value -> builder.setSessionName(() -> value));
+ if (configuration.getSessionTimeout() != null) {
+ builder.setSessionTimeout(UInteger.valueOf(configuration.getSessionTimeout()));
+ }
- if (configuration.getKeyStoreUrl() != null) {
- setKey(configuration, builder);
- }
+ if (configuration.getMaxPendingPublishRequests() != null) {
+ builder.setMaxPendingPublishRequests(UInteger.valueOf(configuration.getMaxPendingPublishRequests()));
+ }
- return builder;
- }
+ if (configuration.getMaxResponseMessageSize() != null) {
+ builder.setMaxResponseMessageSize(UInteger.valueOf(configuration.getMaxPendingPublishRequests()));
+ }
- private void setKey(final MiloClientConfiguration configuration, final OpcUaClientConfigBuilder builder) {
- final KeyStoreLoader loader = new KeyStoreLoader();
+ if (configuration.getSecureChannelReauthenticationEnabled() != null) {
+ builder.setSecureChannelReauthenticationEnabled(configuration.getSecureChannelReauthenticationEnabled());
+ }
- final Result result;
- try {
- // key store properties
- loader.setType(configuration.getKeyStoreType());
- loader.setUrl(configuration.getKeyStoreUrl());
- loader.setKeyStorePassword(configuration.getKeyStorePassword());
+ if (configuration.getKeyStoreUrl() != null) {
+ setKey(configuration, builder);
+ }
- // key properties
- loader.setKeyAlias(configuration.getKeyAlias());
- loader.setKeyPassword(configuration.getKeyPassword());
+ return builder;
+ }
- result = loader.load();
- } catch (GeneralSecurityException | IOException e) {
- throw new IllegalStateException("Failed to load key", e);
- }
+ private void setKey(final MiloClientConfiguration configuration, final OpcUaClientConfigBuilder builder) {
+ final KeyStoreLoader loader = new KeyStoreLoader();
- if (result == null) {
- throw new IllegalStateException("Key not found in keystore");
- }
+ final Result result;
+ try {
+ // key store properties
+ loader.setType(configuration.getKeyStoreType());
+ loader.setUrl(configuration.getKeyStoreUrl());
+ loader.setKeyStorePassword(configuration.getKeyStorePassword());
- builder.setCertificate(result.getCertificate());
- builder.setKeyPair(result.getKeyPair());
- }
+ // key properties
+ loader.setKeyAlias(configuration.getKeyAlias());
+ loader.setKeyPassword(configuration.getKeyPassword());
- private void whenHasText(final Supplier<String> valueSupplier, final Consumer<String> valueConsumer) {
- final String value = valueSupplier.get();
- if (value != null && !value.isEmpty()) {
- valueConsumer.accept(value);
- }
- }
+ result = loader.load();
+ } catch (GeneralSecurityException | IOException e) {
+ throw new IllegalStateException("Failed to load key", e);
+ }
- /**
- * All default options for client
- */
- public void setDefaultConfiguration(final MiloClientConfiguration defaultConfiguration) {
- this.defaultConfiguration = defaultConfiguration;
- }
+ if (result == null) {
+ throw new IllegalStateException("Key not found in keystore");
+ }
- /**
- * Default application name
- */
- public void setApplicationName(final String applicationName) {
- this.defaultConfiguration.setApplicationName(applicationName);
- }
+ builder.setCertificate(result.getCertificate());
+ builder.setKeyPair(result.getKeyPair());
+ }
- /**
- * Default application URI
- */
- public void setApplicationUri(final String applicationUri) {
- this.defaultConfiguration.setApplicationUri(applicationUri);
- }
-
- /**
- * Default product URI
- */
- public void setProductUri(final String productUri) {
- this.defaultConfiguration.setProductUri(productUri);
- }
-
- /**
- * Default reconnect timeout
- */
- public void setReconnectTimeout(final Long reconnectTimeout) {
- this.defaultConfiguration.setRequestTimeout(reconnectTimeout);
- }
-
- public synchronized void disposed(final MiloClientEndpoint endpoint) {
-
- final MiloClientConnection connection = endpoint.getConnection();
-
- // unregister usage of connection
-
- this.connectionMap.remove(connection.getConnectionId(), endpoint);
-
- // test if this was the last endpoint using this connection
-
- if (!this.connectionMap.containsKey(connection.getConnectionId())) {
-
- // this was the last endpoint using the connection ...
-
- // ... remove from the cache
-
- this.cache.remove(connection.getConnectionId());
-
- // ... and close
-
- try {
- connection.close();
- } catch (final Exception e) {
- LOG.warn("Failed to close connection", e);
- }
- }
- }
+ private void whenHasText(final Supplier<String> valueSupplier, final Consumer<String> valueConsumer) {
+ final String value = valueSupplier.get();
+ if (value != null && !value.isEmpty()) {
+ valueConsumer.accept(value);
+ }
+ }
+
+ /**
+ * All default options for client
+ */
+ public void setDefaultConfiguration(final MiloClientConfiguration defaultConfiguration) {
+ this.defaultConfiguration = defaultConfiguration;
+ }
+
+ /**
+ * Default application name
+ */
+ public void setApplicationName(final String applicationName) {
+ this.defaultConfiguration.setApplicationName(applicationName);
+ }
+
+ /**
+ * Default application URI
+ */
+ public void setApplicationUri(final String applicationUri) {
+ this.defaultConfiguration.setApplicationUri(applicationUri);
+ }
+
+ /**
+ * Default product URI
+ */
+ public void setProductUri(final String productUri) {
+ this.defaultConfiguration.setProductUri(productUri);
+ }
+
+ /**
+ * Default reconnect timeout
+ */
+ public void setReconnectTimeout(final Long reconnectTimeout) {
+ this.defaultConfiguration.setRequestTimeout(reconnectTimeout);
+ }
+
+ public synchronized void disposed(final MiloClientEndpoint endpoint) {
+
+ final MiloClientConnection connection = endpoint.getConnection();
+
+ // unregister usage of connection
+
+ this.connectionMap.remove(connection.getConnectionId(), endpoint);
+
+ // test if this was the last endpoint using this connection
+
+ if (!this.connectionMap.containsKey(connection.getConnectionId())) {
+
+ // this was the last endpoint using the connection ...
+
+ // ... remove from the cache
+
+ this.cache.remove(connection.getConnectionId());
+
+ // ... and close
+
+ try {
+ connection.close();
+ } catch (final Exception e) {
+ LOG.warn("Failed to close connection", e);
+ }
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/19db14d7/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConfiguration.java b/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConfiguration.java
index 037a109..b390c08 100644
--- a/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConfiguration.java
+++ b/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConfiguration.java
@@ -26,267 +26,267 @@ import org.apache.camel.spi.UriParams;
@UriParams
public class MiloClientConfiguration implements Cloneable {
- private static final String DEFAULT_APPLICATION_URI = "http://camel.apache.org/EclipseMilo/Client";
+ private static final String DEFAULT_APPLICATION_URI = "http://camel.apache.org/EclipseMilo/Client";
- private static final String DEFAULT_APPLICATION_NAME = "Apache Camel adapter for Eclipse Milo";
+ private static final String DEFAULT_APPLICATION_NAME = "Apache Camel adapter for Eclipse Milo";
- private static final String DEFAULT_PRODUCT_URI = "http://camel.apache.org/EclipseMilo";
+ private static final String DEFAULT_PRODUCT_URI = "http://camel.apache.org/EclipseMilo";
- private String endpointUri;
+ private String endpointUri;
- @UriParam
- private String clientId;
+ @UriParam
+ private String clientId;
- @UriParam(label = "client", defaultValue = DEFAULT_APPLICATION_NAME)
- private String applicationName = DEFAULT_APPLICATION_NAME;
+ @UriParam(label = "client", defaultValue = DEFAULT_APPLICATION_NAME)
+ private String applicationName = DEFAULT_APPLICATION_NAME;
- @UriParam(label = "client", defaultValue = DEFAULT_APPLICATION_URI)
- private String applicationUri = DEFAULT_APPLICATION_URI;
+ @UriParam(label = "client", defaultValue = DEFAULT_APPLICATION_URI)
+ private String applicationUri = DEFAULT_APPLICATION_URI;
- @UriParam(label = "client", defaultValue = DEFAULT_PRODUCT_URI)
- private String productUri = DEFAULT_PRODUCT_URI;
+ @UriParam(label = "client", defaultValue = DEFAULT_PRODUCT_URI)
+ private String productUri = DEFAULT_PRODUCT_URI;
- @UriParam(label = "client")
- private Long requestTimeout;
+ @UriParam(label = "client")
+ private Long requestTimeout;
- @UriParam(label = "client")
- private Long channelLifetime;
+ @UriParam(label = "client")
+ private Long channelLifetime;
- @UriParam(label = "client")
- private String sessionName;
+ @UriParam(label = "client")
+ private String sessionName;
- @UriParam(label = "client")
- private Long sessionTimeout;
+ @UriParam(label = "client")
+ private Long sessionTimeout;
- @UriParam(label = "client")
- private Long maxPendingPublishRequests;
+ @UriParam(label = "client")
+ private Long maxPendingPublishRequests;
- @UriParam(label = "client")
- private Long maxResponseMessageSize;
+ @UriParam(label = "client")
+ private Long maxResponseMessageSize;
- @UriParam(label = "client")
- private Boolean secureChannelReauthenticationEnabled;
+ @UriParam(label = "client")
+ private Boolean secureChannelReauthenticationEnabled;
- @UriParam(label = "client")
- private URL keyStoreUrl;
+ @UriParam(label = "client")
+ private URL keyStoreUrl;
- @UriParam(label = "client")
- private String keyStoreType = KeyStoreLoader.DEFAULT_KEY_STORE_TYPE;
+ @UriParam(label = "client")
+ private String keyStoreType = KeyStoreLoader.DEFAULT_KEY_STORE_TYPE;
- @UriParam(label = "client")
- private String keyAlias;
+ @UriParam(label = "client")
+ private String keyAlias;
- @UriParam(label = "client", secret = true)
- private String keyStorePassword;
+ @UriParam(label = "client", secret = true)
+ private String keyStorePassword;
- @UriParam(label = "client", secret = true)
- private String keyPassword;
-
- public MiloClientConfiguration() {
- }
+ @UriParam(label = "client", secret = true)
+ private String keyPassword;
+
+ public MiloClientConfiguration() {
+ }
- public MiloClientConfiguration(final MiloClientConfiguration other) {
- this.clientId = other.clientId;
- this.endpointUri = other.endpointUri;
- this.applicationName = other.applicationName;
- this.productUri = other.productUri;
- this.requestTimeout = other.requestTimeout;
- }
-
- public void setEndpointUri(final String endpointUri) {
- this.endpointUri = endpointUri;
- }
-
- public String getEndpointUri() {
- return this.endpointUri;
- }
-
- /**
- * A virtual client id to force the creation of a new connection instance
- */
- public void setClientId(final String clientId) {
- this.clientId = clientId;
- }
-
- public String getClientId() {
- return this.clientId;
- }
-
- /**
- * The application name
- */
- public void setApplicationName(final String applicationName) {
- this.applicationName = applicationName;
- }
-
- public String getApplicationName() {
- return this.applicationName;
- }
-
- /**
- * The application URI
- */
- public void setApplicationUri(final String applicationUri) {
- this.applicationUri = applicationUri;
- }
-
- public String getApplicationUri() {
- return this.applicationUri;
- }
-
- /**
- * The product URI
- */
- public void setProductUri(final String productUri) {
- this.productUri = productUri;
- }
-
- public String getProductUri() {
- return this.productUri;
- }
-
- /**
- * Request timeout in milliseconds
- */
- public void setRequestTimeout(final Long reconnectTimeout) {
- this.requestTimeout = reconnectTimeout;
- }
-
- public Long getRequestTimeout() {
- return this.requestTimeout;
- }
-
- /**
- * Channel lifetime in milliseconds
- */
- public void setChannelLifetime(final Long channelLifetime) {
- this.channelLifetime = channelLifetime;
- }
-
- public Long getChannelLifetime() {
- return this.channelLifetime;
- }
-
- /**
- * Session name
- */
- public void setSessionName(final String sessionName) {
- this.sessionName = sessionName;
- }
-
- public String getSessionName() {
- return this.sessionName;
- }
-
- /**
- * Session timeout in milliseconds
- */
- public void setSessionTimeout(final Long sessionTimeout) {
- this.sessionTimeout = sessionTimeout;
- }
-
- public Long getSessionTimeout() {
- return this.sessionTimeout;
- }
-
- /**
- * The maximum number of pending publish requests
- */
- public void setMaxPendingPublishRequests(final Long maxPendingPublishRequests) {
- this.maxPendingPublishRequests = maxPendingPublishRequests;
- }
-
- public Long getMaxPendingPublishRequests() {
- return this.maxPendingPublishRequests;
- }
-
- /**
- * The maximum number of bytes a response message may have
- */
- public void setMaxResponseMessageSize(final Long maxResponseMessageSize) {
- this.maxResponseMessageSize = maxResponseMessageSize;
- }
-
- public Long getMaxResponseMessageSize() {
- return this.maxResponseMessageSize;
- }
-
- /**
- * Whether secure channel re-authentication is enabled
- */
- public void setSecureChannelReauthenticationEnabled(final Boolean secureChannelReauthenticationEnabled) {
- this.secureChannelReauthenticationEnabled = secureChannelReauthenticationEnabled;
- }
-
- public Boolean getSecureChannelReauthenticationEnabled() {
- return this.secureChannelReauthenticationEnabled;
- }
-
- /**
- * The URL where the key should be loaded from
- */
- public void setKeyStoreUrl(final String keyStoreUrl) throws MalformedURLException {
- this.keyStoreUrl = keyStoreUrl != null ? new URL(keyStoreUrl) : null;
- }
-
- public URL getKeyStoreUrl() {
- return this.keyStoreUrl;
- }
-
- /**
- * The key store type
- */
- public void setKeyStoreType(final String keyStoreType) {
- this.keyStoreType = keyStoreType;
- }
-
- public String getKeyStoreType() {
- return this.keyStoreType;
- }
-
- /**
- * The name of the key in the keystore file
- */
- public void setKeyAlias(final String keyAlias) {
- this.keyAlias = keyAlias;
- }
-
- public String getKeyAlias() {
- return this.keyAlias;
- }
-
- /**
- * The keystore password
- */
- public void setKeyStorePassword(final String keyStorePassword) {
- this.keyStorePassword = keyStorePassword;
- }
-
- public String getKeyStorePassword() {
- return this.keyStorePassword;
- }
-
- /**
- * The key password
- */
- public void setKeyPassword(final String keyPassword) {
- this.keyPassword = keyPassword;
- }
-
- public String getKeyPassword() {
- return this.keyPassword;
- }
-
- @Override
- public MiloClientConfiguration clone() {
- return new MiloClientConfiguration(this);
- }
-
- public String toCacheId() {
- if (this.clientId != null && !this.clientId.isEmpty()) {
- return this.endpointUri + "|" + this.clientId;
- } else {
- return this.endpointUri;
- }
- }
+ public MiloClientConfiguration(final MiloClientConfiguration other) {
+ this.clientId = other.clientId;
+ this.endpointUri = other.endpointUri;
+ this.applicationName = other.applicationName;
+ this.productUri = other.productUri;
+ this.requestTimeout = other.requestTimeout;
+ }
+
+ public void setEndpointUri(final String endpointUri) {
+ this.endpointUri = endpointUri;
+ }
+
+ public String getEndpointUri() {
+ return this.endpointUri;
+ }
+
+ /**
+ * A virtual client id to force the creation of a new connection instance
+ */
+ public void setClientId(final String clientId) {
+ this.clientId = clientId;
+ }
+
+ public String getClientId() {
+ return this.clientId;
+ }
+
+ /**
+ * The application name
+ */
+ public void setApplicationName(final String applicationName) {
+ this.applicationName = applicationName;
+ }
+
+ public String getApplicationName() {
+ return this.applicationName;
+ }
+
+ /**
+ * The application URI
+ */
+ public void setApplicationUri(final String applicationUri) {
+ this.applicationUri = applicationUri;
+ }
+
+ public String getApplicationUri() {
+ return this.applicationUri;
+ }
+
+ /**
+ * The product URI
+ */
+ public void setProductUri(final String productUri) {
+ this.productUri = productUri;
+ }
+
+ public String getProductUri() {
+ return this.productUri;
+ }
+
+ /**
+ * Request timeout in milliseconds
+ */
+ public void setRequestTimeout(final Long reconnectTimeout) {
+ this.requestTimeout = reconnectTimeout;
+ }
+
+ public Long getRequestTimeout() {
+ return this.requestTimeout;
+ }
+
+ /**
+ * Channel lifetime in milliseconds
+ */
+ public void setChannelLifetime(final Long channelLifetime) {
+ this.channelLifetime = channelLifetime;
+ }
+
+ public Long getChannelLifetime() {
+ return this.channelLifetime;
+ }
+
+ /**
+ * Session name
+ */
+ public void setSessionName(final String sessionName) {
+ this.sessionName = sessionName;
+ }
+
+ public String getSessionName() {
+ return this.sessionName;
+ }
+
+ /**
+ * Session timeout in milliseconds
+ */
+ public void setSessionTimeout(final Long sessionTimeout) {
+ this.sessionTimeout = sessionTimeout;
+ }
+
+ public Long getSessionTimeout() {
+ return this.sessionTimeout;
+ }
+
+ /**
+ * The maximum number of pending publish requests
+ */
+ public void setMaxPendingPublishRequests(final Long maxPendingPublishRequests) {
+ this.maxPendingPublishRequests = maxPendingPublishRequests;
+ }
+
+ public Long getMaxPendingPublishRequests() {
+ return this.maxPendingPublishRequests;
+ }
+
+ /**
+ * The maximum number of bytes a response message may have
+ */
+ public void setMaxResponseMessageSize(final Long maxResponseMessageSize) {
+ this.maxResponseMessageSize = maxResponseMessageSize;
+ }
+
+ public Long getMaxResponseMessageSize() {
+ return this.maxResponseMessageSize;
+ }
+
+ /**
+ * Whether secure channel re-authentication is enabled
+ */
+ public void setSecureChannelReauthenticationEnabled(final Boolean secureChannelReauthenticationEnabled) {
+ this.secureChannelReauthenticationEnabled = secureChannelReauthenticationEnabled;
+ }
+
+ public Boolean getSecureChannelReauthenticationEnabled() {
+ return this.secureChannelReauthenticationEnabled;
+ }
+
+ /**
+ * The URL where the key should be loaded from
+ */
+ public void setKeyStoreUrl(final String keyStoreUrl) throws MalformedURLException {
+ this.keyStoreUrl = keyStoreUrl != null ? new URL(keyStoreUrl) : null;
+ }
+
+ public URL getKeyStoreUrl() {
+ return this.keyStoreUrl;
+ }
+
+ /**
+ * The key store type
+ */
+ public void setKeyStoreType(final String keyStoreType) {
+ this.keyStoreType = keyStoreType;
+ }
+
+ public String getKeyStoreType() {
+ return this.keyStoreType;
+ }
+
+ /**
+ * The name of the key in the keystore file
+ */
+ public void setKeyAlias(final String keyAlias) {
+ this.keyAlias = keyAlias;
+ }
+
+ public String getKeyAlias() {
+ return this.keyAlias;
+ }
+
+ /**
+ * The keystore password
+ */
+ public void setKeyStorePassword(final String keyStorePassword) {
+ this.keyStorePassword = keyStorePassword;
+ }
+
+ public String getKeyStorePassword() {
+ return this.keyStorePassword;
+ }
+
+ /**
+ * The key password
+ */
+ public void setKeyPassword(final String keyPassword) {
+ this.keyPassword = keyPassword;
+ }
+
+ public String getKeyPassword() {
+ return this.keyPassword;
+ }
+
+ @Override
+ public MiloClientConfiguration clone() {
+ return new MiloClientConfiguration(this);
+ }
+
+ public String toCacheId() {
+ if (this.clientId != null && !this.clientId.isEmpty()) {
+ return this.endpointUri + "|" + this.clientId;
+ } else {
+ return this.endpointUri;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/19db14d7/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConnection.java
----------------------------------------------------------------------
diff --git a/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConnection.java b/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConnection.java
index dd90f80..7abf159 100644
--- a/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConnection.java
+++ b/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConnection.java
@@ -31,97 +31,91 @@ import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger;
public class MiloClientConnection implements AutoCloseable {
- private final MiloClientConfiguration configuration;
-
- private SubscriptionManager manager;
-
- private boolean initialized;
-
- private final OpcUaClientConfigBuilder clientConfiguration;
-
- public MiloClientConnection(final MiloClientConfiguration configuration,
- final OpcUaClientConfigBuilder clientConfiguration) {
- requireNonNull(configuration);
-
- // make a copy since the configuration is mutable
- this.configuration = configuration.clone();
- this.clientConfiguration = clientConfiguration;
- }
-
- protected void init() throws Exception {
- this.manager = new SubscriptionManager(this.configuration, this.clientConfiguration,
- Stack.sharedScheduledExecutor(), 10_000);
- }
-
- @Override
- public void close() throws Exception {
- if (this.manager != null) {
- this.manager.dispose();
- this.manager = null;
- }
- }
-
- protected synchronized void checkInit() {
- if (this.initialized) {
- return;
- }
-
- try {
- init();
- } catch (final Exception e) {
- throw new RuntimeException(e);
- }
- this.initialized = true;
- }
-
- @FunctionalInterface
- public interface MonitorHandle {
- public void unregister();
- }
-
- public MonitorHandle monitorValue(final MiloClientItemConfiguration configuration,
- final Consumer<DataValue> valueConsumer) {
-
- requireNonNull(configuration);
- requireNonNull(valueConsumer);
-
- checkInit();
-
- final NamespaceId namespaceId = configuration.makeNamespaceId();
- final PartialNodeId partialNodeId = configuration.makePartialNodeId();
-
- final UInteger handle = this.manager.registerItem(namespaceId, partialNodeId,
- configuration.getSamplingInterval(), valueConsumer);
-
- return () -> MiloClientConnection.this.manager.unregisterItem(handle);
- }
-
- public String getConnectionId() {
- return this.configuration.toCacheId();
- }
-
- public void writeValue(final NamespaceId namespaceId, final PartialNodeId partialNodeId, final Object value,
- final boolean await) {
- checkInit();
-
- this.manager.write(namespaceId, partialNodeId, mapValue(value), await);
- }
-
- /**
- * Map the incoming value to some value writable to the milo client
- *
- * @param value
- * the incoming value
- * @return the outgoing value
- */
- private DataValue mapValue(final Object value) {
- if (value instanceof DataValue) {
- return (DataValue) value;
- }
- if (value instanceof Variant) {
- return new DataValue((Variant) value);
- }
- return new DataValue(new Variant(value));
- }
+ private final MiloClientConfiguration configuration;
+
+ private SubscriptionManager manager;
+
+ private boolean initialized;
+
+ private final OpcUaClientConfigBuilder clientConfiguration;
+
+ public MiloClientConnection(final MiloClientConfiguration configuration, final OpcUaClientConfigBuilder clientConfiguration) {
+ requireNonNull(configuration);
+
+ // make a copy since the configuration is mutable
+ this.configuration = configuration.clone();
+ this.clientConfiguration = clientConfiguration;
+ }
+
+ protected void init() throws Exception {
+ this.manager = new SubscriptionManager(this.configuration, this.clientConfiguration, Stack.sharedScheduledExecutor(), 10_000);
+ }
+
+ @Override
+ public void close() throws Exception {
+ if (this.manager != null) {
+ this.manager.dispose();
+ this.manager = null;
+ }
+ }
+
+ protected synchronized void checkInit() {
+ if (this.initialized) {
+ return;
+ }
+
+ try {
+ init();
+ } catch (final Exception e) {
+ throw new RuntimeException(e);
+ }
+ this.initialized = true;
+ }
+
+ @FunctionalInterface
+ public interface MonitorHandle {
+ public void unregister();
+ }
+
+ public MonitorHandle monitorValue(final MiloClientItemConfiguration configuration, final Consumer<DataValue> valueConsumer) {
+
+ requireNonNull(configuration);
+ requireNonNull(valueConsumer);
+
+ checkInit();
+
+ final NamespaceId namespaceId = configuration.makeNamespaceId();
+ final PartialNodeId partialNodeId = configuration.makePartialNodeId();
+
+ final UInteger handle = this.manager.registerItem(namespaceId, partialNodeId, configuration.getSamplingInterval(), valueConsumer);
+
+ return () -> MiloClientConnection.this.manager.unregisterItem(handle);
+ }
+
+ public String getConnectionId() {
+ return this.configuration.toCacheId();
+ }
+
+ public void writeValue(final NamespaceId namespaceId, final PartialNodeId partialNodeId, final Object value, final boolean await) {
+ checkInit();
+
+ this.manager.write(namespaceId, partialNodeId, mapValue(value), await);
+ }
+
+ /**
+ * Map the incoming value to some value writable to the milo client
+ *
+ * @param value the incoming value
+ * @return the outgoing value
+ */
+ private DataValue mapValue(final Object value) {
+ if (value instanceof DataValue) {
+ return (DataValue)value;
+ }
+ if (value instanceof Variant) {
+ return new DataValue((Variant)value);
+ }
+ return new DataValue(new Variant(value));
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/19db14d7/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConsumer.java b/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConsumer.java
index a57609e..b05ce87 100644
--- a/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConsumer.java
+++ b/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConsumer.java
@@ -31,62 +31,62 @@ import org.slf4j.LoggerFactory;
public class MiloClientConsumer extends DefaultConsumer {
- private static final Logger LOG = LoggerFactory.getLogger(MiloClientConsumer.class);
+ private static final Logger LOG = LoggerFactory.getLogger(MiloClientConsumer.class);
- private final MiloClientConnection connection;
+ private final MiloClientConnection connection;
- private final MiloClientItemConfiguration configuration;
+ private final MiloClientItemConfiguration configuration;
- private MonitorHandle handle;
+ private MonitorHandle handle;
- public MiloClientConsumer(final MiloClientEndpoint endpoint, final Processor processor,
- final MiloClientConnection connection, final MiloClientItemConfiguration configuration) {
- super(endpoint, processor);
+ public MiloClientConsumer(final MiloClientEndpoint endpoint, final Processor processor, final MiloClientConnection connection,
+ final MiloClientItemConfiguration configuration) {
+ super(endpoint, processor);
- Objects.requireNonNull(connection);
- Objects.requireNonNull(configuration);
+ Objects.requireNonNull(connection);
+ Objects.requireNonNull(configuration);
- this.connection = connection;
- this.configuration = configuration;
- }
+ this.connection = connection;
+ this.configuration = configuration;
+ }
- @Override
- protected void doStart() throws Exception {
- super.doStart();
+ @Override
+ protected void doStart() throws Exception {
+ super.doStart();
- this.handle = this.connection.monitorValue(this.configuration, this::handleValueUpdate);
- }
+ this.handle = this.connection.monitorValue(this.configuration, this::handleValueUpdate);
+ }
- @Override
- protected void doStop() throws Exception {
- if (this.handle != null) {
- this.handle.unregister();
- this.handle = null;
- }
+ @Override
+ protected void doStop() throws Exception {
+ if (this.handle != null) {
+ this.handle.unregister();
+ this.handle = null;
+ }
- super.doStop();
- }
+ super.doStop();
+ }
- private void handleValueUpdate(final DataValue value) {
- final Exchange exchange = getEndpoint().createExchange();
- exchange.setIn(mapMessage(value));
- try {
- getAsyncProcessor().process(exchange);
- } catch (final Exception e) {
- LOG.debug("Failed to process message", e);
- }
- }
+ private void handleValueUpdate(final DataValue value) {
+ final Exchange exchange = getEndpoint().createExchange();
+ exchange.setIn(mapMessage(value));
+ try {
+ getAsyncProcessor().process(exchange);
+ } catch (final Exception e) {
+ LOG.debug("Failed to process message", e);
+ }
+ }
- private Message mapMessage(final DataValue value) {
- if (value == null) {
- return null;
- }
+ private Message mapMessage(final DataValue value) {
+ if (value == null) {
+ return null;
+ }
- final DefaultMessage result = new DefaultMessage();
+ final DefaultMessage result = new DefaultMessage();
- Messages.fillFromDataValue(value, result);
+ Messages.fillFromDataValue(value, result);
- return result;
- }
+ return result;
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/19db14d7/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientEndpoint.java b/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientEndpoint.java
index 6b0b923..7826389 100644
--- a/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientEndpoint.java
+++ b/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientEndpoint.java
@@ -33,146 +33,145 @@ import org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId;
@UriEndpoint(scheme = "milo-client", syntax = "milo-client:tcp://user:password@host:port/path/to/service?itemId=item.id&namespaceUri=urn:foo:bar", title = "Milo based OPC UA Client", consumerClass = MiloClientConsumer.class, label = "iot")
public class MiloClientEndpoint extends DefaultEndpoint implements MiloClientItemConfiguration {
- /**
- * The OPC UA server endpoint
- */
- @UriPath
- @Metadata(required = "true")
- private final String endpointUri;
-
- /**
- * The node definition (see Node ID)
- */
- @UriParam
- private ExpandedNodeId node;
-
- /**
- * The sampling interval in milliseconds
- */
- @UriParam
- private Double samplingInterval;
-
- /**
- * The client configuration
- */
- @UriParam
- private MiloClientConfiguration client;
-
- /**
- * Default "await" setting for writes
- */
- @UriParam
- private boolean defaultAwaitWrites = false;
-
- private final MiloClientConnection connection;
- private final MiloClientComponent component;
-
- public MiloClientEndpoint(final String uri, final MiloClientComponent component,
- final MiloClientConnection connection, final String endpointUri) {
- super(uri, component);
-
- Objects.requireNonNull(component);
- Objects.requireNonNull(connection);
- Objects.requireNonNull(endpointUri);
-
- this.endpointUri = endpointUri;
-
- this.component = component;
- this.connection = connection;
- }
-
- @Override
- protected void doStart() throws Exception {
- super.doStart();
- }
-
- @Override
- protected void doStop() throws Exception {
- this.component.disposed(this);
- super.doStop();
- }
-
- @Override
- public Producer createProducer() throws Exception {
- return new MiloClientProducer(this, this.connection, this, this.defaultAwaitWrites);
- }
-
- @Override
- public Consumer createConsumer(final Processor processor) throws Exception {
- return new MiloClientConsumer(this, processor, this.connection, this);
- }
-
- @Override
- public boolean isSingleton() {
- return true;
- }
-
- public MiloClientConnection getConnection() {
- return this.connection;
- }
-
- // item configuration
-
- @Override
- public PartialNodeId makePartialNodeId() {
- PartialNodeId result = null;
-
- if (this.node != null) {
- result = PartialNodeId.fromExpandedNodeId(this.node);
- }
-
- if (result == null) {
- throw new IllegalStateException("Missing or invalid node id configuration");
- } else {
- return result;
- }
- }
-
- @Override
- public NamespaceId makeNamespaceId() {
- NamespaceId result = null;
-
- if (this.node != null) {
- result = NamespaceId.fromExpandedNodeId(this.node);
- }
-
- if (result == null) {
- throw new IllegalStateException("Missing or invalid node id configuration");
- } else {
- return result;
- }
- }
-
- public void setNode(final String node) {
- if (node == null) {
- this.node = null;
- } else {
- this.node = ExpandedNodeId.parse(node);
- }
- }
-
- public String getNode() {
- if (this.node != null) {
- return this.node.toParseableString();
- } else {
- return null;
- }
- }
-
- @Override
- public Double getSamplingInterval() {
- return this.samplingInterval;
- }
-
- public void setSamplingInterval(final Double samplingInterval) {
- this.samplingInterval = samplingInterval;
- }
-
- public boolean isDefaultAwaitWrites() {
- return this.defaultAwaitWrites;
- }
-
- public void setDefaultAwaitWrites(final boolean defaultAwaitWrites) {
- this.defaultAwaitWrites = defaultAwaitWrites;
- }
+ /**
+ * The OPC UA server endpoint
+ */
+ @UriPath
+ @Metadata(required = "true")
+ private final String endpointUri;
+
+ /**
+ * The node definition (see Node ID)
+ */
+ @UriParam
+ private ExpandedNodeId node;
+
+ /**
+ * The sampling interval in milliseconds
+ */
+ @UriParam
+ private Double samplingInterval;
+
+ /**
+ * The client configuration
+ */
+ @UriParam
+ private MiloClientConfiguration client;
+
+ /**
+ * Default "await" setting for writes
+ */
+ @UriParam
+ private boolean defaultAwaitWrites = false;
+
+ private final MiloClientConnection connection;
+ private final MiloClientComponent component;
+
+ public MiloClientEndpoint(final String uri, final MiloClientComponent component, final MiloClientConnection connection, final String endpointUri) {
+ super(uri, component);
+
+ Objects.requireNonNull(component);
+ Objects.requireNonNull(connection);
+ Objects.requireNonNull(endpointUri);
+
+ this.endpointUri = endpointUri;
+
+ this.component = component;
+ this.connection = connection;
+ }
+
+ @Override
+ protected void doStart() throws Exception {
+ super.doStart();
+ }
+
+ @Override
+ protected void doStop() throws Exception {
+ this.component.disposed(this);
+ super.doStop();
+ }
+
+ @Override
+ public Producer createProducer() throws Exception {
+ return new MiloClientProducer(this, this.connection, this, this.defaultAwaitWrites);
+ }
+
+ @Override
+ public Consumer createConsumer(final Processor processor) throws Exception {
+ return new MiloClientConsumer(this, processor, this.connection, this);
+ }
+
+ @Override
+ public boolean isSingleton() {
+ return true;
+ }
+
+ public MiloClientConnection getConnection() {
+ return this.connection;
+ }
+
+ // item configuration
+
+ @Override
+ public PartialNodeId makePartialNodeId() {
+ PartialNodeId result = null;
+
+ if (this.node != null) {
+ result = PartialNodeId.fromExpandedNodeId(this.node);
+ }
+
+ if (result == null) {
+ throw new IllegalStateException("Missing or invalid node id configuration");
+ } else {
+ return result;
+ }
+ }
+
+ @Override
+ public NamespaceId makeNamespaceId() {
+ NamespaceId result = null;
+
+ if (this.node != null) {
+ result = NamespaceId.fromExpandedNodeId(this.node);
+ }
+
+ if (result == null) {
+ throw new IllegalStateException("Missing or invalid node id configuration");
+ } else {
+ return result;
+ }
+ }
+
+ public void setNode(final String node) {
+ if (node == null) {
+ this.node = null;
+ } else {
+ this.node = ExpandedNodeId.parse(node);
+ }
+ }
+
+ public String getNode() {
+ if (this.node != null) {
+ return this.node.toParseableString();
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public Double getSamplingInterval() {
+ return this.samplingInterval;
+ }
+
+ public void setSamplingInterval(final Double samplingInterval) {
+ this.samplingInterval = samplingInterval;
+ }
+
+ public boolean isDefaultAwaitWrites() {
+ return this.defaultAwaitWrites;
+ }
+
+ public void setDefaultAwaitWrites(final boolean defaultAwaitWrites) {
+ this.defaultAwaitWrites = defaultAwaitWrites;
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/19db14d7/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientItemConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientItemConfiguration.java b/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientItemConfiguration.java
index a8a0b5f..2468449 100644
--- a/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientItemConfiguration.java
+++ b/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientItemConfiguration.java
@@ -20,9 +20,9 @@ import org.apache.camel.component.milo.NamespaceId;
import org.apache.camel.component.milo.PartialNodeId;
public interface MiloClientItemConfiguration {
- public NamespaceId makeNamespaceId();
+ public NamespaceId makeNamespaceId();
- public PartialNodeId makePartialNodeId();
+ public PartialNodeId makePartialNodeId();
- public Double getSamplingInterval();
+ public Double getSamplingInterval();
}
http://git-wip-us.apache.org/repos/asf/camel/blob/19db14d7/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientProducer.java b/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientProducer.java
index 0082596..bc3d6c2 100644
--- a/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientProducer.java
+++ b/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientProducer.java
@@ -27,37 +27,36 @@ import org.slf4j.LoggerFactory;
public class MiloClientProducer extends DefaultProducer {
- private static final Logger LOG = LoggerFactory.getLogger(MiloClientProducer.class);
+ private static final Logger LOG = LoggerFactory.getLogger(MiloClientProducer.class);
- private final MiloClientConnection connection;
+ private final MiloClientConnection connection;
- private final NamespaceId namespaceId;
+ private final NamespaceId namespaceId;
- private final PartialNodeId partialNodeId;
+ private final PartialNodeId partialNodeId;
- private final boolean defaultAwaitWrites;
+ private final boolean defaultAwaitWrites;
- public MiloClientProducer(final Endpoint endpoint, final MiloClientConnection connection,
- final MiloClientItemConfiguration configuration, final boolean defaultAwaitWrites) {
- super(endpoint);
+ public MiloClientProducer(final Endpoint endpoint, final MiloClientConnection connection, final MiloClientItemConfiguration configuration, final boolean defaultAwaitWrites) {
+ super(endpoint);
- this.connection = connection;
- this.defaultAwaitWrites = defaultAwaitWrites;
+ this.connection = connection;
+ this.defaultAwaitWrites = defaultAwaitWrites;
- this.namespaceId = configuration.makeNamespaceId();
- this.partialNodeId = configuration.makePartialNodeId();
- }
+ this.namespaceId = configuration.makeNamespaceId();
+ this.partialNodeId = configuration.makePartialNodeId();
+ }
- @Override
- public void process(final Exchange exchange) throws Exception {
- final Message msg = exchange.getIn();
- final Object value = msg.getBody();
+ @Override
+ public void process(final Exchange exchange) throws Exception {
+ final Message msg = exchange.getIn();
+ final Object value = msg.getBody();
- LOG.debug("Processing message: {}", value);
+ LOG.debug("Processing message: {}", value);
- final Boolean await = msg.getHeader("await", this.defaultAwaitWrites, Boolean.class);
+ final Boolean await = msg.getHeader("await", this.defaultAwaitWrites, Boolean.class);
- this.connection.writeValue(this.namespaceId, this.partialNodeId, value, await != null ? await : false);
- }
+ this.connection.writeValue(this.namespaceId, this.partialNodeId, value, await != null ? await : false);
+ }
}