/* (non-Javadoc)
@see com.ibm.jaggr.service.modulebuilder.IModuleBuilder#getCacheKeyGenerator(com.ibm.jaggr.service.IAggregator)
170337
@Override	public List<ICacheKeyGenerator> getCacheKeyGenerators(IAggregator aggregator) {
		final String sourceMethod = "getCacheKeyGenerators"; //$NON-NLS-1$
		final boolean isTraceLogging = log.isLoggable(Level.FINER);
		if (isTraceLogging) {
			log.entering(sourceClass, sourceMethod, new Object[]{aggregator});
		}
		List<ICacheKeyGenerator> result = super.getCacheKeyGenerators(aggregator);
		if (isFeatureDependent) {
			// If responses are feature dependent, add a FeatueCacheKeyGenerator to the list of
			// cache key generators for this module builder
			result = new ArrayList<ICacheKeyGenerator>(super.getCacheKeyGenerators(aggregator));
			if (result.size() != 2) {
				throw new IllegalStateException("Unexpected list size = " + result.size()); //$NON-NLS-1$
			}
			result.add(new FeatureSetCacheKeyGenerator(new HashSet<String>(), true));
			result = Collections.unmodifiableList(result);
		}
		if (isTraceLogging) {
			log.exiting(sourceClass, sourceMethod, KeyGenUtil.toString(result));
		}
		return result;
	}
1018987
private CacheProvider initSecondLevelCache(final PersistenceUnitMetadata puMetadata)
    {

        String classResourceName = (String) getProperties().get(PersistenceProperties.KUNDERA_CACHE_CONFIG_RESOURCE);

        classResourceName = classResourceName != null ? classResourceName : puMetadata
                .getProperty(PersistenceProperties.KUNDERA_CACHE_CONFIG_RESOURCE);

        String cacheProviderClassName = (String) getProperties()
                .get(PersistenceProperties.KUNDERA_CACHE_PROVIDER_CLASS);

        cacheProviderClassName = cacheProviderClassName != null ? cacheProviderClassName : puMetadata
                .getProperty(PersistenceProperties.KUNDERA_CACHE_PROVIDER_CLASS);

        CacheProvider cacheProvider = null;
        if (cacheProviderClassName != null)
        {
            try
            {
                Class<CacheProvider> cacheProviderClass = (Class<CacheProvider>) Class.forName(cacheProviderClassName);
                cacheProvider = cacheProviderClass.newInstance();
                cacheProvider.init(classResourceName);
            }
            catch (ClassNotFoundException e)
            {
                throw new CacheException("Could not find class " + cacheProviderClassName
                        + ". Check whether you spelled it correctly in persistence.xml", e);
            }
            catch (InstantiationException e)
            {
                throw new CacheException("Could not instantiate " + cacheProviderClassName, e);
            }
            catch (IllegalAccessException e)
            {
                throw new CacheException(e);
            }
        }
        if (cacheProvider == null)
        {
            cacheProvider = new NonOperationalCacheProvider();
        }
        return cacheProvider;
    }
1173726
public IdGenerator getIdGenerator(GenerationType generationType, String name) {
		return getIdGenerator(generationType, name, getIdGenerators());
	}
1324227
public static String getCacheAnnotation(PackageImportAdder packageImportAdder, CacheConfigGetter... cacheConfigGetters) {
        if (cacheConfigGetters == null) {
            return "";
        }

        for (CacheConfigGetter cacheConfigGetter : cacheConfigGetters) {
            if (cacheConfigGetter != null) {
                CacheConfig cacheConfig = cacheConfigGetter.getCacheConfig();

                if (cacheConfig != null) {
                    if (cacheConfig.getUsage().isNone()) {
                        return ""; // cleaner than disabling the cache using @Cache (usage = NONE)
                    } else {
                        packageImportAdder.addImport("org.hibernate.annotations.Cache");
                        packageImportAdder.addImport("static org.hibernate.annotations.CacheConcurrencyStrategy." + cacheConfig.getUsage().name());

                        AttributeBuilder attr = new AttributeBuilder();
                        attr.add("usage = " + cacheConfig.getUsage().name());

                        if (cacheConfig.hasInclude()) {
                            attr.addString("include", cacheConfig.getInclude());
                        }

                        if (cacheConfig.hasRegion()) {
                            attr.addString("region", cacheConfig.getInclude());
                        }

                        return attr.bindAttributesTo("@Cache");
                    }
                }
            }
        }

        return "";
    }
12391
function getCacheCtor(cache){
  if (!cache){
    return;
  }

  if (typeof cache === 'function'){
    return cache;
  }

  function runtimeLoad(moduleRef){
    return require(moduleRef);
  }

  var cacheCtors = {
    disabled: runtimeLoad('./DisabledCache'),
    memory: runtimeLoad('./MemoryStore'),
    memcached: runtimeLoad('./MemcachedStore'),
    redis: runtimeLoad('./RedisStore')
  };

  if (!(cache in cacheCtors)){
    throw new Error('Unsupported cache provider: ' + cache);
  }

  return cacheCtors[cache];
}
29608
private CacheLoader<Query<Entity>, List<Object>> createCacheLoader(
      final Repository<Entity> repository) {
    String repositoryName = repository.getName();
    Fetch idAttributeFetch =
        new Fetch().field(repository.getEntityType().getIdAttribute().getName());
    return new CacheLoader<Query<Entity>, List<Object>>() {
      /**
       * Loads {@link Entity} identifiers for a {@link Query}
       *
       * @param query the cache key to load
       * @return {@link List} of identifier {@link Object}s
       */
      @Override
      public List<Object> load(@Nonnull Query<Entity> query) {
        LOG.trace("Loading identifiers from repository {} for query {}", repositoryName, query);
        return repository
            .findAll(new QueryImpl<>(query).fetch(idAttributeFetch))
            .map(Entity::getIdValue)
            .collect(toList());
      }
    };
  }
