Skip to content

Commit

Permalink
Better code protection & code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
CesarCoelho committed Sep 26, 2023
1 parent 30f76a4 commit e1de4f2
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 58 deletions.
30 changes: 15 additions & 15 deletions mal-impl/src/main/java/esa/mo/mal/impl/MessageSend.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public MALAccessControl getSecurityManager() {
public void register(final MessageTarget details, final MALPubSubOperation op,
final Subscription subscription, final MALInteractionListener listener)
throws MALInteractionException, MALException {
String uri = details.endpoint.getURI().getValue();
String uri = details.getEndpoint().getURI().getValue();
ipsmap.registerNotifyListener(uri, subscription, listener);
initiateSynchronousInteraction(details,
op,
Expand Down Expand Up @@ -120,7 +120,7 @@ public void publishDeregister(final MessageTarget details,
MALPubSubOperation.PUBLISH_DEREGISTER_STAGE,
(MALPublishInteractionListener) null,
(Object[]) null);
ipsmap.getPublishListenerAndRemove(details.endpoint.getURI());
ipsmap.getPublishListenerAndRemove(details.getEndpoint().getURI());
}

/**
Expand All @@ -137,7 +137,7 @@ public void deregister(final MessageTarget details,
final MALPubSubOperation op,
final IdentifierList unsubscription)
throws MALInteractionException, MALException {
String uri = details.endpoint.getURI().getValue();
String uri = details.getEndpoint().getURI().getValue();
initiateSynchronousInteraction(details,
op,
MALPubSubOperation.DEREGISTER_STAGE,
Expand Down Expand Up @@ -171,7 +171,7 @@ public MALMessage publishRegisterAsync(final String from,
IdentifierList publishedKeyNames = (keyNames != null) ? keyNames : new IdentifierList();
AttributeTypeList publishedKeyValues = (keyTypes != null) ? keyTypes : new AttributeTypeList();
final Long transId = icmap.createPubSubTransaction(false, listener);
return initiateAsynchronousInteraction(details.endpoint,
return initiateAsynchronousInteraction(details.getEndpoint(),
details.createMessage(op,
transId,
MALPubSubOperation.PUBLISH_REGISTER_STAGE,
Expand All @@ -196,7 +196,7 @@ public MALMessage registerAsync(final MessageTarget details,
final MALPubSubOperation op,
final Subscription subscription,
final MALInteractionListener listener) throws MALInteractionException, MALException {
String uri = details.endpoint.getURI().getValue();
String uri = details.getEndpoint().getURI().getValue();
ipsmap.registerNotifyListener(uri, subscription, listener);
return asynchronousInteraction(details, op, MALPubSubOperation.REGISTER_STAGE, listener, subscription);
}
Expand All @@ -215,9 +215,9 @@ public MALMessage registerAsync(final MessageTarget details,
public MALMessage publishDeregisterAsync(final MessageTarget details,
final MALPubSubOperation op, final MALPublishInteractionListener listener)
throws MALInteractionException, MALException {
ipsmap.getPublishListenerAndRemove(details.endpoint.getURI());
ipsmap.getPublishListenerAndRemove(details.getEndpoint().getURI());
final Long transId = icmap.createPubSubTransaction(false, listener);
return initiateAsynchronousInteraction(details.endpoint,
return initiateAsynchronousInteraction(details.getEndpoint(),
details.createMessage(op, transId, MALPubSubOperation.PUBLISH_DEREGISTER_STAGE, (Object[]) null));
}

Expand All @@ -241,7 +241,7 @@ public MALMessage deregisterAsync(final MessageTarget details,
MALPubSubOperation.DEREGISTER_STAGE,
listener,
unsubscription);
String uri = details.endpoint.getURI().getValue();
String uri = details.getEndpoint().getURI().getValue();
ipsmap.deregisterNotifyListener(uri, unsubscription);

return msg;
Expand All @@ -268,7 +268,7 @@ public MALMessage onewayInteraction(final MessageTarget details,
}

MALMessage msg = details.createMessage(op, transId, stage, msgBody);
return initiateOnewayInteraction(details.endpoint, msg);
return initiateOnewayInteraction(details.getEndpoint(), msg);
}

/**
Expand All @@ -292,7 +292,7 @@ public MALMessage onewayInteraction(final MessageTarget details,
}

MALMessage msg = details.createMessage(op, transId, stage, msgBody);
return initiateOnewayInteraction(details.endpoint, msg);
return initiateOnewayInteraction(details.getEndpoint(), msg);
}

/**
Expand Down Expand Up @@ -330,7 +330,7 @@ public MALMessageBody synchronousInteraction(final MessageTarget details,
throws MALInteractionException, MALException {
final Long transId = icmap.createTransaction(op.getInteractionType().getOrdinal(), true, listener);
MALMessage msg = details.createMessage(op, transId, syncStage, msgBody);
return initiateSynchronousInteraction(transId, details.endpoint, msg);
return initiateSynchronousInteraction(transId, details.getEndpoint(), msg);
}

/**
Expand All @@ -354,7 +354,7 @@ public MALMessageBody synchronousInteraction(final MessageTarget details,
throws MALInteractionException, MALException {
final Long transId = icmap.createTransaction(op.getInteractionType().getOrdinal(), true, listener);
MALMessage msg = details.createMessage(op, transId, syncStage, msgBody);
return initiateSynchronousInteraction(transId, details.endpoint, msg);
return initiateSynchronousInteraction(transId, details.getEndpoint(), msg);
}

/**
Expand All @@ -377,7 +377,7 @@ public MALMessage asynchronousInteraction(final MessageTarget details,
throws MALInteractionException, MALException {
final Long transId = icmap.createTransaction(op.getInteractionType().getOrdinal(), false, listener);
MALMessage msg = details.createMessage(op, transId, initialStage, msgBody);
return initiateAsynchronousInteraction(details.endpoint, msg);
return initiateAsynchronousInteraction(details.getEndpoint(), msg);
}

/**
Expand All @@ -400,7 +400,7 @@ public MALMessage asynchronousInteraction(final MessageTarget details,
throws MALInteractionException, MALException {
final Long transId = icmap.createTransaction(op.getInteractionType().getOrdinal(), false, listener);
MALMessage msg = details.createMessage(op, transId, initialStage, msgBody);
return initiateAsynchronousInteraction(details.endpoint, msg);
return initiateAsynchronousInteraction(details.getEndpoint(), msg);
}

/**
Expand Down Expand Up @@ -581,7 +581,7 @@ private Long initiateSynchronousInteraction(final MessageTarget details,
final Object... msgBody) throws MALInteractionException, MALException {
final Long transId = icmap.createPubSubTransaction(true, listener);
MALMessage msg = details.createMessage(op, transId, syncStage, msgBody);
initiateSynchronousInteraction(transId, details.endpoint, msg);
initiateSynchronousInteraction(transId, details.getEndpoint(), msg);
return transId;
}

Expand Down
6 changes: 5 additions & 1 deletion mal-impl/src/main/java/esa/mo/mal/impl/MessageTarget.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public final class MessageTarget {
/**
* The MAL endpoint used for this message.
*/
public final MALEndpoint endpoint;
private final MALEndpoint endpoint;

private final URI uriTo;
private final URI brokerUri;
Expand Down Expand Up @@ -73,6 +73,10 @@ public Blob getAuthenticationId() {
return authenticationId;
}

public MALEndpoint getEndpoint() {
return endpoint;
}

public MALMessage createMessage(final MALOperation operation,
final Long transactionId,
final UOctet interactionStage,
Expand Down
Loading

0 comments on commit e1de4f2

Please sign in to comment.