Skip to content

Commit 079e689

Browse files
committed
v1.5.0: java 9 support.
1 parent 3ce1d3e commit 079e689

37 files changed

+463
-811
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,18 @@ for a higher control compared to the EasyML Facade.
6060

6161
### Release Notes
6262

63+
!Release 1.5.0
64+
- requires Java 8 or later.
65+
- NON-BACKWARD COMPATIBLE refactor of ReflectionUtil.
66+
- feature: support for Java 9 security model.
67+
68+
6369
!Release 1.4.7
6470
- last Java 7 compatible release
6571
- bugfix: performance regression in Serialization strategy
6672
- remove AccessibleObject.isAccessible calls
6773

74+
6875
!Release 1.4.6
6976
- remove deprecated v1.3.4 object-o and array-o strategies.
7077
- replaced MarshalContext aliasFor methods with aliasOrNameFor methods.

easyml/src/META-INF/MANIFEST.MF

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Manifest-Version: 1.0
2+

easyml/src/net/sourceforge/easyml/EasyML.java

Lines changed: 10 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import net.sourceforge.easyml.marshalling.java.util.*;
3535
import net.sourceforge.easyml.marshalling.java.util.concurrent.ConcurrentHashMapStrategy;
3636
import net.sourceforge.easyml.marshalling.java.util.regex.PatternStrategy;
37-
import net.sourceforge.easyml.util.Caching;
3837
import org.w3c.dom.Document;
3938
import org.xmlpull.v1.XmlPullParser;
4039

@@ -43,6 +42,7 @@
4342
import java.util.Map;
4443
import java.util.Set;
4544
import java.util.concurrent.ConcurrentHashMap;
45+
import java.util.function.Supplier;
4646

