Search in sources :

Example 1 with IMarshaller

use of org.eclipse.scout.rt.mom.api.marshaller.IMarshaller in project scout.rt by eclipse.

the class JmsMomImplementor method createDefaultMarshaller.

@SuppressWarnings("unchecked")
protected IMarshaller createDefaultMarshaller(final Map<Object, Object> properties) {
    Object prop = properties.get(MARSHALLER);
    if (prop instanceof IMarshaller) {
        return (IMarshaller) prop;
    } else {
        Class<? extends IMarshaller> marshallerClass;
        String marshallerClassName = ObjectUtility.toString(prop);
        if (marshallerClassName != null) {
            try {
                marshallerClass = (Class<? extends IMarshaller>) Class.forName(marshallerClassName);
            } catch (final ClassNotFoundException | ClassCastException e) {
                throw new PlatformException("Failed to load class specified by environment property '{}' [value={}]", MARSHALLER, marshallerClassName, e);
            }
        } else {
            marshallerClass = CONFIG.getPropertyValue(DefaultMarshallerProperty.class);
        }
        return BEANS.get(marshallerClass);
    }
}
Also used : IMarshaller(org.eclipse.scout.rt.mom.api.marshaller.IMarshaller) PlatformException(org.eclipse.scout.rt.platform.exception.PlatformException)

Example 2 with IMarshaller

use of org.eclipse.scout.rt.mom.api.marshaller.IMarshaller in project scout.rt by eclipse.

the class AbstractMomTransport method lookupEnvironment.

/**
 * @return the environment required to initialize the MOM implementor.
 */
protected Map<Object, Object> lookupEnvironment() {
    final Map<String, String> configuredEnv = Assertions.assertNotNull(getConfiguredEnvironment(), "Environment for {} not specified", getClass().getSimpleName());
    final Map<Object, Object> env = new HashMap<Object, Object>(configuredEnv);
    // Use the class name as default symbolic name
    if (!env.containsKey(IMomImplementor.SYMBOLIC_NAME)) {
        env.put(IMomImplementor.SYMBOLIC_NAME, getClass().getSimpleName());
    }
    // Use MOM-specific default marshaller
    if (!env.containsKey(IMomImplementor.MARSHALLER)) {
        IMarshaller defaultMarshaller = getConfiguredDefaultMarshaller();
        if (defaultMarshaller != null) {
            env.put(IMomImplementor.MARSHALLER, defaultMarshaller);
        }
    }
    return env;
}
Also used : IMarshaller(org.eclipse.scout.rt.mom.api.marshaller.IMarshaller) HashMap(java.util.HashMap)

Aggregations

IMarshaller (org.eclipse.scout.rt.mom.api.marshaller.IMarshaller)2 HashMap (java.util.HashMap)1 PlatformException (org.eclipse.scout.rt.platform.exception.PlatformException)1