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>
__protoLoadDirs
protected static int
ALL
static DefaultProtoLoader
DEFAULT_INSTANCE
static int
DEFAULT_PROTO_SEARCH_STRATEGY
The default proto search strategy to use.static java.lang.String
PATH_SEPARATOR
Standard JVM property.private static java.lang.String
PATH_SEPARATOR_DEFAULT
static java.lang.String
PATH_SEPARATOR_PROPERTY
protected static int
PROTO_PATH_AND_CLASSPATH
protected static int
PROTO_PATH_ONLY
protected int
protoSearchStrategy
-
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.File
getBaseDirFromPackagePath(java.lang.String path, Proto importer)
static DefaultProtoLoader
getDefaultInstance()
static java.net.URL
getResource(java.lang.String resource, java.lang.Class<?> context)
Loads aURL
resource from the classloader; If not found, the classloader of thecontext
class specified will be used.static java.net.URL
getResource(java.lang.String resource, java.lang.Class<?> context, boolean checkParent)
Loads aURL
resource from the classloader; If not found, the classloader of thecontext
class specified will be used.Proto
load(java.lang.String path, Proto importer)
protected Proto
loadFrom(java.io.File file, Proto importer)
protected Proto
loadFrom(java.net.URL resource, Proto importer)
static Proto
loadFromClasspath(java.lang.String path, Proto importer)
Loads a proto from the classpath.protected Proto
loadFromOtherResource(java.lang.String path, Proto importer)
protected Proto
searchFromAll(java.lang.String path, Proto importer)
Search from every possible resource.protected Proto
searchFromProtoPathAndClasspath(java.lang.String path, Proto importer)
Search from proto_path and classpath (in that order).protected Proto
searchFromProtoPathOnly(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:
load
in 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 aURL
resource from the classloader; If not found, the classloader of thecontext
class specified will be used.
-
getResource
public static java.net.URL getResource(java.lang.String resource, java.lang.Class<?> context, boolean checkParent)
Loads aURL
resource from the classloader; If not found, the classloader of thecontext
class specified will be used. If the flagcheckParent
is true, the classloader's parent is included in the lookup.
-
-