Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IGNITE-51 Changed CacheInterceptor API. Added CacheLazyEntry,
- Loading branch information
1 parent
736158d
commit 43c04a0
Showing
10 changed files
with
248 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,111 @@ | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one or more | |||
* contributor license agreements. See the NOTICE file distributed with | |||
* this work for additional information regarding copyright ownership. | |||
* The ASF licenses this file to You under the Apache License, Version 2.0 | |||
* (the "License"); you may not use this file except in compliance with | |||
* the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
|
|||
package org.apache.ignite.internal.processors.cache; | |||
|
|||
import org.apache.ignite.internal.util.typedef.internal.*; | |||
|
|||
import javax.cache.*; | |||
|
|||
/** | |||
* | |||
*/ | |||
public class CacheLazyEntry<K, V> implements Cache.Entry<K, V> { | |||
/** Cache context. */ | |||
private GridCacheContext<K, V> cctx; | |||
|
|||
/** Key cache object. */ | |||
private KeyCacheObject keyObj; | |||
|
|||
/** Cache object value. */ | |||
private CacheObject valObj; | |||
|
|||
/** Key. */ | |||
private K key; | |||
|
|||
/** Value. */ | |||
private V val; | |||
|
|||
/** | |||
* @param keyObj Key cache object. | |||
* @param valObj Cache object value. | |||
* @param cctx Cache context. | |||
*/ | |||
public CacheLazyEntry(KeyCacheObject keyObj, CacheObject valObj, GridCacheContext<K, V> cctx) { | |||
this.keyObj = keyObj; | |||
this.valObj = valObj; | |||
this.cctx = cctx; | |||
} | |||
|
|||
/** | |||
* @param key Key. | |||
* @param val Value. | |||
*/ | |||
public CacheLazyEntry(K key, V val) { | |||
this.key = key; | |||
this.val = val; | |||
} | |||
|
|||
/** | |||
* @param keyObj Key cache object. | |||
* @param valObj Cache object value. | |||
* @param key Key. | |||
* @param val Value. | |||
* @param cctx Cache context. | |||
*/ | |||
public CacheLazyEntry(KeyCacheObject keyObj, | |||
CacheObject valObj, | |||
K key, | |||
V val, | |||
GridCacheContext<K, V> cctx) { | |||
this.keyObj = keyObj; | |||
this.valObj = valObj; | |||
this.val = val; | |||
this.key = key; | |||
this.cctx = cctx; | |||
} | |||
|
|||
/** {@inheritDoc} */ | |||
@Override public K getKey() { | |||
if (key == null) | |||
key = CU.value(keyObj, cctx, true); | |||
|
|||
return key; | |||
} | |||
|
|||
/** {@inheritDoc} */ | |||
@Override public V getValue() { | |||
if (val == null) | |||
val = CU.value(valObj, cctx, true); | |||
|
|||
return val; | |||
} | |||
|
|||
/** {@inheritDoc} */ | |||
@SuppressWarnings("unchecked") | |||
@Override public <T> T unwrap(Class<T> cls) { | |||
if(cls.isAssignableFrom(getClass())) | |||
return cls.cast(this); | |||
|
|||
throw new IllegalArgumentException("Unwrapping to class is not supported: " + cls); | |||
} | |||
|
|||
/** {@inheritDoc} */ | |||
public String toString() { | |||
return "CacheEntry [key=" + getKey() + ", val=" + getValue() + ']'; | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.