You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by ge...@apache.org on 2010/04/11 09:34:26 UTC
svn commit: r932845 - in /openwebbeans/trunk/samples/ejb-sample/src/main:
java/org/apache/webbeans/sample/decorator/
java/org/apache/webbeans/sample/ejb/ resources/META-INF/
resources/META-INF/openwebbeans/
Author: gerdogdu
Date: Sun Apr 11 07:34:26 2010
New Revision: 932845
URL: http://svn.apache.org/viewvc?rev=932845&view=rev
Log:
[OWB-348] Adding Interceptor and Decorator Support for EJB Beans
Added:
openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/decorator/
openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/decorator/EchoDecorator.java (with props)
openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/ejb/LogInterceptor.java (with props)
openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/ejb/LogInterceptorBinding.java (with props)
Modified:
openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/ejb/EchoBean.java
openwebbeans/trunk/samples/ejb-sample/src/main/resources/META-INF/beans.xml
openwebbeans/trunk/samples/ejb-sample/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
Added: openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/decorator/EchoDecorator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/decorator/EchoDecorator.java?rev=932845&view=auto
==============================================================================
--- openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/decorator/EchoDecorator.java (added)
+++ openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/decorator/EchoDecorator.java Sun Apr 11 07:34:26 2010
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.webbeans.sample.decorator;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.inject.Inject;
+
+import org.apache.webbeans.sample.ejb.Echo;
+
+@Decorator
+public class EchoDecorator implements Echo
+{
+ private @Inject @Delegate Echo echo;
+
+ @Override
+ public String echo(String name)
+ {
+ System.out.println("Parameter is " + name);
+
+ return this.echo.echo(name);
+ }
+
+}
Propchange: openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/decorator/EchoDecorator.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/ejb/EchoBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/ejb/EchoBean.java?rev=932845&r1=932844&r2=932845&view=diff
==============================================================================
--- openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/ejb/EchoBean.java (original)
+++ openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/ejb/EchoBean.java Sun Apr 11 07:34:26 2010
@@ -24,6 +24,7 @@ import org.apache.webbeans.ejb.common.in
@Interceptors(value=OpenWebBeansEjbInterceptor.class)
public class EchoBean implements Echo
{
+ @LogInterceptorBinding
public String echo(String name)
{
return "Hello " + name;
Added: openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/ejb/LogInterceptor.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/ejb/LogInterceptor.java?rev=932845&view=auto
==============================================================================
--- openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/ejb/LogInterceptor.java (added)
+++ openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/ejb/LogInterceptor.java Sun Apr 11 07:34:26 2010
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.webbeans.sample.ejb;
+
+import java.util.Date;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+@Interceptor @LogInterceptorBinding
+public class LogInterceptor
+{
+
+ @AroundInvoke
+ public Object log(InvocationContext context) throws Exception
+ {
+ System.out.println("Calling method : " + context.getMethod().getName() + " at time " + new Date());
+ return context.proceed();
+ }
+
+ @PostConstruct
+ public void postConstruct(InvocationContext context)
+ {
+ System.out.println("Post Construct");
+ }
+
+ @PreDestroy
+ public void preDestroy(InvocationContext context)
+ {
+ System.out.println("Pre Destroy");
+ }
+
+}
Propchange: openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/ejb/LogInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/ejb/LogInterceptorBinding.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/ejb/LogInterceptorBinding.java?rev=932845&view=auto
==============================================================================
--- openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/ejb/LogInterceptorBinding.java (added)
+++ openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/ejb/LogInterceptorBinding.java Sun Apr 11 07:34:26 2010
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.webbeans.sample.ejb;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.interceptor.InterceptorBinding;
+
+@InterceptorBinding
+@Retention(RetentionPolicy.RUNTIME)
+@Target( { ElementType.TYPE, ElementType.METHOD })
+public @interface LogInterceptorBinding
+{
+
+}
\ No newline at end of file
Propchange: openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/ejb/LogInterceptorBinding.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: openwebbeans/trunk/samples/ejb-sample/src/main/resources/META-INF/beans.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/ejb-sample/src/main/resources/META-INF/beans.xml?rev=932845&r1=932844&r2=932845&view=diff
==============================================================================
--- openwebbeans/trunk/samples/ejb-sample/src/main/resources/META-INF/beans.xml (original)
+++ openwebbeans/trunk/samples/ejb-sample/src/main/resources/META-INF/beans.xml Sun Apr 11 07:34:26 2010
@@ -17,7 +17,13 @@ KIND, either express or implied. See th
specific language governing permissions and limitations
under the License.
-->
-<WebBeans xmlns="urn:java:ee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="urn:java:ee http://java.sun.com/jee/beans-1.0.xsd">
-</WebBeans>
\ No newline at end of file
+<beans>
+ <interceptors>
+ <class>org.apache.webbeans.sample.ejb.LogInterceptor</class>
+ </interceptors>
+
+ <decorators>
+ <class>org.apache.webbeans.sample.decorator.EchoDecorator</class>
+ </decorators>
+
+</beans>
Modified: openwebbeans/trunk/samples/ejb-sample/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/ejb-sample/src/main/resources/META-INF/openwebbeans/openwebbeans.properties?rev=932845&r1=932844&r2=932845&view=diff
==============================================================================
--- openwebbeans/trunk/samples/ejb-sample/src/main/resources/META-INF/openwebbeans/openwebbeans.properties (original)
+++ openwebbeans/trunk/samples/ejb-sample/src/main/resources/META-INF/openwebbeans/openwebbeans.properties Sun Apr 11 07:34:26 2010
@@ -24,9 +24,6 @@
#general configuration section
-#use OWB Specific XML Configuration
-org.apache.webbeans.useOwbSpecificXmlConfig=true
-
org.apache.webbeans.application.useJSF2Extensions=false
#use embedded openejb metadata discovery