Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
514fbcb
upgraded to wildfly-10.1.0.Final, using Weld 3.0.0.Beta1 as a wildfly…
rhanus Jan 3, 2017
56bedc8
added both jcache and jsonb samples
rhanus Jan 10, 2017
fc53274
added jcache samples: cache-basics, cache-remove & cache-remove-all
rhanus Jan 10, 2017
335dd85
fixed both groupId & artifactId identification
rhanus Jan 11, 2017
15339ee
renamed jcache/cache-result to jcache/annotation-cache-result, rename…
rhanus Jan 11, 2017
3d29629
renamed jcache/cache-put to jcache/annotation-cache-put, renamed serv…
rhanus Jan 11, 2017
d97b7f3
renamed jcache/cache-put to jcache/annotation-cache-put, renamed serv…
rhanus Jan 11, 2017
17c5873
renamed jcache/cache-result to jcache/annotation-cache-result, rename…
rhanus Jan 11, 2017
9e1802c
fixed tpo
rhanus Jan 11, 2017
6c2ff32
renamed jcache/cache-remove to jcache/annotation-cache-remove, rename…
rhanus Jan 11, 2017
6a36e3d
renamed jcache/cache-remove-all to jcache/annotation-cache-remove-all…
rhanus Jan 11, 2017
284815b
beans.xml: defined only needed interceptors
rhanus Jan 11, 2017
8541663
added jcache sample configure-cache
rhanus Jan 11, 2017
22f537d
fixed both groupId & artifactId, clarified readme
rhanus Jan 11, 2017
18e5e81
rename jcache sample configure-cache to configure-cache-expiry
rhanus Jan 12, 2017
fbe9746
added jcache sample configure-cache-loaders
rhanus Jan 12, 2017
c223dc1
improved test initialization
rhanus Jan 12, 2017
42af5fd
added jcache sample configure-cache-listener
rhanus Jan 13, 2017
4be2de6
simplifying tests
rhanus Jan 15, 2017
d35bd11
test simplified and clarified
rhanus Jan 15, 2017
26eb5b5
refactored jcache sample create-cache to configure-cache-types
rhanus Jan 16, 2017
7658e87
typo
rhanus Jan 16, 2017
e1c45ed
renamed jcache sample configure-cache-types to runtime-cache-types
rhanus Jan 16, 2017
2f3b486
added jcache sample configure-cache-filter
rhanus Jan 16, 2017
a2bf7bd
added jcache sample configure-cache-store-by
rhanus Jan 18, 2017
4ac3e94
added jcache sample infinispan-max-entries
rhanus Jan 19, 2017
dc39de7
added jcache sample infinispan-externalizer
rhanus Jan 23, 2017
7f03ca1
upgraded to Infinispan 9.0.0.Beta2, using new memory configuration
rhanus Jan 24, 2017
6414891
upgraded to Weld 3.0.0.CR1
rhanus Jan 25, 2017
c6bba03
renamed jcache sample infinispan-max-entries to infinispan-eviction
rhanus Jan 25, 2017
1bd5999
renamed package
rhanus Jan 25, 2017
f6e5da4
added jcache sample infinispan-transaction-mode
rhanus Jan 26, 2017
a271ed2
refactored jcache sample infinispan-transaction-mode
rhanus Jan 29, 2017
bb5a3fe
added jcache sample infinispan-transaction-isolation
rhanus Feb 2, 2017
2d75f55
renamed package of jcache sample infinispan-transaction-mode
rhanus Feb 2, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions README.asciidoc
Original file line number Diff line number Diff line change
@@ -1,30 +1,55 @@
Java EE 8 Samples
=================
-----------------
Covered JSRs
~~~~~~~~~~~~
* JSR 365: CDI 2.0
* JSR 107: JCACHE
* JSR 367: JSON-B

