-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reorganized and refactored the io-hotmoka-node-remote module
- Loading branch information
Showing
41 changed files
with
556 additions
and
249 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
27 changes: 27 additions & 0 deletions
27
io-hotmoka-node-remote/src/main/java/io/hotmoka/remote/RemoteNode.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,27 @@ | ||
/* | ||
Copyright 2021 Dinu Berinde and Fausto Spoto | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package io.hotmoka.remote; | ||
|
||
import io.hotmoka.annotations.ThreadSafe; | ||
import io.hotmoka.node.api.Node; | ||
|
||
/** | ||
* A node that forwards its calls to a remote network service. | ||
*/ | ||
@ThreadSafe | ||
public interface RemoteNode extends Node { | ||
} |
61 changes: 61 additions & 0 deletions
61
io-hotmoka-node-remote/src/main/java/io/hotmoka/remote/RemoteNodeConfig.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,61 @@ | ||
/* | ||
Copyright 2023 Fausto Spoto | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package io.hotmoka.remote; | ||
|
||
import io.hotmoka.annotations.Immutable; | ||
|
||
/** | ||
* The configuration of a node that forwards all its calls to a remote network service. | ||
*/ | ||
@Immutable | ||
public interface RemoteNodeConfig { | ||
|
||
/** | ||
* Yields the URL of the remote service, without the protocol. This defaults | ||
* to {@code localhost:8080}. | ||
* | ||
* @return the URL | ||
*/ | ||
String getURL(); | ||
|
||
/** | ||
* Determines if web sockets should be used for the connection. This defaults to false. | ||
* | ||
* @return true if and only if web sockets should be used for the connection | ||
*/ | ||
boolean usesWebSockets(); | ||
|
||
/** | ||
* Yields a TOML representation of this configuration. | ||
* | ||
* @return the TOML representation, as a string | ||
*/ | ||
String toToml(); | ||
|
||
@Override | ||
boolean equals(Object other); | ||
|
||
@Override | ||
String toString(); | ||
|
||
/** | ||
* Yields a builder initialized with the information in this object. | ||
* | ||
* @return the builder | ||
*/ | ||
RemoteNodeConfigBuilder toBuilder(); | ||
} |
48 changes: 48 additions & 0 deletions
48
io-hotmoka-node-remote/src/main/java/io/hotmoka/remote/RemoteNodeConfigBuilder.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,48 @@ | ||
/* | ||
Copyright 2023 Fausto Spoto | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package io.hotmoka.remote; | ||
|
||
/** | ||
* The builder of a configuration object. | ||
*/ | ||
public interface RemoteNodeConfigBuilder { | ||
|
||
/** | ||
* Specifies the URL of the remote service, without the protocol. | ||
* The default is {@code localhost:8080}. | ||
* | ||
* @param url the url | ||
* @return this same builder | ||
*/ | ||
RemoteNodeConfigBuilder setURL(String url); | ||
|
||
/** | ||
* Sets the use of websockets. | ||
* | ||
* @param usesWebSockets true if and only if websockets should be used | ||
* instead of http connections. This defaults to false | ||
* @return this same builder | ||
*/ | ||
RemoteNodeConfigBuilder usesWebSockets(boolean usesWebSockets); | ||
|
||
/** | ||
* Builds the configuration from this builder. | ||
* | ||
* @return the configuration | ||
*/ | ||
RemoteNodeConfig build(); | ||
} |
65 changes: 65 additions & 0 deletions
65
io-hotmoka-node-remote/src/main/java/io/hotmoka/remote/RemoteNodeConfigBuilders.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,65 @@ | ||
/* | ||
Copyright 2023 Fausto Spoto | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package io.hotmoka.remote; | ||
|
||
import java.io.FileNotFoundException; | ||
import java.nio.file.Path; | ||
|
||
import com.moandjiezana.toml.Toml; | ||
|
||
import io.hotmoka.remote.internal.RemoteNodeConfigImpl.RemoteNodeConfigBuilderImpl; | ||
|
||
/** | ||
* Providers of configuration object builders for a remote node. | ||
*/ | ||
public abstract class RemoteNodeConfigBuilders { | ||
|
||
private RemoteNodeConfigBuilders() {} | ||
|
||
/** | ||
* Creates a builder containing default data. | ||
* | ||
* @return the builder | ||
*/ | ||
public static RemoteNodeConfigBuilder defaults() { | ||
return new RemoteNodeConfigBuilderImpl(); | ||
} | ||
|
||
/** | ||
* Creates a builder from the given TOML configuration file. | ||
* The resulting builder will contain the information in the file, | ||
* and use defaults for the data not contained in the file. | ||
* | ||
* @param path the path to the TOML file | ||
* @return the builder | ||
* @throws FileNotFoundException if {@code path} cannot be found | ||
*/ | ||
public static RemoteNodeConfigBuilder load(Path path) throws FileNotFoundException { | ||
return new RemoteNodeConfigBuilderImpl(path); | ||
} | ||
|
||
/** | ||
* Creates a builder by reading the properties of the given TOML file and | ||
* setting them for the corresponding fields of the builder. | ||
* | ||
* @param toml the file | ||
* @return the builder | ||
*/ | ||
public static RemoteNodeConfigBuilder from(Toml toml) { | ||
return new RemoteNodeConfigBuilderImpl(toml); | ||
} | ||
} |
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
Oops, something went wrong.