Skip to content

Commit b2f5712

Browse files
committed
Add additional CDI primitive code
1 parent c63c927 commit b2f5712

File tree

15 files changed

+312
-41
lines changed

15 files changed

+312
-41
lines changed

daytrader-ee7-web/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ dependencies {
2424
providedCompile group:'javax.servlet', name:'javax.servlet-api', version:'3.1.0'
2525
providedCompile group:'javax.faces', name:'javax.faces-api', version:'2.2'
2626
providedCompile group:'javax.jms', name:'javax.jms-api', version:'2.0'
27-
providedCompile group:'javax.websocket', name:'javax.websocket-api', version:'1.1'
27+
providedCompile group:'javax.websocket' ,name:'javax.websocket-api', version:'1.1'
28+
providedCompile group:'javax.annotation',name:'javax.annotation-api' , version:'1.2'
2829
compile group:'org.apache.struts', name:'struts2-core',version:'2.3.24'
2930
compile group:'org.apache.struts', name:'struts2-convention-plugin',version:'2.3.24'
3031
compile group:'taglibs', name:'standard',version:'1.1.1'

daytrader-ee7-web/src/main/java/com/ibm/websphere/samples/daytrader/web/prims/PingBean.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* (C) Copyright IBM Corporation 2015.
2+
* (C) Copyright IBM Corporation 2016.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

daytrader-ee7-web/src/main/java/com/ibm/websphere/samples/daytrader/web/prims/PingCDIBean.java

100644100755
Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/**
2+
* (C) Copyright IBM Corporation 2015.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package com.ibm.websphere.samples.daytrader.web.prims;
217

318
import java.util.Set;
@@ -8,11 +23,12 @@
823
import javax.naming.InitialContext;
924

1025
@RequestScoped
26+
@PingInterceptorBinding
1127
public class PingCDIBean {
1228

13-
private static int helloHitCount=0;
14-
private static int getBeanManagerHitCount=0;
15-
29+
private static int helloHitCount = 0;
30+
private static int getBeanManagerHitCount = 0;
31+
1632
public int hello() {
1733
return ++helloHitCount;
1834
}
@@ -24,7 +40,6 @@ public int getBeanMangerViaJNDI() throws Exception {
2440
return ++getBeanManagerHitCount;
2541
}
2642
return 0;
27-
43+
2844
}
2945
}
30-

daytrader-ee7-web/src/main/java/com/ibm/websphere/samples/daytrader/web/prims/PingCDIJSFBean.java

100644100755
Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
1+
/**
2+
* (C) Copyright IBM Corporation 2016.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package com.ibm.websphere.samples.daytrader.web.prims;
2-
17+
318
import java.io.Serializable;
419

520
import javax.enterprise.context.SessionScoped;
@@ -9,10 +24,9 @@
924
@SessionScoped
1025
public class PingCDIJSFBean implements Serializable {
1126

12-
private static final long serialVersionUID = -7475815494313679416L;
13-
private int hitCount=0;
14-
15-
27+
private static final long serialVersionUID = -7475815494313679416L;
28+
private int hitCount = 0;
29+
1630
public int getHitCount() {
1731
return ++hitCount;
1832
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* (C) Copyright IBM Corporation 2016.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.ibm.websphere.samples.daytrader.web.prims;
17+
18+
/**
19+
* EJB interface
20+
*/
21+
public interface PingEJBIFace {
22+
23+
public String getMsg();
24+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* (C) Copyright IBM Corporation 2015.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.ibm.websphere.samples.daytrader.web.prims;
17+
18+
import javax.ejb.Local;
19+
import javax.ejb.Stateful;
20+
21+
/**
22+
*
23+
*/
24+
@Stateful
25+
@Local
26+
public class PingEJBLocal implements PingEJBIFace {
27+
28+
private static int hitCount;
29+
30+
/*
31+
* (non-Javadoc)
32+
*
33+
* @see com.ibm.websphere.samples.daytrader.web.prims.EJBIFace#getMsg()
34+
*/
35+
@Override
36+
public String getMsg() {
37+
38+
return "PingEJBLocal: " + hitCount++;
39+
}
40+
41+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* (C) Copyright IBM Corporation 2015.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.ibm.websphere.samples.daytrader.web.prims;
17+
18+
import javax.annotation.Priority;
19+
import javax.decorator.Decorator;
20+
import javax.decorator.Delegate;
21+
import javax.inject.Inject;
22+
import javax.interceptor.Interceptor;
23+
24+
@Decorator
25+
@Priority(Interceptor.Priority.APPLICATION)
26+
public class PingEJBLocalDecorator implements PingEJBIFace {
27+
28+
/*
29+
* (non-Javadoc)
30+
*
31+
* @see com.ibm.websphere.samples.daytrader.web.prims.EJBIFace#getMsg()
32+
*/
33+
@Delegate
34+
@Inject
35+
PingEJBIFace ejb;
36+
37+
@Override
38+
public String getMsg() {
39+
40+
return "Decorated " + ejb.getMsg();
41+
}
42+
43+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* (C) Copyright IBM Corporation 2015.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.ibm.websphere.samples.daytrader.web.prims;
17+
18+
import java.io.Serializable;
19+
20+
import javax.annotation.Priority;
21+
import javax.interceptor.AroundInvoke;
22+
import javax.interceptor.Interceptor;
23+
import javax.interceptor.InvocationContext;
24+
25+
/**
26+
*
27+
*/
28+
@PingInterceptorBinding
29+
@Interceptor
30+
@Priority(Interceptor.Priority.APPLICATION)
31+
public class PingInterceptor implements Serializable {
32+
33+
/** */
34+
private static final long serialVersionUID = 1L;
35+
36+
@AroundInvoke
37+
public Object methodInterceptor(InvocationContext ctx) throws Exception {
38+
39+
//noop
40+
return ctx.proceed();
41+
}
42+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* (C) Copyright IBM Corporation 2015.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.ibm.websphere.samples.daytrader.web.prims;
17+
18+
import java.lang.annotation.ElementType;
19+
import java.lang.annotation.Retention;
20+
import java.lang.annotation.RetentionPolicy;
21+
import java.lang.annotation.Target;
22+
23+
import javax.interceptor.InterceptorBinding;
24+
25+
/**
26+
*
27+
*/
28+
@InterceptorBinding
29+
@Target({ ElementType.TYPE, ElementType.CONSTRUCTOR })
30+
@Retention(RetentionPolicy.RUNTIME)
31+
public @interface PingInterceptorBinding {
32+
33+
}

daytrader-ee7-web/src/main/java/com/ibm/websphere/samples/daytrader/web/prims/PingServlet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
@WebServlet(name = "PingServlet", urlPatterns = { "/servlet/PingServlet" })
3838
public class PingServlet extends HttpServlet {
3939

40-
private static final long serialVersionUID = 8731300373855056660L;
41-
private static String initTime;
40+
private static final long serialVersionUID = 7097023236709683760L;
41+
private static String initTime;
4242
private static int hitCount;
4343

4444
/**

0 commit comments

Comments
 (0)