diff --git a/bundled-war-example/pom.xml b/bundled-war-example/pom.xml index 751e7abd11..58123996f8 100755 --- a/bundled-war-example/pom.xml +++ b/bundled-war-example/pom.xml @@ -253,6 +253,13 @@ provided + + + javax.enterprise + cdi-api + 1.1 + provided + 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 0000000000..a9b938da4a --- /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 getCustomers() { + ArrayList rtn = new ArrayList(); + 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 8f5f5b1c57..4f1866aabd 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 getCustomers() { - ArrayList rtn = new ArrayList(); - 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 0000000000..57025b5976 --- /dev/null +++ b/bundled-war-example/src/main/resources/META-INF/beans.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file