-
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.
The postJarStoreTransaction() method has been moved from Spring to Ho…
…tmoka's websockets
- Loading branch information
Showing
23 changed files
with
686 additions
and
56 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
...ssages-api/src/main/java/io/hotmoka/node/messages/api/PostJarStoreTransactionMessage.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 2024 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.node.messages.api; | ||
|
||
import io.hotmoka.annotations.Immutable; | ||
import io.hotmoka.beans.api.requests.JarStoreTransactionRequest; | ||
import io.hotmoka.node.api.Node; | ||
import io.hotmoka.websockets.beans.api.RpcMessage; | ||
|
||
/** | ||
* The network message corresponding to {@link Node#postJarStoreTransaction(JarStoreTransactionRequest)}. | ||
*/ | ||
@Immutable | ||
public interface PostJarStoreTransactionMessage extends RpcMessage { | ||
|
||
/** | ||
* Yields the request of the required transaction. | ||
* | ||
* @return the request of the required transaction | ||
*/ | ||
JarStoreTransactionRequest getRequest(); | ||
} |
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
80 changes: 80 additions & 0 deletions
80
...node-messages/src/main/java/io/hotmoka/node/messages/PostJarStoreTransactionMessages.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,80 @@ | ||
/* | ||
Copyright 2024 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.node.messages; | ||
|
||
import io.hotmoka.beans.api.requests.JarStoreTransactionRequest; | ||
import io.hotmoka.node.messages.api.PostJarStoreTransactionMessage; | ||
import io.hotmoka.node.messages.internal.PostJarStoreTransactionMessageImpl; | ||
import io.hotmoka.node.messages.internal.gson.PostJarStoreTransactionMessageDecoder; | ||
import io.hotmoka.node.messages.internal.gson.PostJarStoreTransactionMessageEncoder; | ||
import io.hotmoka.node.messages.internal.gson.PostJarStoreTransactionMessageJson; | ||
|
||
/** | ||
* A provider of {@link PostJarStoreTransactionMessage}. | ||
*/ | ||
public final class PostJarStoreTransactionMessages { | ||
|
||
private PostJarStoreTransactionMessages() {} | ||
|
||
/** | ||
* Yields a {@link PostJarStoreTransactionMessage}. | ||
* | ||
* @param id the identifier of the message | ||
* @param request the request of the transaction required to post | ||
* @return the message | ||
*/ | ||
public static PostJarStoreTransactionMessage of(JarStoreTransactionRequest request, String id) { | ||
return new PostJarStoreTransactionMessageImpl(request, id); | ||
} | ||
|
||
/** | ||
* Gson encoder. | ||
*/ | ||
public static class Encoder extends PostJarStoreTransactionMessageEncoder { | ||
|
||
/** | ||
* Creates a new encoder. | ||
*/ | ||
public Encoder() {} | ||
} | ||
|
||
/** | ||
* Gson decoder. | ||
*/ | ||
public static class Decoder extends PostJarStoreTransactionMessageDecoder { | ||
|
||
/** | ||
* Creates a new decoder. | ||
*/ | ||
public Decoder() {} | ||
} | ||
|
||
/** | ||
* Json representation. | ||
*/ | ||
public static class Json extends PostJarStoreTransactionMessageJson { | ||
|
||
/** | ||
* Creates the Json representation for the given message. | ||
* | ||
* @param message the message | ||
*/ | ||
public Json(PostJarStoreTransactionMessage message) { | ||
super(message); | ||
} | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
...essages/src/main/java/io/hotmoka/node/messages/PostJarStoreTransactionResultMessages.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,80 @@ | ||
/* | ||
Copyright 2024 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.node.messages; | ||
|
||
import io.hotmoka.beans.api.transactions.TransactionReference; | ||
import io.hotmoka.node.messages.api.PostJarStoreTransactionResultMessage; | ||
import io.hotmoka.node.messages.internal.PostJarStoreTransactionResultMessageImpl; | ||
import io.hotmoka.node.messages.internal.gson.PostJarStoreTransactionResultMessageDecoder; | ||
import io.hotmoka.node.messages.internal.gson.PostJarStoreTransactionResultMessageEncoder; | ||
import io.hotmoka.node.messages.internal.gson.PostJarStoreTransactionResultMessageJson; | ||
|
||
/** | ||
* A provider of {@link PostJarStoreTransactionResultMessage}. | ||
*/ | ||
public final class PostJarStoreTransactionResultMessages { | ||
|
||
private PostJarStoreTransactionResultMessages() {} | ||
|
||
/** | ||
* Yields a {@link PostJarStoreTransactionResultMessage}. | ||
* | ||
* @param result the result of the call; this is the reference of the transaction that has been posted | ||
* @param id the identifier of the message | ||
* @return the message | ||
*/ | ||
public static PostJarStoreTransactionResultMessage of(TransactionReference result, String id) { | ||
return new PostJarStoreTransactionResultMessageImpl(result, id); | ||
} | ||
|
||
/** | ||
* Gson encoder. | ||
*/ | ||
public static class Encoder extends PostJarStoreTransactionResultMessageEncoder { | ||
|
||
/** | ||
* Creates a new encoder. | ||
*/ | ||
public Encoder() {} | ||
} | ||
|
||
/** | ||
* Gson decoder. | ||
*/ | ||
public static class Decoder extends PostJarStoreTransactionResultMessageDecoder { | ||
|
||
/** | ||
* Creates a new decoder. | ||
*/ | ||
public Decoder() {} | ||
} | ||
|
||
/** | ||
* Json representation. | ||
*/ | ||
public static class Json extends PostJarStoreTransactionResultMessageJson { | ||
|
||
/** | ||
* Creates the Json representation for the given message. | ||
* | ||
* @param message the message | ||
*/ | ||
public Json(PostJarStoreTransactionResultMessage message) { | ||
super(message); | ||
} | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...s/src/main/java/io/hotmoka/node/messages/internal/PostJarStoreTransactionMessageImpl.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,59 @@ | ||
/* | ||
Copyright 2024 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.node.messages.internal; | ||
|
||
import java.util.Objects; | ||
|
||
import io.hotmoka.beans.api.requests.JarStoreTransactionRequest; | ||
import io.hotmoka.node.api.Node; | ||
import io.hotmoka.node.messages.api.PostJarStoreTransactionMessage; | ||
import io.hotmoka.websockets.beans.AbstractRpcMessage; | ||
|
||
/** | ||
* Implementation of the network message corresponding to {@link Node#postJarStoreTransaction(JarStoreTransactionRequest)}. | ||
*/ | ||
public class PostJarStoreTransactionMessageImpl extends AbstractRpcMessage implements PostJarStoreTransactionMessage { | ||
|
||
private final JarStoreTransactionRequest request; | ||
|
||
/** | ||
* Creates the message. | ||
* | ||
* @param request the request of the transaction required to post | ||
* @param id the identifier of the message | ||
*/ | ||
public PostJarStoreTransactionMessageImpl(JarStoreTransactionRequest request, String id) { | ||
super(id); | ||
|
||
this.request = Objects.requireNonNull(request, "request cannot be null"); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
return other instanceof PostJarStoreTransactionMessage pjstm && super.equals(other) && request.equals(pjstm.getRequest()); | ||
} | ||
|
||
@Override | ||
protected String getExpectedType() { | ||
return PostJarStoreTransactionMessage.class.getName(); | ||
} | ||
|
||
@Override | ||
public JarStoreTransactionRequest getRequest() { | ||
return request; | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
...main/java/io/hotmoka/node/messages/internal/PostJarStoreTransactionResultMessageImpl.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,63 @@ | ||
/* | ||
Copyright 2024 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.node.messages.internal; | ||
|
||
import java.util.Objects; | ||
|
||
import io.hotmoka.beans.api.requests.JarStoreTransactionRequest; | ||
import io.hotmoka.beans.api.transactions.TransactionReference; | ||
import io.hotmoka.node.api.Node; | ||
import io.hotmoka.node.messages.api.PostJarStoreTransactionResultMessage; | ||
import io.hotmoka.websockets.beans.AbstractRpcMessage; | ||
|
||
/** | ||
* Implementation of the network message corresponding to the result of the {@link Node#postJarStoreTransaction(JarStoreTransactionRequest)} method. | ||
*/ | ||
public class PostJarStoreTransactionResultMessageImpl extends AbstractRpcMessage implements PostJarStoreTransactionResultMessage { | ||
|
||
/** | ||
* The result of the call; this is the reference to the transaction that has been posted. | ||
*/ | ||
private final TransactionReference result; | ||
|
||
/** | ||
* Creates the message. | ||
* | ||
* @param result the result of the call; this is the reference to the transaction that has been posted | ||
* @param id the identifier of the message | ||
*/ | ||
public PostJarStoreTransactionResultMessageImpl(TransactionReference result, String id) { | ||
super(id); | ||
|
||
this.result = Objects.requireNonNull(result, "result cannot be null"); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
return other instanceof PostJarStoreTransactionResultMessage pjstrm && super.equals(other) && result.equals(pjstrm.get()); | ||
} | ||
|
||
@Override | ||
protected String getExpectedType() { | ||
return PostJarStoreTransactionResultMessage.class.getName(); | ||
} | ||
|
||
@Override | ||
public TransactionReference get() { | ||
return result; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...in/java/io/hotmoka/node/messages/internal/gson/PostJarStoreTransactionMessageDecoder.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,31 @@ | ||
/* | ||
Copyright 2024 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.node.messages.internal.gson; | ||
|
||
import io.hotmoka.node.messages.PostJarStoreTransactionMessages; | ||
import io.hotmoka.node.messages.api.PostJarStoreTransactionMessage; | ||
import io.hotmoka.websockets.beans.MappedDecoder; | ||
|
||
/** | ||
* A decoder for a {@link PostJarStoreTransactionMessage}. | ||
*/ | ||
public class PostJarStoreTransactionMessageDecoder extends MappedDecoder<PostJarStoreTransactionMessage, PostJarStoreTransactionMessages.Json> { | ||
|
||
public PostJarStoreTransactionMessageDecoder() { | ||
super(PostJarStoreTransactionMessages.Json.class); | ||
} | ||
} |
Oops, something went wrong.