4747
/**
4848
* EasyML class is the top-level facade, containing general functionality such
@@ -81,7 +81,7 @@
8181
* objects.<br/>
8282
*
8383
* @author Victor Cordis ( cordis.victor at gmail.com)
84-
* @version 1.4.6
84+
* @version 1.5.0
8585
* @see XMLReader
8686
* @see XMLWriter
8787
* @since 1.0
@@ -383,32 +383,6 @@ public void configure(XMLReader reader) {
383383
public abstract void configure(XMLReader reader);
384384
}
385385

386-
/**
387-
* XmlPullParserProvider interface can be implemented to provide a custom
388-
* {@linkplain XmlPullParser} to be used at deserializing XML, in text form.
389-
* <br/>
390-
* Since EasyML is thread-safe, it cannot reuse the user-specified
391-
* pull-parser instance, like {@linkplain XMLReader} does. This interface
392-
* implementation will be used by EasyML at each text XML
393-
* <code>deserialize()</code> invocation.<br/>
394-
* <br/>
395-
* <b>Note:</b> implementations of this interface MUST be thread-safe.
396-
*
397-
* @author Victor Cordis ( cordis.victor at gmail.com)
398-
* @version 1.3.0
399-
* @since 1.3.0
400-
*/
401-
public interface XmlPullParserProvider {
402-
403-
/**
404-
* Creates and configures a new user-specified
405-
* <code>XmlPullParser</code> parser, to be used at text XML parsing.
406-
*
407-
* @return new xml pull-parser instance
408-
*/
409-
XmlPullParser newXmlPullParser();
410-
}
411-
412386
/**
413387
* Constant defining the default EasyML profile setting.
414388
*/
@@ -435,7 +409,7 @@ public interface XmlPullParserProvider {
435409
/**
436410
* The preferred parser configuration. Is optional.
437411
*/
438-
protected XmlPullParserProvider xmlPullParserProvider = null;
412+
protected Supplier<XmlPullParser> xmlPullParserProvider = null;
439413

440414
/**
441415
* Creates a new instance with the default settings and default reader and
@@ -446,28 +420,15 @@ public EasyML() {
446420
}
447421

448422
private EasyML(Profile profile) {
449-
final ConcurrentHashMap<Class, Object> commonCtorCache = new ConcurrentHashMap<>();
450-
final ConcurrentHashMap<String, Object> readerFieldCache = new ConcurrentHashMap<>();
451-
452-
this.writerPrototype = new XMLWriter(commonCtorCache, Caching.STRATEGY_PUT_IF_ABSENT);
453-
this.readerPrototype = new XMLReader(commonCtorCache, readerFieldCache, Caching.STRATEGY_PUT_IF_ABSENT);
423+
this.writerPrototype = new XMLWriter();
424+
this.readerPrototype = new XMLReader(new ConcurrentHashMap<>());
454425
profile.configure(this.writerPrototype);
455426
profile.configure(this.readerPrototype);
456-
this.perThreadWriter = new ThreadLocal<XMLWriter>() {
457-
@Override
458-
protected XMLWriter initialValue() {
459-
return new XMLWriter(writerPrototype);
460-
}
461-
};
462-
this.perThreadReader = new ThreadLocal<XMLReader>() {
463-
@Override
464-
protected XMLReader initialValue() {
465-
return new XMLReader(readerPrototype);
466-
}
467-
};
427+
this.perThreadWriter = ThreadLocal.withInitial(() -> new XMLWriter(writerPrototype));
428+
this.perThreadReader = ThreadLocal.withInitial(() -> new XMLReader(readerPrototype));
468429
}
469430

470-
EasyML(Profile profile, Style style, XmlPullParserProvider xmlPullParserProvider,
431+
EasyML(Profile profile, Style style, Supplier<XmlPullParser> xmlPullParserProvider,
471432
String dateFormat, String customRootTag, NodeListStrategy customArrayTag, NodeStrategy customStringTag,
472433
Map<Class, String> classToAlias, Map<Field, String> fieldToAlias, Set<Field> excludedFields,
473434
XMLReader.SecurityPolicy deserializationSecurityPolicy,
@@ -747,7 +708,7 @@ public void serialize(Object o, OutputStream out) {
747708
* @return the serialized object string
748709
*/
749710
public String serialize(Object o) {
750-
final StringWriter sw = new StringWriter(32);
711+
final StringWriter sw = new StringWriter();
751712
this.serialize(o, sw);
752713
return sw.toString();
753714
}
@@ -784,9 +745,7 @@ public Object deserialize(Reader in) {
784745
}
785746

786747
private XmlPullParser maybeProvidedXmlPullParser() {
787-
return this.xmlPullParserProvider != null
788-
? this.xmlPullParserProvider.newXmlPullParser()
789-
: null;
748+
return this.xmlPullParserProvider != null ? this.xmlPullParserProvider.get() : null;
790749
}
791750

792751
/**

easyml/src/net/sourceforge/easyml/EasyMLBuilder.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@
2222
import net.sourceforge.easyml.marshalling.SimpleStrategy;
2323
import net.sourceforge.easyml.marshalling.custom.NodeListStrategy;
2424
import net.sourceforge.easyml.marshalling.custom.NodeStrategy;
25+
import org.xmlpull.v1.XmlPullParser;
2526

2627
import java.lang.reflect.Field;
2728
import java.util.HashMap;
2829
import java.util.HashSet;
2930
import java.util.Map;
3031
import java.util.Set;
32+
import java.util.function.Supplier;
3133

3234
/**
3335
* EasyMLBuilder class is the builder of the {@linkplain EasyML} top-level
@@ -58,7 +60,7 @@
5860
* <b>Note:</b> this builder implementation is <b>not</b> thread-safe
5961
*
6062
* @author Victor Cordis ( cordis.victor at gmail.com)
61-
* @version 1.4.0
63+
* @version 1.5.0
6264
* @see EasyML
6365
* @see XMLReader
6466
* @see XMLWriter
@@ -68,7 +70,7 @@ public final class EasyMLBuilder {
6870

6971
private EasyML.Profile profile;
7072
private EasyML.Style style;
71-
private EasyML.XmlPullParserProvider xmlPullParserProvider;
73+
private Supplier<XmlPullParser> xmlPullParserProvider;
7274
private String dateFormat;
7375
private String customRootTag;
7476
private NodeListStrategy customArrayTag;
@@ -111,7 +113,7 @@ public EasyMLBuilder withStyle(EasyML.Style style) {
111113
*
112114
* @param xmlPullParserProvider implementation to be used by the reader
113115
*/
114-
public EasyMLBuilder withXmlPullParserProvider(EasyML.XmlPullParserProvider xmlPullParserProvider) {
116+
public EasyMLBuilder withXmlPullParserProvider(Supplier<XmlPullParser> xmlPullParserProvider) {
115117
this.xmlPullParserProvider = xmlPullParserProvider;
116118
return this;
117119
}

0 commit comments

Comments
 (0)