Exemplo n.º 1
0
  /**
   * Tries to load the class specified otherwise defaults to null
   *
   * @return a map of CacheManagerPeerProviders
   */
  public Map<String, CacheManagerPeerProvider> createCachePeerProviders() {
    String className = null;
    Map<String, CacheManagerPeerProvider> cacheManagerPeerProviders =
        new HashMap<String, CacheManagerPeerProvider>();
    List<FactoryConfiguration> cachePeerProviderFactoryConfiguration =
        configuration.getCacheManagerPeerProviderFactoryConfiguration();
    for (FactoryConfiguration factoryConfiguration : cachePeerProviderFactoryConfiguration) {

      if (factoryConfiguration != null) {
        className = factoryConfiguration.getFullyQualifiedClassPath();
      }
      if (className == null) {
        LOG.fine(
            "No CachePeerProviderFactoryConfiguration specified. Not configuring a CacheManagerPeerProvider.");
        return null;
      } else {
        CacheManagerPeerProviderFactory cacheManagerPeerProviderFactory =
            (CacheManagerPeerProviderFactory) ClassLoaderUtil.createNewInstance(className);
        Properties properties =
            PropertyUtil.parseProperties(
                factoryConfiguration.getProperties(), factoryConfiguration.getPropertySeparator());
        CacheManagerPeerProvider cacheManagerPeerProvider =
            cacheManagerPeerProviderFactory.createCachePeerProvider(cacheManager, properties);
        cacheManagerPeerProviders.put(
            cacheManagerPeerProvider.getScheme(), cacheManagerPeerProvider);
      }
    }
    return cacheManagerPeerProviders;
  }
 /** Given an {@link CacheManager} get the corresponding instance of this class. */
 public static JGroupsCacheManagerPeerProvider getCachePeerProvider(CacheManager cacheManager) {
   final CacheManagerPeerProvider provider =
       cacheManager.getCacheManagerPeerProvider(JGroupsCacheManagerPeerProvider.SCHEME_NAME);
   if (provider == null) {
     LOG.warn(
         "No CacheManagerPeerProvider registered for {} scheme.",
         JGroupsCacheManagerPeerProvider.SCHEME_NAME);
     return null;
   }
   if (!(provider instanceof JGroupsCacheManagerPeerProvider)) {
     LOG.warn(
         "{} for scheme {} cannot be cast to {}.",
         new Object[] {
           provider.getClass(),
           JGroupsCacheManagerPeerProvider.SCHEME_NAME,
           JGroupsCacheManagerPeerProvider.class,
         });
     return null;
   }
   return (JGroupsCacheManagerPeerProvider) provider;
 }
 private void tracePeers() {
   CacheManagerPeerProvider peerProvider = manager.getCacheManagerPeerProvider("RMI");
   int peers = peerProvider.listRemoteCachePeers(manager.getEhcache(cacheName)).size();
   log.trace("Found {} remote cache peer(s)", peers);
 }