if (cls == null) {
return loadDynamicMarshallers();
}
final Object o = cls.newInstance();
final MarshallerFactory marshallerFactory = (MarshallerFactory) o;
return new ServerMappingContext() {
{
MarshallingSessionProviderFactory.setMarshallingSessionProvider(new MarshallingSessionProvider() {
@Override
public MarshallingSession getEncoding() {
return new EncodingSession(get());
}
@Override
public MarshallingSession getDecoding() {
return new DecodingSession(get());
}
@Override
public boolean hasMarshaller(final String fqcn) {
return marshallerFactory.getMarshaller(fqcn) != null;
}
@Override
public Marshaller getMarshaller(final String fqcn) {
return marshallerFactory.getMarshaller(fqcn);
}
@Override
public void registerMarshaller(String fqcn, Marshaller m) {
marshallerFactory.registerMarshaller(fqcn, m);
}
});
}
@Override
public DefinitionsFactory getDefinitionsFactory() {
return DefinitionsFactorySingleton.get();
}
@Override
public Marshaller<Object> getMarshaller(final String clazz) {
return marshallerFactory.getMarshaller(clazz);
}
@Override
public boolean hasMarshaller(final String clazzName) {
return marshallerFactory.getMarshaller(clazzName) != null;
}
@Override
public boolean canMarshal(final String cls) {
return hasMarshaller(cls);