GithubHelp home page GithubHelp logo

coherence-community / coherence-spring Goto Github PK

View Code? Open in Web Editor NEW
25.0 14.0 24.0 453.55 MB

Coherence Spring Project

Home Page: https://spring.coherence.community/

License: Universal Permissive License v1.0

CSS 0.02% Java 99.90% XSLT 0.07%
coherence spring spring-boot java

coherence-spring's Introduction

Welcome to the Oracle Coherence Spring Project

CI Coherence Spring Quality Gate Status Chat with us on slack Stack Exchange questions Twitter Follow

The Coherence Spring project provides bootstrapping support of Oracle Coherence for Spring Framework and Spring Boot. Coherence Spring also provides a set of components to aid in the integration of Oracle Coherence and various other projects of the Spring ecosystem:

  • Spring Data

  • Spring’s Cache Abstraction

  • Spring Session

Furthermore, the project also provides various examples to show-case the integration of Oracle Coherence into Spring-based projects.

Documentation

Detailed project documentation is available on the Coherence Spring website. This includes the reference documentation in various formats (Multi-page/Single-page HTML, PDF), as well as extensive JavaDoc for the Coherence Spring source code.

4.2.0-SNAPSHOT

Website

Multi-page HTML

Single-page HTML

PDF

API Doc.

4.1.3

Website

Multi-page HTML

Single-page HTML

PDF

API Doc.

4.1.4-SNAPSHOT

Website

Multi-page HTML

Single-page HTML

PDF

API Doc.

3.3.6

Website

Multi-page HTML

Single-page HTML

PDF

API Doc.

3.3.7-SNAPSHOT

Website

Multi-page HTML

Single-page HTML

PDF

API Doc.

Note
The Apache Maven-based snapshots and releases for this project are published to Maven Central.

Supported Versions

Coherence Spring Java Coherence CE Spring Boot Jakarta Git Branch/Tag

4.2.x

17, 21

24.03

6.x

3.3.x

4.2.x

4.1.x

17, 21

24.03

6.x

3.2.x

main

3.3.x

11

22.06

5.x

2.x

3.3.x

Quick Start

In order to get started quickly, please read the reference guide as it provides a detailed Quickstart chapter (v4.1.3).

Through the reference documentation we will also refer to various demo and sample applications. Those are part of this repository, and you can find those in the samples module.

Building from Source

Requirements

In order to build Coherence Spring, you need to have installed:

Check out sources

Check out the project using Git:

git clone https://github.com/coherence-community/coherence-spring.git
cd coherence-spring

Coherence Spring uses Apache Maven as build tool. You do not need to have Maven installed to build the project. Simply use the provided Maven Wrapper, e.g.:

  • Windows: mvnw.cmd clean package

  • Linux/Mac: ./mvnw clean package

Build the entire project

Build the entire project using Maven:

./mvnw clean package

Offline Builds

In case you are offline and you run into issues building the project, e.g. the Coherence cluster as part of JUnit tests does not start up successfully, then you may have to provide additional command line arguments:

./mvnw clean package -DargLine="-Dcoherence.localhost=127.0.0.1 -Djava.net.preferIPv4Stack=true"

Build the Documentation

./mvnw clean package -pl coherence-spring-docs

Build the project website

./mvnw clean install -pl coherence-spring-site

Deploy the project website

./mvnw deploy -pl coherence-spring-site

Getting Support

In case you have questions or if you run into issue using the Coherence Spring project, please feel free to reach out to us either via:

Both support channels are monitored by the project community.

Contributing

We would love to review your Pull requests. Please see the contributor guidelines for details.

License

Coherence Spring is Open Source software released under The Universal Permissive License (UPL), Version 1.0.

coherence-spring's People

Contributors

brianoliver avatar dependabot[bot] avatar dhirupandey avatar eddumelendez avatar ghillert avatar pperalta avatar rlubke avatar thegridman avatar vasac avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coherence-spring's Issues

Spring Cache: Add Ability to set cache prefix

In certain situations it might be desirable to set an optional cache prefix. For instance, if you use multiple caches such as:

@Cacheable("books") ...
@Cacheable("readers") ...
@Cacheable("authors") ...