. Download http://download.jboss.org/wildfly/8.2.0.Final/wildfly-8.2.0.Final.zip[WildFly 8.2.0] and unzip
. Download Weld3 Alpha 3
Running the tests
~~~~~~~~~~~~~~~~~
. Download WildFly 10.1 and unzip it
+
[source, text]
----
curl -L -o weld3-alpha3-patch-wildfly8.2.zip http://sourceforge.net/projects/jboss/files/Weld/3.0.0.Alpha3/wildfly-8.2.0.Final-weld-3.0.0.Alpha3-patch.zip/download
curl -L http://download.jboss.org/wildfly/10.1.0.Final/wildfly-10.1.0.Final.zip -o wildfly-10.1.0.Final.zip
----
. Download Weld 3.0.0.CR1 as a patch for WildFly 10.1
+
[source, text]
----
curl -L http://download.jboss.org/weld/3.0.0.CR1/wildfly-10.1.0.Final-weld-3.0.0.CR1-patch.zip -o wildfly-10.1.0.Final-weld-3.0.0.CR1-patch.zip
----
+
. Apply the patch
+
[source, text]
----
./wildfly-8.2.0.Final/bin/jboss-cli.sh --command="patch apply ./weld3-alpha3-patch-wildfly8.2.zip"
./wildfly-10.1.0.Final/bin/jboss-cli.sh --command="patch apply ./wildfly-10.1.0.Final-weld-3.0.0.CR1-patch.zip"
{
"outcome" : "success",
"result" : {}
}
----
+
. Download Infinispan 9.0.0.Beta2 packaged modules for deploying in WildFly
+
[source, text]
----
curl -L http://downloads.jboss.org/infinispan/9.0.0.Beta2/infinispan-wildfly-modules-9.0.0.Beta2.zip -o infinispan-wildfly-modules-9.0.0.Beta2.zip
----
. Unzip and copy modules
+
[source, text]
----
unzip ./infinispan-wildfly-modules-9.0.0.Beta2.zip -d ./wildfly-10.1.0.Final/modules
----
+
. Start WildFly
+
[source, text]
----
./wildfly-8.2.0.Final/bin/standalone.sh
./wildfly-10.1.0.Final/bin/standalone.sh
----
+
. Run tests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,44 @@
package org.javaee8.cdi.events.priority;

import javax.enterprise.context.SessionScoped;
import javax.annotation.Priority;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.event.Observes;
import java.io.Serializable;
import javax.interceptor.Interceptor;
import org.jboss.weld.experimental.Priority;
import java.io.Serializable;

