Examples of IMap


Examples of com.j_spaces.map.IMap

   * @throws CacheNotFoundException if the cache does not exist
   * @throws CacheAccessException   wrapping any unexpected exception thrown by the cache
   */
  protected IMap getCache(String name) throws CacheNotFoundException,
      CacheAccessException {
    IMap cache = (IMap) cachesHolder.get(name);
    try {
      if (cache == null) {
        cache = (IMap) CacheFinder.find(name);
        cachesHolder.put(name, cache);
      }
View Full Code Here

Examples of com.j_spaces.map.IMap

      CacheException cacheException = null;
      int nameCount = cacheNames.length;

      try {
        for (int i = 0; i < nameCount; i++) {
          IMap cache = getCache(cacheNames[i]);
          cache.clear();
        }
      } catch (CacheException exception) {
        cacheException = exception;
      } catch (Exception exception) {
        cacheException = new CacheAccessException(exception);
View Full Code Here

Examples of com.j_spaces.map.IMap

   * @throws CacheAccessException   wrapping any unexpected exception thrown by the cache.
   * @see AbstractCacheProviderFacade#onGetFromCache(Serializable,CachingModel)
   */
  protected Object onGetFromCache(Serializable key, CachingModel model)
      throws CacheException {
    IMap cache = getCache(model);
    GigaSpacesCachingModel gigaSpacesCachingModel = (GigaSpacesCachingModel) model;
    Object cachedObject;

    try {
      Long waitForResponse = gigaSpacesCachingModel.getWaitForResponse();
      if (waitForResponse != null) {
        cachedObject = cache.get(key, waitForResponse.longValue());
      } else {
        cachedObject = cache.get(key);
      }
    } catch (Exception exception) {
      throw new CacheAccessException(exception);
    }
    return cachedObject;
View Full Code Here

Examples of com.j_spaces.map.IMap

   */
  protected void onPutInCache(Serializable key, CachingModel model, Object obj)
      throws CacheException {
    try {
      GigaSpacesCachingModel gigaSpacesCachingModel = (GigaSpacesCachingModel) model;
      IMap cache = getCache(gigaSpacesCachingModel);
      Long timeToLive = gigaSpacesCachingModel.getTimeToLive();
      if (timeToLive != null) {
        cache.put(key, obj, timeToLive.longValue());
      } else {
        cache.put(key, obj);
      }
    } catch (Exception exception) {
      throw new CacheAccessException(exception);
    }
  }
View Full Code Here

Examples of com.j_spaces.map.IMap

   * @see AbstractCacheProviderFacade#onRemoveFromCache(Serializable,
   *CachingModel)
   */
  protected void onRemoveFromCache(Serializable key, CachingModel model)
      throws CacheException {
    IMap cache = getCache(model);
    try {
      cache.remove(key);

    } catch (Exception exception) {
      throw new CacheAccessException(exception);
    }
  }
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IMap

      @Override
      public Response serve(String uri, Method method, Map<String, String> headers, Map<String, String> parms,
          Map<String, String> files) {
        IConstructor methodVal = makeMethod(method);
        IMap headersVal = makeMap(headers);
        IMap paramsVal= makeMap(parms);
        IMap filesVal= makeMap(files);
        ISourceLocation loc = vf.sourceLocation(URIUtil.assumeCorrect("request", "", uri));
        try {
          synchronized (callee.getEval()) {
            callee.getEval().__setInterrupt(false);
            Result<IValue> response = callee.call(argTypes, new IValue[] { loc, methodVal, headersVal, paramsVal, filesVal }, null);
            return translateResponse(method, response.getValue())
          }
        }
        catch (Throw rascalException) {
          ctx.getStdErr().println(rascalException.getMessage());
          return new Response(Status.INTERNAL_ERROR, "text/plain", rascalException.getMessage());
        }
        catch (Throwable unexpected) {
          ctx.getStdErr().println(unexpected.getMessage());
          unexpected.printStackTrace(ctx.getStdErr());
          return new Response(Status.INTERNAL_ERROR, "text/plain", unexpected.getMessage());
        }
      }

      private Response translateResponse(Method method, IValue value) {
        IConstructor cons = (IConstructor) value;
        initMethodAndStatusValues(ctx);
       
        if (cons.getName().equals("fileResponse")) {
          return translateFileResponse(method, cons);
        }
        else {
          return translateTextResponse(method, cons);
        }
      }
     
      private Response translateFileResponse(Method method, IConstructor cons) {
        ISourceLocation l = (ISourceLocation) cons.get("file");
        IString mimeType = (IString) cons.get("mimeType");
        IMap header = (IMap) cons.get("header");
        URI uri = l.getURI();
       
        Response response;
        try {
          response = new Response(Status.OK, mimeType.getValue(), ctx.getResolverRegistry().getInputStream(uri));
          addHeaders(response, header);
          return response;
        } catch (IOException e) {
          e.printStackTrace(ctx.getStdErr());
          return new Response(Status.NOT_FOUND, "text/plain", l + " not found.\n" + e);
        }
      }

      private Response translateTextResponse(Method method, IConstructor cons) {
        IString mimeType = (IString) cons.get("mimeType");
        IMap header = (IMap) cons.get("header");
        IString data = (IString) cons.get("content");
        Status status = translateStatus((IConstructor) cons.get("status"));
       
        if (method != Method.HEAD) {
          switch (status) {
          case BAD_REQUEST:
          case UNAUTHORIZED:
          case NOT_FOUND:
          case FORBIDDEN:
          case RANGE_NOT_SATISFIABLE:
          case INTERNAL_ERROR:
            if (data.length() == 0) {
              data = vf.string(status.getDescription());
            }
          default:
            break;
          }
        }
        Response response = new Response(status, mimeType.getValue(), data.getValue());
        addHeaders(response, header);
        return response;
      }

      private void addHeaders(Response response, IMap header) {
        // TODO add first class support for cache control on the Rascal side. For
        // now we prevent any form of client-side caching with this.. hopefully.
        response.addHeader("Cache-Control", "no-cache, no-store, must-revalidate");
        response.addHeader("Pragma", "no-cache");
        response.addHeader("Expires", "0");
       
        for (IValue key : header) {
          response.addHeader(((IString) key).getValue(), ((IString) header.get(key)).getValue());
        }
      }

      private Status translateStatus(IConstructor cons) {
        initMethodAndStatusValues(ctx);
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IMap

      }
      throw new ImplementationError("class for cached parser " + className + " could not be found");
    }

    ParserGenerator pg = eval.getParserGenerator();
    IMap definitions = currentModule.getSyntaxDefinition();
   
    Class<IGTD<IConstructor, IConstructor, ISourceLocation>> parser = eval.getHeap().getObjectParser(currentModule.getName(), definitions);

    if (parser == null || force) {
      String parserName = currentModule.getName(); // .replaceAll("::", ".");
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IMap

    }
  }

  private IValue traverseMapOnce(IValue subject, CaseBlockList casesOrRules,
      DIRECTION direction, PROGRESS progress, FIXEDPOINT fixedpoint, TraverseResult tr) {
    IMap map = (IMap) subject;
    if(!map.isEmpty()){
      IMapWriter w = eval.getValueFactory().mapWriter(map.getType());
      Iterator<Entry<IValue,IValue>> iter = map.entryIterator();
      boolean hasChanged = false;
      boolean hasMatched = false;
     
      while (iter.hasNext()) {
        Entry<IValue,IValue> entry = iter.next();
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IMap

          String[] keyValue = param.split("=");
          res.put(vf.string(keyValue[0]), vf.string(keyValue[1]));
        }
      }
     
      IMap map = res.done();
      return makeResult(map.getType(), map, ctx);
    }

    default:
      throw new UndeclaredField(name, getTypeFactory().sourceLocationType(), ctx.getCurrentAST());
    }
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IMap

   
    if(testResultListener == null){
      testResultListener = (ITestResultListener) new DefaultTestResultListener(stderr);
    }
   
    IMap symbol_definitions = (IMap) program.get("symbol_definitions");
   
    RVM rvm = new RVM(new RascalExecutionContext(vf, symbol_definitions, debug.getValue(), profile.getValue(), ctx, testResultListener));
   
    ArrayList<String> initializers = new ArrayList<String>();    // initializers of imported modules
    ArrayList<String> testsuites =  new ArrayList<String>()// testsuites of imported modules
   
    Iterator<Entry<IValue, IValue>> entries = imported_types.entryIterator();
    while(entries.hasNext()) {
      Entry<IValue, IValue> entry = entries.next();
      rvm.declareConstructor(((IString) entry.getKey()).getValue(), (IConstructor) entry.getValue());
    }
   
    for(IValue imp : imported_functions){
      IConstructor declaration = (IConstructor) imp;
      if (declaration.getName().contentEquals("FUNCTION")) {
        String name = ((IString) declaration.get("qname")).getValue();
       
        if(name.endsWith("_init(list(value());)#0")){
          initializers.add(name);
        }
        if(name.endsWith("_testsuite(list(value());)#0")){
          testsuites.add(name);
        }
        loadInstructions(name, declaration, rvm, false);
      }
      if (declaration.getName().contentEquals("COROUTINE")) {
        String name = ((IString) declaration.get("qname")).getValue();
        loadInstructions(name, declaration, rvm, true);
      }
    }
   
    // Overloading resolution of imported functions
    rvm.addResolver(imported_overloading_resolvers);
    rvm.fillOverloadedStore(imported_overloaded_functions);

    IMap types = (IMap) program.get("types");
    entries = types.entryIterator();
    while(entries.hasNext()) {
      Entry<IValue, IValue> entry = entries.next();
      rvm.declareConstructor(((IString) entry.getKey()).getValue(), (IConstructor) entry.getValue());
    }
   
    IMap declarations = (IMap) program.get("declarations");
    for (IValue dname : declarations) {
      IConstructor declaration = (IConstructor) declarations.get(dname);

      if (declaration.getName().contentEquals("FUNCTION")) {
        String name = ((IString) declaration.get("qname")).getValue();
        if(name.endsWith(main) || name.endsWith(mu_main)) {
          uid_main = name;      // Get main's uid in current module
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.