├── Dockerfile
├── javaee6angularjsmysql
├── README.md
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── org
│ │ │ └── jboss
│ │ │ └── as
│ │ │ └── quickstarts
│ │ │ └── kitchensink
│ │ │ ├── data
│ │ │ ├── MemberListProducer.java
│ │ │ └── MemberRepository.java
│ │ │ ├── model
│ │ │ └── Member.java
│ │ │ ├── rest
│ │ │ ├── JaxRsActivator.java
│ │ │ └── MemberResourceRESTService.java
│ │ │ ├── service
│ │ │ └── MemberRegistration.java
│ │ │ └── util
│ │ │ └── Resources.java
│ ├── resources
│ │ ├── META-INF
│ │ │ ├── backup_persistence .xml
│ │ │ └── persistence.xml
│ │ └── import.sql
│ └── webapp
│ │ ├── WEB-INF
│ │ └── beans.xml
│ │ ├── css
│ │ └── screen.css
│ │ ├── gfx
│ │ ├── asidebkg.png
│ │ ├── bkg-blkheader.png
│ │ ├── dualbrand_logo.png
│ │ ├── headerbkg.png
│ │ ├── wildfly-banner.png
│ │ └── wildfly_400x130.jpg
│ │ ├── index.html
│ │ ├── js
│ │ ├── app.js
│ │ ├── controllers.js
│ │ ├── libs
│ │ │ ├── angular-resource.js
│ │ │ └── angular.js
│ │ └── services.js
│ │ └── partials
│ │ └── home.html
│ └── test
│ ├── java
│ └── org
│ │ └── jboss
│ │ └── as
│ │ └── quickstarts
│ │ └── kitchensink
│ │ └── test
│ │ └── MemberRegistrationTest.java
│ └── resources
│ ├── META-INF
│ └── test-persistence.xml
│ ├── arquillian.xml
│ └── test-ds.xml
├── mysql-connector-java-5.1.31-bin.jar
├── mysql-sample-ds.xml
├── readme.md
├── screenshots
├── after_docker_build.png
├── browser.png
├── build_success.png
├── connect_to_database.png
├── docker_network_create.png
├── docker_quickstart_terminal.png
├── docker_run_mysql.png
├── download_unzip.png
├── mark_paste.png
├── mysql_root_password.png
├── mysql_sample_ds_xml.png
├── mysql_sql_editor.png
├── mysql_workbench_new_connection.png
├── mysqlapp_with_Dockerfile.png
├── persistence_xml.png
├── sql_editor.png
├── start_sh_running.png
├── target_directory.png
└── wildfly_admin_console.png
└── standalone.xml
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM centos/wildfly
2 |
3 | COPY standalone.xml /opt/wildfly/standalone/configuration/
4 | COPY mysql-connector-java-5.1.31-bin.jar /opt/wildfly/standalone/deployments/
5 | COPY mysql-sample-ds.xml /opt/wildfly/standalone/deployments/
6 |
7 | COPY javaee6angularjsmysql/target/javaee6angularjsmysql.war /opt/wildfly/standalone/deployments/
8 |
--------------------------------------------------------------------------------
/javaee6angularjsmysql/README.md:
--------------------------------------------------------------------------------
1 | See the parent directory's readme.md file
2 |
--------------------------------------------------------------------------------
/javaee6angularjsmysql/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
20 | 4.0.0
21 |
22 | org.wildfly.quickstarts
23 | javaee6angularjsmysql
24 | 9.0.0-SNAPSHOT
25 | war
26 | WildFly Quickstarts: Kitchensink with AngularJS
27 | A starter Java EE 7 webapp project for use on JBoss WildFly / WildFly, generated from the jboss-javaee6-webapp archetype, using AngularJS for the view
28 |
29 | http://wildfly.org
30 |
31 |
32 | Apache License, Version 2.0
33 | repo
34 | http://www.apache.org/licenses/LICENSE-2.0.html
35 |
36 |
37 |
38 |
39 |
40 |
42 | UTF-8
43 |
44 |
45 | 1.0.2.Final
46 |
47 | 8.2.1.Final
48 |
49 |
50 | 3.1
51 | 2.16
52 | 2.5
53 |
54 |
55 | 1.7
56 | 1.7
57 |
58 |
59 |
60 |
61 |
62 |
70 |
71 | org.wildfly.bom
72 | jboss-javaee-7.0-with-tools
73 | ${version.jboss.bom}
74 | pom
75 | import
76 |
77 |
78 | org.wildfly.bom
79 | jboss-javaee-7.0-with-hibernate
80 | ${version.jboss.bom}
81 | pom
82 | import
83 |
84 |
85 |
86 |
87 |
88 |
89 |
91 |
92 |
93 |
94 | javax.enterprise
95 | cdi-api
96 | provided
97 |
98 |
99 |
101 |
102 | org.jboss.spec.javax.annotation
103 | jboss-annotations-api_1.2_spec
104 | provided
105 |
106 |
107 |
108 |
109 | org.jboss.resteasy
110 | jaxrs-api
111 | provided
112 |
113 |
114 |
115 |
116 | org.hibernate.javax.persistence
117 | hibernate-jpa-2.1-api
118 | provided
119 |
120 |
121 |
122 |
123 | org.jboss.spec.javax.ejb
124 | jboss-ejb-api_3.2_spec
125 | provided
126 |
127 |
128 |
129 |
130 |
131 |
132 | org.hibernate
133 | hibernate-validator
134 | provided
135 |
136 |
137 | org.slf4j
138 | slf4j-api
139 |
140 |
141 |
142 |
143 |
144 |
145 |
147 |
148 | org.hibernate
149 | hibernate-jpamodelgen
150 | provided
151 |
152 |
153 |
155 |
156 | org.hibernate
157 | hibernate-validator-annotation-processor
158 | provided
159 |
160 |
161 |
162 |
163 | junit
164 | junit
165 | test
166 |
167 |
168 |
169 |
171 |
172 | org.jboss.arquillian.junit
173 | arquillian-junit-container
174 | test
175 |
176 |
177 |
178 | org.jboss.arquillian.protocol
179 | arquillian-protocol-servlet
180 | test
181 |
182 |
183 |
184 |
185 |
186 |
188 | ${project.artifactId}
189 |
190 |
191 | maven-war-plugin
192 | ${version.war.plugin}
193 |
194 |
196 | false
197 |
198 |
199 |
201 |
202 |
203 | org.wildfly.plugins
204 | wildfly-maven-plugin
205 | ${version.wildfly.maven.plugin}
206 |
207 |
208 |
209 |
210 |
211 |
212 |
214 |
216 | default
217 |
218 | true
219 |
220 |
221 |
222 |
223 | maven-surefire-plugin
224 | ${version.surefire.plugin}
225 |
226 | true
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
237 |
239 |
240 | arq-wildfly-managed
241 |
242 |
243 | org.wildfly
244 | wildfly-arquillian-container-managed
245 | test
246 |
247 |
248 |
249 |
250 |
251 |
253 |
254 | arq-wildfly-remote
255 |
256 |
257 | org.wildfly
258 | wildfly-arquillian-container-remote
259 | test
260 |
261 |
262 |
263 |
264 |
265 |
267 |
269 |
271 |
272 | openshift
273 |
274 |
275 |
276 | maven-war-plugin
277 | ${version.war.plugin}
278 |
279 | deployments
280 | ROOT
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
--------------------------------------------------------------------------------
/javaee6angularjsmysql/src/main/java/org/jboss/as/quickstarts/kitchensink/data/MemberListProducer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JBoss, Home of Professional Open Source
3 | * Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
4 | * contributors by the @authors tag. See the copyright.txt in the
5 | * distribution for a full listing of individual contributors.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.jboss.as.quickstarts.kitchensink.data;
18 |
19 | import javax.annotation.PostConstruct;
20 | import javax.enterprise.context.RequestScoped;
21 | import javax.enterprise.event.Observes;
22 | import javax.enterprise.event.Reception;
23 | import javax.enterprise.inject.Produces;
24 | import javax.inject.Inject;
25 | import javax.inject.Named;
26 | import java.util.List;
27 |
28 | import org.jboss.as.quickstarts.kitchensink.model.Member;
29 |
30 | @RequestScoped
31 | public class MemberListProducer {
32 |
33 | @Inject
34 | private MemberRepository memberRepository;
35 |
36 | private List members;
37 |
38 | // @Named provides access the return value via the EL variable name "members" in the UI (e.g.
39 | // Facelets or JSP view)
40 | @Produces
41 | @Named
42 | public List getMembers() {
43 | return members;
44 | }
45 |
46 | public void onMemberListChanged(@Observes(notifyObserver = Reception.IF_EXISTS) final Member member) {
47 | retrieveAllMembersOrderedByName();
48 | }
49 |
50 | @PostConstruct
51 | public void retrieveAllMembersOrderedByName() {
52 | members = memberRepository.findAllOrderedByName();
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/javaee6angularjsmysql/src/main/java/org/jboss/as/quickstarts/kitchensink/data/MemberRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JBoss, Home of Professional Open Source
3 | * Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
4 | * contributors by the @authors tag. See the copyright.txt in the
5 | * distribution for a full listing of individual contributors.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.jboss.as.quickstarts.kitchensink.data;
18 |
19 | import javax.enterprise.context.ApplicationScoped;
20 | import javax.inject.Inject;
21 | import javax.persistence.EntityManager;
22 | import javax.persistence.criteria.CriteriaBuilder;
23 | import javax.persistence.criteria.CriteriaQuery;
24 | import javax.persistence.criteria.Root;
25 | import java.util.List;
26 |
27 | import org.jboss.as.quickstarts.kitchensink.model.Member;
28 |
29 | @ApplicationScoped
30 | public class MemberRepository {
31 |
32 | @Inject
33 | private EntityManager em;
34 |
35 | public Member findById(Long id) {
36 | return em.find(Member.class, id);
37 | }
38 |
39 | public Member findByEmail(String email) {
40 | CriteriaBuilder cb = em.getCriteriaBuilder();
41 | CriteriaQuery criteria = cb.createQuery(Member.class);
42 | Root member = criteria.from(Member.class);
43 | // Swap criteria statements if you would like to try out type-safe criteria queries, a new
44 | // feature in JPA 2.0
45 | // criteria.select(member).where(cb.equal(member.get(Member_.name), email));
46 | criteria.select(member).where(cb.equal(member.get("email"), email));
47 | return em.createQuery(criteria).getSingleResult();
48 | }
49 |
50 | public List findAllOrderedByName() {
51 | CriteriaBuilder cb = em.getCriteriaBuilder();
52 | CriteriaQuery criteria = cb.createQuery(Member.class);
53 | Root member = criteria.from(Member.class);
54 | // Swap criteria statements if you would like to try out type-safe criteria queries, a new
55 | // feature in JPA 2.0
56 | // criteria.select(member).orderBy(cb.asc(member.get(Member_.name)));
57 | criteria.select(member).orderBy(cb.asc(member.get("name")));
58 | return em.createQuery(criteria).getResultList();
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/javaee6angularjsmysql/src/main/java/org/jboss/as/quickstarts/kitchensink/model/Member.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JBoss, Home of Professional Open Source
3 | * Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
4 | * contributors by the @authors tag. See the copyright.txt in the
5 | * distribution for a full listing of individual contributors.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.jboss.as.quickstarts.kitchensink.model;
18 |
19 | import java.io.Serializable;
20 |
21 | import javax.persistence.Column;
22 | import javax.persistence.Entity;
23 | import javax.persistence.GeneratedValue;
24 | import javax.persistence.Id;
25 | import javax.persistence.Table;
26 | import javax.persistence.UniqueConstraint;
27 | import javax.validation.constraints.Digits;
28 | import javax.validation.constraints.NotNull;
29 | import javax.validation.constraints.Pattern;
30 | import javax.validation.constraints.Size;
31 | import javax.xml.bind.annotation.XmlRootElement;
32 |
33 | import org.hibernate.validator.constraints.Email;
34 | import org.hibernate.validator.constraints.NotEmpty;
35 |
36 | @SuppressWarnings("serial")
37 | @Entity
38 | @XmlRootElement
39 | @Table(uniqueConstraints = @UniqueConstraint(columnNames = "email"))
40 | public class Member implements Serializable {
41 |
42 | @Id
43 | @GeneratedValue
44 | private Long id;
45 |
46 | @NotNull
47 | @Size(min = 1, max = 25)
48 | @Pattern(regexp = "[^0-9]*", message = "Must not contain numbers")
49 | private String name;
50 |
51 | @NotNull
52 | @NotEmpty
53 | @Email
54 | private String email;
55 |
56 | @NotNull
57 | @Size(min = 10, max = 12)
58 | @Digits(fraction = 0, integer = 12)
59 | @Column(name = "phone_number")
60 | private String phoneNumber;
61 |
62 | public Long getId() {
63 | return id;
64 | }
65 |
66 | public void setId(Long id) {
67 | this.id = id;
68 | }
69 |
70 | public String getName() {
71 | return name;
72 | }
73 |
74 | public void setName(String name) {
75 | this.name = name;
76 | }
77 |
78 | public String getEmail() {
79 | return email;
80 | }
81 |
82 | public void setEmail(String email) {
83 | this.email = email;
84 | }
85 |
86 | public String getPhoneNumber() {
87 | return phoneNumber;
88 | }
89 |
90 | public void setPhoneNumber(String phoneNumber) {
91 | this.phoneNumber = phoneNumber;
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/javaee6angularjsmysql/src/main/java/org/jboss/as/quickstarts/kitchensink/rest/JaxRsActivator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JBoss, Home of Professional Open Source
3 | * Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
4 | * contributors by the @authors tag. See the copyright.txt in the
5 | * distribution for a full listing of individual contributors.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.jboss.as.quickstarts.kitchensink.rest;
18 |
19 | import javax.ws.rs.ApplicationPath;
20 | import javax.ws.rs.core.Application;
21 |
22 | /**
23 | * A class extending {@link Application} and annotated with @ApplicationPath is the Java EE 7
24 | * "no XML" approach to activating JAX-RS.
25 | *
26 | *
27 | * Resources are served relative to the servlet path specified in the {@link ApplicationPath}
28 | * annotation.
29 | *
30 | */
31 | @ApplicationPath("/rest")
32 | public class JaxRsActivator extends Application {
33 | /* class body intentionally left blank */
34 | }
35 |
--------------------------------------------------------------------------------
/javaee6angularjsmysql/src/main/java/org/jboss/as/quickstarts/kitchensink/rest/MemberResourceRESTService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JBoss, Home of Professional Open Source
3 | * Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
4 | * contributors by the @authors tag. See the copyright.txt in the
5 | * distribution for a full listing of individual contributors.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.jboss.as.quickstarts.kitchensink.rest;
18 |
19 | import java.util.HashMap;
20 | import java.util.HashSet;
21 | import java.util.List;
22 | import java.util.Map;
23 | import java.util.Set;
24 | import java.util.logging.Logger;
25 |
26 | import javax.enterprise.context.RequestScoped;
27 | import javax.inject.Inject;
28 | import javax.persistence.NoResultException;
29 | import javax.validation.ConstraintViolation;
30 | import javax.validation.ConstraintViolationException;
31 | import javax.validation.ValidationException;
32 | import javax.validation.Validator;
33 | import javax.ws.rs.Consumes;
34 | import javax.ws.rs.GET;
35 | import javax.ws.rs.POST;
36 | import javax.ws.rs.Path;
37 | import javax.ws.rs.PathParam;
38 | import javax.ws.rs.Produces;
39 | import javax.ws.rs.WebApplicationException;
40 | import javax.ws.rs.core.MediaType;
41 | import javax.ws.rs.core.Response;
42 |
43 | import org.jboss.as.quickstarts.kitchensink.data.MemberRepository;
44 | import org.jboss.as.quickstarts.kitchensink.model.Member;
45 | import org.jboss.as.quickstarts.kitchensink.service.MemberRegistration;
46 |
47 | /**
48 | * JAX-RS Example
49 | *
50 | * This class produces a RESTful service to read/write the contents of the members table.
51 | */
52 | @Path("/members")
53 | @RequestScoped
54 | public class MemberResourceRESTService {
55 |
56 | @Inject
57 | private Logger log;
58 |
59 | @Inject
60 | private Validator validator;
61 |
62 | @Inject
63 | private MemberRepository repository;
64 |
65 | @Inject
66 | MemberRegistration registration;
67 |
68 | @GET
69 | @Produces(MediaType.APPLICATION_JSON)
70 | public List listAllMembers() {
71 | return repository.findAllOrderedByName();
72 | }
73 |
74 | @GET
75 | @Path("/{id:[0-9][0-9]*}")
76 | @Produces(MediaType.APPLICATION_JSON)
77 | public Member lookupMemberById(@PathParam("id") long id) {
78 | Member member = repository.findById(id);
79 | if (member == null) {
80 | throw new WebApplicationException(Response.Status.NOT_FOUND);
81 | }
82 | return member;
83 | }
84 |
85 | /**
86 | * Creates a new member from the values provided. Performs validation, and will return a JAX-RS response with either 200 ok,
87 | * or with a map of fields, and related errors.
88 | */
89 | @POST
90 | @Consumes(MediaType.APPLICATION_JSON)
91 | @Produces(MediaType.APPLICATION_JSON)
92 | public Response createMember(Member member) {
93 |
94 | Response.ResponseBuilder builder = null;
95 |
96 | try {
97 | // Validates member using bean validation
98 | validateMember(member);
99 |
100 | registration.register(member);
101 |
102 | // Create an "ok" response
103 | builder = Response.ok();
104 | } catch (ConstraintViolationException ce) {
105 | // Handle bean validation issues
106 | builder = createViolationResponse(ce.getConstraintViolations());
107 | } catch (ValidationException e) {
108 | // Handle the unique constrain violation
109 | Map responseObj = new HashMap<>();
110 | responseObj.put("email", "Email taken");
111 | builder = Response.status(Response.Status.CONFLICT).entity(responseObj);
112 | } catch (Exception e) {
113 | // Handle generic exceptions
114 | Map responseObj = new HashMap<>();
115 | responseObj.put("error", e.getMessage());
116 | builder = Response.status(Response.Status.BAD_REQUEST).entity(responseObj);
117 | }
118 |
119 | return builder.build();
120 | }
121 |
122 | /**
123 | *
124 | * Validates the given Member variable and throws validation exceptions based on the type of error. If the error is standard
125 | * bean validation errors then it will throw a ConstraintValidationException with the set of the constraints violated.
126 | *
127 | *
128 | * If the error is caused because an existing member with the same email is registered it throws a regular validation
129 | * exception so that it can be interpreted separately.
130 | *
131 | *
132 | * @param member Member to be validated
133 | * @throws ConstraintViolationException If Bean Validation errors exist
134 | * @throws ValidationException If member with the same email already exists
135 | */
136 | private void validateMember(Member member) throws ConstraintViolationException, ValidationException {
137 | // Create a bean validator and check for issues.
138 | Set> violations = validator.validate(member);
139 |
140 | if (!violations.isEmpty()) {
141 | throw new ConstraintViolationException(new HashSet>(violations));
142 | }
143 |
144 | // Check the uniqueness of the email address
145 | if (emailAlreadyExists(member.getEmail())) {
146 | throw new ValidationException("Unique Email Violation");
147 | }
148 | }
149 |
150 | /**
151 | * Creates a JAX-RS "Bad Request" response including a map of all violation fields, and their message. This can then be used
152 | * by clients to show violations.
153 | *
154 | * @param violations A set of violations that needs to be reported
155 | * @return JAX-RS response containing all violations
156 | */
157 | private Response.ResponseBuilder createViolationResponse(Set> violations) {
158 | log.fine("Validation completed. violations found: " + violations.size());
159 |
160 | Map responseObj = new HashMap<>();
161 |
162 | for (ConstraintViolation> violation : violations) {
163 | responseObj.put(violation.getPropertyPath().toString(), violation.getMessage());
164 | }
165 |
166 | return Response.status(Response.Status.BAD_REQUEST).entity(responseObj);
167 | }
168 |
169 | /**
170 | * Checks if a member with the same email address is already registered. This is the only way to easily capture the
171 | * "@UniqueConstraint(columnNames = "email")" constraint from the Member class.
172 | *
173 | * @param email The email to check
174 | * @return True if the email already exists, and false otherwise
175 | */
176 | public boolean emailAlreadyExists(String email) {
177 | Member member = null;
178 | try {
179 | member = repository.findByEmail(email);
180 | } catch (NoResultException e) {
181 | // ignore
182 | }
183 | return member != null;
184 | }
185 | }
186 |
--------------------------------------------------------------------------------
/javaee6angularjsmysql/src/main/java/org/jboss/as/quickstarts/kitchensink/service/MemberRegistration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JBoss, Home of Professional Open Source
3 | * Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
4 | * contributors by the @authors tag. See the copyright.txt in the
5 | * distribution for a full listing of individual contributors.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.jboss.as.quickstarts.kitchensink.service;
18 |
19 | import org.jboss.as.quickstarts.kitchensink.model.Member;
20 |
21 | import javax.ejb.Stateless;
22 | import javax.enterprise.event.Event;
23 | import javax.inject.Inject;
24 | import javax.persistence.EntityManager;
25 | import java.util.logging.Logger;
26 |
27 | // The @Stateless annotation eliminates the need for manual transaction demarcation
28 | @Stateless
29 | public class MemberRegistration {
30 |
31 | @Inject
32 | private Logger log;
33 |
34 | @Inject
35 | private EntityManager em;
36 |
37 | @Inject
38 | private Event memberEventSrc;
39 |
40 | public void register(Member member) throws Exception {
41 | log.info("Registering " + member.getName());
42 | em.persist(member);
43 | memberEventSrc.fire(member);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/javaee6angularjsmysql/src/main/java/org/jboss/as/quickstarts/kitchensink/util/Resources.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JBoss, Home of Professional Open Source
3 | * Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
4 | * contributors by the @authors tag. See the copyright.txt in the
5 | * distribution for a full listing of individual contributors.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.jboss.as.quickstarts.kitchensink.util;
18 |
19 | import java.util.logging.Logger;
20 |
21 | import javax.enterprise.inject.Produces;
22 | import javax.enterprise.inject.spi.InjectionPoint;
23 | import javax.persistence.EntityManager;
24 | import javax.persistence.PersistenceContext;
25 |
26 | /**
27 | * This class uses CDI to alias Java EE resources, such as the persistence context, to CDI beans
28 | *
29 | *
30 | * Example injection on a managed bean field:
31 | *
37 | */
38 | public class Resources {
39 |
40 | @Produces
41 | @PersistenceContext
42 | private EntityManager em;
43 |
44 | @Produces
45 | public Logger produceLog(InjectionPoint injectionPoint) {
46 | return Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName());
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/javaee6angularjsmysql/src/main/resources/META-INF/backup_persistence .xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
23 |
24 |
26 |
28 | java:jboss/datasources/ExampleMySQLDS
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/javaee6angularjsmysql/src/main/resources/META-INF/persistence.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 | java:jboss/datasources/MySQLSampleDS
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/javaee6angularjsmysql/src/main/resources/import.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- JBoss, Home of Professional Open Source
3 | -- Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
4 | -- contributors by the @authors tag. See the copyright.txt in the
5 | -- distribution for a full listing of individual contributors.
6 | --
7 | -- Licensed under the Apache License, Version 2.0 (the "License");
8 | -- you may not use this file except in compliance with the License.
9 | -- You may obtain a copy of the License at
10 | -- http://www.apache.org/licenses/LICENSE-2.0
11 | -- Unless required by applicable law or agreed to in writing, software
12 | -- distributed under the License is distributed on an "AS IS" BASIS,
13 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | -- See the License for the specific language governing permissions and
15 | -- limitations under the License.
16 | --
17 |
18 | -- You can use this file to load seed data into the database using SQL statements
19 | insert into Member (id, name, email, phone_number) values (0, 'John Smith', 'john.smith@mailinator.com', '2125551212')
--------------------------------------------------------------------------------
/javaee6angularjsmysql/src/main/webapp/WEB-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
19 |
23 |
24 |
--------------------------------------------------------------------------------
/javaee6angularjsmysql/src/main/webapp/css/screen.css:
--------------------------------------------------------------------------------
1 | /*
2 | * JBoss, Home of Professional Open Source
3 | * Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
4 | * contributors by the @authors tag. See the copyright.txt in the
5 | * distribution for a full listing of individual contributors.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | /* Core styles for the page */
18 | body {
19 | margin: 0;
20 | padding: 0;
21 | background-color: #F1F1F1;
22 | font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
23 | font-size: 0.8em;
24 | color:#363636;
25 | }
26 |
27 | #container {
28 | margin: 0 auto;
29 | padding: 0 20px 10px 20px;
30 | border-top: 5px solid #000000;
31 | border-left: 5px solid #8c8f91;
32 | border-right: 5px solid #8c8f91;
33 | border-bottom: 25px solid #8c8f91;
34 | width: 865px; /* subtract 40px from banner width for padding */
35 | background: #FFFFFF;
36 | background-image: url(../gfx/headerbkg.png);
37 | background-repeat: repeat-x;
38 | padding-top: 30px;
39 | box-shadow: 3px 3px 15px #d5d5d5;
40 | }
41 | #content {
42 | float: left;
43 | width: 500px;
44 | margin: 20px;
45 | }
46 | #aside {
47 | font-size: 0.9em;
48 | width: 275px;
49 | float: left;
50 | margin: 20px 0px;
51 | border: 1px solid #D5D5D5;
52 | background: #F1F1F1;
53 | background-image: url(../gfx/asidebkg.png);
54 | background-repeat: repeat-x;
55 | padding: 20px;
56 | }
57 |
58 | #aside ul {
59 | padding-left: 30px;
60 | }
61 | .dualbrand {
62 | float: right;
63 | padding-right: 10px;
64 | }
65 | #footer {
66 | clear: both;
67 | text-align: center;
68 | color: #666666;
69 | font-size: 0.85em;
70 | }
71 | code {
72 | font-size: 1.1em;
73 | }
74 | a {
75 | color: #4a5d75;
76 | text-decoration: none;
77 | }
78 | a:hover {
79 | color: #369;
80 | text-decoration: underline;
81 | }
82 | h1 {
83 | color:#243446;
84 | font-size: 2.25em;
85 | }
86 | h2 {
87 | font-size: 1em;
88 | }
89 | h3 {
90 | color:#243446;
91 | }
92 | h4 {
93 | }
94 | h5 {
95 | }
96 | h6 {
97 | }
98 | /* Member registration styles */
99 | span.invalid {
100 | padding-left: 3px;
101 | color: red;
102 | }
103 | form {
104 | padding: 1em;
105 | font: 80%/1 sans-serif;
106 | width: 375px;
107 | border: 1px solid #D5D5D5;
108 | }
109 | label {
110 | float: left;
111 | width: 15%;
112 | margin-left: 20px;
113 | margin-right: 0.5em;
114 | padding-top: 0.2em;
115 | text-align: right;
116 | font-weight: bold;
117 | color:#363636;
118 | }
119 | input {
120 | margin-bottom: 8px;
121 | }
122 | .register {
123 | float: left;
124 | margin-left: 85px;
125 | }
126 |
127 | /* ----- table style ------- */
128 |
129 |
130 | /* = Simple Table style (black header, grey/white stripes */
131 |
132 | .simpletablestyle {
133 | background-color:#E6E7E8;
134 | clear:both;
135 | width: 550px;
136 | }
137 |
138 | .simpletablestyle img {
139 | border:0px;
140 | }
141 |
142 | .simpletablestyle td {
143 | height:2em;
144 | padding-left: 6px;
145 | font-size:11px;
146 | padding:5px 5px;
147 | }
148 |
149 | .simpletablestyle th {
150 | background: url(../gfx/bkg-blkheader.png) black repeat-x top left;
151 | font-size:12px;
152 | font-weight:normal;
153 | padding:0 10px 0 5px;
154 | border-bottom:#999999 dotted 1px;
155 | }
156 |
157 | .simpletablestyle thead {
158 | background: url(../gfx/bkg-blkheader.png) black repeat-x top left;
159 | height:31px;
160 | font-size:10px;
161 | font-weight:bold;
162 | color:#FFFFFF;
163 | text-align:left;
164 | }
165 |
166 | .simpletablestyle .header a {
167 | color:#94aebd;
168 | }
169 |
170 | .simpletablestype tfoot {
171 | height: 20px;
172 | font-size: 10px;
173 | font-weight: bold;
174 | background-color: #EAECEE;
175 | text-align: center;
176 | }
177 |
178 | .simpletablestyle tr.header td {
179 | padding: 0px 10px 0px 5px;
180 | }
181 |
182 |
183 | .simpletablestyle .subheader {
184 | background-color: #e6e7e8;
185 | font-size:10px;
186 | font-weight:bold;
187 | color:#000000;
188 | text-align:left;
189 | }
190 |
191 | /* Using new CSS3 selectors for styling*/
192 | .simpletablestyle tr:nth-child(odd) {
193 | background: #f4f3f3;
194 | }
195 | .simpletablestyle tr:nth-child(even) {
196 | background: #ffffff;
197 | }
198 |
199 | .simpletablestyle td a:hover {
200 | color:#3883ce;
201 | text-decoration:none;
202 | }
203 |
--------------------------------------------------------------------------------
/javaee6angularjsmysql/src/main/webapp/gfx/asidebkg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/burrsutter/docker_mysql_tutorial/39fefcf7fd0ca8184a8c0aa5079850247a5b91d7/javaee6angularjsmysql/src/main/webapp/gfx/asidebkg.png
--------------------------------------------------------------------------------
/javaee6angularjsmysql/src/main/webapp/gfx/bkg-blkheader.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/burrsutter/docker_mysql_tutorial/39fefcf7fd0ca8184a8c0aa5079850247a5b91d7/javaee6angularjsmysql/src/main/webapp/gfx/bkg-blkheader.png
--------------------------------------------------------------------------------
/javaee6angularjsmysql/src/main/webapp/gfx/dualbrand_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/burrsutter/docker_mysql_tutorial/39fefcf7fd0ca8184a8c0aa5079850247a5b91d7/javaee6angularjsmysql/src/main/webapp/gfx/dualbrand_logo.png
--------------------------------------------------------------------------------
/javaee6angularjsmysql/src/main/webapp/gfx/headerbkg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/burrsutter/docker_mysql_tutorial/39fefcf7fd0ca8184a8c0aa5079850247a5b91d7/javaee6angularjsmysql/src/main/webapp/gfx/headerbkg.png
--------------------------------------------------------------------------------
/javaee6angularjsmysql/src/main/webapp/gfx/wildfly-banner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/burrsutter/docker_mysql_tutorial/39fefcf7fd0ca8184a8c0aa5079850247a5b91d7/javaee6angularjsmysql/src/main/webapp/gfx/wildfly-banner.png
--------------------------------------------------------------------------------
/javaee6angularjsmysql/src/main/webapp/gfx/wildfly_400x130.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/burrsutter/docker_mysql_tutorial/39fefcf7fd0ca8184a8c0aa5079850247a5b91d7/javaee6angularjsmysql/src/main/webapp/gfx/wildfly_400x130.jpg
--------------------------------------------------------------------------------
/javaee6angularjsmysql/src/main/webapp/index.html:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 | kitchensink
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/javaee6angularjsmysql/src/main/webapp/js/app.js:
--------------------------------------------------------------------------------
1 | /*
2 | * JBoss, Home of Professional Open Source
3 | * Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
4 | * contributors by the @authors tag. See the copyright.txt in the
5 | * distribution for a full listing of individual contributors.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | // Define any routes for the app
18 | // Note that this app is a single page app, and each partial is routed to using the URL fragment. For example, to select the 'home' route, the URL is http://localhost:8080/wildfly-kitchensink-angularjs/#/home
19 | angular.module('kitchensink', ['membersService']).config(
20 | [ '$routeProvider', function($routeProvider) {
21 | $routeProvider.
22 | // if URL fragment is /home, then load the home partial, with the
23 | // MembersCtrl controller
24 | when('/home', {
25 | templateUrl : 'partials/home.html',
26 | controller : MembersCtrl
27 | // Add a default route
28 | }).otherwise({
29 | redirectTo : '/home'
30 | });
31 | } ]);
--------------------------------------------------------------------------------
/javaee6angularjsmysql/src/main/webapp/js/controllers.js:
--------------------------------------------------------------------------------
1 | /*
2 | * JBoss, Home of Professional Open Source
3 | * Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
4 | * contributors by the @authors tag. See the copyright.txt in the
5 | * distribution for a full listing of individual contributors.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | function MembersCtrl($scope, $http, Members) {
18 |
19 | // Define a refresh function, that updates the data from the REST service
20 | $scope.refresh = function() {
21 | $scope.members = Members.query();
22 | };
23 |
24 | // Define a reset function, that clears the prototype newMember object, and
25 | // consequently, the form
26 | $scope.reset = function() {
27 | // clear input fields
28 | $scope.newMember = {};
29 | };
30 |
31 | // Define a register function, which adds the member using the REST service,
32 | // and displays any error messages
33 | $scope.register = function() {
34 | $scope.successMessages = '';
35 | $scope.errorMessages = '';
36 | $scope.errors = {};
37 |
38 | Members.save($scope.newMember, function(data) {
39 |
40 | // mark success on the registration form
41 | $scope.successMessages = [ 'Member Registered' ];
42 |
43 | // Update the list of members
44 | $scope.refresh();
45 |
46 | // Clear the form
47 | $scope.reset();
48 | }, function(result) {
49 | if ((result.status == 409) || (result.status == 400)) {
50 | $scope.errors = result.data;
51 | } else {
52 | $scope.errorMessages = [ 'Unknown server error' ];
53 | }
54 | $scope.$apply();
55 | });
56 |
57 | };
58 |
59 | // Call the refresh() function, to populate the list of members
60 | $scope.refresh();
61 |
62 | // Initialize newMember here to prevent Angular from sending a request
63 | // without a proper Content-Type.
64 | $scope.reset();
65 |
66 | // Set the default orderBy to the name property
67 | $scope.orderBy = 'name';
68 | }
--------------------------------------------------------------------------------
/javaee6angularjsmysql/src/main/webapp/js/libs/angular-resource.js:
--------------------------------------------------------------------------------
1 | /*
2 | * JBoss, Home of Professional Open Source
3 | * Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
4 | * contributors by the @authors tag. See the copyright.txt in the
5 | * distribution for a full listing of individual contributors.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | /**
18 | * @license AngularJS v1.1.2
19 | * (c) 2010-2012 Google, Inc. http://angularjs.org
20 | * License: MIT
21 | */
22 | (function(window, angular, undefined) {
23 | 'use strict';
24 |
25 | /**
26 | * @ngdoc overview
27 | * @name ngResource
28 | * @description
29 | */
30 |
31 | /**
32 | * @ngdoc object
33 | * @name ngResource.$resource
34 | * @requires $http
35 | *
36 | * @description
37 | * A factory which creates a resource object that lets you interact with
38 | * [RESTful](http://en.wikipedia.org/wiki/Representational_State_Transfer) server-side data sources.
39 | *
40 | * The returned resource object has action methods which provide high-level behaviors without
41 | * the need to interact with the low level {@link ng.$http $http} service.
42 | *
43 | * @param {string} url A parameterized URL template with parameters prefixed by `:` as in
44 | * `/user/:username`. If you are using a URL with a port number (e.g.
45 | * `http://example.com:8080/api`), you'll need to escape the colon character before the port
46 | * number, like this: `$resource('http://example.com\\:8080/api')`.
47 | *
48 | * @param {Object=} paramDefaults Default values for `url` parameters. These can be overridden in
49 | * `actions` methods. If any of the parameter value is a function, it will be executed every time
50 | * when a param value needs to be obtained for a request (unless the param was overriden).
51 | *
52 | * Each key value in the parameter object is first bound to url template if present and then any
53 | * excess keys are appended to the url search query after the `?`.
54 | *
55 | * Given a template `/path/:verb` and parameter `{verb:'greet', salutation:'Hello'}` results in
56 | * URL `/path/greet?salutation=Hello`.
57 | *
58 | * If the parameter value is prefixed with `@` then the value of that parameter is extracted from
59 | * the data object (useful for non-GET operations).
60 | *
61 | * @param {Object.