public static Object createKey(Object obj) { if (obj == null) { return NULL; } if (!obj.getClass().isArray()) { return obj; } if (obj instanceof Object[]) { return createKey((Object[])obj); } else if (obj instanceof int[]) { return createKey((int[])obj); } else if (obj instanceof float[]) { return createKey((float[])obj); } else if (obj instanceof long[]) { return createKey((long[])obj); } else if (obj instanceof double[]) { return createKey((double[])obj); } else if (obj instanceof byte[]) { return createKey((byte[])obj); } else if (obj instanceof char[]) { return createKey((char[])obj); } else if (obj instanceof boolean[]) { return createKey((boolean[])obj); } else if (obj instanceof short[]) { return createKey((short[])obj); } else { return obj; } }
mKey = KeyFactory.createKey(keys);
return KeyFactory.createKey(new Object[] { parentLoader, packageName, domainKey, csKey, permsKey, principalsKey });
public static Object createKey(Object obj) { if (obj == null) { return NULL; } if (!obj.getClass().isArray()) { return obj; } if (obj instanceof Object[]) { return createKey((Object[])obj); } else if (obj instanceof int[]) { return createKey((int[])obj); } else if (obj instanceof float[]) { return createKey((float[])obj); } else if (obj instanceof long[]) { return createKey((long[])obj); } else if (obj instanceof double[]) { return createKey((double[])obj); } else if (obj instanceof byte[]) { return createKey((byte[])obj); } else if (obj instanceof char[]) { return createKey((char[])obj); } else if (obj instanceof boolean[]) { return createKey((boolean[])obj); } else if (obj instanceof short[]) { return createKey((short[])obj); } else { return obj; } }
private static void gatherAbstractMethods(Class<?> clazz, Set<Class> seen, Map<Object, Method> allMethods, Map<Object, Method> abstractMethods) { if (clazz == null || !seen.add(clazz)) { return; } for (Method method : clazz.getDeclaredMethods()) { Object key = KeyFactory.createKey(new Object[] { method.getName(), method.getReturnType(), method.getParameterTypes() }); if (!allMethods.containsKey(key)) { allMethods.put(key, method); if (Modifier.isAbstract(method.getModifiers())) { checkMemberAccess(method); checkParameterAccess(method, method.getParameterTypes()); if (!abstractMethods.containsKey(key)) { abstractMethods.put(key, method); } } } } gatherAbstractMethods(clazz.getSuperclass(), seen, allMethods, abstractMethods); for (Class iface : clazz.getInterfaces()) { gatherAbstractMethods(iface, seen, allMethods, abstractMethods); } }
mKey = KeyFactory.createKey(keys);
/** * Returns a search key factory, which is useful for implementing indexes * and queries. * * @param properties properties to build the search key from */ @SuppressWarnings("unchecked") public SearchKeyFactory<S> getSearchKeyFactory(OrderedProperty<S>[] properties) { // This KeyFactory makes arrays work as hashtable keys. Object key = KeyFactory.createKey(new Object[] {mCodecKey, properties}); synchronized (cCodecSearchKeyFactories) { SearchKeyFactory<S> factory = (SearchKeyFactory<S>) cCodecSearchKeyFactories.get(key); if (factory == null) { factory = generateSearchKeyFactory(properties); cCodecSearchKeyFactories.put(key, factory); } return factory; } }
/** * Returns a search key factory, which is useful for implementing indexes * and queries. * * @param properties properties to build the search key from */ @SuppressWarnings("unchecked") public SearchKeyFactory<S> getSearchKeyFactory(OrderedProperty<S>[] properties) { // This KeyFactory makes arrays work as hashtable keys. Object key = KeyFactory.createKey(new Object[] {mCodecKey, properties}); synchronized (cCodecSearchKeyFactories) { SearchKeyFactory<S> factory = (SearchKeyFactory<S>) cCodecSearchKeyFactories.get(key); if (factory == null) { factory = generateSearchKeyFactory(properties); cCodecSearchKeyFactories.put(key, factory); } return factory; } }
/** * Delegate class has a constructor that accepts a {@link DelegateSupport} * instance. * * <pre> * public <init>(DelegateSupport); * </pre> * */ public static <S extends Storable> Class<? extends S> getDelegateClass(Class<S> type, EnumSet<MasterFeature> features) throws SupportException { if (features == null) { features = EnumSet.noneOf(MasterFeature.class); } Object key = KeyFactory.createKey(new Object[] {type, features}); synchronized (cCache) { Class<? extends S> generatedClass = (Class<? extends S>) cCache.get(key); if (generatedClass != null) { return generatedClass; } generatedClass = new DelegateStorableGenerator<S>(type, features) .generateAndInjectClass(); cCache.put(key, generatedClass); return generatedClass; } }
/** * Delegate class has a constructor that accepts a {@link DelegateSupport} * instance. * * <pre> * public <init>(DelegateSupport); * </pre> * */ public static <S extends Storable> Class<? extends S> getDelegateClass(Class<S> type, EnumSet<MasterFeature> features) throws SupportException { if (features == null) { features = EnumSet.noneOf(MasterFeature.class); } Object key = KeyFactory.createKey(new Object[] {type, features}); synchronized (cCache) { Class<? extends S> generatedClass = (Class<? extends S>) cCache.get(key); if (generatedClass != null) { return generatedClass; } generatedClass = new DelegateStorableGenerator<S>(type, features) .generateAndInjectClass(); cCache.put(key, generatedClass); return generatedClass; } }
static <S extends Storable> Class<? extends S> getGeneratedClass(JDBCStorableInfo<S> info, boolean isMaster, boolean autoVersioning, boolean suppressReload) throws SupportException { Object key = KeyFactory.createKey(new Object[] { info, isMaster, autoVersioning, suppressReload}); synchronized (cCache) { Class<? extends S> generatedClass = (Class<? extends S>) cCache.get(key); if (generatedClass != null) { return generatedClass; } generatedClass = new JDBCStorableGenerator<S> (info, isMaster, autoVersioning, suppressReload) .generateAndInjectClass(); cCache.put(key, generatedClass); return generatedClass; } }
static <S extends Storable> Class<? extends S> getGeneratedClass(JDBCStorableInfo<S> info, boolean isMaster, boolean autoVersioning, boolean suppressReload) throws SupportException { Object key = KeyFactory.createKey(new Object[] { info, isMaster, autoVersioning, suppressReload}); synchronized (cCache) { Class<? extends S> generatedClass = (Class<? extends S>) cCache.get(key); if (generatedClass != null) { return generatedClass; } generatedClass = new JDBCStorableGenerator<S> (info, isMaster, autoVersioning, suppressReload) .generateAndInjectClass(); cCache.put(key, generatedClass); return generatedClass; } }
getSupportTrigger(Class<S> type, int blockSize) Object key = KeyFactory.createKey(new Object[] {type, blockSize});
/** * Returns a new or cached StubFactory. * * @param type main remote type * @param remoteInfo remote type as supported by remote server * @throws IllegalArgumentException if type is null or malformed */ public static <R extends Remote> StubFactory<R> getStubFactory(Class<R> type, RemoteInfo remoteInfo) throws IllegalArgumentException { Object key = KeyFactory.createKey(new Object[] {type, remoteInfo.getInfoId()}); synchronized (cCache) { StubFactory<R> factory = (StubFactory<R>) cCache.get(key); if (factory == null) { factory = new StubFactoryGenerator<R>(type, remoteInfo) .generateFactory(); cCache.put(key, factory); } return factory; } }
/** * Returns a new or cached SkeletonFactory for use with remote objects * served by batched methods. * * @param type * @param remoteInfo remote type as supported by remote server * @throws IllegalArgumentException if type is null or malformed */ public static <R extends Remote> SkeletonFactory<R> getSkeletonFactory(Class<R> type, RemoteInfo remoteInfo) { Object key = KeyFactory.createKey(new Object[] {type, remoteInfo.getInfoId()}); synchronized (cCache) { SkeletonFactory<R> factory = (SkeletonFactory<R>) cCache.get(key); if (factory == null) { factory = new SkeletonFactoryGenerator<R>(type, remoteInfo).generateFactory(); cCache.put(key, factory); } return factory; } }
/** * Returns a new or cached SkeletonFactory. * * @param type * @throws IllegalArgumentException if type is null or malformed */ public static <R extends Remote> SkeletonFactory<R> getSkeletonFactory(Class<R> type) throws IllegalArgumentException { RemoteInfo localInfo = RemoteIntrospector.examine(type); Object key = KeyFactory.createKey(new Object[] {type, localInfo.getInfoId()}); synchronized (cCache) { SkeletonFactory<R> factory = (SkeletonFactory<R>) cCache.get(key); if (factory == null) { factory = new SkeletonFactoryGenerator<R>(localInfo, type).generateFactory(); cCache.put(key, factory); } return factory; } }
private synchronized Class<?> syntheticRemoteType(String typeName, Set<Class> ifaceSet) { Object key = KeyFactory.createKey(new Object[] {typeName, ifaceSet});
Object key = KeyFactory.createKey(new Object[] {encodingStrategy, isMaster, layoutKey});
Object key = KeyFactory.createKey(new Object[] {encodingStrategy, isMaster, layoutKey});
synchronized (cCodecDecoders) { Object altLayoutKey = new LayoutKey(mLayout.getGeneration(generation)); Object key = KeyFactory.createKey