697124
@Override
    public CacheKey getCacheKey(HttpServletRequest request, HttpServletResponse response) {
        final CacheKeyBuilder cacheKeyBuilder = CacheKey.builder(this.getClass().getName());

        for (final TransformerConfigurationSource source : this.sources) {
            final CacheKey key = source.getCacheKey(request, response);
            cacheKeyBuilder.add(key);
        }

        return cacheKeyBuilder.build();
    }
519811
@Override
	public void initialize(IAggregator aggregator, IAggregatorExtension extension,
			IExtensionRegistrar registrar) {
		final String sourceMethod = "initialize"; //$NON-NLS-1$
		final boolean isTraceLogging = log.isLoggable(Level.FINER);
		if (isTraceLogging) {
			log.entering(sourceMethod, sourceMethod, new Object[]{aggregator, extension});
		}
		this.aggregator = aggregator;
		isSkipResourceConversion.set(false);

		// Get the transformer javascript resource from init-params
		String xformerUri = extension.getInitParams().getValue(JSXTRANSFORMER_NAME);
		if (xformerUri == null) {
			throw new IllegalStateException("Missing transformer init-param"); //$NON-NLS-1$
		}
		try {
			xformerRes = aggregator.newResource(new URI(xformerUri));
		} catch (URISyntaxException e) {
			throw new RuntimeException(e);
		}
		if (!xformerRes.exists()) {
			throw new RuntimeException(new NotFoundException(xformerUri));
		}
		// Register a cache manager listener so that we can add our named cache after
		// the cache manager has been initialized.
		Dictionary<String,String> dict;
		dict = new Hashtable<String, String>();
		dict.put("name", aggregator.getName()); //$NON-NLS-1$
		cacheMgrListenerReg = aggregator.getPlatformServices().registerService(ICacheManagerListener.class.getName(), this, dict);

		if (ctorScopePoolSize > 0) {
			scopePoolSize = ctorScopePoolSize;
		} else {
			// Get the configured scope pool size
			if (extension != null) {
				scopePoolSize = TypeUtil.asInt(extension.getInitParams().getValue(SCOPE_POOL_SIZE_INITPARAM), DEFAULT_SCOPE_POOL_SIZE);
				// If jsx options have been specified, use them
				String options = extension.getInitParams().getValue(JSX_OPTIONS_INITPARAM);
				if (options != null && options.length() > 0) {
					jsxOptions = options;
				}
			}
		}
		if (isTraceLogging) {
			log.exiting(sourceClass, sourceMethod);
		}
	}
182466
private static CacheProvider getCacheProvider(Method javaMethod) {
        if (!javaMethod.isAnnotationPresent(Cache.class)) {
            return null;
        }

        Cache an = javaMethod.getAnnotation(Cache.class);
        Class<? extends CacheProvider> cacheClazz = an.value();

        try {
            Constructor<? extends CacheProvider> constructor = cacheClazz.getDeclaredConstructor();
            constructor.setAccessible(true);
            return constructor.newInstance();
        } catch (Exception e) {
            throw new EventsException("Cannot instantiate cache provider "
                    + cacheClazz.getSimpleName() + " for method "
                    + Utils.methodToString(javaMethod), e);
        }
    }
658705
public final SecretKey generateKey() {
        if (serviceIterator == null) {
            return spi.engineGenerateKey();
        }
        RuntimeException failure = null;
        KeyGeneratorSpi mySpi = spi;
        do {
            try {
                return mySpi.engineGenerateKey();
            } catch (RuntimeException e) {
                if (failure == null) {
                    failure = e;
                }
                mySpi = nextSpi(mySpi, true);
            }
        } while (mySpi != null);
        throw failure;
   }
1277635
@Override
    public String getCacheKey(final Object keyObject, final String namespace) {
        return namespace + SEPARATOR + defaultKeyProvider.generateKey(keyObject);
    }
1009502
@Override
    public ConstantPoolGen analyze(IAnalysisCache analysisCache, ClassDescriptor descriptor) throws CheckedAnalysisException {
        ClassGen classGen = new ClassGen(analysisCache.getClassAnalysis(JavaClass.class, descriptor));
        return classGen.getConstantPool();
    }