In that case it might be useful to define an application specific common cache prefix, e.g. spring_ in order to make the caches more easily identifiable in your Coherence cluster without having to repeat the prefix with every use of the Spring cache annotations.

CoherenceCache.get() with value loader does not check if entry is locked

According to the official Coherence documentation , cache.lock(key) returns immediately, with a boolean result indicating whether the lock has been obtained.

As a result, the following code will perform the cache.put() unconditionally:

	public <T> T get(Object key, Callable<T> valueLoader) {
	    ...
			this.cache.lock(key);  
			try {                            
                            ...
                            this.cache.put(key, value);  //It will always execute this, no matter what
			}
			finally {
				this.cache.unlock(key);
			}
		}
	}

The code should check on the result, or pass "-1" as second parameter (blocking indefinitely until a lock can be obtained).

Also, valueLoader should throw ValueRetrievalException when the value cannot be loaded, instead of IllegalStateException.

Support for 12.2.1.2.0 needed

Hi,

is it safe change version to 12.2.1.2.0 in?

    <oracle.coherence.version>12.1.2-0-4</oracle.coherence.version>

Should it be done on your side?

Thanks.
Ryszard

Allow SpringAwareBeans to be placed into caches and injected if autowire

eg:

public class SomeValue implements Serializable, ApplicationContextAware {

  private transient ApplicationContext context;

  private transient SomeBean someBean;

  private transient boolean init = false;

  public void setApplicationContext( ApplicationContext applicationContext )
    throws BeansException {
    context = applicationContext;
  }

  @Autowired
  public void setSomeBean( SomeBean someBean)  {
    this.someBean = someBean;
  }

  @PostConstruct
  public void init() {
    someBean.doSomethingUseful();
    init = true;
  }
  ...
}

Imagine being able to invoke NamedCache#put(“key”, someValue) where someValue is an instance of SomeValue class and the cache could to know how to hydrate and call the appropriate methods when deserializing or instantiate the bean through the proper BeanFactory.

Basically this is a "live-spring-bean" (aka: LiveObject) pattern specifically for Spring.

The questions remain: Could we also allow / provide SpringRemoting onto said cached objects?

Spring Cache: Add Ability to set the TTL of cache entries

Currently, cache expiration needs to be configured via cache-config.xml. Similar to Spring Session session support, we can also add a feature to set the TTL via the CacheManager and thus, using the TTL when adding entries to the NamedCache map.

Introduce SpringBasedCoherenceSession to permit programmatic injection of Coherence resources

With the move to non-xml-based configuration and the introduction of Spring Boot, it would be nice to allow Spring-based Applications to create and inject resources into Coherence (aka: the "spring-on-top-model" / "coherence-embedded-in-spring-model").

To achieve this we should introduce the SpringBasedCoherenceSession, that wraps the internal configuration of Coherence and injects the appropriate Spring ApplicationContext into Coherence (ResourceRegistry) prior to starting Coherence. This would thus allow Coherence to look up / inject Spring resources and additionally, allow Spring to control the start and injection of Coherence-based resources (beans) into Spring applications.

Ultimately this should solve the nasty "chicken/egg" start up issues when trying to integrate Coherence and Spring together - eg: which framework is responsible to starting what and how are they integrated without creating infinite loops / race-conditions on startup.

Update to Spring Boot `2.6.6` as soon as available (CVE-2020-36518)

The OWASP Dependency Check failure due to CVE (CVE-2020-36518) was initially fixed but subsequently the CVE itself got updated and the affected version range of Jackson Databind was expanded. The current GA release of Spring Boot 2.6.5 does not include a fixed Jackson Databind dependency, yet.

As soon as an update to Spring Boot 2.6.6 is available, we will update the relevant Spring Boot dependency.

See #92 for further details. See also the Spring Boot issue: spring-projects/spring-boot#30451

SpringBasedCoherenceSession does not honor coherence.cacheconfig property

When coherence.cacheconfig is set, the config file this property point to will be treat as default

However, in the current code

if I use default constructor, it will not load current property file (only load coherence default)
if I use correct URI in constructor, it will not associate as default ConfigurableCacheFactory

