public class DefaultProtoLoader extends Object implements Proto.Loader
| Modifier and Type | Field and Description |
|---|---|
protected static int |
ALL |
static DefaultProtoLoader |
DEFAULT_INSTANCE |
static int |
DEFAULT_PROTO_SEARCH_STRATEGY
The default proto search strategy to use.
|
static String |
PATH_SEPARATOR
Standard JVM property.
|
static String |
PATH_SEPARATOR_PROPERTY |
protected static int |
PROTO_PATH_AND_CLASSPATH |
protected static int |
PROTO_PATH_ONLY |
protected int |
protoSearchStrategy |
| Constructor and Description |
|---|
DefaultProtoLoader() |
DefaultProtoLoader(int protoSearchStrategy) |
| Modifier and Type | Method and Description |
|---|---|
static DefaultProtoLoader |
getDefaultInstance() |
static URL |
getResource(String resource,
Class<?> context)
Loads a
URL resource from the classloader; If not found, the classloader of the context class
specified will be used. |
static URL |
getResource(String resource,
Class<?> context,
boolean checkParent)
Loads a
URL resource from the classloader; If not found, the classloader of the context class
specified will be used. |
Proto |
load(String path,
Proto importer) |
protected Proto |
loadFrom(File file,
Proto importer) |
protected Proto |
loadFrom(URL resource,
Proto importer) |
static Proto |
loadFromClasspath(String path,
Proto importer)
Loads a proto from the classpath.
|
protected Proto |
loadFromOtherResource(String path,
Proto importer) |
protected Proto |
searchFromAll(String path,
Proto importer)
Search from every possible resource.
|
protected Proto |
searchFromProtoPathAndClasspath(String path,
Proto importer)
Search from proto_path and classpath (in that order).
|
protected Proto |
searchFromProtoPathOnly(String path,
Proto importer)
Search from proto_path only.
|
protected static final int ALL
protected static final int PROTO_PATH_ONLY
protected static final int PROTO_PATH_AND_CLASSPATH
public static final int DEFAULT_PROTO_SEARCH_STRATEGY
public static final String PATH_SEPARATOR
public static final String PATH_SEPARATOR_PROPERTY
public static final DefaultProtoLoader DEFAULT_INSTANCE
protected final int protoSearchStrategy
public DefaultProtoLoader()
public DefaultProtoLoader(int protoSearchStrategy)
public static DefaultProtoLoader getDefaultInstance()
public Proto load(String path, Proto importer) throws Exception
load in interface Proto.LoaderExceptionprotected Proto searchFromProtoPathOnly(String path, Proto importer) throws Exception
Enable via: -Dproto_path=$path -Dproto_search_strategy=1
Exceptionprotected Proto searchFromProtoPathAndClasspath(String path, Proto importer) throws Exception
Enable via: -Dproto_path=$path -Dproto_search_strategy=2
Exceptionprotected Proto searchFromAll(String path, Proto importer) throws Exception
Search order is: 1. relative path 2. proto_path 3. classpath
Exceptionprotected Proto loadFromOtherResource(String path, Proto importer) throws Exception
Exceptionpublic static Proto loadFromClasspath(String path, Proto importer) throws Exception
Exceptionpublic static URL getResource(String resource, Class<?> context)
URL resource from the classloader; If not found, the classloader of the context class
specified will be used.public static URL getResource(String resource, Class<?> context, boolean checkParent)
URL resource from the classloader; If not found, the classloader of the context class
specified will be used. If the flag checkParent is true, the classloader's parent is included in the
lookup.Copyright © 2009–2021. All rights reserved.