Class DefaultProtoLoader

    • Field Detail

      • 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
      • __protoLoadDirs

        private static final java.util.ArrayList<java.io.File> __protoLoadDirs
      • protoSearchStrategy

        protected final int protoSearchStrategy
    • Constructor Detail

      • DefaultProtoLoader

        public DefaultProtoLoader()
      • DefaultProtoLoader

        public DefaultProtoLoader​(int protoSearchStrategy)
    • Method Detail

      • load

        public Proto load​(java.lang.String path,
                          Proto importer)
                   throws java.lang.Exception
        Specified by:
        load in interface Proto.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 a URL resource from the classloader; If not found, the classloader of the context class specified will be used.
      • getResource

        public static java.net.URL getResource​(java.lang.String resource,
                                               java.lang.Class<?> context,
                                               boolean checkParent)
        Loads a 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.