keycloak-memoizeit
Changes
bundled-war-example/pom.xml 7(+7 -0)
Details
bundled-war-example/pom.xml 7(+7 -0)
diff --git a/bundled-war-example/pom.xml b/bundled-war-example/pom.xml
index 751e7ab..5812399 100755
--- a/bundled-war-example/pom.xml
+++ b/bundled-war-example/pom.xml
@@ -253,6 +253,13 @@
<scope>provided</scope>
</dependency>
+ <!-- CDI -->
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
diff --git a/bundled-war-example/src/main/java/org/keycloak/example/oauth/CustomerDataProvider.java b/bundled-war-example/src/main/java/org/keycloak/example/oauth/CustomerDataProvider.java
new file mode 100644
index 0000000..a9b938d
--- /dev/null
+++ b/bundled-war-example/src/main/java/org/keycloak/example/oauth/CustomerDataProvider.java
@@ -0,0 +1,35 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright Red Hat, Inc., and individual contributors.
+ *
+ * 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 org.keycloak.example.oauth;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class CustomerDataProvider {
+
+ public List<String> getCustomers() {
+ ArrayList<String> rtn = new ArrayList<String>();
+ rtn.add("Bill Burke");
+ rtn.add("Stian Thorgersen");
+ rtn.add("Stan Silvert");
+ rtn.add("Gabriel Cardoso");
+ rtn.add("Viliam Rockai");
+ rtn.add("Marek Posolda");
+ rtn.add("Boleslaw Dawidowicz");
+ return rtn;
+ }
+}
diff --git a/bundled-war-example/src/main/java/org/keycloak/example/oauth/CustomerService.java b/bundled-war-example/src/main/java/org/keycloak/example/oauth/CustomerService.java
index 8f5f5b1..4f1866a 100755
--- a/bundled-war-example/src/main/java/org/keycloak/example/oauth/CustomerService.java
+++ b/bundled-war-example/src/main/java/org/keycloak/example/oauth/CustomerService.java
@@ -2,10 +2,10 @@ package org.keycloak.example.oauth;
import org.jboss.resteasy.annotations.cache.NoCache;
+import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
-import java.util.ArrayList;
import java.util.List;
/**
@@ -14,18 +14,14 @@ import java.util.List;
*/
@Path("customers")
public class CustomerService {
+
+ @Inject
+ private CustomerDataProvider provider;
+
@GET
@Produces("application/json")
@NoCache
public List<String> getCustomers() {
- ArrayList<String> rtn = new ArrayList<String>();
- rtn.add("Bill Burke");
- rtn.add("Stian Thorgersen");
- rtn.add("Stan Silvert");
- rtn.add("Gabriel Cardoso");
- rtn.add("Viliam Rockai");
- rtn.add("Marek Posolda");
- rtn.add("Boleslaw Dawidowicz");
- return rtn;
+ return provider.getCustomers();
}
}
diff --git a/bundled-war-example/src/main/resources/META-INF/beans.xml b/bundled-war-example/src/main/resources/META-INF/beans.xml
new file mode 100644
index 0000000..57025b5
--- /dev/null
+++ b/bundled-war-example/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ JBoss, Home of Professional Open Source
+ Copyright Red Hat, Inc., and individual contributors.
+
+ 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.
+
+-->
+<beans xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd">
+
+</beans>
\ No newline at end of file