/**
* Using {@link javax.annotation.Priority} annotation to define an order in which observer methods are called.<br/>
* Observers with smaller priority values are called first.
*
* @author Radim Hanus
* @author Arun Gupta
*
* @see <a href="http://docs.jboss.org/cdi/spec/2.0.EDR2/cdi-spec.html#observer_ordering">relevant chapter in cdi-2.0 spec</a>
*/
@SessionScoped
@RequestScoped
public class GreetingReceiver implements EventReceiver, Serializable {

private String greet = "Willkommen";

/**
* Lower priority
* @param greet
* Higher priority
*/
void receive(@Observes @Priority(Interceptor.Priority.APPLICATION + 200) String greet) {
this.greet += greet + "2";
void receiveFirst(@Observes @Priority(Interceptor.Priority.APPLICATION) String greet) {
this.greet = greet + "First ";
}

/**
* Higher priority
* @param greet
* Middle priority, uses default priority Interceptor.Priority.APPLICATION + 500
*/
void receiveSecond(@Observes String greet) {
this.greet += greet + "Second ";
}

/**
* Lower priority
*/
void receive2(@Observes @Priority(Interceptor.Priority.APPLICATION) String greet) {
this.greet = greet + "1";
void receiveThird(@Observes @Priority(Interceptor.Priority.APPLICATION + 1000) String greet) {
this.greet += greet + "Third";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package org.javaee8.cdi.events.priority;

import org.javaee8.cdi.events.priority.EventSender;
import org.javaee8.cdi.events.priority.GreetingSender;
import org.javaee8.cdi.events.priority.GreetingReceiver;
import org.javaee8.cdi.events.priority.EventReceiver;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Archive;
Expand All @@ -15,8 +11,6 @@
import javax.inject.Inject;

import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;

Expand All @@ -41,17 +35,14 @@ public static Archive<?> deploy() {

@Test
public void test() throws Exception {
assertThat(sender, is(notNullValue()));
assertThat(sender, instanceOf(GreetingSender.class));

assertThat(receiver, is(notNullValue()));
assertThat(receiver, instanceOf(GreetingReceiver.class));

// default greet
assertEquals("Willkommen", receiver.getGreet());
// send a new greet
sender.send("Welcome");
sender.send("Welcome:");
// receiver must not belongs to the dependent pseudo-scope since we are checking the result
assertEquals("Welcome1Welcome2", receiver.getGreet());
assertEquals("Welcome:First Welcome:Second Welcome:Third", receiver.getGreet());
}
}
5 changes: 2 additions & 3 deletions cdi/events-priority/src/test/resources/beans.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd"
version="2.0"
bean-discovery-mode="all">

</beans>
7 changes: 5 additions & 2 deletions cdi/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.javaee8</groupId>
<artifactId>javaee8-samples</artifactId>
Expand All @@ -12,9 +14,10 @@
<artifactId>cdi-samples</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Java EE 8 CDI Samples</name>
<name>JSR 365: CDI 2.0 Samples</name>

<modules>
<module>events-priority</module>
</modules>

</project>
2 changes: 2 additions & 0 deletions jcache/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
JSR 107: JCACHE Samples
=======================
12 changes: 12 additions & 0 deletions jcache/annotation-cache-put/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.javaee8.jcache</groupId>
<artifactId>jcache-samples</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>annotation-cache-put</artifactId>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.javaee8.jcache.annotation;

import javax.cache.annotation.CacheDefaults;
import javax.cache.annotation.CachePut;
import javax.cache.annotation.CacheResult;
import javax.cache.annotation.CacheValue;


/**
* @author Radim Hanus
*/
@CacheDefaults(cacheName = "cache.default")
public class KeyValueService<K, V> {
@CachePut
public void put(K key, @CacheValue V value) {
}

@CacheResult
public V get(K key) {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.javaee8.jcache.annotation;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;

import javax.inject.Inject;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;


@RunWith(Arquillian.class)
public class KeyValueServiceTest {
@Deployment
public static Archive<?> deploy() {
return ShrinkWrap.create(WebArchive.class)
.addClasses(KeyValueService.class)
.addAsWebInfResource("beans.xml")
.addAsWebInfResource("jboss-deployment-structure.xml");
}

@Inject
private KeyValueService<String, String> service;

@Test
public void test() throws Exception {
assertNull(service.get("JSR107"));

service.put("JSR107", "JCACHE");
assertEquals("JCACHE", service.get("JSR107"));
}
}
14 changes: 14 additions & 0 deletions jcache/annotation-cache-put/src/test/resources/beans.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd"
version="2.0"
bean-discovery-mode="all">

<interceptors>
<class>org.infinispan.jcache.annotation.InjectedCacheResultInterceptor</class>
<class>org.infinispan.jcache.annotation.InjectedCachePutInterceptor</class>
</interceptors>

</beans>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.3">
<deployment>
<dependencies>
<module name="org.infinispan.cdi.embedded" slot="ispn-9.0" services="import"/>
<module name="org.infinispan.jcache" slot="ispn-9.0" services="import"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
12 changes: 12 additions & 0 deletions jcache/annotation-cache-remove-all/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.javaee8.jcache</groupId>
<artifactId>jcache-samples</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>annotation-cache-remove-all</artifactId>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.javaee8.jcache.annotation;

import javax.cache.annotation.*;


/**
* @author Radim Hanus
*/
@CacheDefaults(cacheName = "cache.default")
public class KeyValueService<K, V> {
@CachePut
public void put(K key, @CacheValue V value) {
}

@CacheResult
public V get(K key) {
return null;
}

@CacheRemoveAll
public void deleteAll() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.javaee8.jcache.annotation;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;

import javax.inject.Inject;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;


@RunWith(Arquillian.class)
public class KeyValueServiceTest {
@Deployment
public static Archive<?> deploy() {
return ShrinkWrap.create(WebArchive.class)
.addClasses(KeyValueService.class)
.addAsWebInfResource("beans.xml")
.addAsWebInfResource("jboss-deployment-structure.xml");
}

@Inject
private KeyValueService<String, String> service;

@Test
public void test() throws Exception {
assertNull(service.get("JSR107"));
assertNull(service.get("JSR367"));

service.put("JSR107", "JCACHE");
assertEquals("JCACHE", service.get("JSR107"));

service.put("JSR367", "JSON-B");
assertEquals("JSON-B", service.get("JSR367"));

service.deleteAll();
assertNull(service.get("JSR107"));
assertNull(service.get("JSR367"));
}
}
16 changes: 16 additions & 0 deletions jcache/annotation-cache-remove-all/src/test/resources/beans.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd"
version="2.0"
bean-discovery-mode="all">

<interceptors>
<class>org.infinispan.jcache.annotation.InjectedCacheResultInterceptor</class>
<class>org.infinispan.jcache.annotation.InjectedCachePutInterceptor</class>
<class>org.infinispan.jcache.annotation.InjectedCacheRemoveEntryInterceptor</class>
<class>org.infinispan.jcache.annotation.InjectedCacheRemoveAllInterceptor</class>
</interceptors>

</beans>
Loading