Package io.protostuff.parser
Class DefaultProtoLoader
- java.lang.Object
-
- io.protostuff.parser.DefaultProtoLoader
-
- All Implemented Interfaces:
Proto.Loader
- Direct Known Subclasses:
CachingProtoLoader
public class DefaultProtoLoader extends java.lang.Object implements Proto.Loader
Default proto loader for imported protos.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.ArrayList<java.io.File>__protoLoadDirsprotected static intALLstatic DefaultProtoLoaderDEFAULT_INSTANCEstatic intDEFAULT_PROTO_SEARCH_STRATEGYThe default proto search strategy to use.static java.lang.StringPATH_SEPARATORStandard JVM property.private static java.lang.StringPATH_SEPARATOR_DEFAULTstatic java.lang.StringPATH_SEPARATOR_PROPERTYprotected static intPROTO_PATH_AND_CLASSPATHprotected static intPROTO_PATH_ONLYprotected intprotoSearchStrategy
-
Constructor Summary
Constructors Constructor Description DefaultProtoLoader()DefaultProtoLoader(int protoSearchStrategy)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static java.io.FilegetBaseDirFromPackagePath(java.lang.String path, Proto importer)static DefaultProtoLoadergetDefaultInstance()static java.net.URLgetResource(java.lang.String resource, java.lang.Class<?> context)Loads aURLresource from the classloader; If not found, the classloader of thecontextclass specified will be used.static java.net.URLgetResource(java.lang.String resource, java.lang.Class<?> context, boolean checkParent)Loads aURLresource from the classloader; If not found, the classloader of thecontextclass specified will be used.Protoload(java.lang.String path, Proto importer)protected ProtoloadFrom(java.io.File file, Proto importer)protected ProtoloadFrom(java.net.URL resource, Proto importer)static ProtoloadFromClasspath(java.lang.String path, Proto importer)Loads a proto from the classpath.protected ProtoloadFromOtherResource(java.lang.String path, Proto importer)protected ProtosearchFromAll(java.lang.String path, Proto importer)Search from every possible resource.protected ProtosearchFromProtoPathAndClasspath(java.lang.String path, Proto importer)Search from proto_path and classpath (in that order).protected ProtosearchFromProtoPathOnly(java.lang.String path, Proto importer)Search from proto_path only.
-
-
-
Field Detail
-
ALL
protected static final int ALL
- See Also:
- Constant Field Values
-
PROTO_PATH_ONLY
protected static final int PROTO_PATH_ONLY
- See Also:
- Constant Field Values
-
PROTO_PATH_AND_CLASSPATH
protected static final int PROTO_PATH_AND_CLASSPATH
- See Also:
- Constant Field Values
-
DEFAULT_PROTO_SEARCH_STRATEGY
public static final int DEFAULT_PROTO_SEARCH_STRATEGY
The default proto search strategy to use.
-
PATH_SEPARATOR
public static final java.lang.String PATH_SEPARATOR
Standard JVM property. See https://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html
-
PATH_SEPARATOR_PROPERTY
public static final java.lang.String PATH_SEPARATOR_PROPERTY
- See Also:
- Constant Field Values
-
PATH_SEPARATOR_DEFAULT
private static final java.lang.String PATH_SEPARATOR_DEFAULT
- See Also:
- Constant Field Values
-
DEFAULT_INSTANCE
public static final DefaultProtoLoader DEFAULT_INSTANCE
-
__protoLoadDirs
private static final java.util.ArrayList<java.io.File> __protoLoadDirs
-
protoSearchStrategy
protected final int protoSearchStrategy
-
-
Method Detail
-
getDefaultInstance
public static DefaultProtoLoader getDefaultInstance()
-
load
public Proto load(java.lang.String path, Proto importer) throws java.lang.Exception
- Specified by:
loadin interfaceProto.Loader- Throws:
java.lang.Exception
-
searchFromProtoPathOnly
protected Proto searchFromProtoPathOnly(java.lang.String path, Proto importer) throws java.lang.Exception
Search from proto_path only. For full protoc compatibility, use this.Enable via: -Dproto_path=$path -Dproto_search_strategy=1
- Throws:
java.lang.Exception
-
searchFromProtoPathAndClasspath
protected Proto searchFromProtoPathAndClasspath(java.lang.String path, Proto importer) throws java.lang.Exception
Search from proto_path and classpath (in that order).Enable via: -Dproto_path=$path -Dproto_search_strategy=2
- Throws:
java.lang.Exception
-
searchFromAll
protected Proto searchFromAll(java.lang.String path, Proto importer) throws java.lang.Exception
Search from every possible resource. Also loads from a remote url (if path starts with http://).Search order is: 1. relative path 2. proto_path 3. classpath
- Throws:
java.lang.Exception
-
getBaseDirFromPackagePath
static java.io.File getBaseDirFromPackagePath(java.lang.String path, Proto importer)
-
loadFromOtherResource
protected Proto loadFromOtherResource(java.lang.String path, Proto importer) throws java.lang.Exception
- Throws:
java.lang.Exception
-
loadFrom
protected Proto loadFrom(java.io.File file, Proto importer) throws java.lang.Exception
- Throws:
java.lang.Exception
-
loadFrom
protected Proto loadFrom(java.net.URL resource, Proto importer) throws java.lang.Exception
- Throws:
java.lang.Exception
-
loadFromClasspath
public static Proto loadFromClasspath(java.lang.String path, Proto importer) throws java.lang.Exception
Loads a proto from the classpath.- Throws:
java.lang.Exception
-
getResource
public static java.net.URL getResource(java.lang.String resource, java.lang.Class<?> context)Loads aURLresource from the classloader; If not found, the classloader of thecontextclass specified will be used.
-
getResource
public static java.net.URL getResource(java.lang.String resource, java.lang.Class<?> context, boolean checkParent)Loads aURLresource from the classloader; If not found, the classloader of thecontextclass specified will be used. If the flagcheckParentis true, the classloader's parent is included in the lookup.
-
-