Package org.ringojs.repository

Examples of org.ringojs.repository.Repository


        }
        if (ringoHome == null) {
            ringoHome = ".";
        }
        File file = new File(ringoHome);
        Repository home = file.isFile() && StringUtils.isZipOrJarFile(ringoHome) ?
                new ZipRepository(file) : new FileRepository(file);
        String extraPath = System.getProperty("ringo.modulepath");
        if (extraPath == null) {
            extraPath = System.getenv("RINGO_MODULE_PATH");
        }
View Full Code Here


        this.worker = engine.getWorker();
        this.scope = engine.getShellScope(worker);
        this.silent = silent;
        // FIXME give shell code a trusted code source in case security is on
        if (config.isPolicyEnabled()) {
            Repository modules = config.getRingoHome().getChildRepository("modules");
            codeSource = new CodeSource(modules.getUrl(), (CodeSigner[])null);
        }
    }
View Full Code Here

            boolean production = getBooleanParameter(config, "production", false);
            boolean verbose = getBooleanParameter(config, "verbose", false);
            boolean legacyMode = getBooleanParameter(config, "legacy-mode", false);

            ServletContext context = config.getServletContext();
            Repository base = new WebappRepository(context, "/");
            Repository home = new WebappRepository(context, ringoHome);

            try {
                if (!home.exists()) {
                    home = new FileRepository(ringoHome);
                    System.err.println("Resource \"" + ringoHome + "\" not found, "
                            + "reverting to file repository " + home);
                }
                // Use ',' as platform agnostic path separator
View Full Code Here

        }
   
        @Override
        public void put(int index, Scriptable start, Object value) {
            if (paths != null) {
                Repository repo;
                try {
                    repo = toRepository(value);
                } catch (IOException iox) {
                    throw new WrappedException(iox);
                }
View Full Code Here

        }
   
        @Override
        public Object get(int index, Scriptable start) {
            if (paths != null) {
                Repository value = index < paths.size() ? paths.get(index) : null;
                return value == null ? NOT_FOUND : value.getPath();
            }
            return super.get(index, start);
        }
View Full Code Here

   
        private Repository toRepository(Object value) throws IOException {
            if (value instanceof Wrapper) {
                value = ((Wrapper) value).unwrap();
            }
            Repository repo = null;
            if (value instanceof Repository) {
                repo = (Repository) value;
                // repositories in module search path must be configured as root repository
                repo.setRoot();
                cache.put(repo.getPath(), new SoftReference<Repository>(repo));
            } else if (value != null && value != Undefined.instance) {
                String str = ScriptRuntime.toString(value);
                SoftReference<Repository> ref = cache.get(str);
                repo = ref == null ? null : ref.get();
                if (repo == null) {
                    File file = new File(str);
                    if (file.isFile() && StringUtils.isZipOrJarFile(str)) {
                        repo = new ZipRepository(str);
                    } else {
                        repo = new FileRepository(str);
                    }
                    cache.put(repo.getPath(), new SoftReference<Repository>(repo));
                }
            } else {
                throw Context.reportRuntimeError("Invalid module path item: " + value);
            }
            return repo;
View Full Code Here

            throw Context.reportRuntimeError(
                    "getRepository() requires a string argument");
        }
        RhinoEngine engine = ((RingoGlobal) funObj.getParentScope()).engine;
        try {
            Repository repo = engine.findRepository((String) args[0],
                    engine.getParentRepository(thisObj));
            return cx.getWrapFactory().wrapAsJavaObject(cx, engine.getScope(), repo, null);
        } catch (IOException iox) {
            throw Context.reportRuntimeError("Cannot find repository " + args[0] + "'");
        }
View Full Code Here

     * @throws IOException indicates that in input/output related error occurred
     */
    public Scriptable loadModule(Context cx, String moduleName,
                                 Scriptable loadingScope)
            throws IOException {
        Repository local = engine.getParentRepository(loadingScope);
        ReloadableScript script = engine.getScript(moduleName, local);

        // check if we already came across the module in the current context/request
        if (checkedModules.containsKey(script.resource)) {
            return checkedModules.get(script.resource);
View Full Code Here

TOP

Related Classes of org.ringojs.repository.Repository

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.