/** * Tests whether the type should be excluded from MarshalledValue wrapping. * * @param type type to test. Should not be null. * @return true if it should be excluded from MarshalledValue wrapping. */ public static boolean isTypeExcluded(Class<?> type) { return type.equals(String.class) || type.isPrimitive() || type.equals(Void.class) || type.equals(Boolean.class) || type.equals(Character.class) || type.equals(Byte.class) || type.equals(Short.class) || type.equals(Integer.class) || type.equals(Long.class) || type.equals(Float.class) || type.equals(Double.class) || (type.isArray() && isTypeExcluded(type.getComponentType())); } }
/** * {@inheritDoc} * @see org.jboss.web.tomcat.service.session.distributedcache.spi.SessionAttributeMarshaller#marshal(java.lang.Object) */ @Override public Object marshal(Object value) { if ((value == null) || MarshalledValueHelper.isTypeExcluded(value.getClass())) return value; if (!(value instanceof Serializable)) { throw new IllegalArgumentException(String.format("%s does not implement %s", value, Serializable.class.getName())); } return new SimpleCachableMarshalledValue((Serializable) value, this.source, true); }