Visitar URL original
Merge branch 'release/3.0.0-RC4' · apache/polygene-java@b4f6be8 · GitHub
Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

Commit b4f6be8

Browse files
committed
Merge branch 'release/3.0.0-RC4'
2 parents 464da13 + 42b3d33 commit b4f6be8

19 files changed

Lines changed: 90 additions & 308 deletions

File tree

‎core/api/src/main/java/org/apache/polygene/api/composite/DecoratorMixin.java‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
public class DecoratorMixin
3838
implements InvocationHandler
3939
{
40+
private static final String NL = System.getProperty( "line.separator" );
41+
4042
private Object delegate;
4143

4244
public DecoratorMixin( @Uses Object delegate )
@@ -78,15 +80,15 @@ public Object invoke( Object object, Method method, Object[] args )
7880
private String constructMessage( Method method, Object[] args )
7981
{
8082
StringBuilder builder = new StringBuilder();
81-
builder.append( "\nmethod: " );
83+
builder.append( NL ).append( "method: " );
8284
builder.append( method.getDeclaringClass().getName() );
8385
builder.append( "." );
8486
builder.append( method.getName() );
85-
builder.append( "\ndelegate: " );
87+
builder.append( NL ).append( "delegate: " );
8688
builder.append( delegate );
87-
builder.append( "\ndelegateType: " );
89+
builder.append( NL ).append( "delegateType: " );
8890
builder.append( delegate == null ? "n/a" : delegate.getClass().getName() );
89-
builder.append( "\narguments: \n" );
91+
builder.append( NL ).append( "arguments:" ).append( NL );
9092
for( Object arg : args )
9193
{
9294
builder.append( " " );
@@ -99,7 +101,7 @@ private String constructMessage( Method method, Object[] args )
99101
{
100102
builder.append( argClass.getName() );
101103
}
102-
builder.append( '\n' );
104+
builder.append( NL );
103105
}
104106
return builder.toString();
105107
}

‎core/api/src/main/java/org/apache/polygene/api/composite/InvalidCompositeException.java‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
*/
3535
public class InvalidCompositeException extends RuntimeException
3636
{
37+
private static final String NL = System.getProperty( "line.separator" );
3738
private static boolean aggregateProblems = true;
3839
private static ThreadLocal<ArrayList<InvalidCompositeException>> report = ThreadLocal.withInitial( ArrayList::new );
3940
private ModuleDescriptor module;
@@ -73,13 +74,13 @@ private InvalidCompositeException( String message, ModuleDescriptor module, Clas
7374
public String getMessage()
7475
{
7576
String typeNames = typesString();
76-
String primary = primaryType == null ? "" : " primary: " + primaryType.toGenericString() + "\n";
77+
String primary = primaryType == null ? "" : " primary: " + primaryType.toGenericString() + NL;
7778
String methodName = memberString();
78-
String message = super.getMessage() == null ? "" : " message: " + super.getMessage() + "\n";
79-
String fragment = fragmentClass == null ? "" : " fragmentClass: " + fragmentClass.getName() + "\n";
80-
String valueType = this.valueType == null ? "" : " valueType: " + this.valueType.getTypeName() + "\n";
81-
String module = this.module == null ? "" : " layer: " + this.module.layer().name() + "\n module: "
82-
+ this.module.name() + "\n";
79+
String message = super.getMessage() == null ? "" : " message: " + super.getMessage() + NL;
80+
String fragment = fragmentClass == null ? "" : " fragmentClass: " + fragmentClass.getName() + NL;
81+
String valueType = this.valueType == null ? "" : " valueType: " + this.valueType.getTypeName() + NL;
82+
String module = this.module == null ? "" : " layer: " + this.module.layer().name() + NL + " module: "
83+
+ this.module.name() + NL;
8384
return message + module + primary + fragment + methodName + valueType + typeNames;
8485
}
8586

@@ -93,7 +94,7 @@ private String typesString()
9394
+ types.stream()
9495
.map( Class::getSimpleName )
9596
.collect( Collectors.joining( ",", "[", "]" ) )
96-
+ "\n";
97+
+ NL;
9798
}
9899

99100
private String memberString()
@@ -108,12 +109,12 @@ private String memberString()
108109
String parameters = Arrays.stream( method.getParameters() )
109110
.map( p -> p.getType().getSimpleName() + " " + p.getName() )
110111
.collect( Collectors.joining( ", ", "(", ")" ) );
111-
return " method: " + method.getReturnType().getSimpleName() + " " + method.getName() + parameters + "\n";
112+
return " method: " + method.getReturnType().getSimpleName() + " " + method.getName() + parameters + NL;
112113
}
113114
if( member instanceof Field )
114115
{
115116
Field field = (Field) member;
116-
return " field: " + field.getType().getSimpleName() + " " + field.getName() + "\n";
117+
return " field: " + field.getType().getSimpleName() + " " + field.getName() + NL;
117118
}
118119
return member.toString();
119120
}
@@ -122,10 +123,10 @@ public static String modelReport()
122123
{
123124
if( report.get().size() > 0 )
124125
{
125-
String reportText = "\nComposition Problems Report:\n"
126+
String reportText = NL + "Composition Problems Report:" + NL
126127
+ report.get().stream()
127128
.map( Throwable::getMessage )
128-
.map( m -> m + "\n--\n" )
129+
.map( m -> m + NL + "--" + NL )
129130
.collect( Collectors.joining() );
130131
report.set( new ArrayList<>() );
131132
return reportText;

‎core/api/src/main/java/org/apache/polygene/api/composite/NoSuchCompositeTypeException.java‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
*/
3333
public abstract class NoSuchCompositeTypeException extends InvalidApplicationException
3434
{
35+
private static final String NL = System.getProperty( "line.separator" );
36+
3537
private final String compositeType;
3638
private final String moduleName;
3739
private final String visibleTypes;
@@ -40,7 +42,7 @@ public abstract class NoSuchCompositeTypeException extends InvalidApplicationExc
4042

4143
protected NoSuchCompositeTypeException( String metaType, String compositeType, ModuleDescriptor module )
4244
{
43-
super( "\n\tCould not find any visible " + metaType + " of type [" + compositeType + "] in module [" + module.name() + "]." );
45+
super( NL + "\tCould not find any visible " + metaType + " of type [" + compositeType + "] in module [" + module.name() + "]." );
4446
this.metaType = metaType;
4547
this.compositeType = compositeType;
4648
this.moduleName = module.name();
@@ -71,7 +73,7 @@ public String candidateTypes()
7173
@Override
7274
public String getMessage()
7375
{
74-
return super.getMessage() + "\n" + candidateTypes + "\n" + visibleTypes;
76+
return super.getMessage() + NL + candidateTypes + NL + visibleTypes;
7577
}
7678

7779
private String formatVisibleTypes( TypeLookup typeLookup )
@@ -85,7 +87,7 @@ private String formatVisibleTypes( TypeLookup typeLookup )
8587
} )
8688
.sorted()
8789
.distinct()
88-
.collect( joining( "\n", "\tVisible " + metaType + " types are:\n", "" ) );
90+
.collect( joining( NL, "\tVisible " + metaType + " types are:" + NL, "" ) );
8991
}
9092

9193
private String findCandidateTypes( ModuleDescriptor module )
@@ -102,7 +104,7 @@ private String findCandidateTypes( ModuleDescriptor module )
102104
return "\t\t[ " + typeName + "] in [" + descriptor.module().name() + "] with visibility " + descriptor.visibility();
103105
} )
104106
.distinct()
105-
.collect( joining( "\n", "\tInvisible " + metaType + " types are:\n", "" ) );
107+
.collect( joining( NL, "\tInvisible " + metaType + " types are:" + NL, "" ) );
106108
}
107109

