* Load the default array marshaller.
*/
MetaClass arrayType = MetaClassFactory.get(marshaller.getTypeHandled()).asArrayOf(1);
if (!factory.hasDefinition(arrayType)) {
factory.addDefinition(new MappingDefinition(
EncDecUtil.qualifyMarshaller(new DefaultArrayMarshaller(arrayType, marshaller)), true));
/**
* If this a pirmitive wrapper, create a special case for it using the same marshaller.
*/
if (MarshallUtil.isPrimitiveWrapper(marshaller.getTypeHandled())) {
factory.addDefinition(new MappingDefinition(
EncDecUtil.qualifyMarshaller(new DefaultArrayMarshaller(
arrayType.getOuterComponentType().asUnboxed().asArrayOf(1), marshaller)), true));
}
}
}
catch (ClassCastException e) {
throw new RuntimeException("@ServerMarshaller class "
+ m.getName() + " is not an instance of " + Marshaller.class.getName());
}
catch (Throwable t) {
throw new RuntimeException("Error instantiating " + m.getName(), t);
}
}
for (Class<?> exposed : factory.getExposedClasses()) {
if (exposed.isAnnotationPresent(Portable.class)) {
Portable p = exposed.getAnnotation(Portable.class);
if (!p.aliasOf().equals(Object.class)) {
if (!factory.hasDefinition(p.aliasOf())) {
throw new RuntimeException("cannot alias " + exposed.getName() + " to unmapped type: "
+ p.aliasOf().getName());
}
factory.getDefinition(exposed)
.setMarshallerInstance(factory.getDefinition(p.aliasOf()).getMarshallerInstance());
}
if (exposed.isEnum()) {
factory.getDefinition(exposed)
.setMarshallerInstance(new DefaultEnumMarshaller(exposed));
}
MappingDefinition definition = factory.getDefinition(exposed);
for (MemberMapping mapping : definition.getMemberMappings()) {
if (mapping.getType().isArray()) {
MetaClass type = mapping.getType();
MetaClass compType = type.getOuterComponentType();
if (!factory.hasDefinition(type.getInternalName())) {
MappingDefinition outerDef = factory.getDefinition(compType);
Marshaller<Object> marshaller = outerDef.getMarshallerInstance();
MappingDefinition def = new MappingDefinition(EncDecUtil.qualifyMarshaller(
new DefaultArrayMarshaller(type, marshaller)), true);
def.setClientMarshallerClass(outerDef.getClientMarshallerClass());
factory.addDefinition(def);
}