static {
    // Initialize the cache
    try {
      CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory();
      cache = cacheFactory.createCache(Collections.emptyMap());
    } catch (CacheException e) {
      log.severe("Exception creating cache: " + e.getMessage() + ": " + e.getStackTrace());
      cache = null;
    }

    // Read important properties from file
    Properties properties = new Properties();
    try {
      properties.load(new FileInputStream("WEB-INF/project.properties"));
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }

    CLIENT_ID = properties.getProperty("clientId");
    CLIENT_SECRET = properties.getProperty("clientSecret");
    REDIRECTION_ENDPOINT = properties.getProperty("redirectionEndpoint");
    AUTHORIZATION_ENDPOINT = properties.getProperty("authorizationEndpoint");
    TOKEN_ENDPOINT = properties.getProperty("tokenEndpoint");

    FACEBOOK_API_ENDPOINT = "https://graph.facebook.com/v2.5/";
    MAX_NUMBER_OF_FACEBOOK_POSTS_TO_REQUEST = 200;
    FACEBOOK_REQUESTED_PROFILE_FIELDS = "id,birthday,hometown,name,website,work";
    FACEBOOK_REQUESTED_FEED_FIELDS =
        "id,name,type,message,status_type,created_time,from,likes%7Bid,name%7D";
  }
Esempio n. 2
0
 public CacheService() {
   try {
     cache = CacheManager.getInstance().getCacheFactory().createCache(Collections.emptyMap());
   } catch (CacheException e) {
     LOGGER.error("Can't init cache manager. " + e.getMessage());
   }
   localCache = new HashMap<String, Object>();
   localCacheTime = System.currentTimeMillis();
 }
  /*
   * (non-Javadoc)
   *
   * @see es.alvsanand.webpage.services.admin.WebAdminService#eraseCache()
   */
  public void eraseCache() {
    Cache cache;

    try {
      logger.debug("Erasing cache data");

      CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory();
      cache = cacheFactory.createCache(Collections.emptyMap());

      for (String cacheName : Globals.CAHE_NAMES) {
        cache.remove(cacheName);
      }
    } catch (CacheException cacheException) {
      logger.error("Error removing erasing cache data.", cacheException);
    }
  }
 @SuppressWarnings({"serial", "unchecked"})
 public static Cache getCacheInstance() {
   if (cache == null) {
     try {
       cache =
           CacheManager.getInstance()
               .getCacheFactory()
               .createCache(
                   new HashMap() {
                     {
                       put(GCacheFactory.EXPIRATION_DELTA, 60);
                     }
                   });
     } catch (Exception e) {
       logger.error(className + " Unable to create Cache instance: " + e.getMessage());
       throw new RuntimeException(e);
     }
   }
   return cache;
 }
 protected CacheManager getCacheManager() {
   CacheManager manager = CacheManager.getInstance();
   Assert.assertNotNull(manager);
   return manager;
 }