use of org.grails.encoder.CodecFactory in project grails-core by grails.
the class DefaultGrailsCodecClass method initializeCodec.
private void initializeCodec() {
if (initialized)
return;
initialized = true;
Integer orderSetting = getStaticPropertyValue("order", Integer.class);
if (orderSetting != null) {
order = orderSetting;
}
Object instance = getReferenceInstance();
if (Encoder.class.isAssignableFrom(getClazz())) {
encoder = (Encoder) instance;
encoder = (Encoder) autowireCodecBean(encoder);
if (encoder instanceof Ordered) {
order = ((Ordered) encoder).getOrder();
}
}
if (Decoder.class.isAssignableFrom(getClazz())) {
decoder = (Decoder) instance;
decoder = (Decoder) autowireCodecBean(decoder);
if (decoder instanceof Ordered) {
order = ((Ordered) decoder).getOrder();
}
}
if (encoder == null && decoder == null) {
CodecFactory codecFactory = null;
if (CodecFactory.class.isAssignableFrom(getClazz())) {
codecFactory = (CodecFactory) instance;
codecFactory = (CodecFactory) autowireCodecBean(codecFactory);
}
if (codecFactory == null) {
codecFactory = getStaticPropertyValue("codecFactory", CodecFactory.class);
codecFactory = (CodecFactory) autowireCodecBean(codecFactory);
}
if (codecFactory == null) {
codecFactory = new ClosureCodecFactory(instance);
}
encoder = codecFactory.getEncoder();
decoder = codecFactory.getDecoder();
if (codecFactory instanceof Ordered) {
order = ((Ordered) codecFactory).getOrder();
}
}
if (encoder != null) {
if (encoder instanceof StreamingEncoder) {
encoder = new StreamingStateAwareEncoderWrapper((StreamingEncoder) encoder);
} else {
encoder = new StateAwareEncoderWrapper(encoder);
}
}
}
Aggregations