108110
protected abstract Stream<? extends CompositeDescriptor> descriptors( TypeLookup typeLookup );

‎core/api/src/main/java/org/apache/polygene/api/constraint/ConstraintViolationException.java‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,12 @@
4747
*/
4848
public class ConstraintViolationException extends IllegalArgumentException
4949
{
50+
private static final String NL = System.getProperty( "line.separator" );
5051
private static final boolean longNames = Boolean.getBoolean( "polygene.constraints.longNames" );
51-
private static final String DEFAULT_PATTERN = "\n\tConstraint Violation(s) in {0} of types [{3}].\n";
52-
private static final String ENTITY_DEFAULT_PATTERN = "\n\tConstraint Violation(s) in entity {0} with id=[{2}].\n";
53-
private static final String SERVICE_DEFAULT_PATTERN = "\n\tConstraint Violation(s) in service {0} with id=[{2}].\n";
54-
private static final String MIXIN_DEFAULT_PATTERN = "\t\t@{2}({3}) on {0}.{1}(). Parameter [{4}] does not allow value [{5}].\n";
52+
private static final String DEFAULT_PATTERN = NL + "\tConstraint Violation(s) in {0} of types [{3}]." + NL;
53+
private static final String ENTITY_DEFAULT_PATTERN = NL + "\tConstraint Violation(s) in entity {0} with id=[{2}]." + NL;
54+
private static final String SERVICE_DEFAULT_PATTERN = NL + "\tConstraint Violation(s) in service {0} with id=[{2}]." + NL;
55+
private static final String MIXIN_DEFAULT_PATTERN = "\t\t@{2}({3}) on {0}.{1}(). Parameter [{4}] does not allow value [{5}]." + NL;
5556

5657
private String instanceToString; // arg {0}
5758
private Class<?> primaryType; // arg {1}

‎core/api/src/main/java/org/apache/polygene/api/object/NoSuchObjectTypeException.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public class NoSuchObjectTypeException
3030
extends InvalidApplicationException
3131
{
3232
private static final long serialVersionUID = -1121690536365682511L;
33+
private static final String NL = System.getProperty( "line.separator" );
3334

3435
private final String objectType;
3536
private final String moduleName;
@@ -38,8 +39,8 @@ public NoSuchObjectTypeException( String type, String moduleName, Stream<Class<?
3839
{
3940
super( "Could not find any visible Object of type [" + type + "] in module ["
4041
+ moduleName
41-
+ "]. The visible types are: \n"
42-
+ visible.map( Class::getName ).collect( Collectors.joining("\n") )
42+
+ "]. The visible types are: " + NL
43+
+ visible.map( Class::getName ).collect( Collectors.joining( NL ) )
4344
);
4445
this.objectType = type;
4546
this.moduleName = moduleName;

‎core/api/src/main/java/org/apache/polygene/api/unitofwork/ConcurrentEntityModificationException.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,15 @@ public class ConcurrentEntityModificationException
3434
extends UnitOfWorkCompletionException
3535
{
3636
private static final long serialVersionUID = 3872723845064767689L;
37+
private static final String NL = System.getProperty( "line.separator" );
3738

3839
private final Map<EntityComposite, HasTypes> concurrentlyModifiedEntities;
3940

4041
public ConcurrentEntityModificationException( Map<EntityComposite, HasTypes> concurrentlyModifiedEntities,
4142
Usecase usecase
4243
)
4344
{
44-
super( "Entities changed concurrently, and detected in usecase '" + usecase + "'\nModified entities : " + format( concurrentlyModifiedEntities ) );
45+
super( "Entities changed concurrently, and detected in usecase '" + usecase + "'" + NL + "Modified entities : " + format( concurrentlyModifiedEntities ) );
4546
this.concurrentlyModifiedEntities = concurrentlyModifiedEntities;
4647
}
4748

@@ -54,7 +55,7 @@ private static String format( Map<EntityComposite, HasTypes> concurrentlyModifie
5455
+ entry.getValue().types().map( Class::getSimpleName )
5556
.collect( Collectors.joining( "," ) )
5657
)
57-
.collect( Collectors.joining( "\n" ) );
58+
.collect( Collectors.joining( NL ) );
5859
}
5960

6061
public Map<EntityComposite, HasTypes> concurrentlyModifiedEntities()

‎core/bootstrap/src/main/java/org/apache/polygene/bootstrap/AssemblyReportException.java‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import java.io.ByteArrayOutputStream;
2323
import java.io.PrintStream;
24-
import java.util.List;
2524
import java.util.Set;
2625
import java.util.stream.Collectors;
2726

@@ -30,6 +29,8 @@
3029
*/
3130
public class AssemblyReportException extends AssemblyException
3231
{
32+
private static final String NL = System.getProperty( "line.separator" );
33+
3334
private Set<Throwable> problems;
3435
private String modelReport;
3536

@@ -44,15 +45,15 @@ public String getMessage()
4445
String message;
4546
if( modelReport == null )
4647
{
47-
message = "\nComposition Problems Report:\n";
48+
message = NL+ "Composition Problems Report:" + NL;
4849
}
4950
else
5051
{
5152
message = modelReport;
5253
}
5354
return message + problems.stream()
5455
.map( this::composeMessage )
55-
.map( m -> m + "\n--\n" )
56+
.map( m -> m + NL + "--" + NL )
5657
.collect( Collectors.joining() );
5758
}
5859

‎core/bootstrap/src/main/java/org/apache/polygene/bootstrap/Energy4Java.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ public ApplicationDescriptor newApplicationModel( ApplicationAssembler assembler
7676
String modelReport = InvalidCompositeException.modelReport();
7777
if( modelReport != null )
7878
{
79-
throw new AssemblyException( "Composition problems\n\n" + modelReport );
79+
String nl = System.getProperty( "line.separator" );
80+
throw new AssemblyException( "Composition problems" + nl + nl + modelReport );
8081
}
8182
return model;
8283
}

‎core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/CompositeAssemblyImpl.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ private MixinModel implementMethod( Method method, List<Class<?>> mixinDeclarati
338338
{
339339
return implementMethodWithClass( method, mixinClass );
340340
}
341-
handleInvalidCompositeType( "No implementation found for method ", null, null, null, null, method, types );
341+
handleInvalidCompositeType( "No implementation found for method", null, null, null, null, method, types );
342342
return null;
343343
}
344344

‎core/runtime/src/main/java/org/apache/polygene/runtime/composite/CompositeMethodsModel.java‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
public final class CompositeMethodsModel
4040
implements VisitableHierarchy<Object, Object>, Dependencies
4141
{
42+
private static final String NL = System.getProperty( "line.separator" );
43+
4244
private final LinkedHashMap<Method, CompositeMethodModel> methods;
4345
private final MixinsModel mixinsModel;
4446

@@ -102,14 +104,15 @@ public Object invoke( MixinsInstance mixins,
102104
// return method.invoke( proxy, args );
103105
String message = "We have detected a default method on an interface that is not backed by a Composite. "
104106
+ "Please report this to dev@polygene.apache.org together with the information below, "
105-
+ "that/those class(es) and the relevant assembly information. Thank you\nMethod:"
107+
+ "that/those class(es) and the relevant assembly information. Thank you"
108+
+ NL + "Method:"
106109
+ method.toGenericString()
107-
+ "\nDeclaring Class:"
110+
+ NL + "Declaring Class:"
108111
+ method.getDeclaringClass().toGenericString()
109-
+ "\nTypes:"
112+
+ NL + "Types:"
110113
+ mixinsModel.mixinTypes()
111114
.map( Class::toGenericString )
112-
.collect( Collectors.joining( "\n" ) );
115+
.collect( Collectors.joining( NL ) );
113116
throw new UnsupportedOperationException( message );
114117
}
115118
throw new MissingMethodException( "Method '" + method + "' is not implemented" );

0 commit comments

Comments
 (0)