Showing preview only (347K chars total). Download the full file or copy to clipboard to get everything.
Repository: jsr107/jsr107spec
Branch: master
Commit: 763de4830fbc
Files: 74
Total size: 322.4 KB
Directory structure:
gitextract_8lerwxfn/
├── .gitignore
├── LICENSE.txt
├── README.md
├── bnd.bnd
├── checkstyle/
│ ├── ClassHeader.txt
│ ├── checkstyle.xml
│ └── suppressions.xml
├── findbugs/
│ └── findbugs-exclude.xml
├── pom.xml
└── src/
└── main/
└── java/
└── javax/
└── cache/
├── Cache.java
├── CacheException.java
├── CacheManager.java
├── Caching.java
├── annotation/
│ ├── CacheDefaults.java
│ ├── CacheInvocationContext.java
│ ├── CacheInvocationParameter.java
│ ├── CacheKey.java
│ ├── CacheKeyGenerator.java
│ ├── CacheKeyInvocationContext.java
│ ├── CacheMethodDetails.java
│ ├── CachePut.java
│ ├── CacheRemove.java
│ ├── CacheRemoveAll.java
│ ├── CacheResolver.java
│ ├── CacheResolverFactory.java
│ ├── CacheResult.java
│ ├── CacheValue.java
│ ├── GeneratedCacheKey.java
│ └── package-info.java
├── configuration/
│ ├── CacheEntryListenerConfiguration.java
│ ├── CompleteConfiguration.java
│ ├── Configuration.java
│ ├── Factory.java
│ ├── FactoryBuilder.java
│ ├── MutableCacheEntryListenerConfiguration.java
│ ├── MutableConfiguration.java
│ ├── OptionalFeature.java
│ └── package-info.java
├── event/
│ ├── CacheEntryCreatedListener.java
│ ├── CacheEntryEvent.java
│ ├── CacheEntryEventFilter.java
│ ├── CacheEntryExpiredListener.java
│ ├── CacheEntryListener.java
│ ├── CacheEntryListenerException.java
│ ├── CacheEntryRemovedListener.java
│ ├── CacheEntryUpdatedListener.java
│ ├── EventType.java
│ └── package-info.java
├── expiry/
│ ├── AccessedExpiryPolicy.java
│ ├── CreatedExpiryPolicy.java
│ ├── Duration.java
│ ├── EternalExpiryPolicy.java
│ ├── ExpiryPolicy.java
│ ├── ModifiedExpiryPolicy.java
│ ├── TouchedExpiryPolicy.java
│ └── package-info.java
├── integration/
│ ├── CacheLoader.java
│ ├── CacheLoaderException.java
│ ├── CacheWriter.java
│ ├── CacheWriterException.java
│ ├── CompletionListener.java
│ ├── CompletionListenerFuture.java
│ └── package-info.java
├── management/
│ ├── CacheMXBean.java
│ ├── CacheStatisticsMXBean.java
│ └── package-info.java
├── package-info.java
├── processor/
│ ├── EntryProcessor.java
│ ├── EntryProcessorException.java
│ ├── EntryProcessorResult.java
│ ├── MutableEntry.java
│ └── package-info.java
└── spi/
├── CachingProvider.java
└── package-info.java
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
*.iml
*.ipr
*.iws
.idea
target
/.settings
/.project
/.classpath
/.checkstyle
================================================
FILE: LICENSE.txt
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed 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.
================================================
FILE: README.md
================================================
JSR107 (JCache)
===============
About
-----
*JCache* is the Java caching API. It was defined by JSR107. It defines a standard Java Caching API for use by developers and a standard SPI ("Service
Provider Interface") for use by implementers.
## Releases
* 10 May 2019: 1.1.1 Maintenance Release.
* 16 December 2017: 1.1.0 Maintenance Release.
* 18 March 2014: 1.0.0. Final Release. Unchanged from 1.0.0-RC1.
* 16 December 2013: 1.0.0-RC1. This is the version matching the final specification and is what is up on https://jcp.org/aboutJava/communityprocess/final/jsr107/index.html.
* 21 October 2013: 1.0.0-PFD for the cache-api and 0.11 for other artifacts.Proposed Final Draft
* 26 August 2013: 0.10 Third Public Review Draft
* 25 June 2013: 0.9 Second Public Review Draft
* 25 June 2013: 0.8 Public Review Draft
* 17 April 2013 0.7
* 12 February 2013 0.6
* 13 March 2012: 0.5 Early Draft Submission uses this release.
* December 2011: 0.4
* 12 October 2011: 0.3
* 16 August 2011: 0.2 Initial release
Maven snippet:
<dependency>
<groupId>javax.cache</groupId>
<artifactId>cache-api</artifactId>
<version>1.0.0</version>
</dependency>
Maven Central Releases
----------------------
Releases of jars for binaries, source and javadoc are available on Maven central.
Download the cache-api from <https://oss.sonatype.org/index.html#nexus-search;quick~javax-cache>
or use the following Maven snippet:
<dependency>
<groupId>javax.cache</groupId>
<artifactId>cache-api</artifactId>
<version>1.1.1</version>
</dependency>
Javadoc
-------
The JavaDoc is available as a jar with the releases. You can also find the JavaDoc [online](http://www.javadoc.io/doc/javax.cache/cache-api/1.1.1).
Specification
-------------
The specification is available online as a [Google Doc](https://docs.google.com/document/d/1ijduF_tmHvBaUS7VBBU2ZN8_eEBiFaXXg9OI0_ZxCrA/edit?usp=sharing).
Reference Implementation
------------------------
The reference implementation ("RI") source is available on [GitHub](https://github.com/jsr107/RI).
This implementation is not meant for production use. For that we would refer you
to one of the many high quality open source and commercial implementations of JCache. See the [official list of compatible implementions](https://jcp.org/aboutJava/communityprocess/implementations/jsr107/index.html),
and also the community maintained [JSR107 Test Zoo](https://github.com/cruftex/jsr107-test-zoo/blob/master/report.md).
The RI is there to ensure that the specification and API works as its only purpose.
For example, some things that we leave out:
- tiered storage. A simple on-heap store is used.
- replicated or distributed caching
Why did we do this? Because a much greater engineering effort, which gets put into the open source and commercial caches
which implement this API, is required to accomplish these things.
Having said that, the RI is Apache 2 and is a correct implementation of the spec. It can be used to create new cache
implementations.
Building From Source
--------------------
Building uses Maven in all modules. Maven 3.3.9 - 3.5.4 have been tested.
JCache is compatible with Java 6 to Java 11. We have tested building from Java 8 and Java 11.
See each module's README.md for build instructions.
Please add the following to your settings.xml to enable the CDI RI to be sucked down from JBoss.
<profiles>
<profile>
<id>jboss-public-repository</id>
<repositories>
<repository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Maven Repository Group</name>
<url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Maven Repository Group</name>
<url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
Testing Implementions of JSR107
-------------------------------
See the [TCK User Guide](https://docs.google.com/document/d/1w3Ugj_oEqjMlhpCkGQOZkd9iPf955ZWHAVdZzEwYYdU/edit?usp=sharing)
for instructions on how to use this TCK.
Mailing list
------------
Please join the mailing list if you're interested in using or developing the software: <http://groups.google.com/group/jsr107>
Issue tracker
-------------
Please log issues to: <https://github.com/jsr107/jsr107spec/issues>
User Questions
--------------
Some of the expert group monitor the tags "jcache" and "jsr107" on [stackoverflow](http://stackoverflow.com).
Contributing
------------
Admission to the Expert Group is closed, but please feel free to post to the mailing list.
License
-------
The API is available under the Apache 2.0 license.
The TCK is available under a restricted Standalone TCK (SATCK) license and must be
licensed from Oracle as is the usual case with JSRs.
The reference implementation is available under an Apache 2.0 license.
For details please read the license in each source code file.
Contributors
------------
This free, open source software was made possible by the JSR107 Expert Group who put many hours of hard work into it.
Copyright
---------
Copyright (c) JSR107 Expert Group
================================================
FILE: bnd.bnd
================================================
Export-Package: javax.cache;\
javax.cache.annotation;\
javax.cache.configuration;\
javax.cache.event;\
javax.cache.expiry;\
javax.cache.integration;\
javax.cache.management;\
javax.cache.processor;\
javax.cache.spi;\
Bundle-SymbolicName: javax.cache
Bundle-Version: ${project.version}
================================================
FILE: checkstyle/ClassHeader.txt
================================================
/**
* Copyright 2011-2016 Terracotta, Inc.
* Copyright 2011-2016 Oracle America Incorporated
*
* Licensed 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.
*/
================================================
FILE: checkstyle/checkstyle.xml
================================================
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
<module name="Checker">
<property name="severity" value="error"/>
<module name="Translation">
<property name="severity" value="error"/>
</module>
<module name="JavadocPackage">
<property name="allowLegacy" value="true"/>
</module>
<!-- Header
<module name="Header">
<property name="headerFile" value="${basedir}/checkstyle/ClassHeader.txt"/>
</module>-->
<module name="FileLength">
<property name="max" value="1400"/>
</module>
<!-- Duplicate Code -->
<module name="StrictDuplicateCode">
<property name="min" value="30"/>
</module>
<module name="NewlineAtEndOfFile">
<property name="lineSeparator" value="lf"/>
<property name="severity" value="warning"/>
</module>
<module name="FileTabCharacter"/>
<!-- Miscellaneous -->
<module name="RegexpSingleline">
<!-- . matches any character, so we need to escape it and use \. to match dots. -->
<property name="format" value="System\.out\.println"/>
</module>
<!-- Make sure commons logging is not used -->
<module name="RegexpSingleline">
<property name="format"
value="import org\.apache\.commons\.logging\.Log;"/>
</module>
<!-- Make sure we are using safe element.get methods everywhere -->
<module name="RegexpSingleline">
<!-- . matches any character, so we need to escape it and use \. to match dots. -->
<property name="format" value="[^entry]\\.getKey\\(\\)"/>
</module>
<module name="RegexpSingleline">
<!-- . matches any character, so we need to escape it and use \. to match dots. -->
<property name="format" value="[^entry]\\.getValue\\(\\)"/>
</module>
<module name="TreeWalker">
<!--<property name="cacheFile" value="checkstyle.cache}"/>-->
<!--Java 5 checks-->
<module name="MissingDeprecated">
<property name="severity" value="warning"/>
</module>
<!-- javadoc -->
<module name="JavadocType"/>
<module name="JavadocMethod">
<property name="scope" value="package"/>
<property name="allowMissingParamTags" value="true"/>
<property name="allowMissingThrowsTags" value="true"/>
<property name="allowMissingReturnTag" value="true"/>
<property name="allowUndeclaredRTE" value="true"/>
</module>
<module name="JavadocVariable">
<property name="scope" value="package"/>
</module>
<module name="JavadocStyle">
<property name="scope" value="public"/>
<property name="checkFirstSentence" value="false"/>
</module>
<!-- Naming Conventions -->
<module name="ConstantName"/>
<module name="MethodName"/>
<module name="StaticVariableName"/>
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
<module name="MemberName"/>
<module name="PackageName">
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
</module>
<module name="ParameterName"/>
<module name="TypeName"/>
<!-- Imports -->
<module name="AvoidStarImport"/>
<module name="IllegalImport"/>
<module name="RedundantImport"/>
<module name="UnusedImports">
<property name="processJavadoc" value="true"/>
</module>
<!-- Size Violations -->
<module name="LineLength">
<property name="max" value="150"/>
<property name="ignorePattern" value="^ *\* *"/>
</module>
<module name="MethodLength">
<property name="max" value="200"/>
<property name="tokens" value="METHOD_DEF"/>
</module>
<module name="MethodLength">
<property name="max" value="60"/>
<property name="tokens" value="CTOR_DEF"/>
</module>
<module name="ParameterNumber">
<property name="max" value="8"/>
<property name="tokens" value="METHOD_DEF"/>
</module>
<module name="ParameterNumber">
<property name="max" value="12"/>
<property name="tokens" value="CTOR_DEF"/>
</module>
<module name="AnonInnerLength">
<property name="max" value="25"/>
</module>
<module name="ExecutableStatementCount">
<property name="max" value="20"/>
<property name="tokens" value="CTOR_DEF, INSTANCE_INIT, STATIC_INIT"/>
</module>
<!-- Whitespace -->
<module name="EmptyForInitializerPad"/>
<module name="EmptyForIteratorPad"/>
<module name="MethodParamPad"/>
<module name="NoWhitespaceAfter">
<property name="allowLineBreaks" value="false"/>
</module>
<module name="NoWhitespaceBefore">
<property name="allowLineBreaks" value="false"/>
</module>
<module name="ParenPad"/>
<module name="GenericWhitespace"/>
<module name="WhitespaceAfter">
<property name="tokens" value="COMMA, SEMI"/>
</module>
<module name="WhitespaceAround">
<property name="tokens"
value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LCURLY, LE, LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, RCURLY, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN, STAR, STAR_ASSIGN"/>
<property name="allowEmptyConstructors" value="true"/>
<property name="allowEmptyMethods" value="true"/>
</module>
<module name="OperatorWrap">
<property name="tokens"
value="ASSIGN, DIV_ASSIGN, PLUS_ASSIGN, MINUS_ASSIGN, STAR_ASSIGN, MOD_ASSIGN, SR_ASSIGN, BSR_ASSIGN, SL_ASSIGN, BXOR_ASSIGN, BOR_ASSIGN, BAND_ASSIGN"/>
<property name="option" value="eol"/>
</module>
<!-- Modifiers -->
<module name="ModifierOrder">
<property name="severity" value="warning"/>
</module>
<module name="RedundantModifier">
<property name="severity" value="warning"/>
</module>
<!-- Blocks -->
<module name="EmptyBlock">
<property name="option" value="text"/>
<property name="tokens" value="LITERAL_CATCH"/>
</module>
<module name="EmptyBlock">
<property name="tokens"
value="LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_IF, LITERAL_FOR, LITERAL_TRY, LITERAL_WHILE, STATIC_INIT"/>
</module>
<module name="RightCurly">
<property name="option" value="same"/>
</module>
<module name="LeftCurly"/>
<module name="AvoidNestedBlocks">
<property name="allowInSwitchCase" value="true"/>
</module>
<!-- Coding Problems -->
<module name="ArrayTrailingComma"/>
<module name="CovariantEquals"/>
<module name="DeclarationOrder"/>
<module name="ParameterAssignment"/>
<module name="ExplicitInitialization"/>
<module name="DefaultComesLast"/>
<module name="FallThrough"/>
<module name="MultipleVariableDeclarations"/>
<module name="EmptyStatement"/>
<module name="HiddenField">
<property name="tokens" value="VARIABLE_DEF"/>
</module>
<module name="IllegalInstantiation">
<property name="classes" value="java.lang.Boolean"/>
</module>
<module name="IllegalTokenText">
<property name="tokens" value="NUM_INT,NUM_LONG"/>
<property name="format" value="^0[^lx]"/>
<property name="ignoreCase" value="true"/>
</module>
<module name="IllegalType">
<property name="ignoredMethodNames" value="getInstance"/>
<property name="tokens" value="PARAMETER_DEF, METHOD_DEF"/>
</module>
<module name="InnerAssignment"/>
<module name="JUnitTestCase"/>
<module name="ReturnCount">
<property name="max" value="5"/>
</module>
<module name="NestedIfDepth">
<property name="max" value="2"/>
</module>
<module name="NestedTryDepth">
<property name="max" value="2"/>
</module>
<module name="PackageDeclaration"/>
<module name="RedundantThrows">
<property name="severity" value="warning"/>
<property name="allowUnchecked" value="true"/>
</module>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>
<module name="StringLiteralEquality"/>
<module name="SuperClone"/>
<module name="SuperFinalize"/>
<module name="MagicNumber"/>
<module name="EqualsHashCode"/>
<module name="IllegalInstantiation"/>
<module name="InnerAssignment"/>
<module name="MissingSwitchDefault"/>
<!-- Class Design -->
<module name="FinalClass"/>
<module name="HideUtilityClassConstructor">
<property name="severity" value="warning"/>
</module>
<module name="InterfaceIsType"/>
<module name="MutableException"/>
<module name="ThrowsCount">
<property name="max" value="3"/>
</module>
<module name="VisibilityModifier">
<property name="protectedAllowed" value="true"/>
</module>
<!-- Metrics -->
<module name="BooleanExpressionComplexity">
<property name="max" value="4"/>
</module>
<module name="ClassDataAbstractionCoupling">
<property name="max" value="15"/>
</module>
<module name="ClassFanOutComplexity">
<property name="max" value="40"/>
</module>
<module name="CyclomaticComplexity">
<property name="severity" value="error"/>
<property name="max" value="12"/>
</module>
<module name="NPathComplexity">
<property name="max" value="50"/>
</module>
<module name="ArrayTypeStyle"/>
<module name="TodoComment">
<property name="format" value="WARNING"/>
</module>
<module name="TrailingComment"/>
<module name="UpperEll"/>
</module>
</module>
================================================
FILE: checkstyle/suppressions.xml
================================================
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
<suppressions>
<!-- Suppress duplicate checking of copyright notice -->
<suppress checks="StrictDuplicateCode" files=".java" lines="1-6"/>
<!--Includes Configuration -->
<suppress checks="StrictDuplicateCode" files="CacheMXBean.java" lines="34-150"/>
<suppress checks="StrictDuplicateCode" files="Configuration.java" lines="34-150"/>
<suppress checks="WhitespaceAround" files="[\\/]annotation[\\/]"/>
<suppress checks="ParenPad" files="[\\/]annotation[\\/]"/>
<suppress checks="MagicNumber" files=""/>
<suppress checks="NPathComplexity" files="MutableCacheEntryListenerConfiguration.java"/>
<suppress checks="CyclomaticComplexity" files="MutableConfiguration.java"/>
<suppress checks="NPathComplexity" files="MutableConfiguration.java"/>
<suppress checks="IllegalType" files="Caching.java"/>
<!--Exclude Clover instrumented sources-->
<suppress checks="" files="[\\/]src-instrumented[\\/]"/>
</suppressions>
================================================
FILE: findbugs/findbugs-exclude.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
<Match>
<!--Two false NO_NOTIFY_NOT_NOTIFYALL errors in CompletionListenerFuture-->
<Class name="javax.cache.integration.CompletionListenerFuture" />
</Match>
<Match>
<!--Non problematic SIC_INNER_SHOULD_BE_STATIC_ANON error in anonymous inner class in CachingProviderRegistry -->
<Class name="javax.cache.Caching$CachingProviderRegistry$1" />
</Match>
</FindBugsFilter>
================================================
FILE: pom.xml
================================================
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>7</version>
<!--Fixes broken Maven 3 warning-->
<relativePath/>
</parent>
<groupId>javax.cache</groupId>
<artifactId>cache-api</artifactId>
<version>1.1.2-SNAPSHOT</version>
<packaging>jar</packaging>
<name>JSR107 API and SPI</name>
<url>https://github.com/jsr107/jsr107spec</url>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<comments>A business-friendly OSS license</comments>
</license>
</licenses>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<!--This is only needed if you are using a CDI based implementation of the annotations support.
In CDI 1.1. we should be able to remove this dependency completely. -->
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>1.0-SP4</version>
<scope>provided</scope>
<optional>true</optional>
<exclusions>
<exclusion>
<artifactId>jsr250-api</artifactId>
<groupId>javax.annotation</groupId>
</exclusion>
<exclusion>
<artifactId>jboss-interceptors-api_1.1_spec</artifactId>
<groupId>org.jboss.spec.javax.interceptor</groupId>
</exclusion>
<exclusion>
<artifactId>javax.inject</artifactId>
<groupId>javax.inject</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<failOnError>false</failOnError>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.12</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>checkstyle</goal>
</goals>
</execution>
</executions>
<configuration>
<configLocation>${basedir}/checkstyle/checkstyle.xml
</configLocation>
<suppressionsLocation>${basedir}/checkstyle/suppressions.xml
</suppressionsLocation>
<headerLocation>${basedir}/checkstyle/ClassHeader.txt
</headerLocation>
<enableRSS>false</enableRSS>
<linkXRef>true</linkXRef>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<failOnViolation>true</failOnViolation>
<includeTestSourceDirectory>false</includeTestSourceDirectory>
<enableRulesSummary>true</enableRulesSummary>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifestFile>
${project.build.outputDirectory}/META-INF/MANIFEST.MF
</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<extensions>true</extensions>
<configuration>
<instructions>
<_include>bnd.bnd</_include>
<Include-Resource>{maven-resources}</Include-Resource>
</instructions>
</configuration>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.6</version>
<configuration>
</configuration>
</plugin>
<!--
To run a build with clover instrumentation:
mvn clean com.atlassian.maven.plugins:maven-clover2-plugin:setup install
To run the clover report:
mvn com.atlassian.maven.plugins:maven-clover2-plugin:clover
-->
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-clover2-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<cloverDatabase>${java.io.tmpdir}/clover/clover.db</cloverDatabase>
<singleCloverDatabase>true</singleCloverDatabase>
<license>insert license here</license>
<instrumentation>method</instrumentation>
<includesTestSourceRoots>false</includesTestSourceRoots>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<!--Only releases need to be signed. Use mvn -Prelease clean deploy to deploy releases -->
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<!-- run doclint on java8.
but do not complain if documentation is missing for parameter or return statement.
the profile enables automatically on java 8. this is backwards compatible,
if someone wants to build on java 7. -->
<profile>
<id>doclint-java8-all-but-missing</id>
<activation>
<jdk>[1.8,)</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<doclint>all</doclint>
<doclint>-missing</doclint>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<scm>
<connection>scm:git:git@github.com:juven/git-demo.git</connection>
<developerConnection>scm:git:git@github.com:juven/git-demo.git
</developerConnection>
<url>git@github.com:juven/git-demo.git</url>
</scm>
<!--Note: site URL repeated here to ensure correct deployment path-->
<distributionManagement>
<!--
The server id here defined must also appear in ~/.m2/settings.xml with username
-->
<repository>
<id>sourceforge-releases</id>
<name>Sourceforge Release Repository</name>
<url>http://oss.sonatype.org/service/local/staging/deploy/maven2</url>
</repository>
<snapshotRepository>
<id>sourceforge-snapshots</id>
<name>Sourceforge Snapshot Repository</name>
<url>http://oss.sonatype.org/content/repositories/sourceforge-snapshots</url>
</snapshotRepository>
</distributionManagement>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.6</version>
<reportSets>
<reportSet>
<reports><!-- select reports -->
<!--<report>index</report>-->
</reports>
</reportSet>
</reportSets>
</plugin>
<!--Use mvn compile site to generate this-->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.5</version>
<configuration>
<effort>Max</effort>
<threshold>Low</threshold>
<excludeFilterFile>${basedir}/findbugs/findbugs-exclude.xml
</excludeFilterFile>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.5</version>
</plugin>
</plugins>
</reporting>
</project>
================================================
FILE: src/main/java/javax/cache/Cache.java
================================================
/**
* Copyright 2011-2016 Terracotta, Inc.
* Copyright 2011-2016 Oracle America Incorporated
*
* Licensed 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 javax.cache;
import javax.cache.configuration.CacheEntryListenerConfiguration;
import javax.cache.configuration.Configuration;
import javax.cache.event.CacheEntryListener;
import javax.cache.event.CacheEntryRemovedListener;
import javax.cache.expiry.ExpiryPolicy;
import javax.cache.integration.CacheLoader;
import javax.cache.integration.CacheWriter;
import javax.cache.integration.CompletionListener;
import javax.cache.processor.EntryProcessor;
import javax.cache.processor.EntryProcessorException;
import javax.cache.processor.EntryProcessorResult;
import java.io.Closeable;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
/**
* A {@link Cache} is a Map-like data structure that provides temporary storage
* of application data.
* <p>
* Like {@link Map}s, {@link Cache}s
* <ol>
* <li>store key-value pairs, each referred to as an {@link Entry}</li>
* <li>allow use of Java Generics to improve application type-safety</li>
* <li>are {@link Iterable}</li>
* </ol>
* <p>
* Unlike {@link Map}s, {@link Cache}s
* <ol>
* <li>do not allow null keys or values. Attempts to use <code>null</code>
* will result in a {@link NullPointerException}</li>
* <li>provide the ability to read values from a
* {@link CacheLoader} (read-through-caching)
* when a value being requested is not in a cache</li>
* <li>provide the ability to write values to a
* {@link CacheWriter} (write-through-caching)
* when a value being created/updated/removed from a cache</li>
* <li>provide the ability to observe cache entry changes</li>
* <li>may capture and measure operational statistics</li>
* </ol>
* <p>
* A simple example of how to use a cache is:
* <pre><code>
* String cacheName = "sampleCache";
* CachingProvider provider = Caching.getCachingProvider();
* CacheManager manager = provider.getCacheManager();
* Cache<Integer, Date> cache = manager.getCache(cacheName, Integer.class,
* Date.class);
* Date value1 = new Date();
* Integer key = 1;
* cache.put(key, value1);
* Date value2 = cache.get(key);
* </code></pre>
*
* @param <K> the type of key
* @param <V> the type of value
* @author Greg Luck
* @author Yannis Cosmadopoulos
* @author Brian Oliver
* @since 1.0
*/
public interface Cache<K, V> extends Iterable<Cache.Entry<K, V>>, Closeable {
/**
* Gets an entry from the cache.
* <p>
* If the cache is configured to use read-through, and get would return null
* because the entry is missing from the cache, the Cache's {@link CacheLoader}
* is called in an attempt to load the entry.
*
* @param key the key whose associated value is to be returned
* @return the element, or null, if it does not exist.
* @throws IllegalStateException if the cache is {@link #isClosed()}
* @throws NullPointerException if the key is null
* @throws CacheException if there is a problem fetching the value
* @throws ClassCastException if the implementation is configured to perform
* runtime-type-checking, and the key or value
* types are incompatible with those that have been
* configured for the {@link Cache}
*/
V get(K key);
/**
* Gets a collection of entries from the {@link Cache}, returning them as
* {@link Map} of the values associated with the set of keys requested.
* <p>
* If the cache is configured read-through, and a get for a key would
* return null because an entry is missing from the cache, the Cache's
* {@link CacheLoader} is called in an attempt to load the entry. If an
* entry cannot be loaded for a given key, the key will not be present in
* the returned Map.
*
* @param keys The keys whose associated values are to be returned.
* @return A map of entries that were found for the given keys. Keys not found
* in the cache are not in the returned map.
* @throws NullPointerException if keys is null or if keys contains a null
* @throws IllegalStateException if the cache is {@link #isClosed()}
* @throws CacheException if there is a problem fetching the values
* @throws ClassCastException if the implementation is configured to perform
* runtime-type-checking, and the key or value
* types are incompatible with those that have been
* configured for the {@link Cache}
*/
Map<K, V> getAll(Set<? extends K> keys);
/**
* Determines if the {@link Cache} contains an entry for the specified key.
* <p>
* More formally, returns <tt>true</tt> if and only if this cache contains a
* mapping for a key <tt>k</tt> such that <tt>key.equals(k)</tt>.
* (There can be at most one such mapping.)</p>
* <p>
* If the cache is configured read-through the associated {@link CacheLoader}
* is not called. Only the cache is checked.
* </p>
* @param key key whose presence in this cache is to be tested.
* @return <tt>true</tt> if this map contains a mapping for the specified key
* @throws NullPointerException if key is null
* @throws IllegalStateException if the cache is {@link #isClosed()}
* @throws CacheException it there is a problem checking the mapping
* @throws ClassCastException if the implementation is configured to perform
* runtime-type-checking, and the key or value
* types are incompatible with those that have been
* configured for the {@link Cache}
* @see java.util.Map#containsKey(Object)
*/
boolean containsKey(K key);
/**
* Asynchronously loads the specified entries into the cache using the
* configured {@link CacheLoader} for the given keys.
* <p>
* If an entry for a key already exists in the Cache, a value will be loaded
* if and only if <code>replaceExistingValues</code> is true. If no loader
* is configured for the cache, no objects will be loaded. If a problem is
* encountered during the retrieving or loading of the objects,
* an exception is provided to the {@link CompletionListener}. Once the
* operation has completed, the specified CompletionListener is notified.
* <p>
* Implementations may choose to load multiple keys from the provided
* {@link Set} in parallel. Iteration however must not occur in parallel,
* thus allow for non-thread-safe {@link Set}s to be used.
* <p>
* The thread on which the completion listener is called is implementation
* dependent. An implementation may also choose to serialize calls to
* different CompletionListeners rather than use a thread per
* CompletionListener.
*
* @param keys the keys to load
* @param replaceExistingValues when true existing values in the Cache will
* be replaced by those loaded from a CacheLoader
* @param completionListener the CompletionListener (may be null)
* @throws NullPointerException if keys is null or if keys contains a null.
* @throws IllegalStateException if the cache is {@link #isClosed()}
* @throws CacheException thrown if there is a problem performing the
* load. This may also be thrown on calling if
* there are insufficient threads available to
* perform the load.
* @throws ClassCastException if the implementation is configured to perform
* runtime-type-checking, and the key or value
* types are incompatible with those that have been
* configured for the {@link Cache}
*/
void loadAll(Set<? extends K> keys, boolean replaceExistingValues,
CompletionListener completionListener);
/**
* Associates the specified value with the specified key in the cache.
* <p>
* If the {@link Cache} previously contained a mapping for the key, the old
* value is replaced by the specified value. (A cache <tt>c</tt> is said to
* contain a mapping for a key <tt>k</tt> if and only if {@link
* #containsKey(Object) c.containsKey(k)} would return <tt>true</tt>.)
* <p>
* If the cache is configured write-through the
* {@link CacheWriter#write(Cache.Entry)} method will be called.
* </p>
*
* @param key key with which the specified value is to be associated
* @param value value to be associated with the specified key
* @throws NullPointerException if key is null or if value is null
* @throws IllegalStateException if the cache is {@link #isClosed()}
* @throws CacheException if there is a problem doing the put
* @throws ClassCastException if the implementation is configured to perform
* runtime-type-checking, and the key or value
* types are incompatible with those that have been
* configured for the {@link Cache}
* @see java.util.Map#put(Object, Object)
* @see #getAndPut(Object, Object)
* @see #getAndReplace(Object, Object)
* @see CacheWriter#write
*/
void put(K key, V value);
/**
* Associates the specified value with the specified key in this cache,
* returning an existing value if one existed.
* <p>
* If the cache previously contained a mapping for
* the key, the old value is replaced by the specified value. (A cache
* <tt>c</tt> is said to contain a mapping for a key <tt>k</tt> if and only
* if {@link #containsKey(Object) c.containsKey(k)} would return
* <tt>true</tt>.)
* <p>
* The previous value is returned, or null if there was no value associated
* with the key previously.</p>
* <p>
* If the cache is configured write-through the associated
* {@link CacheWriter#write(Cache.Entry)} method will be called.
* </p>
*
* @param key key with which the specified value is to be associated
* @param value value to be associated with the specified key
* @return the value associated with the key at the start of the operation or
* null if none was associated
* @throws NullPointerException if key is null or if value is null
* @throws IllegalStateException if the cache is {@link #isClosed()}
* @throws CacheException if there is a problem doing the put
* @throws ClassCastException if the implementation is configured to perform
* runtime-type-checking, and the key or value
* types are incompatible with those that have been
* configured for the {@link Cache}
* @see #put(Object, Object)
* @see #getAndReplace(Object, Object)
* @see CacheWriter#write(Cache.Entry)
*/
V getAndPut(K key, V value);
/**
* Copies all of the entries from the specified map to the {@link Cache}.
* <p>
* The effect of this call is equivalent to that of calling
* {@link #put(Object, Object) put(k, v)} on this cache once for each mapping
* from key <tt>k</tt> to value <tt>v</tt> in the specified map.
* <p>
* The order in which the individual puts occur is undefined.
* <p>
* The behavior of this operation is undefined if entries in the cache
* corresponding to entries in the map are modified or removed while this
* operation is in progress. or if map is modified while the operation is in
* progress.
* <p>
* In Default Consistency mode, individual puts occur atomically but not
* the entire putAll. Listeners may observe individual updates.
* <p>
* If the cache is configured write-through the associated
* {@link CacheWriter#writeAll} method will be called.
* </p>
*
* @param map mappings to be stored in this cache
* @throws NullPointerException if map is null or if map contains null keys
* or values.
* @throws IllegalStateException if the cache is {@link #isClosed()}
* @throws CacheException if there is a problem doing the put.
* @throws ClassCastException if the implementation is configured to perform
* runtime-type-checking, and the key or value
* types are incompatible with those that have been
* configured for the {@link Cache}
* @see CacheWriter#writeAll
*/
void putAll(java.util.Map<? extends K, ? extends V> map);
/**
* Atomically associates the specified key with the given value if it is
* not already associated with a value.
* <p>
* This is equivalent to:
* <pre><code>
* if (!cache.containsKey(key)) {}
* cache.put(key, value);
* return true;
* } else {
* return false;
* }
* </code></pre>
* except that the action is performed atomically.
* <p>
* If the cache is configured write-through, and this method returns true,
* the associated {@link CacheWriter#write(Cache.Entry)} method will be called.
* </p>
* @param key key with which the specified value is to be associated
* @param value value to be associated with the specified key
* @return true if a value was set.
* @throws NullPointerException if key is null or value is null
* @throws IllegalStateException if the cache is {@link #isClosed()}
* @throws CacheException if there is a problem doing the put
* @throws ClassCastException if the implementation is configured to perform
* runtime-type-checking, and the key or value
* types are incompatible with those that have been
* configured for the {@link Cache}
* @see CacheWriter#write
*/
boolean putIfAbsent(K key, V value);
/**
* Removes the mapping for a key from this cache if it is present.
* <p>
* More formally, if this cache contains a mapping from key <tt>k</tt> to
* value <tt>v</tt> such that
* <code>(key==null ? k==null : key.equals(k))</code>, that mapping is removed.
* (The cache can contain at most one such mapping.)
*
* <p>Returns <tt>true</tt> if this cache previously associated the key,
* or <tt>false</tt> if the cache contained no mapping for the key.
* <p>
* The cache will not contain a mapping for the specified key once the
* call returns.
* <p>
* If the cache is configured write-through the associated
* {@link CacheWriter#delete(Object)} method will be called.
* </p>
* @param key key whose mapping is to be removed from the cache
* @return returns false if there was no matching key
* @throws NullPointerException if key is null
* @throws IllegalStateException if the cache is {@link #isClosed()}
* @throws CacheException if there is a problem doing the remove
* @throws ClassCastException if the implementation is configured to perform
* runtime-type-checking, and the key or value
* types are incompatible with those that have been
* configured for the {@link Cache}
* @see CacheWriter#delete
*/
boolean remove(K key);
/**
* Atomically removes the mapping for a key only if currently mapped to the
* given value.
* <p>
* This is equivalent to:
* <pre><code>
* if (cache.containsKey(key) && equals(cache.get(key), oldValue) {
* cache.remove(key);
* return true;
* } else {
* return false;
* }
* </code></pre>
* except that the action is performed atomically.
* <p>
* If the cache is configured write-through, and this method returns true,
* the associated {@link CacheWriter#delete(Object)} method will be called.
* </p>
* @param key key whose mapping is to be removed from the cache
* @param oldValue value expected to be associated with the specified key
* @return returns false if there was no matching key
* @throws NullPointerException if key is null
* @throws IllegalStateException if the cache is {@link #isClosed()}
* @throws CacheException if there is a problem doing the remove
* @throws ClassCastException if the implementation is configured to perform
* runtime-type-checking, and the key or value
* types are incompatible with those that have been
* configured for the {@link Cache}
* @see CacheWriter#delete
*/
boolean remove(K key, V oldValue);
/**
* Atomically removes the entry for a key only if currently mapped to some
* value.
* <p>
* This is equivalent to:
* <pre><code>
* if (cache.containsKey(key)) {
* V oldValue = cache.get(key);
* cache.remove(key);
* return oldValue;
* } else {
* return null;
* }
* </code></pre>
* except that the action is performed atomically.
* <p>
* If the cache is configured write-through the associated
* {@link CacheWriter#delete(Object)} method will be called.
* </p>
*
* @param key key with which the specified value is associated
* @return the value if one existed or null if no mapping existed for this key
* @throws NullPointerException if the specified key or value is null.
* @throws IllegalStateException if the cache is {@link #isClosed()}
* @throws CacheException if there is a problem during the remove
* @throws ClassCastException if the implementation is configured to perform
* runtime-type-checking, and the key or value
* types are incompatible with those that have been
* configured for the {@link Cache}
* @see CacheWriter#delete
*/
V getAndRemove(K key);
/**
* Atomically replaces the entry for a key only if currently mapped to a
* given value.
* <p>
* This is equivalent to:
* <pre><code>
* if (cache.containsKey(key) && equals(cache.get(key), oldValue)) {
* cache.put(key, newValue);
* return true;
* } else {
* return false;
* }
* </code></pre>
* except that the action is performed atomically.
* <p>
* If the cache is configured write-through, and this method returns true,
* the associated {@link CacheWriter#write(Cache.Entry)} method will be called.
* </p>
* @param key key with which the specified value is associated
* @param oldValue value expected to be associated with the specified key
* @param newValue value to be associated with the specified key
* @return <tt>true</tt> if the value was replaced
* @throws NullPointerException if key is null or if the values are null
* @throws IllegalStateException if the cache is {@link #isClosed()}
* @throws CacheException if there is a problem during the replace
* @throws ClassCastException if the implementation is configured to perform
* runtime-type-checking, and the key or value
* types are incompatible with those that have been
* configured for the {@link Cache}
* @see CacheWriter#write
*/
boolean replace(K key, V oldValue, V newValue);
/**
* Atomically replaces the entry for a key only if currently mapped to some
* value.
* <p>
* This is equivalent to
* <pre><code>
* if (cache.containsKey(key)) {
* cache.put(key, value);
* return true;
* } else {
* return false;
* }</code></pre>
* except that the action is performed atomically.
* <p>
* If the cache is configured write-through, and this method returns true,
* the associated {@link CacheWriter#write(Cache.Entry)} method will be called.
* </p>
* @param key the key with which the specified value is associated
* @param value the value to be associated with the specified key
* @return <tt>true</tt> if the value was replaced
* @throws NullPointerException if key is null or if value is null
* @throws IllegalStateException if the cache is {@link #isClosed()}
* @throws CacheException if there is a problem during the replace
* @throws ClassCastException if the implementation is configured to perform
* runtime-type-checking, and the key or value
* types are incompatible with those that have been
* configured for the {@link Cache}
* @see #getAndReplace(Object, Object)
* @see CacheWriter#write
*/
boolean replace(K key, V value);
/**
* Atomically replaces the value for a given key if and only if there is a
* value currently mapped by the key.
* <p>
* This is equivalent to
* <pre><code>
* if (cache.containsKey(key)) {
* V oldValue = cache.get(key);
* cache.put(key, value);
* return oldValue;
* } else {
* return null;
* }
* </code></pre>
* except that the action is performed atomically.
* <p>
* If the cache is configured write-through, and this method returns true,
* the associated {@link CacheWriter#write(Cache.Entry)} method will be called.
* </p>
* @param key key with which the specified value is associated
* @param value value to be associated with the specified key
* @return the previous value associated with the specified key, or
* <tt>null</tt> if there was no mapping for the key.
* @throws NullPointerException if key is null or if value is null
* @throws IllegalStateException if the cache is {@link #isClosed()}
* @throws CacheException if there is a problem during the replace
* @throws ClassCastException if the implementation is configured to perform
* runtime-type-checking, and the key or value
* types are incompatible with those that have been
* configured for the {@link Cache}
* @see java.util.concurrent.ConcurrentMap#replace(Object, Object)
* @see CacheWriter#write
*/
V getAndReplace(K key, V value);
/**
* Removes entries for the specified keys.
* <p>
* The order in which the individual entries are removed is undefined.
* <p>
* For every entry in the key set, the following are called:
* <ul>
* <li>any registered {@link CacheEntryRemovedListener}s</li>
* <li>if the cache is a write-through cache, the {@link CacheWriter}</li>
* </ul>
*
* @param keys the keys to remove
* @throws NullPointerException if keys is null or if it contains a null key
* @throws IllegalStateException if the cache is {@link #isClosed()}
* @throws CacheException if there is a problem during the remove
* @throws ClassCastException if the implementation is configured to perform
* runtime-type-checking, and the key or value
* types are incompatible with those that have been
* configured for the {@link Cache}
* @see CacheWriter#deleteAll
*/
void removeAll(Set<? extends K> keys);
/**
* Removes all of the mappings from this cache.
* <p>
* The order that the individual entries are removed is undefined.
* <p>
* For every mapping that exists the following are called:
* <ul>
* <li>any registered {@link CacheEntryRemovedListener}s</li>
* <li>if the cache is a write-through cache, the {@link CacheWriter}</li>
* </ul>
* If the cache is empty, the {@link CacheWriter} is not called.
* <p>
* This is potentially an expensive operation as listeners are invoked.
* Use {@link #clear()} to avoid this.
*
* @throws IllegalStateException if the cache is {@link #isClosed()}
* @throws CacheException if there is a problem during the remove
* @see #clear()
* @see CacheWriter#deleteAll
*/
void removeAll();
/**
* Clears the contents of the cache, without notifying listeners or
* {@link CacheWriter}s.
*
* @throws IllegalStateException if the cache is {@link #isClosed()}
* @throws CacheException if there is a problem during the clear
*/
void clear();
/**
* Provides a standard way to access the configuration of a cache using
* JCache configuration or additional proprietary configuration.
* <p>
* The returned value must be immutable.
* <p>
* If the provider's implementation does not support the specified class,
* the {@link IllegalArgumentException} is thrown.
*
* @param <C> the type of the Configuration
* @param clazz the configuration interface or class to return. This includes
* {@link Configuration}.class and
* {@link javax.cache.configuration.CompleteConfiguration}s.
* @return the requested implementation of {@link Configuration}
* @throws IllegalArgumentException if the caching provider doesn't support
* the specified class.
*/
<C extends Configuration<K, V>> C getConfiguration(Class<C> clazz);
/**
* Invokes an {@link EntryProcessor} against the {@link Entry} specified by
* the provided key.
*
* @param <T> the type of the return value
* @param key the key to the entry
* @param entryProcessor the {@link EntryProcessor} to invoke
* @param arguments additional arguments to pass to the
* {@link EntryProcessor}
* @return the result of the processing, if any, defined by the
* {@link EntryProcessor} implementation
* @throws NullPointerException if key or {@link EntryProcessor} is null
* @throws IllegalStateException if the cache is {@link #isClosed()}
* @throws ClassCastException if the implementation is configured to perform
* runtime-type-checking, and the key or value
* types are incompatible with those that have been
* configured for the {@link Cache}
* @throws EntryProcessorException if an exception is thrown by the {@link
* EntryProcessor}, a Caching Implementation
* must wrap any {@link Exception} thrown
* wrapped in an {@link EntryProcessorException}.
* @see EntryProcessor
*/
<T> T invoke(K key,
EntryProcessor<K, V, T> entryProcessor,
Object... arguments) throws EntryProcessorException;
/**
* Invokes an {@link EntryProcessor} against the set of {@link Entry}s
* specified by the set of keys.
* <p>
* The order that the entries for the keys are processed is undefined.
* Implementations may choose to process the entries in any order, including
* concurrently. Furthermore there is no guarantee implementations will
* use the same {@link EntryProcessor} instance to process each entry, as
* the case may be in a non-local cache topology.
* <p>
* The result of executing the {@link EntryProcessor} is returned as a
* {@link Map} of {@link EntryProcessorResult}s, one result per key. Should the
* {@link EntryProcessor} or Caching implementation throw an exception, the
* exception is wrapped and re-thrown when a call to
* {@link javax.cache.processor.EntryProcessorResult#get()} is made.
*
* @param <T> the type of the return value
* @param keys the set of keys for entries to process
* @param entryProcessor the {@link EntryProcessor} to invoke
* @param arguments additional arguments to pass to the
* {@link EntryProcessor}
* @return the map of {@link EntryProcessorResult}s of the processing per key,
* if any, defined by the {@link EntryProcessor} implementation. No mappings
* will be returned for {@link EntryProcessor}s that return a
* <code>null</code> value for a key.
* @throws NullPointerException if keys or {@link EntryProcessor} are null
* @throws IllegalStateException if the cache is {@link #isClosed()}
* @throws ClassCastException if the implementation is configured to perform
* runtime-type-checking, and the key or value
* types are incompatible with those that have been
* configured for the {@link Cache}
* @see EntryProcessor
*/
<T> Map<K, EntryProcessorResult<T>> invokeAll(Set<? extends K> keys,
EntryProcessor<K, V, T>
entryProcessor,
Object... arguments);
/**
* Return the name of the cache.
*
* @return the name of the cache.
*/
String getName();
/**
* Gets the {@link CacheManager} that owns and manages the {@link Cache}.
*
* @return the manager or <code>null</code> if the {@link Cache} is not
* managed
*/
CacheManager getCacheManager();
/**
* Closing a {@link Cache} signals to the {@link CacheManager} that produced or
* owns the {@link Cache} that it should no longer be managed. At this
* point in time the {@link CacheManager}:
* <ul>
* <li>must close and release all resources being coordinated on behalf of the
* Cache by the {@link CacheManager}. This includes calling the <code>close
* </code> method on configured {@link CacheLoader},
* {@link CacheWriter}, registered {@link CacheEntryListener}s and
* {@link ExpiryPolicy} instances that implement the java.io.Closeable
* interface.
* <li>prevent events being delivered to configured {@link CacheEntryListener}s
* registered on the {@link Cache}
* </li>
* <li>not return the name of the Cache when the CacheManager getCacheNames()
* method is called</li>
* </ul>
* Once closed any attempt to use an operational method on a Cache will throw an
* {@link IllegalStateException}.
* <p>
* Closing a Cache does not necessarily destroy the contents of a Cache.
* It simply signals to the owning CacheManager that the Cache is no longer
* required by the application and that future uses of a specific Cache instance
* should not be permitted.
* <p>
* Depending on the implementation and Cache topology,
* (e.g. a storage-backed or distributed cache), the contents of a closed Cache
* may still be available and accessible by other applications, or, in fact, via
* the Cache Manager that previously owned the Cache, if an application calls
* getCache at some point in the future.
*
* @throws SecurityException when the operation could not be performed
* due to the current security settings
*/
void close();
/**
* Determines whether this Cache instance has been closed. A Cache is
* considered closed if;
* <ol>
* <li>the {@link #close()} method has been called</li>
* <li>the associated {@link #getCacheManager()} has been closed, or</li>
* <li>the Cache has been removed from the associated
* {@link #getCacheManager()}</li>
* </ol>
* <p>
* This method generally cannot be called to determine whether a Cache instance
* is valid or invalid. A typical client can determine that a Cache is invalid
* by catching any exceptions that might be thrown when an operation is
* attempted.
*
* @return true if this Cache instance is closed; false if it is still open
*/
boolean isClosed();
/**
* Provides a standard way to access the underlying concrete caching
* implementation to provide access to further, proprietary features.
* <p>
* If the provider's implementation does not support the specified class,
* the {@link IllegalArgumentException} is thrown.
*
* @param <T> the type of the underlying {@link Cache} implementation
* @param clazz the proprietary class or interface of the underlying concrete
* cache. It is this type that is returned.
* @return an instance of the underlying concrete cache
* @throws IllegalArgumentException if the caching provider doesn't support
* the specified class.
* @throws SecurityException when the operation could not be performed
* due to the current security settings
*/
<T> T unwrap(java.lang.Class<T> clazz);
/**
* Registers a {@link CacheEntryListener}. The supplied
* {@link CacheEntryListenerConfiguration} is used to instantiate a listener
* and apply it to those events specified in the configuration.
*
* @param cacheEntryListenerConfiguration
* a factory and related configuration
* for creating the listener
* @throws IllegalArgumentException is the same CacheEntryListenerConfiguration
* is used more than once
* @throws IllegalStateException if the cache is {@link #isClosed()}
* @see CacheEntryListener
*/
void registerCacheEntryListener(
CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration);
/**
* Deregisters a listener, using the
* {@link CacheEntryListenerConfiguration} that was used to register it.
* <p>
* Both listeners registered at configuration time,
* and those created at runtime with {@link #registerCacheEntryListener} can
* be deregistered.
*
* @param cacheEntryListenerConfiguration
* the factory and related configuration
* that was used to create the
* listener
* @throws IllegalStateException if the cache is {@link #isClosed()}
*/
void deregisterCacheEntryListener(CacheEntryListenerConfiguration<K, V>
cacheEntryListenerConfiguration);
/**
* {@inheritDoc}
* <p>
* The ordering of iteration over entries is undefined.
* <p>
* During iteration, any entries that are removed will have their appropriate
* CacheEntryRemovedListeners notified.
* <p>
* When iterating over a cache it must be assumed that the underlying
* cache may be changing, with entries being added, removed, evicted
* and expiring. {@link java.util.Iterator#next()} may therefore return
* null.
*
* @throws IllegalStateException if the cache is {@link #isClosed()}
*/
Iterator<Cache.Entry<K, V>> iterator();
/**
* A cache entry (key-value pair).
*/
interface Entry<K, V> {
/**
* Returns the key corresponding to this entry.
*
* @return the key corresponding to this entry
*/
K getKey();
/**
* Returns the value stored in the cache when this entry was created.
*
* @return the value corresponding to this entry
*/
V getValue();
/**
* Provides a standard way to access the underlying concrete cache entry
* implementation in order to provide access to further, proprietary features.
* <p>
* If the provider's implementation does not support the specified class,
* the {@link IllegalArgumentException} is thrown.
*
* @param <T> the type of the underlying {@link Entry} implementation
* @param clazz the proprietary class or interface of the underlying
* concrete cache. It is this type that is returned.
* @return an instance of the underlying concrete cache
* @throws IllegalArgumentException if the caching provider doesn't support
* the specified class.
*/
<T> T unwrap(Class<T> clazz);
}
}
================================================
FILE: src/main/java/javax/cache/CacheException.java
================================================
/**
* Copyright 2011-2016 Terracotta, Inc.
* Copyright 2011-2016 Oracle America Incorporated
*
* Licensed 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 javax.cache;
/**
* Thrown to indicate an exception has occurred in the Cache.
* <p>
* This is the base class for all cache exceptions.
*
* @author Greg Luck
* @since 1.0
*/
public class CacheException extends RuntimeException {
private static final long serialVersionUID = 1L;
/**
* Constructs a new CacheException.
*
* @since 1.0
*/
public CacheException() {
super();
}
/**
* Constructs a new CacheException with a message string.
*
* @param message the detail message. The detail message is saved for
* later retrieval by the {@link #getMessage()} method.
* @since 1.0
*/
public CacheException(String message) {
super(message);
}
/**
* Constructs a CacheException with a message string, and
* a base exception
*
* @param message the detail message. The detail message is saved for
* later retrieval by the {@link #getMessage()} method.
* @param cause the cause (that is saved for later retrieval by the
* {@link #getCause()} method). (A <tt>null</tt> value is
* permitted, and indicates that the cause is nonexistent or
* unknown.)
* @since 1.0
*/
public CacheException(String message, Throwable cause) {
super(message, cause);
}
/**
* Constructs a new CacheException with the specified cause and a
* detail message of <tt>(cause==null ? null : cause.toString())</tt>
* (that typically contains the class and detail message of
* <tt>cause</tt>). This constructor is useful for runtime exceptions
* that are little more than wrappers for other throwables.
*
* @param cause the cause (that is saved for later retrieval by the
* {@link #getCause()} method). (A <tt>null</tt> value is
* permitted, and indicates that the cause is nonexistent or
* unknown.)
* @since 1.0
*/
public CacheException(Throwable cause) {
super(cause);
}
}
================================================
FILE: src/main/java/javax/cache/CacheManager.java
================================================
/**
* Copyright 2011-2016 Terracotta, Inc.
* Copyright 2011-2016 Oracle America Incorporated
*
* Licensed 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 javax.cache;
import javax.cache.configuration.Configuration;
import javax.cache.management.CacheMXBean;
import javax.cache.spi.CachingProvider;
import java.io.Closeable;
import java.lang.management.ManagementFactory;
import java.net.URI;
import java.util.Properties;
/**
* A {@link CacheManager} provides a means of establishing, configuring,
* acquiring, closing and destroying uniquely named {@link Cache}s.
* <p>
* {@link Cache}s produced and owned by a {@link CacheManager} typically share
* common infrastructure, for example, a common {@link ClassLoader} and
* implementation specific {@link Properties}.
* <p>
* Implementations of {@link CacheManager} may additionally provide and share
* external resources between the {@link Cache}s being managed, for example,
* the content of the managed {@link Cache}s may be stored in the same cluster.
* <p>
* By default {@link CacheManager} instances are typically acquired through the
* use of a {@link CachingProvider}. Implementations however may additionally
* provide other mechanisms to create, acquire, manage and configure
* {@link CacheManager}s, including:
* <ul>
* <li>making use of {@link java.util.ServiceLoader}s,</li>
* <li>permitting the use of the <code>new</code> operator to create a
* concrete implementation, </li>
* <li>providing the construction through the use of one or more
* builders, and</li>
* <li>through the use of dependency injection.</li>
* </ul>
* <p>
* The default {@link CacheManager} however can always be acquired using the
* default configured {@link CachingProvider} obtained by the {@link Caching}
* class. For example:
* <pre><code>
* CachingProvider provider = Caching.getCachingProvider();
* CacheManager manager = provider.getCacheManager();
* </code></pre>
* <p>
* Within a Java process {@link CacheManager}s and the {@link Cache}s they
* manage are scoped and uniquely identified by a {@link URI}, the meaning of
* which is implementation specific. To obtain the default {@link URI},
* {@link ClassLoader} and {@link Properties} for an implementation, consult the
* {@link CachingProvider} class.
*
*
* @author Greg Luck
* @author Yannis Cosmadopoulos
* @author Brian Oliver
* @see Caching
* @see CachingProvider
* @see Cache
* @since 1.0
*
*/
public interface CacheManager extends Closeable {
/**
* Get the {@link CachingProvider} that created and is responsible for
* the {@link CacheManager}.
*
* @return the CachingProvider or <code>null</code> if the {@link CacheManager}
* was created without using a {@link CachingProvider}
*/
CachingProvider getCachingProvider();
/**
* Get the URI of the {@link CacheManager}.
*
* @return the URI of the {@link CacheManager}
*/
URI getURI();
/**
* Get the {@link ClassLoader} used by the {@link CacheManager}.
*
* @return the {@link ClassLoader} used by the {@link CacheManager}
*/
ClassLoader getClassLoader();
/**
* Get the {@link Properties} that were used to create this
* {@link CacheManager}.
* <p>
* Implementations are not required to re-configure the
* {@link CacheManager} should modifications to the returned
* {@link Properties} be made.
*
* @return the Properties used to create the {@link CacheManager}
*/
Properties getProperties();
/**
* Creates a named {@link Cache} at runtime.
* <p>
* If a {@link Cache} with the specified name is known to the {@link
* CacheManager}, a CacheException is thrown.
* <p>
* If a {@link Cache} with the specified name is unknown the {@link
* CacheManager}, one is created according to the provided {@link Configuration}
* after which it becomes managed by the {@link CacheManager}.
* <p>
* Prior to a {@link Cache} being created, the provided {@link Configuration}s is
* validated within the context of the {@link CacheManager} properties and
* implementation.
* <p>
* Implementers should be aware that the {@link Configuration} may be used to
* configure other {@link Cache}s.
* <p>
* There's no requirement on the part of a developer to call this method for
* each {@link Cache} an application may use. Implementations may support
* the use of declarative mechanisms to pre-configure {@link Cache}s, thus
* removing the requirement to configure them in an application. In such
* circumstances a developer may simply call either the
* {@link #getCache(String)} or {@link #getCache(String, Class, Class)}
* methods to acquire a previously established or pre-configured {@link Cache}.
*
* @param <K> the type of key
* @param <V> the type of value
* @param <C> the type of the Configuration
* @param cacheName the name of the {@link Cache}. Names should not use
* forward slashes(/) or colons(:), or start with
* java. or javax. These prefixes are reserved.
* @param configuration a {@link Configuration} for the {@link Cache}
* @throws IllegalStateException if the {@link CacheManager}
* {@link #isClosed()}
* @throws CacheException if there was an error configuring the
* {@link Cache}, which includes trying
* to create a cache that already exists.
* @throws IllegalArgumentException if the configuration is invalid
* @throws UnsupportedOperationException if the configuration specifies
* an unsupported feature
* @throws NullPointerException if the cache configuration or name
* is null
* @throws SecurityException when the operation could not be performed
* due to the current security settings
*/
<K, V, C extends Configuration<K, V>> Cache<K, V> createCache(String cacheName,
C configuration)
throws IllegalArgumentException;
/**
* Looks up a managed {@link Cache} given its name.
* <p>
* Use this method to check runtime key and value types.
* <p>
* Use {@link #getCache(String)} where this check is not required.
* <p>
* Implementations must ensure that the key and value types are the same as
* those configured for the {@link Cache} prior to returning from this method.
* <p>
* Implementations may further perform type checking on mutative cache operations
* and throw a {@link ClassCastException} if these checks fail.
* <p>
* Implementations that support declarative mechanisms for pre-configuring
* {@link Cache}s may return a pre-configured {@link Cache} instead of
* <code>null</code>.
*
* @param <K> the type of key
* @param <V> the type of value
* @param cacheName the name of the managed {@link Cache} to acquire
* @param keyType the expected {@link Class} of the key
* @param valueType the expected {@link Class} of the value
* @return the Cache or null if it does exist or can't be pre-configured
* @throws IllegalStateException if the {@link CacheManager}
* is {@link #isClosed()}
* @throws ClassCastException if the specified key and/or value types are
* incompatible with the configured cache.
* @throws NullPointerException if either keyType or classType is null.
* @throws SecurityException when the operation could not be performed
* due to the current security settings
*/
<K, V> Cache<K, V> getCache(String cacheName, Class<K> keyType,
Class<V> valueType);
/**
* Looks up a managed {@link Cache} given its name.
* <p>
* This method may only be used to acquire {@link Cache}s that were
* configured without runtime key and value types, or were configured
* to use Object.class key and value types.
* <p>
* Use the {@link #getCache(String, Class, Class)} method to acquire
* {@link Cache}s with a check that the supplied key and value type parameters
* match the runtime types.
* <p>
* Implementations that support declarative mechanisms for pre-configuring
* {@link Cache}s may return a pre-configured {@link Cache} instead of
* <code>null</code>.
*
* @param <K> the type of key
* @param <V> the type of value
* @param cacheName the name of the cache to look for
* @return the Cache or null if it does exist or can't be pre-configured
* @throws IllegalStateException if the CacheManager is {@link #isClosed()}
* @throws SecurityException when the operation could not be performed
* due to the current security settings
* @see #getCache(String, Class, Class)
*/
<K, V> Cache<K, V> getCache(String cacheName);
/**
* Obtains an {@link Iterable} over the names of {@link Cache}s managed by the
* {@link CacheManager}.
* <p>
* {@link java.util.Iterator}s returned by the {@link Iterable} are immutable.
* If the {@link Cache}s managed by the {@link CacheManager} change,
* the {@link Iterable} and associated {@link java.util.Iterator}s are not
* affected.
* <p>
* {@link java.util.Iterator}s returned by the {@link Iterable} may not provide
* all of the {@link Cache}s managed by the {@link CacheManager}. For example:
* Internally defined or platform specific {@link Cache}s that may be accessible
* by a call to {@link #getCache(String)} or {@link #getCache(String, Class,
* Class)} may not be present in an iteration.
*
* @return an {@link Iterable} over the names of managed {@link Cache}s.
* @throws IllegalStateException if the {@link CacheManager}
* is {@link #isClosed()}
* @throws SecurityException when the operation could not be performed
* due to the current security settings
*/
Iterable<String> getCacheNames();
/**
* Destroys a specifically named and managed {@link Cache}. Once destroyed
* a new {@link Cache} of the same name but with a different {@link
* Configuration} may be configured.
* <p>
* This is equivalent to the following sequence of method calls:
* <ol>
* <li>{@link Cache#clear()}</li>
* <li>{@link Cache#close()}</li>
* </ol>
* followed by allowing the name of the {@link Cache} to be used for other
* {@link Cache} configurations.
* <p>
* From the time this method is called, the specified {@link Cache} is not
* available for operational use. An attempt to call an operational method on
* the {@link Cache} will throw an {@link IllegalStateException}.
*
* @param cacheName the cache to destroy
* @throws IllegalStateException if the {@link CacheManager}
* {@link #isClosed()}
* @throws NullPointerException if cacheName is null
* @throws SecurityException when the operation could not be performed
* due to the current security settings
*/
void destroyCache(String cacheName);
/**
* Controls whether management is enabled. If enabled the {@link CacheMXBean}
* for each cache is registered in the platform MBean server. The platform
* MBeanServer is obtained using
* {@link ManagementFactory#getPlatformMBeanServer()}.
* <p>
* Management information includes the name and configuration information for
* the cache.
* <p>
* Each cache's management object must be registered with an ObjectName that
* is unique and has the following type and attributes:
* <p>
* Type:
* <code>javax.cache:type=CacheConfiguration</code>
* <p>
* Required Attributes:
* <ul>
* <li>CacheManager the URI of the CacheManager
* <li>Cache the name of the Cache
* </ul>
*
* @param cacheName the name of the cache to register
* @param enabled true to enable management, false to disable.
* @throws IllegalStateException if the {@link CacheManager} or
* {@link Cache} {@link #isClosed()}
* @throws SecurityException when the operation could not be performed
* due to the current security settings
*/
void enableManagement(String cacheName, boolean enabled);
/**
* Enables or disables statistics gathering for a managed {@link Cache} at
* runtime.
* <p>
* Each cache's statistics object must be registered with an ObjectName that
* is unique and has the following type and attributes:
* <p>
* Type:
* <code>javax.cache:type=CacheStatistics</code>
* <p>
* Required Attributes:
* <ul>
* <li>CacheManager the URI of the CacheManager
* <li>Cache the name of the Cache
* </ul>
*
* @param cacheName the name of the cache to register
* @param enabled true to enable statistics, false to disable.
* @throws IllegalStateException if the {@link CacheManager} or
* {@link Cache} {@link #isClosed()}
* @throws NullPointerException if cacheName is null
* @throws SecurityException when the operation could not be performed
* due to the current security settings
*/
void enableStatistics(String cacheName, boolean enabled);
/**
* Closes the {@link CacheManager}.
* <p>
* For each {@link Cache} managed by the {@link CacheManager}, the
* {@link Cache#close()} method will be invoked, in no guaranteed order.
* <p>
* If a {@link Cache#close()} call throws an exception, the exception will be
* ignored.
* <p>
* After executing this method, the {@link #isClosed()} method will return
* <code>true</code>.
* <p>
* All attempts to close a previously closed {@link CacheManager} will be
* ignored.
*
* Closing a CacheManager does not necessarily destroy the contents of the
* Caches in the CacheManager.
* <p>
* It simply signals that the CacheManager is no longer required by the application
* and that future uses of a specific CacheManager instance should not be permitted.
* <p>
* Depending on the implementation and Cache topology,
* (e.g. a storage-backed or distributed cache), the contents of closed Caches
* previously referenced by the CacheManager, may still be available and accessible
* by other applications.
*
* @throws SecurityException when the operation could not be performed due to the
* current security settings
*/
void close();
/**
* Determines whether the {@link CacheManager} instance has been closed. A
* {@link CacheManager} is considered closed if;
* <ol>
* <li>the {@link #close()} method has been called</li>
* <li>the associated {@link #getCachingProvider()} has been closed, or</li>
* <li>the {@link CacheManager} has been closed using the associated
* {@link #getCachingProvider()}</li>
* </ol>
* <p>
* This method generally cannot be called to determine whether the
* {@link CacheManager} is valid or invalid. A typical client can determine
* that a {@link CacheManager} is invalid by catching any exceptions that
* might be thrown when an operation is attempted.
*
* @return true if this {@link CacheManager} instance is closed; false if it
* is still open
*/
boolean isClosed();
/**
* Provides a standard mechanism to access the underlying concrete caching
* implementation to provide access to further, proprietary features.
* <p>
* If the provider's implementation does not support the specified class,
* the {@link IllegalArgumentException} is thrown.
*
* @param <T> the type of the underlying {@link CacheManager}
* @param clazz the proprietary class or interface of the underlying concrete
* {@link CacheManager}. It is this type that is returned.
* @return an instance of the underlying concrete {@link CacheManager}
* @throws IllegalArgumentException if the caching provider doesn't support the
* specified class.
* @throws SecurityException when the operation could not be performed
* due to the current security settings
*/
<T> T unwrap(java.lang.Class<T> clazz);
}
================================================
FILE: src/main/java/javax/cache/Caching.java
================================================
/**
* Copyright 2011-2016 Terracotta, Inc.
* Copyright 2011-2016 Oracle America Incorporated
*
* Licensed 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 javax.cache;
import javax.cache.spi.CachingProvider;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.ServiceLoader;
import java.util.WeakHashMap;
/**
* The {@link Caching} class provides a convenient means for an application to
* acquire an appropriate {@link CachingProvider} implementation.
* <p>
* While defined as part of the specification, its use is not required.
* Applications and/or containers may instead choose to directly instantiate a
* {@link CachingProvider} implementation based on implementation specific
* instructions.
* <p>
* When using the {@link Caching} class, {@link CachingProvider} implementations
* are automatically discovered when they follow the conventions outlined by the
* Java Development Kit {@link ServiceLoader} class.
* <p>
* Although automatically discovered, applications that choose to use this class
* should not make assumptions regarding the order in which implementations are
* returned by the {@link #getCachingProviders()} or
* {@link #getCachingProviders(ClassLoader)} methods.
* <p>
* For a {@link CachingProvider} to be automatically discoverable by the
* {@link Caching} class, the fully qualified class name of the
* {@link CachingProvider} implementation must be declared in the following
* file:
* <pre>
* META-INF/services/javax.cache.spi.CachingProvider
* </pre>
* This file must be resolvable via the class path.
* <p>
* For example, in the reference implementation the contents of this file are:
* <code>org.jsr107.ri.RICachingProvider</code>
* <p>
* Alternatively when the fully qualified class name of a
* {@link CachingProvider} implementation is specified using the system property
* <code>javax.cache.spi.cachingprovider</code>, that implementation will be used
* as the default {@link CachingProvider}.
* <p>
* All {@link CachingProvider}s that are automatically detected or explicitly
* declared and loaded by the {@link Caching} class are maintained in an
* internal registry. Consequently when a previously loaded
* {@link CachingProvider} is requested, it will be simply returned from the
* internal registry, without reloading and/or instantiating the said
* implementation again.
* <p>
* As required by some applications and containers, multiple co-existing
* {@link CachingProvider}s implementations, from the same or different
* implementors are permitted at runtime.
* <p>
* To iterate through those that are currently registered a developer may use
* the following methods:
* <ol>
* <li>{@link #getCachingProviders()}</li>
* <li>{@link #getCachingProviders(ClassLoader)}</li>
* </ol>
* To request a specific {@link CachingProvider} implementation, a developer
* should use either the {@link #getCachingProvider(String)} or
* {@link #getCachingProvider(String, ClassLoader)} method.
* <p>
* Where multiple {@link CachingProvider}s are present, the
* {@link CachingProvider} returned by getters {@link #getCachingProvider()} and
* {@link #getCachingProvider(ClassLoader)} is undefined and as a result a
* {@link CacheException} will be thrown when attempted.
*
* @author Brian Oliver
* @author Greg Luck
* @author Yannis Cosmadopoulos
* @since 1.0
* @see ServiceLoader
* @see CachingProvider
*/
public final class Caching {
/**
* The <code>javax.cache.spi.cachingprovider</code> constant.
*/
public static final String JAVAX_CACHE_CACHING_PROVIDER = "javax.cache" +
".spi.CachingProvider";
/**
* The {@link CachingProviderRegistry} that tracks the {@link CachingProvider}s.
*/
private static final CachingProviderRegistry CACHING_PROVIDERS =
new CachingProviderRegistry();
/**
* No public constructor as all methods are static.
*/
private Caching() {
}
/**
* Obtains the {@link ClassLoader} to use for API methods that don't
* explicitly require a {@link ClassLoader} but internally require one.
* <p>
* By default this is the {@link Thread#getContextClassLoader()}.
*
* @return the default {@link ClassLoader}
*/
public static ClassLoader getDefaultClassLoader() {
return CACHING_PROVIDERS.getDefaultClassLoader();
}
/**
* Set the {@link ClassLoader} to use for API methods that don't explicitly
* require a {@link ClassLoader}, but internally use one.
*
* @param classLoader the {@link ClassLoader} or <code>null</code> if the
* calling {@link Thread#getContextClassLoader()} should
* be used
*/
public static void setDefaultClassLoader(ClassLoader classLoader) {
CACHING_PROVIDERS.setDefaultClassLoader(classLoader);
}
/**
* Obtains the default {@link CachingProvider} available via the
* {@link #getDefaultClassLoader()}.
*
* @return the {@link CachingProvider}
* @throws CacheException should zero, or more than one
* {@link CachingProvider} be available on the
* classpath, or it could not be loaded
* @throws SecurityException when the operation could not be performed
* due to the current security settings
*/
public static CachingProvider getCachingProvider() {
return CACHING_PROVIDERS.getCachingProvider();
}
/**
* Obtains the single {@link CachingProvider} visible to the specified
* {@link ClassLoader}.
*
* @param classLoader the {@link ClassLoader} to use for loading the
* {@link CachingProvider}
* @return the {@link CachingProvider}
* @throws CacheException should zero, or more than one
* {@link CachingProvider} be available on the
* classpath, or it could not be loaded
* @throws SecurityException when the operation could not be performed
* due to the current security settings
* @see #getCachingProviders(ClassLoader)
*/
public static CachingProvider getCachingProvider(ClassLoader classLoader) {
return CACHING_PROVIDERS.getCachingProvider(classLoader);
}
/**
* Obtains the {@link CachingProvider}s that are available via the
* {@link #getDefaultClassLoader()}.
* <p>
* If a <code>javax.cache.spi.cachingprovider</code> system property is defined,
* only that {@link CachingProvider} specified by that property is returned.
* Otherwise all {@link CachingProvider}s that are available via a
* {@link ServiceLoader} for {@link CachingProvider}s using the default
* {@link ClassLoader} (including those previously requested via
* {@link #getCachingProvider(String)}) are returned.
*
* @return an {@link Iterable} of {@link CachingProvider}s loaded by the
* specified {@link ClassLoader}
*/
public static Iterable<CachingProvider> getCachingProviders() {
return CACHING_PROVIDERS.getCachingProviders();
}
/**
* Obtains the {@link CachingProvider}s that are available via the specified
* {@link ClassLoader}.
* <p>
* If a <code>javax.cache.spi.cachingprovider</code> system property is defined,
* only that {@link CachingProvider} specified by that property is returned.
* Otherwise all {@link CachingProvider}s that are available via a
* {@link ServiceLoader} for {@link CachingProvider}s using the specified
* {@link ClassLoader} (including those previously requested via
* {@link #getCachingProvider(String, ClassLoader)}) are returned.
*
* @param classLoader the {@link ClassLoader} of the returned
* {@link CachingProvider}s
* @return an {@link Iterable} of {@link CachingProvider}s loaded by the
* specified {@link ClassLoader}
*/
public static Iterable<CachingProvider> getCachingProviders(
ClassLoader classLoader) {
return CACHING_PROVIDERS.getCachingProviders(classLoader);
}
/**
* Obtain the {@link CachingProvider} that is implemented by the specified
* fully qualified class name using the {@link #getDefaultClassLoader()}.
* Should this {@link CachingProvider} already be loaded it is simply returned,
* otherwise an attempt will be made to load and instantiate the specified
* class (using a no-args constructor).
*
* @param fullyQualifiedClassName the fully qualified class name of the
* {@link CachingProvider}
* @return the {@link CachingProvider}
* @throws CacheException if the {@link CachingProvider} cannot be created
* @throws SecurityException when the operation could not be performed
* due to the current security settings
*/
public static CachingProvider getCachingProvider(String fullyQualifiedClassName) {
return CACHING_PROVIDERS.getCachingProvider(fullyQualifiedClassName);
}
/**
* Obtain the {@link CachingProvider} that is implemented by the specified
* fully qualified class name using the provided {@link ClassLoader}.
* Should this {@link CachingProvider} already be loaded it is returned,
* otherwise an attempt will be made to load and instantiate the specified
* class (using a no-args constructor).
*
* @param fullyQualifiedClassName the fully qualified class name of the
* {@link CachingProvider}
* @param classLoader the {@link ClassLoader} to load the
* {@link CachingProvider}
* @return the {@link CachingProvider}
* @throws CacheException if the {@link CachingProvider} cannot be created
* @throws SecurityException when the operation could not be performed
* due to the current security settings
*/
public static CachingProvider getCachingProvider(String fullyQualifiedClassName,
ClassLoader classLoader) {
return CACHING_PROVIDERS.getCachingProvider(fullyQualifiedClassName,
classLoader);
}
/**
* A convenience that method that looks up a managed {@link Cache} given its
* name. using the default <code>CachingProvider</code> and <code>CacheManager
* </code>. For the full range of <code>Cache</code> look up methods see
* {@link CacheManager}.
* <p>
* This method must be used for {@link Cache}s that were configured with
* runtime key and value types. Use {@link CacheManager#getCache(String)} for
* {@link Cache}s where these were not specified.
* <p>
* Implementations must ensure that the key and value types are the same as
* those configured for the {@link Cache} prior to returning from this method.
* <p>
* Implementations may further perform type checking on mutative cache operations
* and throw a {@link ClassCastException} if these checks fail.
* <p>
* Implementations that support declarative mechanisms for pre-configuring
* {@link Cache}s may return a pre-configured {@link Cache} instead of
* <code>null</code>.
* @param <K> the type of key
* @param <V> the type of value
* @param cacheName the name of the managed {@link Cache} to acquire
* @param keyType the expected {@link Class} of the key
* @param valueType the expected {@link Class} of the value
* @return the Cache or null if it does exist or can't be pre-configured
* @throws IllegalStateException if the CacheManager is
* {@link CacheManager#isClosed()}
* @throws IllegalArgumentException if the specified key and/or value types are
* incompatible with the configured cache.
* @throws SecurityException when the operation could not be performed
* due to the current security settings
* @see CacheManager#getCache(String, Class, Class)
* @see CacheManager#getCache(String)
*/
public static <K, V> Cache<K, V> getCache(String cacheName, Class<K> keyType,
Class<V> valueType) {
return getCachingProvider().getCacheManager().getCache(cacheName, keyType,
valueType);
}
/**
* Maintains a registry of loaded {@link CachingProvider}s scoped by
* {@link ClassLoader}.
*/
private static class CachingProviderRegistry {
/**
* The {@link CachingProvider}s by Class Name organized by the
* {@link ClassLoader} was used to load them.
*/
private WeakHashMap<ClassLoader, LinkedHashMap<String, CachingProvider>>
cachingProviders;
/**
* The default {@link ClassLoader}. When <code>null</code> the
* {@link Thread#getContextClassLoader()} will be used.
*/
private volatile ClassLoader classLoader;
/**
* Constructs a CachingProviderManager.
*/
public CachingProviderRegistry() {
this.cachingProviders = new WeakHashMap<ClassLoader, LinkedHashMap<String,
CachingProvider>>();
this.classLoader = null;
}
/**
* Obtains the {@link ClassLoader} to use for API methods that don't
* explicitly require a {@link ClassLoader} but internally require one.
* <p>
* By default this is the {@link Thread#getContextClassLoader()}.
* </p>
* @return the default {@link ClassLoader}
*/
public ClassLoader getDefaultClassLoader() {
ClassLoader loader = classLoader;
return loader == null ? Thread.currentThread().getContextClassLoader() : loader;
}
/**
* Set the {@link ClassLoader} to use for API methods that don't explicitly
* require a {@link ClassLoader}, but internally use one.
*
* @param classLoader the {@link ClassLoader} or <code>null</code> if the
* calling {@link Thread#getContextClassLoader()} should
* be used
*/
public void setDefaultClassLoader(ClassLoader classLoader) {
this.classLoader = classLoader;
}
/**
* Obtains the only {@link CachingProvider} defined by the
* {@link #getDefaultClassLoader()}.
* <p>
* Should zero or more than one {@link CachingProvider}s be available, a
* CacheException is thrown.
* </p>
* @return the {@link CachingProvider}
* @throws CacheException should zero or more than one
* {@link CachingProvider} be available
* or a {@link CachingProvider} could not be loaded
* @see #getCachingProvider(ClassLoader)
* @see #getCachingProviders(ClassLoader)
*/
public CachingProvider getCachingProvider() {
return getCachingProvider(getDefaultClassLoader());
}
/**
* Obtains the only {@link CachingProvider} defined by the specified
* {@link ClassLoader}.
* <p>
* Should zero or more than one {@link CachingProvider}s be available, a
* CacheException is thrown.
* </p>
* @param classLoader the {@link ClassLoader} to use for loading the
* {@link CachingProvider}
* @return the {@link CachingProvider}
* @throws CacheException should zero or more than one
* {@link CachingProvider} be available
* or a {@link CachingProvider} could not be loaded
* @see #getCachingProviders(ClassLoader)
*/
public CachingProvider getCachingProvider(ClassLoader classLoader) {
Iterator<CachingProvider> iterator = getCachingProviders(classLoader).iterator();
if (iterator.hasNext()) {
CachingProvider provider = iterator.next();
if (iterator.hasNext()) {
throw new CacheException("Multiple CachingProviders have been configured when only a single CachingProvider is expected");
} else {
return provider;
}
} else {
throw new CacheException("No CachingProviders have been configured");
}
}
/**
* Obtain the {@link CachingProvider}s that are available via the
* {@link #getDefaultClassLoader()}.
* <p>
* If a <code>javax.cache.spi.cachingprovider</code> system property is defined,
* only that {@link CachingProvider} specified by that property is returned.
* Otherwise all {@link CachingProvider}s that are available via a
* {@link ServiceLoader} for {@link CachingProvider}s using the default
* {@link ClassLoader} (and those explicitly requested via
* {@link #getCachingProvider(String)}) are returned.
* </p>
* @return an {@link Iterable} of {@link CachingProvider}s loaded by the
* default {@link ClassLoader}
*/
public Iterable<CachingProvider> getCachingProviders() {
return getCachingProviders(getDefaultClassLoader());
}
/**
* Obtain the {@link CachingProvider}s that are available via the specified
* {@link ClassLoader}.
* <p>
* If a <code>javax.cache.spi.cachingprovider</code> system property is defined,
* only that {@link CachingProvider} specified by that property is returned.
* Otherwise all {@link CachingProvider}s that are available via a
* {@link ServiceLoader} for {@link CachingProvider}s using the specified
* {@link ClassLoader} (and those explicitly requested via
* {@link #getCachingProvider(String, ClassLoader)}) are returned.
* </p>
* @param classLoader the {@link ClassLoader} of the returned
* {@link CachingProvider}s
* @return an {@link Iterable} of {@link CachingProvider}s loaded by the
* specified {@link ClassLoader}
*/
public synchronized Iterable<CachingProvider> getCachingProviders(ClassLoader classLoader) {
final ClassLoader serviceClassLoader = classLoader == null ? getDefaultClassLoader() : classLoader;
LinkedHashMap<String, CachingProvider> providers = cachingProviders.get(serviceClassLoader);
if (providers == null) {
String className = System.getProperty(JAVAX_CACHE_CACHING_PROVIDER);
if (className != null) {
providers = new LinkedHashMap<String, CachingProvider>();
providers.put(className, loadCachingProvider(className, serviceClassLoader));
} else {
providers = AccessController.doPrivileged(new PrivilegedAction<LinkedHashMap<String, CachingProvider>>() {
@Override
public LinkedHashMap<String, CachingProvider> run() {
LinkedHashMap<String, CachingProvider> result = new LinkedHashMap<String, CachingProvider>();
ServiceLoader<CachingProvider> serviceLoader = ServiceLoader.load(CachingProvider.class, serviceClassLoader);
for (CachingProvider provider : serviceLoader) {
result.put(provider.getClass().getName(), provider);
}
return result;
}
});
}
cachingProviders.put(serviceClassLoader, providers);
}
return providers.values();
}
/**
* Obtain the {@link CachingProvider} that is implemented by the specified
* fully qualified class name using the {@link #getDefaultClassLoader()}.
* Should this {@link CachingProvider} already be loaded it is simply
* returned, otherwise an attempt will be made to load and instantiate the
* specified class name (using a no-args constructor).
*
* @param fullyQualifiedClassName the fully qualified class name of the
* {@link CachingProvider}
* @return the {@link CachingProvider}
* @throws CacheException when the {@link CachingProvider} can't be created
*/
public CachingProvider getCachingProvider(String fullyQualifiedClassName) {
return getCachingProvider(fullyQualifiedClassName, getDefaultClassLoader());
}
/**
* Load and instantiate the {@link CachingProvider} with the specified
* fully qualified class name using the provided {@link ClassLoader}
*
* @param fullyQualifiedClassName the name of the {@link CachingProvider}
* class
* @param classLoader the {@link ClassLoader} to use
* @return a new {@link CachingProvider} instance
* @throws CacheException if the specified {@link CachingProvider} could not be
* loaded
* or the specified class is not a {@link
* CachingProvider}
*/
protected CachingProvider loadCachingProvider(String fullyQualifiedClassName, ClassLoader classLoader) throws CacheException {
synchronized (classLoader) {
try {
Class<?> clazz = classLoader.loadClass(fullyQualifiedClassName);
if (CachingProvider.class.isAssignableFrom(clazz)) {
return ((Class<CachingProvider>) clazz).newInstance();
} else {
throw new CacheException("The specified class [" + fullyQualifiedClassName + "] is not a CachingProvider");
}
} catch (Exception e) {
throw new CacheException("Failed to load the CachingProvider [" + fullyQualifiedClassName + "]", e);
}
}
}
/**
* Obtain the {@link CachingProvider} that is implemented by the specified
* fully qualified class name using the provided {@link ClassLoader}.
* Should this {@link CachingProvider} already be loaded it is returned,
* otherwise an attempt will be made to load and instantiate the specified
* class (using a no-args constructor).
*
* @param fullyQualifiedClassName the fully qualified class name of the
* {@link CachingProvider}
* @param classLoader the {@link ClassLoader} to load the
* {@link CachingProvider}
* @return the {@link CachingProvider}
* @throws CacheException when the {@link CachingProvider} can't be created
*/
public synchronized CachingProvider getCachingProvider(String fullyQualifiedClassName, ClassLoader classLoader) {
ClassLoader serviceClassLoader = classLoader == null ? getDefaultClassLoader() : classLoader;
LinkedHashMap<String, CachingProvider> providers = cachingProviders.get(serviceClassLoader);
if (providers == null) {
// first load the CachingProviders for the {@link ClassLoader}
// this may automatically load the CachingProvider we desire
getCachingProviders(serviceClassLoader);
providers = cachingProviders.get(serviceClassLoader);
}
CachingProvider provider = providers.get(fullyQualifiedClassName);
if (provider == null) {
provider = loadCachingProvider(fullyQualifiedClassName, serviceClassLoader);
providers.put(fullyQualifiedClassName, provider);
}
return provider;
}
}
}
================================================
FILE: src/main/java/javax/cache/annotation/CacheDefaults.java
================================================
/**
* Copyright 2011-2016 Terracotta, Inc.
* Copyright 2011-2016 Oracle America Incorporated
*
* Licensed 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 javax.cache.annotation;
import javax.cache.CacheManager;
import javax.enterprise.util.Nonbinding;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.Arrays;
/**
* Allows the configuration of defaults for {@link CacheResult}, {@link CachePut},
* {@link CacheRemove}, and {@link CacheRemoveAll} at the class level. Without
* the method level annotations this annotation has no effect.
* <p>
* Following is an example of specifying a default cache name that is used by
* the annotations on the getDomain and deleteDomain methods. The annotation for
* getAllDomains would use the "allDomains" cache name specified in the method
* level annotation.
* <pre><code>
* package my.app;
*
* @CacheDefaults(cacheName="domainCache")
* public class DomainDao {
* @CacheResult
* public Domain getDomain(String domainId, int index) {
* ...
* }
*
* @CacheRemove
* public void deleteDomain(String domainId, int index) {
* ...
* }
*
* @CacheResult(cacheName="allDomains")
* public List<Domain> getAllDomains() {
* ...
* }
* }
* </code></pre>
*
* @author Rick Hightower
* @since 1.0
*/
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface CacheDefaults {
/**
* The default name of the cache for the annotated class
* <p>
* If not specified defaults to:
* package.name.ClassName.methodName(package.ParameterType,package.ParameterType)
* <p>
* Applicable for {@link CacheResult}, {@link CachePut}, {@link CacheRemove},
* and {@link CacheRemoveAll}
*/
@Nonbinding String cacheName() default "";
/**
* The {@link CacheResolverFactory} used to find the {@link CacheResolver} to
* use at runtime.
* <p>
* The default resolver pair will resolve the cache by name from the default
* {@link CacheManager}
* <p>
* Applicable for {@link CacheResult}, {@link CachePut}, {@link CacheRemove},
* and {@link CacheRemoveAll}
*/
@Nonbinding Class<? extends CacheResolverFactory> cacheResolverFactory()
default CacheResolverFactory.class;
/**
* The {@link CacheKeyGenerator} to use to generate the
* {@link GeneratedCacheKey} for interacting with the specified Cache.
* <p>
* Defaults to a key generator that uses {@link Arrays#deepHashCode(Object[])}
* and {@link Arrays#deepEquals(Object[], Object[])} with the array returned by
* {@link CacheKeyInvocationContext#getKeyParameters()}
* </p>
* Applicable for {@link CacheResult}, {@link CachePut}, and {@link CacheRemove}
*
* @see CacheKey
*/
@Nonbinding Class<? extends CacheKeyGenerator> cacheKeyGenerator()
default CacheKeyGenerator.class;
}
================================================
FILE: src/main/java/javax/cache/annotation/CacheInvocationContext.java
================================================
/**
* Copyright 2011-2016 Terracotta, Inc.
* Copyright 2011-2016 Oracle America Incorporated
*
* Licensed 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 javax.cache.annotation;
import java.lang.annotation.Annotation;
/**
* Runtime information about an intercepted method invocation for a method
* annotated with {@link CacheResult}, {@link CachePut}, {@link CacheRemove},
* or {@link CacheRemoveAll}
* <p>
* Used with {@link CacheResolver#resolveCache(CacheInvocationContext)} to
* determine the {@link javax.cache.Cache} to use at runtime for the method
* invocation.
*
* @param <A> The type of annotation this context information is for. One of
* {@link CacheResult}, {@link CachePut}, {@link CacheRemove}, or {@link
* CacheRemoveAll}.
* @author Eric Dalquist
* @see CacheResolver
*/
public interface CacheInvocationContext<A extends Annotation>
extends CacheMethodDetails<A> {
/**
* @return The object the intercepted method was invoked on.
*/
Object getTarget();
/**
* Returns a clone of the array of all method parameters.
*
* @return An array of all parameters for the annotated method
*/
CacheInvocationParameter[] getAllParameters();
/**
* Return an object of the specified type to allow access to the
* provider-specific API. If the provider's
* implementation does not support the specified class, the {@link
* IllegalArgumentException} is thrown.
*
* @param <T> The type of the expected underlying {@link javax.cache.Cache} implementation.
* @param cls the class of the object to be returned. This is normally either the
* underlying implementation class or an interface that it implements.
* @return an instance of the specified class
* @throws IllegalArgumentException if the provider doesn't support the specified
* class.
*/
<T> T unwrap(java.lang.Class<T> cls);
}
================================================
FILE: src/main/java/javax/cache/annotation/CacheInvocationParameter.java
================================================
/**
* Copyright 2011-2016 Terracotta, Inc.
* Copyright 2011-2016 Oracle America Incorporated
*
* Licensed 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 javax.cache.annotation;
import java.lang.annotation.Annotation;
import java.util.Set;
/**
* A parameter to an intercepted method invocation. Contains the parameter value
* as well static type and annotation information about the parameter.
*
* @author Eric Dalquist
*/
public interface CacheInvocationParameter {
/**
* The parameter type as declared on the method.
*/
Class<?> getRawType();
/**
* @return The parameter value
*/
Object getValue();
/**
* @return An immutable Set of all Annotations on this method parameter, never
* null.
*/
Set<Annotation> getAnnotations();
/**
* The index of the parameter in the original parameter array as returned by
* {@link CacheInvocationContext#getAllParameters()}
*
* @return The index of the parameter in the original parameter array.
*/
int getParameterPosition();
}
================================================
FILE: src/main/java/javax/cache/annotation/CacheKey.java
================================================
/**
* Copyright 2011-2016 Terracotta, Inc.
* Copyright 2011-2016 Oracle America Incorporated
*
* Licensed 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 javax.cache.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Marks a method argument as part of the cache key.
* If no arguments are marked all arguments are used. The exception is
* for a method annotated with {@link CachePut} where the {@link CacheValue}
* parameter is never included in the key
*
* @author Rick Hightower
* @see CacheResult
* @see CachePut
* @see CacheRemove
* @see CacheKeyInvocationContext#getKeyParameters()
* @since 1.0
*/
@Target({ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
public @interface CacheKey {
}
================================================
FILE: src/main/java/javax/cache/annotation/CacheKeyGenerator.java
================================================
/**
* Copyright 2011-2016 Terracotta, Inc.
* Copyright 2011-2016 Oracle America Incorporated
*
* Licensed 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 javax.cache.annotation;
import java.lang.annotation.Annotation;
/**
* Generates a {@link GeneratedCacheKey} based on
* a {@link CacheKeyInvocationContext}.
* <p>
* Implementations must be thread-safe.
*
* @author Eric Dalquist
* @since 1.0
*/
public interface CacheKeyGenerator {
/**
* Called for each intercepted method invocation to generate a suitable
* cache key (as a {@link GeneratedCacheKey}) from the
* {@link CacheKeyInvocationContext} data.
*
* @param cacheKeyInvocationContext Information about the intercepted method invocation
* @return A non-null cache key for the invocation.
*/
GeneratedCacheKey generateCacheKey(CacheKeyInvocationContext<? extends Annotation> cacheKeyInvocationContext);
}
================================================
FILE: src/main/java/javax/cache/annotation/CacheKeyInvocationContext.java
================================================
/**
* Copyright 2011-2016 Terracotta, Inc.
* Copyright 2011-2016 Oracle America Incorporated
*
* Licensed 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 javax.cache.annotation;
import java.lang.annotation.Annotation;
/**
* Runtime information about an intercepted method invocation for a method
* annotated with {@link CacheResult}, {@link CachePut}, or
* {@link CacheRemove}.
* <p>
* Used with {@link CacheKeyGenerator#generateCacheKey(CacheKeyInvocationContext)}
* to generate a {@link GeneratedCacheKey} for the invocation.
*
* @param <A> The type of annotation this context information is for. One of
* {@link CacheResult}, {@link CachePut}, or {@link CacheRemove}.
* @author Eric Dalquist
* @see CacheKeyGenerator
*/
public interface CacheKeyInvocationContext<A extends Annotation>
extends CacheInvocationContext<A> {
/**
* Returns a clone of the array of all method parameters to be used by the
* {@link
* CacheKeyGenerator} in creating a {@link GeneratedCacheKey}. The returned array
* may be the same as or a subset of the array returned by
* {@link #getAllParameters()}
* <p>
* Parameters in this array are selected by the following rules:
* <ul>
* <li>If no parameters are annotated with {@link CacheKey} or {@link
* CacheValue}
* then all parameters are included</li>
* <li>If a {@link CacheValue} annotation exists and no {@link CacheKey} then
* all
* parameters except the one annotated with {@link CacheValue} are included</li>
* <li>If one or more {@link CacheKey} annotations exist only those parameters
* with the {@link CacheKey} annotation are included</li>
* </ul>
*
* @return An array of all parameters to be used in cache key generation
*/
CacheInvocationParameter[] getKeyParameters();
/**
* When a method is annotated with {@link CachePut} this is the parameter
* annotated with {@link CacheValue}
*
* @return The parameter to cache, will never be null for methods annotated with
* {@link CachePut}, will be null for methods not annotated with {@link
* CachePut}
*/
CacheInvocationParameter getValueParameter();
}
================================================
FILE: src/main/java/javax/cache/annotation/CacheMethodDetails.java
================================================
/**
* Copyright 2011-2016 Terracotta, Inc.
* Copyright 2011-2016 Oracle America Incorporated
*
* Licensed 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 javax.cache.annotation;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Set;
/**
* Static information about a method annotated with one of:
* {@link CacheResult}, {@link CachePut}, {@link CacheRemove}, or {@link
* CacheRemoveAll}
* <p>
* Used with {@link CacheResolverFactory#getCacheResolver(CacheMethodDetails)} to
* determine the {@link CacheResolver} to use with the method.
*
* @param <A> The type of annotation this context information is for. One of
* {@link CacheResult}, {@link CachePut}, {@link CacheRemove}, or
* {@link CacheRemoveAll}.
* @author Eric Dalquist
* @see CacheResolverFactory
*/
public interface CacheMethodDetails<A extends Annotation> {
/**
* The annotated method
*
* @return The annotated method
*/
Method getMethod();
/**
* An immutable Set of all Annotations on this method
*
* @return An immutable Set of all Annotations on this method
*/
Set<Annotation> getAnnotations();
/**
* The caching related annotation on the method.
* One of: {@link CacheResult}, {@link CachePut}, {@link CacheRemove}, or
* {@link CacheRemoveAll}
*
* @return The caching related annotation on the method.
*/
A getCacheAnnotation();
/**
* The cache name resolved by the implementation.
* <p>
* The cache name is determined by first looking at the cacheName attribute of
* the method level annotation. If that attribute is not set then the class
* level {@link CacheDefaults} annotation is checked. If that annotation does
* not exist or does not have its cacheName attribute set then the following
* cache name generation rules are followed:
* <p>
* "fully qualified class name"."method name"("fully qualified parameter class
* names")
* <p>
* For example:
* <pre><code>
* package my.app;
*
* public class DomainDao {
* @CacheResult
* public Domain getDomain(String domainId, int index) {
* ...
* }
* }
* </code></pre>
* <p>
* Results in the cache name: "my.app.DomainDao.getDomain(java.lang.String,int)"
*
* @return The fully resolved cache name
*/
String getCacheName();
}
================================================
FILE: src/main/java/javax/cache/annotation/CachePut.java
================================================
/**
* Copyright 2011-2016 Terracotta, Inc.
* Copyright 2011-2016 Oracle America Incorporated
*
* Licensed 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 javax.cache.annotation;
import javax.cache.Cache;
import javax.cache.CacheManager;
import javax.enterprise.util.Nonbinding;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.Arrays;
/**
* When a method annotated with {@link CachePut} is invoked a {@link
* GeneratedCacheKey} will be generated and {@link Cache#put(Object,
* Object)} will be invoked on the specified cache storing the value marked with
* {@link CacheValue}.
* <p>
* The default behavior is to call {@link Cache#put(Object, Object)}
* after the annotated method is invoked, this behavior can be changed by setting
* {@link #afterInvocation()} to false in which case
* {@link Cache#put(Object, Object)} will be called before the annotated method is
* invoked.
* <p>
* Example of caching the Domain object with a key generated from the String and
* int parameters. The {@link CacheValue} annotation is used to designate which
* parameter should be stored in the "domainDao" cache.
* <pre><code>
* package my.app;
*
* public class DomainDao {
* @CachePut(cacheName="domainCache")
* public void updateDomain(String domainId, int index, @CacheValue Domain
* domain) {
* ...
* }
* }
* </code></pre>
* <p>
* Exception Handling, only used if {@link #afterInvocation()} is true.
* <ol>
* <li>If {@link #cacheFor()} and {@link #noCacheFor()} are both empty then all
* exceptions prevent the put</li>
* <li>If {@link #cacheFor()} is specified and {@link #noCacheFor()} is not
* specified then only exceptions that pass an instanceof check against the
* cacheFor list result in a put</li>
* <li>If {@link #noCacheFor()} is specified and {@link #cacheFor()} is not
* specified then all exceptions that do not pass an instanceof check against the
* noCacheFor result in a put</li>
* <li>If {@link #cacheFor()} and {@link #noCacheFor()} are both specified then
* exceptions that pass an instanceof check against the cacheFor list but do not
* pass an instanceof check against the noCacheFor list result in a put</li>
* </ol>
*
* @author Eric Dalquist
* @author Rick Hightower
* @see CacheValue
* @see CacheKey
* @since 1.0
*/
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface CachePut {
/**
* The name of the cache.
* <p>
* If not specified defaults first to {@link CacheDefaults#cacheName()} and if
* that is not set it defaults to:
* package.name.ClassName.methodName(package.ParameterType,package.ParameterType)
*/
@Nonbinding String cacheName() default "";
/**
* When {@link Cache#put(Object, Object)} should be called. If true it is called
* after the annotated method invocation completes successfully. If false it is
* called before the annotated method is invoked.
* <p>
* Defaults to true.
* <p>
* If true and the annotated method throws an exception the rules governing
* {@link #cacheFor()} and {@link #noCacheFor()} will be followed.
*/
@Nonbinding boolean afterInvocation() default true;
/**
* The {@link CacheResolverFactory} used to find the {@link CacheResolver} to
* use at runtime.
* <p>
* The default resolver pair will resolve the cache by name from the default
* {@link CacheManager}
*/
@Nonbinding Class<? extends CacheResolverFactory> cacheResolverFactory()
default CacheResolverFactory.class;
/**
* The {@link CacheKeyGenerator} to use to generate the {@link
* GeneratedCacheKey} for interacting with the specified Cache.
* <p>
* Defaults to a key generator that uses {@link Arrays#deepHashCode(Object[])}
* and {@link Arrays#deepEquals(Object[], Object[])} with the array
* returned by {@link CacheKeyInvocationContext#getKeyParameters()}
*
* @see CacheKey
*/
@Nonbinding Class<? extends CacheKeyGenerator> cacheKeyGenerator()
default CacheKeyGenerator.class;
/**
* Defines zero (0) or more exception {@link Class classes}, that must be a
* subclass of {@link Throwable}, indicating the exception types that <b>must</b>
* cause the parameter to be cached. Only used if {@link #afterInvocation()} is
* true.
*/
@Nonbinding Class<? extends Throwable>[] cacheFor() default {};
/**
* Defines zero (0) or more exception {@link Class Classes}, which must be a
* subclass of {@link Throwable}, indicating which exception types <b>must
* not</b> cause the parameter to be cached. Only used if
* {@link #afterInvocation()} is true.
*/
@Nonbinding Class<? extends Throwable>[] noCacheFor() default {};
}
================================================
FILE: src/main/java/javax/cache/annotation/CacheRemove.java
================================================
/**
* Copyright 2011-2016 Terracotta, Inc.
* Copyright 2011-2016 Oracle America Incorporated
*
* Licensed 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 javax.cache.annotation;
import javax.cache.Cache;
import javax.cache.CacheManager;
import javax.enterprise.util.Nonbinding;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* When a method annotated with {@link CacheRemove} is invoked a {@link
* GeneratedCacheKey} will be generated and {@link Cache#remove(Object)} will be
* invoked on the specified cache.
* <p>
* The default behavior is to call {@link Cache#remove(Object)} after
* the annotated method is invoked, this behavior can be changed by setting
* {@link #afterInvocation()} to false in which case
* {@link Cache#remove(Object)} will be called before the annotated
* method is invoked.
* <p>
* Example of removing a specific Domain object from the "domainCache". A {@link
* GeneratedCacheKey} will be generated from the String and int parameters and
* used to call {@link Cache#remove(Object)} after the deleteDomain
* method completes successfully.
* <pre><code>
* package my.app;
*
* public class DomainDao {
* @CacheRemove(cacheName="domainCache")
* public void deleteDomain(String domainId, int index) {
* ...
* }
* }
* </code></pre>
* <p>
* Exception Handling, only used if {@link #afterInvocation()} is true.
* <ol>
* <li>If {@link #evictFor()} and {@link #noEvictFor()} are both empty then all
* exceptions prevent the remove</li>
* <li>If {@link #evictFor()} is specified and {@link #noEvictFor()} is not
* specified then only exceptions that pass an instanceof check against the
* evictFor list result in a remove</li>
* <li>If {@link #noEvictFor()} is specified and {@link #evictFor()} is not
* specified then all exceptions that do not pass an instanceof check against the
* noEvictFor result in a remove</li>
* <li>If {@link #evictFor()} and {@link #noEvictFor()} are both specified then
* exceptions that pass an instanceof check against the evictFor list but do not
* pass an instanceof check against the noEvictFor list result in a remove</li>
* </ol>
*
* @author Eric Dalquist
* @author Rick Hightower
* @author Greg Luck
* @see CacheKey
* @since 1.0
*/
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface CacheRemove {
/**
* The name of the cache.
* <p>
* If not specified defaults first to {@link CacheDefaults#cacheName()},
* and if that is not set then to:
* package.name.ClassName.methodName(package.ParameterType,package.ParameterType)
*/
@Nonbinding String cacheName() default "";
/**
* When {@link Cache#remove(Object)} should be called. If true it is called
* after the annotated method invocation completes successfully. If false it is
* called before the annotated method is invoked.
* <p>
* Defaults to true.
* <p>
* If true and the annotated method throws an exception the remove will not be
* executed.
*/
@Nonbinding boolean afterInvocation() default true;
/**
* The {@link CacheResolverFactory} used to find the {@link CacheResolver} to
* use at runtime.
* <p>
* The default resolver pair will resolve the cache by name from the default
* {@link CacheManager}
*/
@Nonbinding Class<? extends CacheResolverFactory> cacheResolverFactory()
default CacheResolverFactory.class;
/**
* The {@link CacheKeyGenerator} to use to generate the {@link
* GeneratedCacheKey} for interacting with the specified Cache.
* <p>
* Defaults to a key generator that uses
* {@link java.util.Arrays#deepHashCode(Object[])}
* and {@link java.util.Arrays#deepEquals(Object[], Object[])} with the array
* returned by {@link CacheKeyInvocationContext#getKeyParameters()}
*
* @see CacheKey
*/
@Nonbinding Class<? extends CacheKeyGenerator> cacheKeyGenerator()
default CacheKeyGenerator.class;
/**
* Defines zero (0) or more exception {@link Class classes}, that must be a
* subclass of {@link Throwable}, indicating the exception types that must cause
* a cache eviction. Only used if {@link #afterInvocation()} is true.
*/
@Nonbinding Class<? extends Throwable>[] evictFor() default {};
/**
* Defines zero (0) or more exception {@link Class Classes}, that must be a
* subclass of {@link Throwable}, indicating the exception types that must
* <b>not</b> cause a cache eviction. Only used if {@link #afterInvocation()} is
* true.
*/
@Nonbinding Class<? extends Throwable>[] noEvictFor() default {};
}
================================================
FILE: src/main/java/javax/cache/annotation/CacheRemoveAll.java
================================================
/**
* Copyright 2011-2016 Terracotta, Inc.
* Copyright 2011-2016 Oracle America Incorporated
*
* Licensed 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 javax.cache.annotation;
import javax.cache.Cache;
import javax.cache.CacheManager;
import javax.enterprise.util.Nonbinding;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* When a method annotated with {@link CacheRemoveAll} is invoked all elements in
* the specified cache will be removed via the
* {@link Cache#removeAll()} method
* <p>
* The default behavior is to call {@link Cache#removeAll()} after the
* annotated method is invoked, this behavior can be changed by setting {@link
* #afterInvocation()} to false in which case {@link Cache#removeAll()}
* will be called before the annotated method is invoked.
* <p>
* Example of removing all Domain objects from the "domainCache". {@link
* Cache#removeAll()} will be called after deleteAllDomains() returns
* successfully.
* <pre><code>
* package my.app;
*
* public class DomainDao {
* @CacheRemoveAll(cacheName="domainCache")
* public void deleteAllDomains() {
* ...
* }
* }
* </code></pre>
* <p>
* Exception Handling, only used if {@link #afterInvocation()} is true.
* <ol>
* <li>If {@link #evictFor()} and {@link #noEvictFor()} are both empty then all
* exceptions prevent the removeAll</li>
* <li>If {@link #evictFor()} is specified and {@link #noEvictFor()} is not
* specified then only exceptions that pass an instanceof check against the
* evictFor list result in a removeAll</li>
* <li>If {@link #noEvictFor()} is specified and {@link #evictFor()} is not
* specified then all exceptions that do not pass an instanceof check against the
* noEvictFor result in a removeAll</li>
* <li>If {@link #evictFor()} and {@link #noEvictFor()} are both specified then
* exceptions that pass an instanceof check against the evictFor list but do not
* pass an instanceof check against the noEvictFor list result in a removeAll</li>
* </ol>
*
* @author Eric Dalquist
* @author Rick Hightower
* @since 1.0
*/
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface CacheRemoveAll {
/**
* /**
* The name of the cache.
* <p>
* If not specified defaults first to {@link CacheDefaults#cacheName()} and if
* that is not set it defaults to:
* package.name.ClassName.methodName(package.ParameterType,package.ParameterType)
*/
@Nonbinding String cacheName() default "";
/**
* When {@link Cache#removeAll()} should be called. If true it is called after
* the annotated method invocation completes successfully. If false it is called
* before the annotated method is invoked.
* <p>
* Defaults to true.
* <p>
* If true and the annotated method throws an exception the removeAll will not be
* executed.
*/
@Nonbinding boolean afterInvocation() default true;
/**
* The {@link CacheResolverFactory} used to find the {@link CacheResolver} to
* use at runtime.
* <p>
* The default resolver pair will resolve the cache by name from the default
* {@link CacheManager}
*/
@Nonbinding Class<? extends CacheResolverFactory> cacheResolverFactory()
default CacheResolverFactory.class;
/**
* Defines zero (0) or more exception {@link Class classes}, that must be a
* subclass of {@link Throwable}, indicating the exception types that must
* cause a cache eviction. Only used if {@link #afterInvocation()} is true.
*/
@Nonbinding Class<? extends Throwable>[] evictFor() default {};
/**
* Defines zero (0) or more exception {@link Class Classes}, that must be a
* subclass of {@link Throwable}, indicating the exception types that must
* <b>not</b> cause a cache eviction. Only used if {@link #afterInvocation()} is
* true.
*/
@Nonbinding Class<? extends Throwable>[] noEvictFor() default {};
}
================================================
FILE: src/main/java/javax/cache/annotation/CacheResolver.java
================================================
/**
* Copyright 2011-2016 Terracotta, Inc.
* Copyright 2011-2016 Oracle America Incorporated
*
* Licensed 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 javax.cache.annotation;
import javax.cache.Cache;
import java.lang.annotation.Annotation;
/**
* Determines the {@link Cache} to use for an intercepted method invocation.
* <p>
* Implementations MUST be thread-safe.
*
* @author Eric Dalquist
* @see CacheResolverFactory
* @since 1.0
*/
public interface CacheResolver {
/**
* Resolve the {@link Cache} to use for the {@link CacheInvocationContext}.
*
* @param <K> the type of key
* @param <V> the type of value
* @param cacheInvocationContext The context data for the intercepted method
* invocation
* @return The {@link Cache} instance to be used by the interceptor
*/
<K, V> Cache<K, V> resolveCache(CacheInvocationContext<? extends Annotation>
cacheInvocationContext);
}
================================================
FILE: src/main/java/javax/cache/annotation/CacheResolverFactory.java
================================================
/**
* Copyright 2011-2016 Terracotta, Inc.
* Copyright 2011-2016 Oracle America Incorporated
*
* Licensed 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 javax.cache.annotation;
import javax.cache.Cache;
import java.lang.annotation.Annotation;
/**
* Determines the {@link CacheResolver} to use for an annotated method. The
* {@link CacheResolver} will be retrieved once per annotated method.
* <p>
* Implementations MUST be thread-safe.
*
* @author Eric Dalquist
* @since 1.0
*/
public interface CacheResolverFactory {
/**
* Get the {@link CacheResolver} used at runtime for resolution of the
* {@link Cache} for the {@link CacheResult}, {@link CachePut},
* {@link CacheRemove}, or {@link CacheRemoveAll} annotation.
*
* @param cacheMethodDetails The details of the annotated method to get the
* {@link CacheResolver} for. @return The {@link
* CacheResolver} instance to be
* used by the interceptor.
*/
CacheResolver getCacheResolver(CacheMethodDetails<? extends Annotation>
cacheMethodDetails);
/**
* Get the {@link CacheResolver} used at runtime for resolution of the {@link
* Cache} for the {@link CacheResult} annotation to cache exceptions.
* <p>
* Will only be called if {@link CacheResult#exceptionCacheName()} is not empty.
*
* @param cacheMethodDetails The details of the annotated method to get the
* {@link CacheResolver} for.
* @return The {@link CacheResolver} instance to be used by the interceptor.
*/
CacheResolver getExceptionCacheResolver(CacheMethodDetails<CacheResult>
cacheMethodDetails);
}
================================================
FILE: src/main/java/javax/cache/annotation/CacheResult.java
================================================
/**
* Copyright 2011-2016 Terracotta, Inc.
* Copyright 2011-2016 Oracle America Incorporated
*
* Licensed 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 javax.cache.annotation;
import javax.cache.Cache;
import javax.cache.CacheManager;
import javax.enterprise.util.Nonbinding;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* When a method annotated with {@link CacheResult} is invoked a
* {@link GeneratedCacheKey} will be generated and {@link Cache#get(Object)} is
* called before the annotated method actually executes. If a value is found in the
* cache it is returned and the annotated method is never actually executed. If no
* value is found the annotated method is invoked and the returned value is stored
* in the cache with the generated key.
* <p>
* Exceptions are not cached by default. Caching of exceptions can be enabled by
* specifying an {@link #exceptionCacheName()}. If an exception cache is specified
* it is checked before invoking the annotated method and if a cached exception is
* found it is re-thrown.
* <p>
* The {@link #cachedExceptions()} and {@link #nonCachedExceptions()} properties
* can be used to control the exceptions are cached and those that are not.
* <p>
* To always invoke the annotated method and still cache the result set
* {@link #skipGet()} to true. This will disable the pre-invocation
* {@link Cache#get(Object)} call. If {@link #exceptionCacheName()} is
* specified the pre-invocation exception check is also disabled. This feature is
* useful for methods that create or update objects to be cached.
* <p>
* Example of caching the Domain object with a key generated from the
* <code>String</code> and <code>int</code> parameters.
* <p>
* With no {@link #cacheName()} specified a cache name of
* "my.app.DomainDao.getDomain(java.lang.String,int)" will be generated.
* </p>
* <pre><code>
* package my.app;
*
* public class DomainDao {
* @CacheResult
* public Domain getDomain(String domainId, int index) {
* ...
* }
* }
* </code></pre>
* <p>
* Example using the {@link GeneratedCacheKey} annotation so that only the domainId
* parameter is used in key generation:
* <pre><code>
* package my.app;
*
* public class DomainDao {
* @CacheResult
* public Domain getDomain(@CacheKey String domainId, Monitor mon) {
* ...
* }
* }
* </code></pre>
* <p>
* If exception caching is enabled via specification of
* {@link #exceptionCacheName()} the following rules are used to determine if a
* thrown exception is cached:
* <ol>
* <li>If {@link #cachedExceptions()} and {@link #nonCachedExceptions()} are both
* empty then all exceptions are cached</li>
* <li>If {@link #cachedExceptions()} is specified and
* {@link #nonCachedExceptions()} is not specified then only exceptions
* that pass an instanceof check against the cachedExceptions list are cached</li>
* <li>If {@link #nonCachedExceptions()} is specified and
* {@link #cachedExceptions()} is not specified then all exceptions
* that do not pass an instanceof check against the nonCachedExceptions list are
* cached</li>
* <li>If {@link #cachedExceptions()} and {@link #nonCachedExceptions()} are both
* specified then exceptions that pass an instanceof check against the
* cachedExceptions list but do not pass an instanceof check against the
* nonCachedExceptions list are cached</li>
* </ol>
*
* @author Eric Dalquist
* @author Rick Hightower
* @see CacheKey
* @since 1.0
*/
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface CacheResult {
/**
* <p>
* The name of the cache.
* </p>
* If not specified defaults first to {@link CacheDefaults#cacheName()} and if
* that is not set it defaults to:
* package.name.ClassName.methodName(package.ParameterType,package.ParameterType)
*/
@Nonbinding String cacheName() default "";
/**
* If set to true the pre-invocation {@link Cache#get(Object)} is
* skipped and the annotated method is always executed with the returned value
* being cached as normal. This is useful for create or update methods that
* should always be executed and have their returned value placed in the cache.
* <p>
* If true and an {@link #exceptionCacheName()} is specified the pre-invocation
* check for a thrown exception is also skipped. If an exception is thrown during
* invocation it will be cached following the standard exception caching rules.
* <p>
* Defaults to false.
*
* @see CachePut
*/
@Nonbinding boolean skipGet() default false;
/**
* The {@link CacheResolverFactory} used to find the {@link CacheResolver} to
* use at runtime.
* <p>
* The default resolver pair will resolve the cache by name from the default
* {@link CacheManager}
*/
@Nonbinding Class<? extends CacheResolverFactory> cacheResolverFactory()
default CacheResolverFactory.class;
/**
* The {@link CacheKeyGenerator} to use to generate the {@link GeneratedCacheKey}
* for interacting with the specified Cache.
* <p>
* Defaults to a key generator that uses
* {@link java.util.Arrays#deepHashCode(Object[])} and
* {@link java.util.Arrays#deepEquals(Object[], Object[])} with the array
* returned by {@link CacheKeyInvocationContext#getKeyParameters()}
*
* @see CacheKey
*/
@Nonbinding Class<? extends CacheKeyGenerator> cacheKeyGenerator()
default CacheKeyGenerator.class;
/**
* The name of the cache to cache exceptions.
* <p>
* If not specified no exception caching is done.
*/
@Nonbinding String exceptionCacheName() default "";
/**
* Defines zero (0) or more exception {@link Class classes}, that must be a
* subclass of {@link Throwable}, indicating the exception types that
* <b>must</b> be cached. Only consulted if {@link #exceptionCacheName()} is
* specified.
*/
@Nonbinding Class<? extends Throwable>[] cachedExceptions() default {};
/**
* Defines zero (0) or more exception {@link Class Classes}, that must be a
* subclass of {@link Throwable}, indicating the exception types that
* <b>must not</b> be cached. Only consulted if {@link #exceptionCacheName()}
* is specified.
*/
@Nonbinding Class<? extends Throwable>[] nonCachedExceptions() default {};
}
================================================
FILE: src/main/java/javax/cache/annotation/CacheValue.java
================================================
/**
* Copyright 2011-2016 Terracotta, Inc.
* Copyright 2011-2016 Oracle America Incorporated
*
* Licensed 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 javax.cache.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Marks the parameter to be cached for a method annotated with {@link CachePut}.
*
* @author Eric Dalquist
* @author Rick Hightower
* @see CachePut
* @since 1.0
*/
@Target({ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
public @interface CacheValue {
}
================================================
FILE: src/main/java/javax/cache/annotation/GeneratedCacheKey.java
================================================
/**
* Copyright 2011-2016 Terracotta, Inc.
* Copyright 2011-2016 Oracle America Incorporated
*
* Licensed 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 javax.cache.annotation;
import java.io.Serializable;
/**
* A {@link Serializable}, immutable, thread-safe object that is used as a key,
* automatically generated by a {@link CacheKeyGenerator}.
* <p>
* The implementation MUST follow the Java contract for {@link Object#hashCode()}
* and {@link Object#equals(Object)} to ensure correct behavior.
* <p>
* It is recommended that implementations also override {@link Object#toString()}
* and provide a human-readable string representation of the key.
*
* @author Eric Dalquist
* @see CacheKeyGenerator
* @since 1.0
*/
public interface GeneratedCacheKey extends Serializable {
/**
* The immutable hash code of the cache key.
*
* @return The hash code of the object
* @see Object#hashCode()
*/
@Override
int hashCode();
/**
* Compare this {@link GeneratedCacheKey} with another. If the two objects
* are equal their {@link #hashCode()} values MUST be equal as well.
*
* @param object The other object to compare to.
* @return true if the objects are equal
* @see Object#equals(Object)
*/
@Override
boolean equals(Object object);
}
================================================
FILE: src/main/java/javax/cache/annotation/package-info.java
================================================
/**
* Copyright 2011-2016 Terracotta, Inc.
* Copyright 2011-2016 Oracle America Incorporated
*
* Licensed 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.
*/
/**
* The annotations in this package provide method interceptors for user supplied
* classes.
* <p>
* In the case of a the {@link javax.cache.annotation.CacheResult} annotation,
* if the cache can satisfy the request a result is returned by the method from
* cache, not from method execution. For the mutative annotations such as
* {@link javax.cache.annotation.CacheResult} the annotation allows the cached
* value to be mutated so that it will be correct the next time
* {@link javax.cache.annotation.CacheResult} is used.
* <p>
* Any operations against a cache via an annotation will have the same behaviour
* as if the {@link javax.cache.annotation.CacheResult} methods were used. So
* if the same underlying cache is used for an annotation and a direct API call,
* the same data would be returned. Annotations therefore provide an additional
* API for interacting with caches.
* <p>
* To use these annotations you'll need a library or framework that processes
* these annotations and intercepts calls to your application objects
* to provide the caching behaviour. This would commonly be provided by a
* dependency injection framework such as defined by CDI in Java EE.
*
* @author Eric Dalquist
* @author Greg Luck
* @since 1.0
*/
package javax.cache.annotation;
================================================
FILE: src/main/java/javax/cache/configuration/CacheEntryListenerConfiguration.java
================================================
/**
* Copyright 2011-2016 Terracotta, Inc.
* Copyright 2011-2016 Oracle America Incorporated
*
* Licensed 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 javax.cache.configuration;
import javax.cache.event.CacheEntryEventFilter;
import javax.cache.event.CacheEntryListener;
import java.io.Serializable;
/**
* Defines the configuration requirements for a
* {@link CacheEntryListener} and a {@link Factory} for its
* creation.
*
* @param <K> the type of keys
* @param <V> the type of values
* @author Brian Oliver
* @author Greg Luck
* @since 1.0
*/
public interface CacheEntryListenerConfiguration<K, V> extends Serializable {
/**
* Obtains the {@link Factory} for the
* {@link CacheEntryListener}.
*
* @return the {@link Factory} for the
* {@link CacheEntryListener}
*/
Factory<CacheEntryListener<? super K, ? super V>> getCacheEntryListenerFactory();
/**
* Determines if the old value should be provided to the
* {@link CacheEntryListener}.
*
* @return <code>true</code> if the old value is required by the
* {@link CacheEntryListener}
*/
boolean isOldValueRequired();
/**
* Obtains the {@link Factory} for the {@link CacheEntryEventFilter} that should be
* applied prior to notifying the {@link CacheEntryListener}.
* <p>
* When <code>null</code> no filtering is applied and all appropriate events
* are notified.
*
* @return the {@link Factory} for the
* {@link CacheEntryEventFilter} or <code>null</code>
* if no filtering is required
*/
Factory<CacheEntryEventFilter<? super K, ? super V>>
getCacheEntryEventFilterFactory();
/**
* Determines if the thread that caused an event to be created should be
* blocked (not return from the operation causing the event) until the
* {@link CacheEntryListener} has been notified.
*
* @return <code>true</code> if the thread that created the event should block
*/
boolean isSynchronous();
}
================================================
FILE: src/main/java/javax/cache/configuration/CompleteConfiguration.java
================================================
/**
* Copyright 2011-2016 Terracotta, Inc.
* Copyright 2011-2016 Oracle America Incorporated
*
* Licensed 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 javax.cache.configuration;
import javax.cache.expiry.ExpiryPolicy;
import javax.cache.integration.CacheLoader;
import javax.cache.integration.CacheWriter;
import java.io.Serializable;
/**
* A read-only representation of the complete JCache {@link javax.cache.Cache}
* configuration.
* <p>
* The properties provided by instances of this interface are used by
* {@link javax.cache.CacheManager}s to configure {@link javax.cache.Cache}s.
* <p>
* Implementations of this interface must override {@link Object#hashCode()} and
* {@link Object#equals(Object)} as
* {@link javax.cache.configuration.CompleteConfiguration}s are often compared at
* runtime.
*
* @param <K> the type of keys maintained the cache
* @param <V> the type of cached values
* @author Greg Luck
* @author Yannis Cosmadopoulos
* @author Brian Oliver
* @since 1.0
*/
public interface CompleteConfiguration<K, V> extends Configuration<K, V>,
Serializable {
/**
* Determines if a {@link javax.cache.Cache} should operate in read-through mode.
* <p>
* When in "read-through" mode, cache misses that occur due to cache entries
* not existing as a result of performing a "get" will appropriately
* cause the configured {@link javax.cache.integration.CacheLoader} to be
* invoked.
* <p>
* The default value is <code>false</code>.
*
* @return <code>true</code> when a {@link javax.cache.Cache} is in
* "read-through" mode.
* @see #getCacheLoaderFactory()
*/
boolean isReadThrough();
/**
* Determines if a {@link javax.cache.Cache} should operate in write-through
* mode.
* <p>
* When in "write-through" mode, cache updates that occur as a result of
* performing "put" operations called via one of
* {@link javax.cache.Cache#put(Object, Object)},
* {@link javax.cache.Cache#getAndRemove(Object)},
* {@link javax.cache.Cache#removeAll()},
* {@link javax.cache.Cache#getAndPut(Object, Object)}
* {@link javax.cache.Cache#getAndRemove(Object)},
* {@link javax.cache.Cache#getAndReplace(Object,
* Object)}, {@link javax.cache.Cache#invoke(Object,
* javax.cache.processor.EntryProcessor,
* Object...)}, {@link javax.cache.Cache#invokeAll(java.util.Set,
* javax.cache.processor.EntryProcessor, Object...)} will appropriately cause
* the configured {@link javax.cache.integration.CacheWriter} to be invoked.
* <p>
* The default value is <code>false</code>.
*
* @return <code>true</code> when a {@link javax.cache.Cache} is in
* "write-through" mode.
* @see #getCacheWriterFactory()
*/
boolean isWriteThrough();
/**
* Checks whether statistics collection is enabled in this cache.
* <p>
* The default value is <code>false</code>.
*
* @return true if statistics collection is enabled
*/
boolean isStatisticsEnabled();
/**
* Checks whether management is enabled on this cache.
* <p>
* The default value is <code>false</code>.
*
* @return true if management is enabled
*/
boolean isManagementEnabled();
/**
* Obtains the {@link javax.cache.configuration.CacheEntryListenerConfiguration}s
* for {@link javax.cache.event.CacheEntryListener}s to be configured on a
* {@link javax.cache.Cache}.
*
* @return an {@link Iterable} over the
* {@link javax.cache.configuration.CacheEntryListenerConfiguration}s
*/
Iterable<CacheEntryListenerConfiguration<K,
V>> getCacheEntryListenerConfigurations();
/**
* Gets the {@link javax.cache.configuration.Factory} for the
* {@link javax.cache.integration.CacheLoader}, if any.
* <p>
* A CacheLoader should be configured for "Read Through" caches to load values
* when a cache miss occurs using either the
* {@link javax.cache.Cache#get(Object)} and/or
* {@link javax.cache.Cache#getAll(java.util.Set)} methods.
* <p>
* The default value is <code>null</code>.
*
* @return the {@link javax.cache.configuration.Factory} for the
* {@link javax.cache.integration.CacheLoader} or null if none has been set.
*/
Factory<CacheLoader<K, V>> getCacheLoaderFactory();
/**
* Gets the {@link javax.cache.configuration.Factory} for the
* {@link javax.cache.integration.CacheWriter}, if any.
* <p>
* The default value is <code>null</code>.
*
* @return the {@link javax.cache.configuration.Factory} for the
* {@link javax.cache.integration.CacheWriter} or null if none has been set.
*/
Factory<CacheWriter<? super K, ? super V>> getCacheWriterFactory();
/**
* Gets the {@link javax.cache.configuration.Factory} for the
* {@link javax.cache.expiry.ExpiryPolicy} to be used for caches.
* <p>
* The default value is a {@link javax.cache.configuration.Factory} that will
* produce a {@link javax.cache.expiry.EternalExpiryPolicy} instance.
*
* @return the {@link javax.cache.configuration.Factory} for
* {@link javax.cache.expiry.ExpiryPolicy} (must not be <code>null</code>)
*/
Factory<ExpiryPolicy> getExpiryPolicyFactory();
}
================================================
FILE: src/main/java/javax/cache/configuration/Configuration.java
================================================
/**
* Copyright 2011-2016 Terracotta, Inc.
* Copyright 2011-2016 Oracle America Incorporated
*
* Licensed 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 javax.cache.configuration;
import javax.cache.Cache;
import javax.cache.CacheManager;
import java.io.Serializable;
/**
* A basic read-only representation of a {@link Cache} configuration.
* <p>
* The properties provided by instances of this interface are used by
* {@link CacheManager}s to configure {@link Cache}s.
* <p>
* Implementations of this interface must override {@link Object#hashCode()} and
* {@link Object#equals(Object)} as {@link Configuration}s are often compared at
* runtime.
*
* @param <K> the type of keys maintained the cache
* @param <V> the type of cached values
* @author Greg Luck
* @author Brian Oliver
* @since 1.0
*/
public interface Configuration<K, V> extends Serializable {
/**
* Determines the required type of keys for {@link Cache}s configured
* with this {@link Configuration}.
*
* @return the key type or <code>Object.class</code> if the type is undefined
*/
Class<K> getKeyType();
/**
* Determines the required type of values for {@link Cache}s configured
* with this {@link Configuration}.
*
* @return the value type or <code>Object.class</code> if the type is undefined
*/
Class<V> getValueType();
/**
* Whether storeByValue (true) or storeByReference (false).
* When true, both keys and values are stored by value.
* <p>
* When false, both keys and values are stored by reference.
* Caches stored by reference are capable of mutation by any threads holding
* the reference. The effects are:
* <ul>
* <li>if the key is mutated, then the key may not be retrievable or
* removable</li>
* <li>if the value is mutated, then all threads in the JVM can potentially
* observe those mutations, subject to the normal Java Memory Model rules.</li>
* </ul>
* Storage by reference only applies to the local heap. If an entry is moved off
* heap it will need to be transformed into a representation. Any mutations that
* occur after transformation may not be reflected in the cache.
* <p>
* When a cache is storeByValue, any mutation to the key or value does not
* affect the key of value stored in the cache.
* <p>
* The default value is <code>true</code>.
*
* @return true if the cache is store by value
*/
boolean isStoreByValue();
}
================================================
FILE: src/main/java/javax/cache/configuration/Factory.java
================================================
/**
* Copyright 2011-2016 Terracotta, Inc.
* Copyright 2011-2016 Oracle America Incorporated
*
* Licensed 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 javax.cache.configuration;
import java.io.Serializable;
/**
* Constructs and returns a fully configured instance of a specific factory type.
* <p>
* Implementations may choose not to construct a new instance, but instead
* return a previously created instance.
* <p>
* Implementations must correctly implement {@link Object#equals(Object)} and
* {@link Object#hashCode()} as {@link Factory}s are often compared with each
* other for equivalence.
*
* @param <T> the type of factory constructed
* @author Brian Oliver
* @since 1.0
*/
public interface Factory<T> extends Serializable {
/**
* Constructs and returns a fully configured instance of T.
*
* @return an instance of T.
*/
T create();
}
================================================
FILE: src/main/java/javax/cache/configuration/FactoryBuilder.java
================================================
/**
* Copyright 2011-2016 Terracotta, Inc.
* Copyright 2011-2016 Oracle America Incorporated
*
* Licensed 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 javax.cache.configuration;
import java.io.Serializable;
/**
* A convenience class that defines generically typed static methods to aid in
* the building of {@link Factory} instances.
* <p>
* {@link Factory} is used by {@link MutableConfiguration} to avoid adding
* non-Serializable instances that would assume usage in the local JVM.
* <p>
* Two styles of builder are available:
* <ul>
* <li>those taking a Class or className. A new instance will be created by
* the {@link Factory}
* </li>
* <li>those taking a Serializable instance. That instance will be created
* by the {@link Factory}. As the instance is Serializable it no assumption of
* usage in the local JVM is implied.
* </li>
* </ul>
*
* Factory instances can also be created in other ways.
*
* @author Brian Oliver
* @author Greg Luck
* @since 1.0
*/
public final class FactoryBuilder {
/**
* A private constructor to prevent instantiation.
*/
private FactoryBuilder() {
//deliberately empty - no instances allowed!
}
/**
* Constructs a {@link Factory} that will produce factory instances of the
* specified class.
* <p>
* The specified class must have a no-args constructor.
*
* @param clazz the class of instances to be produced by the returned
* {@link Factory}
* @param <T> the type of the instances produced by the {@link Factory}
* @return a {@link Factory} for the specified clazz
*/
public static <T> Factory<T> factoryOf(Class<T> clazz) {
return new ClassFactory<T>(clazz);
}
/**
* Constructs a {@link Factory} that will produce factory instances of the
* specified class.
* <p>
* The specified class must have a no-args constructor.
*
* @param className the class of instances to be produced by the returned
* {@link Factory}
* @param <T> the type of the instances produced by the {@link Factory}
* @return a {@link Factory} for the specified clazz
*/
public static <T> Factory<T> factoryOf(String className) {
return new ClassFactory<T>(className);
}
/**
* Constructs a {@link Factory} that will return the specified factory
* Serializable instance.
* <p>
* If T is not Serializable use {@link #factoryOf(Class)} or
* {@link #factoryOf(String)}.
*
* @param instance the Serializable instance the {@link Factory} will return
* @param <T> the type of the instances returned
* @return a {@link Factory} for the instance
*/
public static <T extends Serializable> Factory<T> factoryOf(T instance) {
return new SingletonFactory<T>(instance);
}
/**
* A {@link Factory} that instantiates a specific Class.
*
* @param <T> the type of the instance produced by the {@link Factory}
*/
public static class ClassFactory<T> implements Factory<T>, Serializable {
/**
* The serialVersionUID required for {@link Serializable}.
*/
public static final long serialVersionUID = 201305101626L;
/**
* The name of the Class.
*/
private String className;
/**
* Constructor for the {@link ClassFactory}.
*
* @param clazz the Class to instantiate
*/
public ClassFactory(Class<T> clazz) {
this.className = clazz.getName();
}
/**
* Constructor for the {@link ClassFactory}.
*
* @param className the name of the Class to instantiate
*/
public ClassFactory(String className) {
this.className = className;
}
@Override
public T create() {
try {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
Class<?> clazz = loader.loadClass(className);
return (T) clazz.newInstance();
} catch (Exception e) {
throw new RuntimeException("Failed to create an instance of " + className, e);
}
}
@Override
public boolean equals(Object other) {
if (this == other) return true;
if (other == null || getClass() != other.getClass()) return false;
ClassFactory that = (ClassFactory) other;
if (!className.equals(that.className)) return false;
return true;
}
@Override
public int hashCode() {
return className.hashCode();
}
}
/**
* A {@link Factory} that always returns a specific instance. ie: the
* factory returns a singleton, regardless of the number of times
* {@link Factory#create()} is called.
*
* @param <T> the type of the instance produced by the {@link Factory}
*/
public static class SingletonFactory<T> implements Factory<T>, Serializable {
/**
* The serialVersionUID required for {@link java.io.Serializable}.
*/
public static final long serialVersionUID = 201305101634L;
/**
* The singleton instance.
*/
private T instance;
/**
* Constructor for the {@link SingletonFactory}.
*
* @param instance the instance to return
*/
public SingletonFactory(T instance) {
this.instance = instance;
}
@Override
public T create() {
return instance;
}
@Override
public boolean equals(Object other) {
if (this == other) return true;
if (other == null || getClass() != other.getClass()) return false;
SingletonFactory that = (SingletonFactory) other;
if (!instance.equals(that.instance)) return false;
return true;
}
@Override
public int hashCode() {
return instance.hashCode();
}
}
}
================================================
FILE: src/main/java/javax/cache/configuration/MutableCacheEntryListenerConfiguration.java
================================================
/**
* Copyright 2011-2016 Terracotta, Inc.
* Copyright 2011-2016 Oracle America Incorporated
*
* Licensed 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 javax.cache.configuration;
import javax.cache.event.CacheEntryEventFilter;
import javax.cache.event.CacheEntryListener;
/**
* A convenience class providing a mutable, serializable implementation of a
* {@link CacheEntryListenerConfiguration}.
*
* @param <K> the type of keys maintained the cache
* @param <V> the type of cached values
* @author Brian Oliver
* @since 1.0
*/
public class MutableCacheEntryListenerConfiguration<K, V>
implements CacheEntryListenerConfiguration<K, V> {
/**
* The serialVersionUID required for {@link java.io.Serializable}.
*/
public static final long serialVersionUID = 201306200822L;
/**
* The {@link Factory} to be used to create the {@link CacheEntryListener}.
*/
private Factory<CacheEntryListener<? super K, ? super V>> listenerFactory;
/**
* The {@link Factory} to be used to create the {@link CacheEntryEventFilter}.
* (may be null if no filtering is required)
*/
private Factory<CacheEntryEventFilter<? super K, ? super V>> filterFactory;
/**
* Is the old value required to be provide to the {@link CacheEntryListener}?
*/
private boolean isOldValueRequired;
/**
* Should the {@link CacheEntryListener} be notified as part of an operation
* or is asynchronous delivery acceptable?
*/
private boolean isSynchronous;
/**
* Constructs a {@link MutableCacheEntryListenerConfiguration} based on
* another {@link CacheEntryListenerConfiguration}.
*
* @param configuration the {@link CacheEntryListenerConfiguration}
*/
public MutableCacheEntryListenerConfiguration(CacheEntryListenerConfiguration<K, V> configuration) {
this.listenerFactory = configuration.getCacheEntryListenerFactory();
this.filterFactory = configuration.getCacheEntryEventFilterFactory();
this.isOldValueRequired = configuration.isOldValueRequired();
this.isSynchronous = configuration.isSynchronous();
}
/**
* Constructs a {@link MutableCacheEntryListenerConfiguration}.
*
* @param listenerFactory the {@link CacheEntryListener} {@link Factory}
* @param filterFactory the optional {@link CacheEntryEventFilter} {@link Factory}
* @param isOldValueRequired if the old value is required for events with this listenerFactory
* @param isSynchronous if the listenerFactory should block the thread causing the event
*/
public MutableCacheEntryListenerConfiguration(Factory<? extends CacheEntryListener<? super K, ? super V>> listenerFactory,
Factory<? extends
CacheEntryEventFilter<? super K, ? super V>> filterFactory,
boolean isOldValueRequired,
boolean isSynchronous) {
this.listenerFactory = (Factory<CacheEntryListener<? super K, ? super V>>) listenerFactory;
this.filterFactory = (Factory<CacheEntryEventFilter<? super K, ? super V>>) filterFactory;
this.isOldValueRequired = isOldValueRequired;
this.isSynchronous = isSynchronous;
}
/**
* {@inheritDoc}
*/
@Override
public Factory<CacheEntryListener<? super K, ? super V>> getCacheEntryListenerFactory() {
return listenerFactory;
}
/**
* Sets the {@link Factory} to be used to create a {@link CacheEntryListener}.
*
* @param listenerFactory the {@link Factory}
* @return the {@link MutableCacheEntryListenerConfiguration} to permit
* fluent-style method calls
*/
public MutableCacheEntryListenerConfiguration<K, V> setCacheEntryListenerFactory(
Factory<? extends CacheEntryListener<? super K, ? super V>> listenerFactory) {
this.listenerFactory = (Factory<CacheEntryListener<? super K, ? super V>>) listenerFactory;
return this;
}
/**
* {@inheritDoc}
*/
@Override
public Factory<CacheEntryEventFilter<? super K, ? super V>> getCacheEntryEventFilterFactory() {
return filterFactory;
}
/**
* Sets the {@link Factory} to be used to create a {@link CacheEntryEventFilter}.
*
* @param filterFactory the {@link Factory}, or <code>null</code> if event
* filtering is not requried
* @return the {@link MutableCacheEntryListenerConfiguration} to permit
* fluent-style method calls
*/
public MutableCacheEntryListenerConfiguration<K, V> setCacheEntryEventFilterFactory(
Factory<? extends CacheEntryEventFilter<? super K, ? super V>> filterFactory) {
this.fil
gitextract_8lerwxfn/
├── .gitignore
├── LICENSE.txt
├── README.md
├── bnd.bnd
├── checkstyle/
│ ├── ClassHeader.txt
│ ├── checkstyle.xml
│ └── suppressions.xml
├── findbugs/
│ └── findbugs-exclude.xml
├── pom.xml
└── src/
└── main/
└── java/
└── javax/
└── cache/
├── Cache.java
├── CacheException.java
├── CacheManager.java
├── Caching.java
├── annotation/
│ ├── CacheDefaults.java
│ ├── CacheInvocationContext.java
│ ├── CacheInvocationParameter.java
│ ├── CacheKey.java
│ ├── CacheKeyGenerator.java
│ ├── CacheKeyInvocationContext.java
│ ├── CacheMethodDetails.java
│ ├── CachePut.java
│ ├── CacheRemove.java
│ ├── CacheRemoveAll.java
│ ├── CacheResolver.java
│ ├── CacheResolverFactory.java
│ ├── CacheResult.java
│ ├── CacheValue.java
│ ├── GeneratedCacheKey.java
│ └── package-info.java
├── configuration/
│ ├── CacheEntryListenerConfiguration.java
│ ├── CompleteConfiguration.java
│ ├── Configuration.java
│ ├── Factory.java
│ ├── FactoryBuilder.java
│ ├── MutableCacheEntryListenerConfiguration.java
│ ├── MutableConfiguration.java
│ ├── OptionalFeature.java
│ └── package-info.java
├── event/
│ ├── CacheEntryCreatedListener.java
│ ├── CacheEntryEvent.java
│ ├── CacheEntryEventFilter.java
│ ├── CacheEntryExpiredListener.java
│ ├── CacheEntryListener.java
│ ├── CacheEntryListenerException.java
│ ├── CacheEntryRemovedListener.java
│ ├── CacheEntryUpdatedListener.java
│ ├── EventType.java
│ └── package-info.java
├── expiry/
│ ├── AccessedExpiryPolicy.java
│ ├── CreatedExpiryPolicy.java
│ ├── Duration.java
│ ├── EternalExpiryPolicy.java
│ ├── ExpiryPolicy.java
│ ├── ModifiedExpiryPolicy.java
│ ├── TouchedExpiryPolicy.java
│ └── package-info.java
├── integration/
│ ├── CacheLoader.java
│ ├── CacheLoaderException.java
│ ├── CacheWriter.java
│ ├── CacheWriterException.java
│ ├── CompletionListener.java
│ ├── CompletionListenerFuture.java
│ └── package-info.java
├── management/
│ ├── CacheMXBean.java
│ ├── CacheStatisticsMXBean.java
│ └── package-info.java
├── package-info.java
├── processor/
│ ├── EntryProcessor.java
│ ├── EntryProcessorException.java
│ ├── EntryProcessorResult.java
│ ├── MutableEntry.java
│ └── package-info.java
└── spi/
├── CachingProvider.java
└── package-info.java
SYMBOL INDEX (334 symbols across 49 files)
FILE: src/main/java/javax/cache/Cache.java
type Cache (line 80) | public interface Cache<K, V> extends Iterable<Cache.Entry<K, V>>, Closea...
method get (line 98) | V get(K key);
method getAll (line 121) | Map<K, V> getAll(Set<? extends K> keys);
method containsKey (line 144) | boolean containsKey(K key);
method loadAll (line 181) | void loadAll(Set<? extends K> keys, boolean replaceExistingValues,
method put (line 210) | void put(K key, V value);
method getAndPut (line 244) | V getAndPut(K key, V value);
method putAll (line 278) | void putAll(java.util.Map<? extends K, ? extends V> map);
method putIfAbsent (line 310) | boolean putIfAbsent(K key, V value);
method remove (line 340) | boolean remove(K key);
method remove (line 372) | boolean remove(K key, V oldValue);
method getAndRemove (line 405) | V getAndRemove(K key);
method replace (line 438) | boolean replace(K key, V oldValue, V newValue);
method replace (line 470) | boolean replace(K key, V value);
method getAndReplace (line 505) | V getAndReplace(K key, V value);
method removeAll (line 528) | void removeAll(Set<? extends K> keys);
method removeAll (line 550) | void removeAll();
method clear (line 559) | void clear();
method getConfiguration (line 578) | <C extends Configuration<K, V>> C getConfiguration(Class<C> clazz);
method invoke (line 603) | <T> T invoke(K key,
method invokeAll (line 640) | <T> Map<K, EntryProcessorResult<T>> invokeAll(Set<? extends K> keys,
method getName (line 650) | String getName();
method getCacheManager (line 658) | CacheManager getCacheManager();
method close (line 694) | void close();
method isClosed (line 713) | boolean isClosed();
method unwrap (line 731) | <T> T unwrap(java.lang.Class<T> clazz);
method registerCacheEntryListener (line 746) | void registerCacheEntryListener(
method deregisterCacheEntryListener (line 763) | void deregisterCacheEntryListener(CacheEntryListenerConfiguration<K, V>
method iterator (line 781) | Iterator<Cache.Entry<K, V>> iterator();
type Entry (line 786) | interface Entry<K, V> {
method getKey (line 793) | K getKey();
method getValue (line 800) | V getValue();
method unwrap (line 816) | <T> T unwrap(Class<T> clazz);
FILE: src/main/java/javax/cache/CacheException.java
class CacheException (line 28) | public class CacheException extends RuntimeException {
method CacheException (line 36) | public CacheException() {
method CacheException (line 47) | public CacheException(String message) {
method CacheException (line 63) | public CacheException(String message, Throwable cause) {
method CacheException (line 80) | public CacheException(Throwable cause) {
FILE: src/main/java/javax/cache/CacheManager.java
type CacheManager (line 76) | public interface CacheManager extends Closeable {
method getCachingProvider (line 85) | CachingProvider getCachingProvider();
method getURI (line 92) | URI getURI();
method getClassLoader (line 99) | ClassLoader getClassLoader();
method getProperties (line 111) | Properties getProperties();
method createCache (line 158) | <K, V, C extends Configuration<K, V>> Cache<K, V> createCache(String c...
method getCache (line 194) | <K, V> Cache<K, V> getCache(String cacheName, Class<K> keyType,
method getCache (line 221) | <K, V> Cache<K, V> getCache(String cacheName);
method getCacheNames (line 244) | Iterable<String> getCacheNames();
method destroyCache (line 270) | void destroyCache(String cacheName);
method enableManagement (line 300) | void enableManagement(String cacheName, boolean enabled);
method enableStatistics (line 326) | void enableStatistics(String cacheName, boolean enabled);
method close (line 357) | void close();
method isClosed (line 377) | boolean isClosed();
method unwrap (line 395) | <T> T unwrap(java.lang.Class<T> clazz);
FILE: src/main/java/javax/cache/Caching.java
class Caching (line 95) | public final class Caching {
method Caching (line 112) | private Caching() {
method getDefaultClassLoader (line 123) | public static ClassLoader getDefaultClassLoader() {
method setDefaultClassLoader (line 135) | public static void setDefaultClassLoader(ClassLoader classLoader) {
method getCachingProvider (line 150) | public static CachingProvider getCachingProvider() {
method getCachingProvider (line 168) | public static CachingProvider getCachingProvider(ClassLoader classLoad...
method getCachingProviders (line 186) | public static Iterable<CachingProvider> getCachingProviders() {
method getCachingProviders (line 206) | public static Iterable<CachingProvider> getCachingProviders(
method getCachingProvider (line 225) | public static CachingProvider getCachingProvider(String fullyQualified...
method getCachingProvider (line 245) | public static CachingProvider getCachingProvider(String fullyQualified...
method getCache (line 286) | public static <K, V> Cache<K, V> getCache(String cacheName, Class<K> k...
class CachingProviderRegistry (line 297) | private static class CachingProviderRegistry {
method CachingProviderRegistry (line 315) | public CachingProviderRegistry() {
method getDefaultClassLoader (line 329) | public ClassLoader getDefaultClassLoader() {
method setDefaultClassLoader (line 342) | public void setDefaultClassLoader(ClassLoader classLoader) {
method getCachingProvider (line 360) | public CachingProvider getCachingProvider() {
method getCachingProvider (line 379) | public CachingProvider getCachingProvider(ClassLoader classLoader) {
method getCachingProviders (line 409) | public Iterable<CachingProvider> getCachingProviders() {
method getCachingProviders (line 429) | public synchronized Iterable<CachingProvider> getCachingProviders(Cl...
method getCachingProvider (line 475) | public CachingProvider getCachingProvider(String fullyQualifiedClass...
method loadCachingProvider (line 492) | protected CachingProvider loadCachingProvider(String fullyQualifiedC...
method getCachingProvider (line 521) | public synchronized CachingProvider getCachingProvider(String fullyQ...
FILE: src/main/java/javax/cache/annotation/CacheInvocationContext.java
type CacheInvocationContext (line 36) | public interface CacheInvocationContext<A extends Annotation>
method getTarget (line 42) | Object getTarget();
method getAllParameters (line 49) | CacheInvocationParameter[] getAllParameters();
method unwrap (line 64) | <T> T unwrap(java.lang.Class<T> cls);
FILE: src/main/java/javax/cache/annotation/CacheInvocationParameter.java
type CacheInvocationParameter (line 28) | public interface CacheInvocationParameter {
method getRawType (line 33) | Class<?> getRawType();
method getValue (line 38) | Object getValue();
method getAnnotations (line 44) | Set<Annotation> getAnnotations();
method getParameterPosition (line 52) | int getParameterPosition();
FILE: src/main/java/javax/cache/annotation/CacheKeyGenerator.java
type CacheKeyGenerator (line 30) | public interface CacheKeyGenerator {
method generateCacheKey (line 40) | GeneratedCacheKey generateCacheKey(CacheKeyInvocationContext<? extends...
FILE: src/main/java/javax/cache/annotation/CacheKeyInvocationContext.java
type CacheKeyInvocationContext (line 34) | public interface CacheKeyInvocationContext<A extends Annotation>
method getKeyParameters (line 58) | CacheInvocationParameter[] getKeyParameters();
method getValueParameter (line 68) | CacheInvocationParameter getValueParameter();
FILE: src/main/java/javax/cache/annotation/CacheMethodDetails.java
type CacheMethodDetails (line 37) | public interface CacheMethodDetails<A extends Annotation> {
method getMethod (line 43) | Method getMethod();
method getAnnotations (line 50) | Set<Annotation> getAnnotations();
method getCacheAnnotation (line 59) | A getCacheAnnotation();
method getCacheName (line 89) | String getCacheName();
FILE: src/main/java/javax/cache/annotation/CacheResolver.java
type CacheResolver (line 31) | public interface CacheResolver {
method resolveCache (line 42) | <K, V> Cache<K, V> resolveCache(CacheInvocationContext<? extends Annot...
FILE: src/main/java/javax/cache/annotation/CacheResolverFactory.java
type CacheResolverFactory (line 31) | public interface CacheResolverFactory {
method getCacheResolver (line 43) | CacheResolver getCacheResolver(CacheMethodDetails<? extends Annotation>
method getExceptionCacheResolver (line 56) | CacheResolver getExceptionCacheResolver(CacheMethodDetails<CacheResult>
FILE: src/main/java/javax/cache/annotation/GeneratedCacheKey.java
type GeneratedCacheKey (line 35) | public interface GeneratedCacheKey extends Serializable {
method hashCode (line 43) | @Override
method equals (line 54) | @Override
FILE: src/main/java/javax/cache/configuration/CacheEntryListenerConfiguration.java
type CacheEntryListenerConfiguration (line 34) | public interface CacheEntryListenerConfiguration<K, V> extends Serializa...
method getCacheEntryListenerFactory (line 42) | Factory<CacheEntryListener<? super K, ? super V>> getCacheEntryListene...
method isOldValueRequired (line 51) | boolean isOldValueRequired();
method getCacheEntryEventFilterFactory (line 64) | Factory<CacheEntryEventFilter<? super K, ? super V>>
method isSynchronous (line 74) | boolean isSynchronous();
FILE: src/main/java/javax/cache/configuration/CompleteConfiguration.java
type CompleteConfiguration (line 43) | public interface CompleteConfiguration<K, V> extends Configuration<K, V>,
method isReadThrough (line 60) | boolean isReadThrough();
method isWriteThrough (line 86) | boolean isWriteThrough();
method isStatisticsEnabled (line 95) | boolean isStatisticsEnabled();
method isManagementEnabled (line 104) | boolean isManagementEnabled();
method getCacheEntryListenerConfigurations (line 114) | Iterable<CacheEntryListenerConfiguration<K,
method getCacheLoaderFactory (line 131) | Factory<CacheLoader<K, V>> getCacheLoaderFactory();
method getCacheWriterFactory (line 142) | Factory<CacheWriter<? super K, ? super V>> getCacheWriterFactory();
method getExpiryPolicyFactory (line 154) | Factory<ExpiryPolicy> getExpiryPolicyFactory();
FILE: src/main/java/javax/cache/configuration/Configuration.java
type Configuration (line 39) | public interface Configuration<K, V> extends Serializable {
method getKeyType (line 47) | Class<K> getKeyType();
method getValueType (line 55) | Class<V> getValueType();
method isStoreByValue (line 81) | boolean isStoreByValue();
FILE: src/main/java/javax/cache/configuration/Factory.java
type Factory (line 35) | public interface Factory<T> extends Serializable {
method create (line 42) | T create();
FILE: src/main/java/javax/cache/configuration/FactoryBuilder.java
class FactoryBuilder (line 45) | public final class FactoryBuilder {
method FactoryBuilder (line 50) | private FactoryBuilder() {
method factoryOf (line 65) | public static <T> Factory<T> factoryOf(Class<T> clazz) {
method factoryOf (line 80) | public static <T> Factory<T> factoryOf(String className) {
method factoryOf (line 95) | public static <T extends Serializable> Factory<T> factoryOf(T instance) {
class ClassFactory (line 105) | public static class ClassFactory<T> implements Factory<T>, Serializable {
method ClassFactory (line 122) | public ClassFactory(Class<T> clazz) {
method ClassFactory (line 131) | public ClassFactory(String className) {
method create (line 135) | @Override
method equals (line 148) | @Override
method hashCode (line 160) | @Override
class SingletonFactory (line 173) | public static class SingletonFactory<T> implements Factory<T>, Seriali...
method SingletonFactory (line 190) | public SingletonFactory(T instance) {
method create (line 194) | @Override
method equals (line 199) | @Override
method hashCode (line 211) | @Override
FILE: src/main/java/javax/cache/configuration/MutableCacheEntryListenerConfiguration.java
class MutableCacheEntryListenerConfiguration (line 31) | public class MutableCacheEntryListenerConfiguration<K, V>
method MutableCacheEntryListenerConfiguration (line 67) | public MutableCacheEntryListenerConfiguration(CacheEntryListenerConfig...
method MutableCacheEntryListenerConfiguration (line 82) | public MutableCacheEntryListenerConfiguration(Factory<? extends CacheE...
method getCacheEntryListenerFactory (line 96) | @Override
method setCacheEntryListenerFactory (line 108) | public MutableCacheEntryListenerConfiguration<K, V> setCacheEntryListe...
method getCacheEntryEventFilterFactory (line 117) | @Override
method setCacheEntryEventFilterFactory (line 130) | public MutableCacheEntryListenerConfiguration<K, V> setCacheEntryEvent...
method isOldValueRequired (line 139) | @Override
method setOldValueRequired (line 151) | public MutableCacheEntryListenerConfiguration<K, V> setOldValueRequired(
method isSynchronous (line 160) | @Override
method setSynchronous (line 174) | public MutableCacheEntryListenerConfiguration<K, V> setSynchronous(
method hashCode (line 184) | @Override
method equals (line 199) | @Override
FILE: src/main/java/javax/cache/configuration/MutableConfiguration.java
class MutableConfiguration (line 37) | public class MutableConfiguration<K, V> implements CompleteConfiguration...
method MutableConfiguration (line 122) | public MutableConfiguration() {
method MutableConfiguration (line 145) | public MutableConfiguration(CompleteConfiguration<K, V> configuration) {
method getKeyType (line 179) | @Override
method getValueType (line 187) | @Override
method setTypes (line 210) | public MutableConfiguration<K, V> setTypes(Class<K> keyType, Class<V> ...
method getCacheEntryListenerConfigurations (line 223) | @Override
method addCacheEntryListenerConfiguration (line 238) | public MutableConfiguration<K, V> addCacheEntryListenerConfiguration(
method removeCacheEntryListenerConfiguration (line 268) | public MutableConfiguration<K, V> removeCacheEntryListenerConfiguration(
method getCacheLoaderFactory (line 283) | @Override
method setCacheLoaderFactory (line 294) | public MutableConfiguration<K, V> setCacheLoaderFactory(Factory<? extends
method getCacheWriterFactory (line 303) | @Override
method setCacheWriterFactory (line 314) | public MutableConfiguration<K, V> setCacheWriterFactory(Factory<? extends
method getExpiryPolicyFactory (line 323) | public Factory<ExpiryPolicy> getExpiryPolicyFactory() {
method setExpiryPolicyFactory (line 336) | public MutableConfiguration<K, V> setExpiryPolicyFactory(Factory<? ext...
method isReadThrough (line 349) | @Override
method setReadThrough (line 363) | public MutableConfiguration<K, V> setReadThrough(boolean isReadThrough) {
method isWriteThrough (line 371) | @Override
method setWriteThrough (line 385) | public MutableConfiguration<K, V> setWriteThrough(boolean isWriteThrou...
method isStoreByValue (line 393) | @Override
method setStoreByValue (line 406) | public MutableConfiguration<K, V> setStoreByValue(boolean isStoreByVal...
method isStatisticsEnabled (line 414) | @Override
method setStatisticsEnabled (line 428) | public MutableConfiguration<K, V> setStatisticsEnabled(boolean enabled) {
method isManagementEnabled (line 436) | @Override
method setManagementEnabled (line 450) | public MutableConfiguration<K, V> setManagementEnabled(boolean enabled) {
method hashCode (line 459) | @Override
method equals (line 485) | @Override
FILE: src/main/java/javax/cache/configuration/OptionalFeature.java
type OptionalFeature (line 26) | public enum OptionalFeature {
FILE: src/main/java/javax/cache/event/CacheEntryCreatedListener.java
type CacheEntryCreatedListener (line 33) | public interface CacheEntryCreatedListener<K, V> extends CacheEntryListe...
method onCreated (line 41) | void onCreated(Iterable<CacheEntryEvent<? extends K, ? extends V>> eve...
FILE: src/main/java/javax/cache/event/CacheEntryEvent.java
class CacheEntryEvent (line 31) | public abstract class CacheEntryEvent<K, V> extends EventObject
method CacheEntryEvent (line 42) | public CacheEntryEvent(Cache source, EventType eventType) {
method getSource (line 50) | @Override
method getValue (line 70) | @Override
method getOldValue (line 88) | public abstract V getOldValue();
method isOldValueAvailable (line 101) | public abstract boolean isOldValueAvailable();
method getEventType (line 108) | public final EventType getEventType() {
FILE: src/main/java/javax/cache/event/CacheEntryEventFilter.java
type CacheEntryEventFilter (line 31) | public interface CacheEntryEventFilter<K, V> {
method evaluate (line 41) | boolean evaluate(CacheEntryEvent<? extends K, ? extends V> event)
FILE: src/main/java/javax/cache/event/CacheEntryExpiredListener.java
type CacheEntryExpiredListener (line 28) | public interface CacheEntryExpiredListener<K, V> extends CacheEntryListe...
method onExpired (line 37) | void onExpired(Iterable<CacheEntryEvent<? extends K, ? extends V>> eve...
FILE: src/main/java/javax/cache/event/CacheEntryListener.java
type CacheEntryListener (line 62) | public interface CacheEntryListener<K, V> extends EventListener {
FILE: src/main/java/javax/cache/event/CacheEntryListenerException.java
class CacheEntryListenerException (line 29) | public class CacheEntryListenerException extends CacheException {
method CacheEntryListenerException (line 37) | public CacheEntryListenerException() {
method CacheEntryListenerException (line 47) | public CacheEntryListenerException(String message) {
method CacheEntryListenerException (line 63) | public CacheEntryListenerException(String message, Throwable cause) {
method CacheEntryListenerException (line 81) | public CacheEntryListenerException(Throwable cause) {
FILE: src/main/java/javax/cache/event/CacheEntryRemovedListener.java
type CacheEntryRemovedListener (line 29) | public interface CacheEntryRemovedListener<K, V> extends CacheEntryListe...
method onRemoved (line 38) | void onRemoved(Iterable<CacheEntryEvent<? extends K, ? extends V>> eve...
FILE: src/main/java/javax/cache/event/CacheEntryUpdatedListener.java
type CacheEntryUpdatedListener (line 30) | public interface CacheEntryUpdatedListener<K, V> extends CacheEntryListe...
method onUpdated (line 38) | void onUpdated(Iterable<CacheEntryEvent<? extends K, ? extends V>> eve...
FILE: src/main/java/javax/cache/event/EventType.java
type EventType (line 25) | public enum EventType {
FILE: src/main/java/javax/cache/expiry/AccessedExpiryPolicy.java
class AccessedExpiryPolicy (line 32) | public final class AccessedExpiryPolicy implements ExpiryPolicy, Seriali...
method AccessedExpiryPolicy (line 50) | public AccessedExpiryPolicy(Duration expiryDuration) {
method factoryOf (line 59) | public static Factory<ExpiryPolicy> factoryOf(Duration duration) {
method getExpiryForCreation (line 67) | @Override
method getExpiryForAccess (line 76) | @Override
method getExpiryForUpdate (line 86) | @Override
method hashCode (line 95) | @Override
method equals (line 106) | @Override
FILE: src/main/java/javax/cache/expiry/CreatedExpiryPolicy.java
class CreatedExpiryPolicy (line 32) | public final class CreatedExpiryPolicy implements ExpiryPolicy, Serializ...
method CreatedExpiryPolicy (line 50) | public CreatedExpiryPolicy(Duration expiryDuration) {
method factoryOf (line 59) | public static Factory<ExpiryPolicy> factoryOf(Duration duration) {
method getExpiryForCreation (line 66) | @Override
method getExpiryForAccess (line 75) | @Override
method getExpiryForUpdate (line 84) | @Override
method hashCode (line 93) | @Override
method equals (line 104) | @Override
FILE: src/main/java/javax/cache/expiry/Duration.java
class Duration (line 38) | public class Duration implements Serializable {
method Duration (line 106) | public Duration() {
method Duration (line 120) | public Duration(TimeUnit timeUnit, long durationAmount) {
method Duration (line 156) | public Duration(long startTime, long endTime) {
method getTimeUnit (line 177) | public TimeUnit getTimeUnit() {
method getDurationAmount (line 186) | public long getDurationAmount() {
method isEternal (line 195) | public boolean isEternal() {
method isZero (line 204) | public boolean isZero() {
method getAdjustedTime (line 218) | public long getAdjustedTime(long time) {
method equals (line 229) | @Override
method hashCode (line 256) | @Override
FILE: src/main/java/javax/cache/expiry/EternalExpiryPolicy.java
class EternalExpiryPolicy (line 36) | public final class EternalExpiryPolicy implements ExpiryPolicy, Serializ...
method factoryOf (line 48) | public static Factory<ExpiryPolicy> factoryOf() {
method getExpiryForCreation (line 56) | @Override
method getExpiryForAccess (line 64) | @Override
method getExpiryForUpdate (line 72) | @Override
method hashCode (line 80) | @Override
method equals (line 88) | @Override
FILE: src/main/java/javax/cache/expiry/ExpiryPolicy.java
type ExpiryPolicy (line 32) | public interface ExpiryPolicy {
method getExpiryForCreation (line 49) | Duration getExpiryForCreation();
method getExpiryForAccess (line 66) | Duration getExpiryForAccess();
method getExpiryForUpdate (line 83) | Duration getExpiryForUpdate();
FILE: src/main/java/javax/cache/expiry/ModifiedExpiryPolicy.java
class ModifiedExpiryPolicy (line 33) | public final class ModifiedExpiryPolicy implements ExpiryPolicy, Seriali...
method ModifiedExpiryPolicy (line 51) | public ModifiedExpiryPolicy(Duration expiryDuration) {
method factoryOf (line 61) | public static Factory<ExpiryPolicy> factoryOf(Duration duration) {
method getExpiryForCreation (line 68) | @Override
method getExpiryForAccess (line 76) | @Override
method getExpiryForUpdate (line 85) | @Override
method hashCode (line 95) | @Override
method equals (line 106) | @Override
FILE: src/main/java/javax/cache/expiry/TouchedExpiryPolicy.java
class TouchedExpiryPolicy (line 33) | public final class TouchedExpiryPolicy implements ExpiryPolicy, Serializ...
method TouchedExpiryPolicy (line 51) | public TouchedExpiryPolicy(Duration expiryDuration) {
method factoryOf (line 60) | public static Factory<ExpiryPolicy> factoryOf(Duration duration) {
method getExpiryForCreation (line 67) | @Override
method getExpiryForAccess (line 76) | @Override
method getExpiryForUpdate (line 85) | @Override
method hashCode (line 94) | @Override
method equals (line 105) | @Override
FILE: src/main/java/javax/cache/integration/CacheLoader.java
type CacheLoader (line 35) | public interface CacheLoader<K, V> {
method load (line 48) | V load(K key) throws CacheLoaderException;
method loadAll (line 62) | Map<K, V> loadAll(Iterable<? extends K> keys) throws CacheLoaderExcept...
FILE: src/main/java/javax/cache/integration/CacheLoaderException.java
class CacheLoaderException (line 29) | public class CacheLoaderException extends CacheException {
method CacheLoaderException (line 37) | public CacheLoaderException() {
method CacheLoaderException (line 47) | public CacheLoaderException(String message) {
method CacheLoaderException (line 63) | public CacheLoaderException(String message, Throwable cause) {
method CacheLoaderException (line 81) | public CacheLoaderException(Throwable cause) {
FILE: src/main/java/javax/cache/integration/CacheWriter.java
type CacheWriter (line 47) | public interface CacheWriter<K, V> {
method write (line 60) | void write(Cache.Entry<? extends K, ? extends V> entry) throws CacheWr...
method writeAll (line 82) | void writeAll(Collection<Cache.Entry<? extends K, ? extends V>> entrie...
method delete (line 98) | void delete(Object key) throws CacheWriterException;
method deleteAll (line 128) | void deleteAll(Collection<?> keys) throws CacheWriterException;
FILE: src/main/java/javax/cache/integration/CacheWriterException.java
class CacheWriterException (line 29) | public class CacheWriterException extends CacheException {
method CacheWriterException (line 37) | public CacheWriterException() {
method CacheWriterException (line 47) | public CacheWriterException(String message) {
method CacheWriterException (line 63) | public CacheWriterException(String message, Throwable cause) {
method CacheWriterException (line 81) | public CacheWriterException(Throwable cause) {
FILE: src/main/java/javax/cache/integration/CompletionListener.java
type CompletionListener (line 40) | public interface CompletionListener {
method onCompletion (line 45) | void onCompletion();
method onException (line 52) | void onException(Exception e);
FILE: src/main/java/javax/cache/integration/CompletionListenerFuture.java
class CompletionListenerFuture (line 49) | public class CompletionListenerFuture implements CompletionListener, Fut...
method CompletionListenerFuture (line 58) | public CompletionListenerFuture() {
method onCompletion (line 67) | @Override
method onException (line 83) | @Override
method markAsCompleted (line 97) | private void markAsCompleted() {
method cancel (line 108) | @Override
method isCancelled (line 118) | @Override
method isDone (line 123) | @Override
method get (line 140) | @Override
method get (line 167) | @Override
FILE: src/main/java/javax/cache/management/CacheMXBean.java
type CacheMXBean (line 44) | @MXBean
method getKeyType (line 53) | String getKeyType();
method getValueType (line 60) | String getValueType();
method isReadThrough (line 80) | boolean isReadThrough();
method isWriteThrough (line 104) | boolean isWriteThrough();
method isStoreByValue (line 130) | boolean isStoreByValue();
method isStatisticsEnabled (line 139) | boolean isStatisticsEnabled();
method isManagementEnabled (line 148) | boolean isManagementEnabled();
FILE: src/main/java/javax/cache/management/CacheStatisticsMXBean.java
type CacheStatisticsMXBean (line 45) | @MXBean
method clear (line 51) | void clear();
method getCacheHits (line 69) | long getCacheHits();
method getCacheHitPercentage (line 79) | float getCacheHitPercentage();
method getCacheMisses (line 104) | long getCacheMisses();
method getCacheMissPercentage (line 115) | float getCacheMissPercentage();
method getCacheGets (line 129) | long getCacheGets();
method getCachePuts (line 141) | long getCachePuts();
method getCacheRemovals (line 149) | long getCacheRemovals();
method getCacheEvictions (line 158) | long getCacheEvictions();
method getAverageGetTime (line 168) | float getAverageGetTime();
method getAveragePutTime (line 175) | float getAveragePutTime();
method getAverageRemoveTime (line 182) | float getAverageRemoveTime();
FILE: src/main/java/javax/cache/processor/EntryProcessor.java
type EntryProcessor (line 144) | public interface EntryProcessor<K, V, T> {
method process (line 154) | T process(MutableEntry<K, V> entry, Object... arguments)
FILE: src/main/java/javax/cache/processor/EntryProcessorException.java
class EntryProcessorException (line 31) | public class EntryProcessorException extends CacheException {
method EntryProcessorException (line 39) | public EntryProcessorException() {
method EntryProcessorException (line 49) | public EntryProcessorException(String message) {
method EntryProcessorException (line 65) | public EntryProcessorException(String message, Throwable cause) {
method EntryProcessorException (line 83) | public EntryProcessorException(Throwable cause) {
FILE: src/main/java/javax/cache/processor/EntryProcessorResult.java
type EntryProcessorResult (line 30) | public interface EntryProcessorResult<T> {
method get (line 47) | T get() throws EntryProcessorException;
FILE: src/main/java/javax/cache/processor/MutableEntry.java
type MutableEntry (line 35) | public interface MutableEntry<K, V> extends Cache.Entry<K, V> {
method exists (line 42) | boolean exists();
method remove (line 49) | void remove();
method getValue (line 61) | V getValue();
method setValue (line 78) | void setValue(V value);
FILE: src/main/java/javax/cache/spi/CachingProvider.java
type CachingProvider (line 40) | public interface CachingProvider extends Closeable {
method getCacheManager (line 77) | CacheManager getCacheManager(URI uri, ClassLoader classLoader,
method getDefaultClassLoader (line 86) | ClassLoader getDefaultClassLoader();
method getDefaultURI (line 96) | URI getDefaultURI();
method getDefaultProperties (line 106) | Properties getDefaultProperties();
method getCacheManager (line 128) | CacheManager getCacheManager(URI uri, ClassLoader classLoader);
method getCacheManager (line 143) | CacheManager getCacheManager();
method close (line 157) | void close();
method close (line 171) | void close(ClassLoader classLoader);
method close (line 183) | void close(URI uri, ClassLoader classLoader);
method isSupported (line 192) | boolean isSupported(OptionalFeature optionalFeature);
Condensed preview — 74 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (346K chars).
[
{
"path": ".gitignore",
"chars": 77,
"preview": "*.iml\n*.ipr\n*.iws\n.idea\ntarget\n/.settings\n/.project\n/.classpath\n/.checkstyle\n"
},
{
"path": "LICENSE.txt",
"chars": 11357,
"preview": "\n Apache License\n Version 2.0, January 2004\n "
},
{
"path": "README.md",
"chars": 6452,
"preview": "JSR107 (JCache)\n===============\n\nAbout\n-----\n\n*JCache* is the Java caching API. It was defined by JSR107. It defines a s"
},
{
"path": "bnd.bnd",
"chars": 294,
"preview": "Export-Package: javax.cache;\\\n\tjavax.cache.annotation;\\\n\tjavax.cache.configuration;\\\n\tjavax.cache.event;\\\n\tjavax.cache.e"
},
{
"path": "checkstyle/ClassHeader.txt",
"chars": 656,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "checkstyle/checkstyle.xml",
"chars": 10827,
"preview": "<?xml version=\"1.0\"?>\n<!DOCTYPE module PUBLIC\n \"-//Puppy Crawl//DTD Check Configuration 1.2//EN\"\n \"http://"
},
{
"path": "checkstyle/suppressions.xml",
"chars": 1140,
"preview": "<?xml version=\"1.0\"?>\n\n<!DOCTYPE suppressions PUBLIC\n \"-//Puppy Crawl//DTD Suppressions 1.1//EN\"\n \"http://"
},
{
"path": "findbugs/findbugs-exclude.xml",
"chars": 474,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<FindBugsFilter>\n <Match>\n <!--Two false NO_NOTIFY_NOT_NOTIFYALL errors"
},
{
"path": "pom.xml",
"chars": 11870,
"preview": "<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n "
},
{
"path": "src/main/java/javax/cache/Cache.java",
"chars": 37967,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/CacheException.java",
"chars": 2669,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/CacheManager.java",
"chars": 17065,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/Caching.java",
"chars": 23427,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/annotation/CacheDefaults.java",
"chars": 3480,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/annotation/CacheInvocationContext.java",
"chars": 2425,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/annotation/CacheInvocationParameter.java",
"chars": 1539,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/annotation/CacheKey.java",
"chars": 1358,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/annotation/CacheKeyGenerator.java",
"chars": 1408,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/annotation/CacheKeyInvocationContext.java",
"chars": 2686,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/annotation/CacheMethodDetails.java",
"chars": 2883,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/annotation/CachePut.java",
"chars": 5345,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/annotation/CacheRemove.java",
"chars": 5221,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/annotation/CacheRemoveAll.java",
"chars": 4528,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/annotation/CacheResolver.java",
"chars": 1495,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/annotation/CacheResolverFactory.java",
"chars": 2285,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/annotation/CacheResult.java",
"chars": 6938,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/annotation/CacheValue.java",
"chars": 1131,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/annotation/GeneratedCacheKey.java",
"chars": 1805,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/annotation/package-info.java",
"chars": 1956,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/configuration/CacheEntryListenerConfiguration.java",
"chars": 2494,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/configuration/CompleteConfiguration.java",
"chars": 5684,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/configuration/Configuration.java",
"chars": 2958,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/configuration/Factory.java",
"chars": 1390,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/configuration/FactoryBuilder.java",
"chars": 6169,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/configuration/MutableCacheEntryListenerConfiguration.java",
"chars": 7952,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/configuration/MutableConfiguration.java",
"chars": 16528,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/configuration/OptionalFeature.java",
"chars": 948,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/configuration/package-info.java",
"chars": 1703,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/event/CacheEntryCreatedListener.java",
"chars": 1515,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/event/CacheEntryEvent.java",
"chars": 3853,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/event/CacheEntryEventFilter.java",
"chars": 1481,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/event/CacheEntryExpiredListener.java",
"chars": 1381,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/event/CacheEntryListener.java",
"chars": 2406,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/event/CacheEntryListenerException.java",
"chars": 2863,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/event/CacheEntryRemovedListener.java",
"chars": 1404,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/event/CacheEntryUpdatedListener.java",
"chars": 1380,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/event/EventType.java",
"chars": 1195,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/event/package-info.java",
"chars": 1525,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/expiry/AccessedExpiryPolicy.java",
"chars": 3516,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/expiry/CreatedExpiryPolicy.java",
"chars": 3423,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/expiry/Duration.java",
"chars": 7568,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/expiry/EternalExpiryPolicy.java",
"chars": 2324,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/expiry/ExpiryPolicy.java",
"chars": 3315,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/expiry/ModifiedExpiryPolicy.java",
"chars": 3522,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/expiry/TouchedExpiryPolicy.java",
"chars": 3405,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/expiry/package-info.java",
"chars": 764,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/integration/CacheLoader.java",
"chars": 2430,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/integration/CacheLoaderException.java",
"chars": 2830,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/integration/CacheWriter.java",
"chars": 5422,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/integration/CacheWriterException.java",
"chars": 2831,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/integration/CompletionListener.java",
"chars": 1790,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/integration/CompletionListenerFuture.java",
"chars": 5485,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/integration/package-info.java",
"chars": 1037,
"preview": "/**\n * Copyright (c) 2011-2013 Terracotta, Inc.\n * Copyright (c) 2011-2013 Oracle and/or its affiliates.\n *\n * All ri"
},
{
"path": "src/main/java/javax/cache/management/CacheMXBean.java",
"chars": 4824,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/management/CacheStatisticsMXBean.java",
"chars": 5421,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/management/package-info.java",
"chars": 785,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/package-info.java",
"chars": 10280,
"preview": "\n/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the"
},
{
"path": "src/main/java/javax/cache/processor/EntryProcessor.java",
"chars": 6933,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/processor/EntryProcessorException.java",
"chars": 2873,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/processor/EntryProcessorResult.java",
"chars": 1823,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/processor/MutableEntry.java",
"chars": 2494,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/processor/package-info.java",
"chars": 458,
"preview": "/**\n * Copyright (c) 2011-2013 Terracotta, Inc.\n * Copyright (c) 2011-2013 Oracle and/or its affiliates.\n *\n * All ri"
},
{
"path": "src/main/java/javax/cache/spi/CachingProvider.java",
"chars": 8123,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
},
{
"path": "src/main/java/javax/cache/spi/package-info.java",
"chars": 893,
"preview": "/**\n * Copyright 2011-2016 Terracotta, Inc.\n * Copyright 2011-2016 Oracle America Incorporated\n *\n * Licensed under the "
}
]
About this extraction
This page contains the full source code of the jsr107/jsr107spec GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 74 files (322.4 KB), approximately 77.5k tokens, and a symbol index with 334 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.