either way won't way.

need code change to check that situation.

Unit tests fail when running against JDK11

Test fails with NPE as coherence isn't @autowired.

2020-12-07 12:49:58,296 [main] INFO  org.springframework.test.context.support.DefaultTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener]
2020-12-07 12:49:58,303 [main] INFO  org.springframework.test.context.support.DefaultTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@2e54db99, org.springframework.test.context.support.DependencyInjectionTestExecutionListener@55e8ec2f, org.springframework.test.context.support.DirtiesContextTestExecutionListener@4f2613d1, org.springframework.test.context.event.EventPublishingTestExecutionListener@6d24ffa1]

java.lang.NullPointerException
	at com.oracle.coherence.spring.cache.CoherenceCacheManagerTests.getBasicCaches(CoherenceCacheManagerTests.java:79)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:688)
	at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
	at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
	at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)

<snip/>

2020-12-07 12:49:58,801 [main] ERROR org.springframework.test.context.TestContextManager - Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@55e8ec2f] to prepare test instance [com.oracle.coherence.spring.cache.CoherenceCacheManagerTests@55b8dbda]```

Make the Coherence instance type configurable

Currently the Coherence instance type is always specified as Cluster Member. We should configure the Coherence instance as Client automatically (sensible default), if all configured sessions are either of type Coherence*Extend or gRPC. Users should also be able to explicitly configure (override) the setting either through Spring Configuration or a Spring Boot property.

CoherenceApplicationContext already registered

I have configured two distributed caches, each one has its own service and each one has a spring bean as cache store/loader (see attached coherence caches configuration).

After populating both caches, if I start a second cache node which should join coherence cluster, I got following exception:

2013-12-13 15:45:39.893/2.121 Oracle Coherence GE 12.1.2.0.1 <Error> (thread=DistributedCache:DistributedCache1, member=2): 
java.lang.IllegalArgumentException: Can not register resource [default] as resource [com.oracle.coherence.spring.SpringNamespaceHandler$SpringBeanFactoryBuilder$CoherenceApplicationContext; loaded from [file:/home/stefano/Dev/spikes/coherence-12c-spike/bin/application-context.xml]] is it already registered with [interface org.springframework.beans.factory.BeanFactory] as [default]
at com.tangosol.util.SimpleResourceRegistry.registerResource(SimpleResourceRegistry.java:183)
at com.oracle.coherence.spring.SpringNamespaceHandler$SpringBeanFactoryBuilder.realize(SpringNamespaceHandler.java:723)
at com.oracle.coherence.spring.SpringNamespaceHandler$SpringBeanBuilder.ensureBeanFactory(SpringNamespaceHandler.java:543)
at com.oracle.coherence.spring.SpringNamespaceHandler$SpringBeanBuilder.realize(SpringNamespaceHandler.java:440)
at com.tangosol.coherence.config.scheme.ClassScheme.realize(ClassScheme.java:162)
at com.tangosol.coherence.config.scheme.CacheStoreScheme.realizeLocal(CacheStoreScheme.java:45)
at com.tangosol.coherence.config.scheme.CacheStoreScheme.realize(CacheStoreScheme.java:59)
at com.tangosol.coherence.config.scheme.ReadWriteBackingMapScheme.realizeMap(ReadWriteBackingMapScheme.java:83)
at com.tangosol.coherence.config.scheme.ReadWriteBackingMapScheme.realizeMap(ReadWriteBackingMapScheme.java:45)
at com.tangosol.net.ExtensibleConfigurableCacheFactory$Manager.instantiateBackingMap(ExtensibleConfigurableCacheFactory.java:1399)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$Storage.instantiateBackingMap(PartitionedCache.CDB:24)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$Storage.setCacheName(PartitionedCache.CDB:25)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache.ensureKnownStorage(PartitionedCache.CDB:20)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache.finalizeAcceptingClients(PartitionedCache.CDB:17)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.PartitionedService.finalizeStartup(PartitionedService.CDB:15)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.PartitionedService.onServiceStarted(PartitionedService.CDB:83)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache.onServiceStarted(PartitionedCache.CDB:30)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid$MemberWelcomeRequest$Poll.onCompletion(Grid.CDB:82)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.PartitionedService$MemberWelcomeRequest$Poll.onCompletion(PartitionedService.CDB:1)
at com.tangosol.coherence.component.net.Poll.close(Poll.CDB:10)
at com.tangosol.coherence.component.net.Poll.onResponded(Poll.CDB:43)
at com.tangosol.coherence.component.net.Poll.onResponse(Poll.CDB:3)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid$MemberWelcomeRequest$Poll.onResponse(Grid.CDB:6)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$MemberWelcomeRequest$Poll.onResponse(PartitionedCache.CDB:29)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.onMessage(Grid.CDB:53)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.onNotify(Grid.CDB:23)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.PartitionedService.onNotify(PartitionedService.CDB:3)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache.onNotify(PartitionedCache.CDB:3)
at com.tangosol.coherence.component.util.Daemon.run(Daemon.CDB:51)
at java.lang.Thread.run(Thread.java:662)

I have verified that changing inside SpringNamespaceHandler the way application context is registered inside coherence (setting the RegistrationBehavior to IGNORE) solves the problem.

Increase default timeout

We should increase the default Coherence startup timeout to 5 minutes (Currently it is set to 1 minute).

Coherence Spring Data - When updating don't throw NullPointerException

When doing an update for a non-existing id via CoherenceRepository using e.g.:

this.taskRepository.update(id, myModel -> {
        myModel.setDescription(description);
        return myModel;
    });

then a NullPointerException is thrown:

(Wrapped: Failed request execution for PartitionedCache service on Member(Id=1, Timestamp=2021-10-27 11:06:31.053, Address=10.10.0.15:62339, MachineId=14914, Location=process:61491, Role=IntellijRtJunitJUnitStarter)) java.lang.NullPointerException
	at com.tangosol.util.Base.ensureRuntimeException(Base.java:252)
	at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.tagException(Grid.CDB:61)
	at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache.onInvokeRequest(PartitionedCache.CDB:93)
	at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$InvokeRequest.run(PartitionedCache.CDB:1)
	at com.tangosol.coherence.component.util.DaemonPool$WrapperTask.run(DaemonPool.CDB:1)
	at com.tangosol.coherence.component.util.DaemonPool$WrapperTask.run(DaemonPool.CDB:32)
	at com.tangosol.coherence.component.util.daemon.queueProcessor.Service$DaemonPool$WrapperTask.run(Service.CDB:12)
	at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.PartitionedService$DaemonPool$WrapperTask.run(PartitionedService.CDB:1)
	at com.tangosol.coherence.component.util.DaemonPool$Daemon.onNotify(DaemonPool.CDB:66)
	at com.tangosol.coherence.component.util.Daemon.run(Daemon.CDB:54)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.NullPointerException
	at java.base/java.util.Objects.requireNonNull(Objects.java:221)
	at com.oracle.coherence.examples.todo.server.service.SpringDataTaskService$lambda$update$c3e6a45f$1$0:CD693EBC65EA338BA81B91F7C8B386B4.lambda$update$c3e6a45f$1(Unknown Source)
	at com.oracle.coherence.examples.todo.server.service.SpringDataTaskService$lambda$update$c3e6a45f$1$0:CD693EBC65EA338BA81B91F7C8B386B4.apply(Unknown Source)
	at com.oracle.coherence.repository.AbstractRepositoryBase$lambda$updateFunctionProcessor$b845d0ab$1$0:8240A1DA38A2C604E65046FD1F877E5F.lambda$updateFunctionProcessor$b845d0ab$1(Unknown Source)
	at com.oracle.coherence.repository.AbstractRepositoryBase$lambda$updateFunctionProcessor$b845d0ab$1$0:8240A1DA38A2C604E65046FD1F877E5F.process(Unknown Source)
	at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$Storage.invoke(PartitionedCache.CDB:17)
	at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache.onInvokeRequest(PartitionedCache.CDB:56)
	... 8 more

We should throw a more business-friendly exception, possibly even considering returning Spring data exceptions:

See: https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/dao/package-summary.html

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.