Skip to content

Commit

Permalink
Renamed config.[get|set]CreationInfo -> [get|set]Origin
Browse files Browse the repository at this point in the history
  • Loading branch information
stolsvik committed Feb 21, 2022
1 parent aaf3720 commit 3486673
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 39 deletions.
14 changes: 7 additions & 7 deletions mats-api/src/main/java/io/mats3/MatsEndpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,20 +260,20 @@ interface EndpointConfig<R, S> extends MatsConfig {
Class<?> getIncomingClass();

/**
* Sets the creation info for this Endpoint, i.e. where it was created. Use this to set something sane if the
* {@link #getCreationInfo() automatically created creation info} is useless. It should be a single line, no
* line feeds, but tooling might split the String into multiple lines on the character ';'. It should definitely
* be short, but informative.
* Sets the origin for this Endpoint, i.e. where it was created. Use this to set something sane if the
* {@link #getOrigin() automatically created creation info} is useless. It should be a single line, no line
* feeds, but tooling might split the String into multiple lines on the character ';'. It should definitely be
* short, but informative.
*/
EndpointConfig<R, S> setCreationInfo(String info);
EndpointConfig<R, S> setOrigin(String info);

/**
* @return some human-interpretable information about where in the codebase this Endpoint was created. If this
* is displayed in a multi-line capable situation, you should split on ';'. An attempt at some automatic
* creation is performed, based on creating an exception and introspecting the result. If this doesn't
* yield any good result, it might be overridden by {@link #setCreationInfo(String)}.
* yield any good result, it might be overridden by {@link #setOrigin(String)}.
*/
String getCreationInfo();
String getOrigin();

// Overridden to return the more specific EndpointConfig instead of MatsConfig
@Override
Expand Down
14 changes: 7 additions & 7 deletions mats-api/src/main/java/io/mats3/MatsStage.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,22 @@ interface StageConfig<R, S, I> extends MatsConfig {
int getRunningStageProcessors();

/**
* Sets the creation info for this Stage, i.e. where it was created. Use this to set something sane if the
* {@link #getCreationInfo() automatically created creation info} is useless. It should be a single line, no
* line feeds, but tooling might split the String into multiple lines on the character ';'. It should definitely
* be short, but informative.
* Sets the origin for this Stage, i.e. where it was created. Use this to set something sane if the
* {@link #getOrigin() automatically created creation info} is useless. It should be a single line, no line
* feeds, but tooling might split the String into multiple lines on the character ';'. It should definitely be
* short, but informative.
*
* @return <code>this</code>, for chaining.
*/
StageConfig<R, S, I> setCreationInfo(String info);
StageConfig<R, S, I> setOrigin(String info);

/**
* @return some human-interpretable information about where in the codebase this Stage was created. If this is
* displayed in a multi-line capable situation, you should split on ';'. An attempt at some automatic
* creation is performed, based on creating an exception and introspecting the result. If this doesn't
* yield any good result, it might be overridden by {@link #setCreationInfo(String)}.
* yield any good result, it might be overridden by {@link #setOrigin(String)}.
*/
String getCreationInfo();
String getOrigin();

// Overridden to return the more specific StageConfig instead of MatsConfig
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.mats3.MatsConfig;
import io.mats3.MatsEndpoint;
import io.mats3.MatsFactory;
import io.mats3.MatsStage;
Expand Down Expand Up @@ -92,7 +91,7 @@ public <I> MatsStage<R, S, I> stage(Class<I> incomingClass,
_stages.get(_stages.size() - 1).setNextStageId(stageId);
}
_stages.add(stage);
stage.getStageConfig().setCreationInfo(getInvocationPoint());
stage.getStageConfig().setOrigin(getInvocationPoint());
stageConfigLambda.accept(stage.getStageConfig());
@SuppressWarnings("unchecked")
MatsStage<R, S, I> matsStage = stage;
Expand Down Expand Up @@ -255,16 +254,16 @@ public Class<?> getIncomingClass() {
}

@Override
public EndpointConfig<R, S> setCreationInfo(String info) {
if (info == null) {
throw new NullPointerException("info");
public EndpointConfig<R, S> setOrigin(String origin) {
if (origin == null) {
throw new NullPointerException("origin");
}
_creationInfo = info;
_creationInfo = origin;
return this;
}

@Override
public String getCreationInfo() {
public String getOrigin() {
return _creationInfo;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;

import javax.jms.MessageConsumer;
import javax.sql.DataSource;
Expand Down Expand Up @@ -362,7 +361,7 @@ public <R, S> JmsMatsEndpoint<R, S, Z> staged(String endpointId, Class<R> replyC
public <R, S> JmsMatsEndpoint<R, S, Z> staged(String endpointId, Class<R> replyClass, Class<S> stateClass,
Consumer<? super EndpointConfig<R, S>> endpointConfigLambda) {
JmsMatsEndpoint<R, S, Z> endpoint = new JmsMatsEndpoint<>(this, endpointId, true, stateClass, replyClass);
endpoint.getEndpointConfig().setCreationInfo(getInvocationPoint());
endpoint.getEndpointConfig().setOrigin(getInvocationPoint());
validateNewEndpoint(endpoint);
endpointConfigLambda.accept(endpoint.getEndpointConfig());
return endpoint;
Expand Down Expand Up @@ -438,7 +437,7 @@ private <S, I> JmsMatsEndpoint<Void, S, Z> terminator(boolean queue, String endp
// Need to create the JmsMatsEndpoint ourselves, since we need to set the queue-parameter.
JmsMatsEndpoint<Void, S, Z> endpoint = new JmsMatsEndpoint<>(this, endpointId, queue, stateClass,
Void.TYPE);
endpoint.getEndpointConfig().setCreationInfo(getInvocationPoint());
endpoint.getEndpointConfig().setOrigin(getInvocationPoint());
validateNewEndpoint(endpoint);
endpointConfigLambda.accept(endpoint.getEndpointConfig());
// :: Wrap the ProcessTerminatorLambda in a single stage that does not return.
Expand Down
10 changes: 5 additions & 5 deletions mats-impl-jms/src/main/java/io/mats3/impl/jms/JmsMatsStage.java
Original file line number Diff line number Diff line change
Expand Up @@ -263,16 +263,16 @@ public int getRunningStageProcessors() {
}

@Override
public StageConfig<R, S, I> setCreationInfo(String info) {
if (info == null) {
throw new NullPointerException("info");
public StageConfig<R, S, I> setOrigin(String origin) {
if (origin == null) {
throw new NullPointerException("origin");
}
_creationInfo = info;
_creationInfo = origin;
return this;
}

@Override
public String getCreationInfo() {
public String getOrigin() {
return _creationInfo;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ public void createEndpointReport(Appendable out, MatsEndpoint<?, ?> matsEndpoint
out.append(" - <b>Concurrency:</b> " + formatConcurrency(config) + "\n");
out.append("<br/>");
out.append("<div class='matsli_creation_info'>")
.append(matsEndpoint.getEndpointConfig().getCreationInfo().replace(";", " - \n"))
.append(matsEndpoint.getEndpointConfig().getOrigin().replace(";", " - \n"))
.append("</div>");
out.append("</div>\n");

Expand Down Expand Up @@ -638,7 +638,7 @@ public void createStageReport(Appendable out, MatsStage<?, ?, ?> matsStage) thro
out.append(" - <b>Running stage processors:</b> " + config.getRunningStageProcessors() + "\n");
out.append("<br/>");
out.append("<div class='matsli_creation_info'>")
.append(matsStage.getStageConfig().getCreationInfo().replace(";", " - \n"))
.append(matsStage.getStageConfig().getOrigin().replace(";", " - \n"))
.append("</div>");
out.append("</div>");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ else if (paramsLength == 1) {
// Get an argument array for the method populated with default values for all types: Primitives cannot be null.
Object[] templateArgsArray = defaultArgsArray(method);

String creationInfo = creationInfoForMethod(matsMapping, method);
String origin = originForMethod(matsMapping, method);
MatsEndpoint<?, ?> matsEndpoint;
// ?: Do we have a void return value?
if (replyType.getName().equals("void")) {
Expand Down Expand Up @@ -604,7 +604,7 @@ else if (paramsLength == 1) {
stoParamF, state);
return helperCast(reply);
});
matsStage.getStageConfig().setCreationInfo(creationInfo);
matsStage.getStageConfig().setOrigin(origin);
}
else {
// -> No state parameter, so use the proper Single endpoint.
Expand All @@ -617,11 +617,11 @@ else if (paramsLength == 1) {
-1, null);
return helperCast(reply);
});
matsEndpoint.getStages().get(0).getStageConfig().setCreationInfo(creationInfo);
matsEndpoint.getStages().get(0).getStageConfig().setOrigin(origin);
}
}
// Set creation-info on the MatsEndpoint
matsEndpoint.getEndpointConfig().setCreationInfo(creationInfo);
matsEndpoint.getEndpointConfig().setOrigin(origin);

if (log.isInfoEnabled()) {
String procCtxParamDesc = processContextParam != -1 ? "param#" + processContextParam : "<not present>";
Expand Down Expand Up @@ -703,7 +703,7 @@ else if (paramsLength == 1) {
matsEndpointSetup.matsFactoryBeanName());
MatsEndpoint<?, ?> endpoint = matsFactoryToUse
.staged(matsEndpointSetup.endpointId(), matsEndpointSetup.reply(), matsEndpointSetup.state());
endpoint.getEndpointConfig().setCreationInfo(creationInfoForMethod(matsEndpointSetup, method));
endpoint.getEndpointConfig().setOrigin(originForMethod(matsEndpointSetup, method));

// Invoke the @MatsEndpointSetup-annotated setup method
Object[] args = new Object[paramsLength];
Expand Down Expand Up @@ -853,7 +853,7 @@ private void processMatsClassMapping(MatsClassMapping matsClassMapping, Object b
+ classNameWithoutPackage(bean) + "'", e);
}
ep.getEndpointConfig()
.setCreationInfo("@MatsClassMapping " + matsClass.getSimpleName() + ";" + matsClass.getName());
.setOrigin("@MatsClassMapping " + matsClass.getSimpleName() + ";" + matsClass.getName());

// :: Hold on to all non-null fields of the bean - these are what Spring has injected. Make "template".

Expand Down Expand Up @@ -1082,7 +1082,7 @@ public MessageReference next(Object incomingDto) {
}
});
Stage stageAnnotation = stages.get(method);
stage.getStageConfig().setCreationInfo("@Stage(" + stageAnnotation.ordinal() + ") "
stage.getStageConfig().setOrigin("@Stage(" + stageAnnotation.ordinal() + ") "
+ method.getDeclaringClass().getSimpleName() + "." + method.getName() + "(..);"
+ method.getDeclaringClass().getName());
});
Expand Down Expand Up @@ -1506,7 +1506,7 @@ public MatsSpringInvocationTargetException(String message, Throwable cause) {
}
}

private static String creationInfoForMethod(Annotation annotation, Method method) {
private static String originForMethod(Annotation annotation, Method method) {
return "@" + annotation.annotationType().getSimpleName() + " " + method.getDeclaringClass().getSimpleName()
+ "." + method.getName() + "(..);" + method.getDeclaringClass().getName();
}
Expand Down

0 comments on commit 3486673

Please sign in to comment.