com.dyuproject.protostuff.runtime.RuntimeEnv Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of protostuff-runtime Show documentation
Show all versions of protostuff-runtime Show documentation
protobuf serialization for pre-existing objects
//========================================================================
//Copyright 2007-2011 David Yu [email protected]
//------------------------------------------------------------------------
//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//You may obtain a copy of the License at
//http://www.apache.org/licenses/LICENSE-2.0
//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License.
//========================================================================
package com.dyuproject.protostuff.runtime;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Properties;
/**
* The runtime environment.
*
* @author David Yu
* @created Jul 8, 2011
*/
public final class RuntimeEnv
{
/**
* Returns true if serializing enums by name is activated.
* Disabled by default.
*/
public static final boolean ENUMS_BY_NAME;
/**
* Enabled by default. For security purposes, you probably would want to
* register all known classes and disable this option.
*/
public static final boolean AUTO_LOAD_POLYMORPHIC_CLASSES;
/**
* Disabled by default. For pojos that are not declared final, they
* could still be morphed to their respective subclasses (inheritance).
* Enable this option if your parent classes aren't abstract classes.
*/
public static final boolean MORPH_NON_FINAL_POJOS;
/**
* Disabled by default. If true, type metadata will be included on serialization
* for fields that are collection interfaces.
* Enabling this is useful if you want to retain the actual collection impl used.
*
* If disabled, type metadata will not be included and instead, will be mapped
* to a default impl.
*
* Collection = ArrayList
* List = ArrayList
* Set = HashSet
* SortedSet = TreeSet
* NavigableSet = TreeSet
* Queue = LinkedList
* BlockingQueue = LinkedBlockingQueue
* Deque = LinkedList
* BlockingDequeue = LinkedBlockingDeque
*
*
* You can optionally enable only for a particular field by annotation it with
* {@link com.dyuproject.protostuff.Morph}.
*/
public static final boolean MORPH_COLLECTION_INTERFACES;
/**
* Disabled by default. If true, type metadata will be included on serialization
* for fields that are map interfaces.
* Enabling this is useful if you want to retain the actual map impl used.
*
* If disabled, type metadata will not be included and instead, will be mapped
* to a default impl.
*
* Map = HashMap
* SortedMap = TreeMap
* NavigableMap = TreeMap
* ConcurrentMap = ConcurrentHashMap
* ConcurrentNavigableMap = ConcurrentSkipListMap
*
*
* You can optionally enable only for a particular field by annotation it with
* {@link com.dyuproject.protostuff.Morph}.
*/
public static final boolean MORPH_MAP_INTERFACES;
/**
* On repeated fields, the List/Collection itself is not serialized (only its values).
* If you enable this option, the repeated field will be serialized as a
* standalone message with a collection schema. Even if the List/Collection is empty,
* an empty collection message is still written.
*
* This is particularly useful if you rely on {@link Object#equals(Object)} on your
* pojos.
*
* Disabled by default for protobuf compatibility.
*/
public static final boolean COLLECTION_SCHEMA_ON_REPEATED_FIELDS;
/**
* If true, sun.misc.Unsafe is used to access the fields of the objects instead of
* plain java reflections. Enabled by default if running on a sun jre.
*/
public static final boolean USE_SUN_MISC_UNSAFE;
/**
* If true, the constructor will always be obtained from
* {@code ReflectionFactory.newConstructorFromSerialization}.
*
* Disabled by default, which means that if the pojo has a no-args constructor,
* that will be used instead.
*
* Enable this if you intend to avoid deserializing objects whose no-args constructor
* initializes (unwanted) internal state. This applies to complex/framework objects.
*
* If you intend to fill default field values using your default constructor,
* leave this disabled. This normally applies to java beans/data objects.
*/
public static final boolean ALWAYS_USE_SUN_REFLECTION_FACTORY;
static final Method newInstanceFromObjectInputStream;
static final Constructor