207167
KeyPair generateKeyPair(int keySize) throws Exception {
        KeyPairGenerator generator = KeyPairGenerator.getInstance(KEY_GENERATION_ALGORITHM, PROVIDER_NAME);
        generator.initialize(keySize, new SecureRandom());
        return generator.generateKeyPair();
    }
618187
@Override
    public String getCacheDigest(String cacheInstance, boolean useMemoryCacheDigest,
                                 boolean cacheIDOnly, boolean debug) throws javax.management.AttributeNotFoundException { // LI4337-17

        if (tc.isEntryEnabled()) {
            Tr.entry(tc, "getCacheDigest: cacheInstance=" + cacheInstance + " useMemoryCacheDigest=" + useMemoryCacheDigest +
                         " cacheIDOnly=" + cacheIDOnly + " debug=" + debug);
        }
        // Get the cache for this cacheInstance
        DCache cache1 = getCache(cacheInstance);

        // Get the message digest
        getMessageDigestMD5();

        // Calculate total hashcode for cache ids and cache value in memory cache  
        int totalHashcode = cache1.getMemoryCacheHashcode(debug, !cacheIDOnly);

        if (cacheIDOnly == true) {
            // Calculate total hashcode for cache ids in PushPullTable  
            totalHashcode += cache1.getCacheIdsHashcodeInPushPullTable(debug);
        }

        if (useMemoryCacheDigest == false) {
            // Calculate total hashcode for cache ids and cache value in disk cache  
            try {
                totalHashcode += cache1.getDiskCacheHashcode(debug, !cacheIDOnly);
            } catch (DynamicCacheException e) {
                Tr.error(tc, "DYNA1053E", new Object[] { DynaCacheConstants.MBEAN_GET_CACHE_DIGEST, e.getMessage() });
                throw new AttributeNotFoundException(e.getMessage());
            }
        }

        // Convert hashcode to MD5 digest
        String md5Hash = MessageDigestUtility.processMessageDigestForData(MBeans.messageDigestMD5, totalHashcode);

        if (tc.isEntryEnabled()) {
            Tr.exit(tc, "getCacheDigest: Exiting. Entire cache hash in MD5 is " + md5Hash + " for cacheInstance = " + cacheInstance);
        }
        return md5Hash;
    }
260585
public long addEntry(UniqueKeyGenerator generator) throws PersistenceException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "addEntry", "GeneratorName="+generator.getName());

        if (!_generators.containsKey(generator.getName()))
        {
            Transaction transaction = null;

            try
            {
                transaction = _objectManager.getTransaction();

                // Add the ManagedObject for this generator
                UniqueKeyGeneratorManagedObject uniqueKey = new UniqueKeyGeneratorManagedObject(generator);
                Token uniqueKeyToken = _objectStore.allocate(uniqueKey);
                transaction.add(uniqueKey);

                // Add token to the list of generators
                LinkedList list = (LinkedList)_uniqueKeyRootToken.getManagedObject();
                list.add(uniqueKeyToken, transaction);

                // Commit all of the work
                transaction.commit(false);

                // Store the token in our list to access at runtime.
                _generators.put(generator.getName(), uniqueKey);
            }
            catch (ObjectManagerException ome)
            {
                com.ibm.ws.ffdc.FFDCFilter.processException(ome, "com.ibm.ws.sib.msgstore.persistence.objectManager.UniqueKeyRangeManager.addEntry", "1:217:1.8", this);
                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.event(tc, "Exception caught creating new unique key generator!", ome);

                if (transaction != null)
                {
                    try
                    {
                        // Clean up our ObjectManager work.
                        transaction.backout(false);
                    }
                    catch (ObjectManagerException e)
                    {
                        com.ibm.ws.ffdc.FFDCFilter.processException(e, "com.ibm.ws.sib.msgstore.persistence.objectManager.UniqueKeyRangeManager.addEntry", "1:229:1.8", this);
                        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.event(tc, "Exception caught backing out unique key generator creation!", e);
                    }
                }

                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "addEntry");
                throw new PersistenceException("Exception caught creating new unique key generator!", ome);
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "addEntry", "return="+UNIQUE_KEY_INITIAL_VALUE);
        return UNIQUE_KEY_INITIAL_VALUE;
    }
1271347
protected Object _getCacheManager() {
        net.sf.ehcache.CacheManager cacheManager = net.sf.ehcache.CacheManager.getInstance();
        if (cacheManager != null)
            return cacheManager;
        return net.sf.ehcache.CacheManager.newInstance();
    }
259207
<E> Node generate(E entity, PersistenceDelegator delegator, PersistenceCache pc, NodeState state)
    {

        EntityMetadata entityMetadata = KunderaMetadataManager.getEntityMetadata(delegator.getKunderaMetadata(),
                entity.getClass());

        if (!new NullOrInvalidEntityRule<E>(entityMetadata).validate(entity))
        {
            Object entityId = onPreChecks(entity, delegator);

            // TODO::check for composite key.
            Node node = builder.buildNode(entity, delegator, entityId, state);

            node = traverseNode(entity, delegator, pc, entityId, node);

            return node;
        }

        return null;
    }