tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r1134423 - in /openejb/trunk/openejb3/examples: ./ decorators/ decorators/src/ decorators/src/main/ decorators/src/main/java/ decorators/src/main/java/org/ decorators/src/main/java/org/superbiz/ decorators/src/main/java/org/superbiz/cdi/ de...
Date Fri, 10 Jun 2011 19:29:25 GMT
Author: dblevins
Date: Fri Jun 10 19:29:24 2011
New Revision: 1134423

URL: http://svn.apache.org/viewvc?rev=1134423&view=rev
Log:
OPENEJB-1576: CDI Decorators

Added:
    openejb/trunk/openejb3/examples/decorators/
    openejb/trunk/openejb3/examples/decorators/decorators.iml
    openejb/trunk/openejb3/examples/decorators/pom.xml
    openejb/trunk/openejb3/examples/decorators/src/
    openejb/trunk/openejb3/examples/decorators/src/main/
    openejb/trunk/openejb3/examples/decorators/src/main/java/
    openejb/trunk/openejb3/examples/decorators/src/main/java/org/
    openejb/trunk/openejb3/examples/decorators/src/main/java/org/superbiz/
    openejb/trunk/openejb3/examples/decorators/src/main/java/org/superbiz/cdi/
    openejb/trunk/openejb3/examples/decorators/src/main/java/org/superbiz/cdi/decorators/
    openejb/trunk/openejb3/examples/decorators/src/main/java/org/superbiz/cdi/decorators/AccessDeniedException.java
    openejb/trunk/openejb3/examples/decorators/src/main/java/org/superbiz/cdi/decorators/Calculator.java
    openejb/trunk/openejb3/examples/decorators/src/main/java/org/superbiz/cdi/decorators/CalculatorBean.java
    openejb/trunk/openejb3/examples/decorators/src/main/java/org/superbiz/cdi/decorators/CalculatorLogging.java
    openejb/trunk/openejb3/examples/decorators/src/main/java/org/superbiz/cdi/decorators/CalculatorSecurity.java
    openejb/trunk/openejb3/examples/decorators/src/main/resources/
    openejb/trunk/openejb3/examples/decorators/src/main/resources/META-INF/
    openejb/trunk/openejb3/examples/decorators/src/main/resources/META-INF/beans.xml
    openejb/trunk/openejb3/examples/decorators/src/test/
    openejb/trunk/openejb3/examples/decorators/src/test/java/
    openejb/trunk/openejb3/examples/decorators/src/test/java/org/
    openejb/trunk/openejb3/examples/decorators/src/test/java/org/superbiz/
    openejb/trunk/openejb3/examples/decorators/src/test/java/org/superbiz/cdi/
    openejb/trunk/openejb3/examples/decorators/src/test/java/org/superbiz/cdi/decorators/
    openejb/trunk/openejb3/examples/decorators/src/test/java/org/superbiz/cdi/decorators/CalculatorTest.java
    openejb/trunk/openejb3/examples/decorators/src/test/resources/
    openejb/trunk/openejb3/examples/decorators/src/test/resources/org/
    openejb/trunk/openejb3/examples/decorators/src/test/resources/org/superbiz/
    openejb/trunk/openejb3/examples/decorators/src/test/resources/org/superbiz/cdi/
    openejb/trunk/openejb3/examples/decorators/src/test/resources/org/superbiz/cdi/decorators/
Modified:
    openejb/trunk/openejb3/examples/pom.xml

Added: openejb/trunk/openejb3/examples/decorators/decorators.iml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/decorators/decorators.iml?rev=1134423&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/decorators/decorators.iml (added)
+++ openejb/trunk/openejb3/examples/decorators/decorators.iml Fri Jun 10 19:29:24 2011
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE"
version="4">
+  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="false">
+    <output url="file://$MODULE_DIR$/target/classes" />
+    <output-test url="file://$MODULE_DIR$/target/test-classes" />
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false"
/>
+      <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test/resources" isTestSource="true" />
+      <excludeFolder url="file://$MODULE_DIR$/target" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="module" module-name="javaee-api" scope="PROVIDED" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.geronimo.specs:geronimo-activation_1.1_spec:1.1"
level="project" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.geronimo.specs:geronimo-annotation_1.1_spec:1.0"
level="project" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.geronimo.specs:geronimo-atinject_1.0_spec:1.0"
level="project" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.geronimo.specs:geronimo-ccpp_1.0_spec:1.0-beta"
level="project" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.geronimo.specs:geronimo-ejb_3.1_spec:1.0.2"
level="project" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.geronimo.specs:geronimo-el_2.2_spec:1.0"
level="project" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.geronimo.specs:geronimo-interceptor_1.1_spec:1.0"
level="project" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.geronimo.specs:geronimo-j2ee-connector_1.6_spec:1.0"
level="project" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.geronimo.specs:geronimo-j2ee-management_1.1_spec:1.0.1"
level="project" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.geronimo.specs:geronimo-jacc_1.4_spec:1.0"
level="project" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.geronimo.specs:geronimo-jaspic_1.0_spec:1.1"
level="project" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.geronimo.specs:geronimo-j2ee-deployment_1.1_spec:1.1"
level="project" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.geronimo.specs:geronimo-jaxb_2.2_spec:1.0.1"
level="project" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.geronimo.specs:geronimo-jaxr_1.0_spec:2.1"
level="project" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.geronimo.specs:geronimo-jaxrpc_1.1_spec:2.1"
level="project" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.geronimo.specs:geronimo-jaxws_2.2_spec:1.0"
level="project" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.geronimo.specs:geronimo-jcdi_1.0_spec:1.0"
level="project" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.geronimo.specs:geronimo-jms_1.1_spec:1.1.1"
level="project" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.geronimo.specs:geronimo-jpa_2.0_spec:1.1"
level="project" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.geronimo.specs:geronimo-jsp_2.2_spec:1.0"
level="project" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.geronimo.specs:geronimo-jta_1.1_spec:1.1.1"
level="project" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.geronimo.specs:geronimo-saaj_1.3_spec:1.1"
level="project" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.geronimo.specs:geronimo-servlet_3.0_spec:1.0"
level="project" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.geronimo.specs:geronimo-stax-api_1.2_spec:1.0"
level="project" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.geronimo.specs:geronimo-validation_1.0_spec:1.1"
level="project" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.geronimo.specs:geronimo-ws-metadata_2.0_spec:1.1.3"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.8.1" level="project"
/>
+    <orderEntry type="module" module-name="openejb-core" scope="TEST" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.bval:bval-core:0.2-incubating"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: commons-lang:commons-lang:2.4"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: commons-logging:commons-logging:1.1.1"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: commons-beanutils:commons-beanutils:1.8.3"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: commons-collections:commons-collections:3.2.1"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.bval:bval-jsr303:0.2-incubating"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: log4j:log4j:1.2.16" level="project"
/>
+    <orderEntry type="module" module-name="openejb-api" scope="TEST" />
+    <orderEntry type="module" module-name="openejb-loader" scope="TEST" />
+    <orderEntry type="module" module-name="openejb-javaagent" scope="TEST" />
+    <orderEntry type="module" module-name="openejb-jee" scope="TEST" />
+    <orderEntry type="library" scope="TEST" name="Maven: commons-cli:commons-cli:1.2"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.activemq:activemq-ra:5.4.2"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.activemq:activemq-core:5.4.2"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: commons-logging:commons-logging-api:1.1"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.activemq:activeio-core:3.1.2"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.activemq:kahadb:5.4.2"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.activemq.protobuf:activemq-protobuf:1.1"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.osgi:org.osgi.core:4.1.0"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: commons-net:commons-net:2.0"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: com.ibm.icu:icu4j:4.0.1" level="project"
/>
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.openjpa:openjpa:2.0.1"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: net.sourceforge.serp:serp:1.13.1"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.geronimo.components:geronimo-connector:2.2.2-SNAPSHOT"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.slf4j:slf4j-api:1.6.1" level="project"
/>
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.geronimo.components:geronimo-transaction:2.2.2-SNAPSHOT"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.objectweb.howl:howl:1.0.1-1"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.geronimo.javamail:geronimo-javamail_1.4_mail:1.8.2"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.xbean:xbean-asm-shaded:3.8-SNAPSHOT"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: asm:asm:3.2" level="project"
/>
+    <orderEntry type="library" scope="TEST" name="Maven: asm:asm-all:3.2" level="project"
/>
+    <orderEntry type="module" module-name="xbean-finder" scope="TEST" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.xbean:xbean-bundleutils:3.8-SNAPSHOT"
level="project" />
+    <orderEntry type="module" module-name="xbean-reflect" scope="TEST" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.xbean:xbean-naming:3.8-SNAPSHOT"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: hsqldb:hsqldb:1.8.0.10" level="project"
/>
+    <orderEntry type="library" scope="TEST" name="Maven: commons-dbcp:commons-dbcp:1.4"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: commons-pool:commons-pool:1.5.5"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.codehaus.swizzle:swizzle-stream:1.0.2"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: wsdl4j:wsdl4j:1.6.2" level="project"
/>
+    <orderEntry type="library" scope="TEST" name="Maven: org.quartz-scheduler:quartz:1.8.5"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.slf4j:slf4j-log4j12:1.6.1"
level="project" />
+    <orderEntry type="module" module-name="openwebbeans-impl" scope="TEST" />
+    <orderEntry type="library" scope="TEST" name="Maven: javassist:javassist:3.12.0.GA"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: net.sf.scannotation:scannotation:1.0.2"
level="project" />
+    <orderEntry type="module" module-name="openwebbeans-spi" scope="TEST" />
+    <orderEntry type="module" module-name="openwebbeans-ejb" scope="TEST" />
+    <orderEntry type="module" module-name="openwebbeans-ee" scope="TEST" />
+    <orderEntry type="module" module-name="openwebbeans-ee-common" scope="TEST" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.beanshell:bsh:2.0b5" level="project"
/>
+  </component>
+</module>
+

Added: openejb/trunk/openejb3/examples/decorators/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/decorators/pom.xml?rev=1134423&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/decorators/pom.xml (added)
+++ openejb/trunk/openejb3/examples/decorators/pom.xml Fri Jun 10 19:29:24 2011
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+-->
+
+<!-- $Rev: 1090810 $ $Date: 2011-04-10 07:49:26 -0700 (Sun, 10 Apr 2011) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.superbiz</groupId>
+  <artifactId>decorators</artifactId>
+  <packaging>jar</packaging>
+  <version>1.1-SNAPSHOT</version>
+  <name>OpenEJB :: Examples :: Decorators</name>
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+  <build>
+    <defaultGoal>install</defaultGoal>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.3.2</version>
+        <configuration>
+          <source>1.6</source>
+          <target>1.6</target>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  <repositories>
+    <repository>
+      <id>apache-m2-snapshot</id>
+      <name>Apache Snapshot Repository</name>
+      <url>http://repository.apache.org/snapshots</url>
+    </repository>
+  </repositories>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>javaee-api</artifactId>
+      <version>6.0-SNAPSHOT</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.8.1</version>
+      <scope>test</scope>
+    </dependency>
+
+    <!--
+    The <scope>test</scope> guarantees that non of your runtime
+    code is dependent on any OpenEJB classes.
+    -->
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>openejb-core</artifactId>
+      <version>4.0.0-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <!--
+  This section allows you to configure where to publish libraries for sharing.
+  It is not required and may be deleted.  For more information see:
+  http://maven.apache.org/plugins/maven-deploy-plugin/
+  -->
+  <distributionManagement>
+    <repository>
+      <id>localhost</id>
+      <url>file://${basedir}/target/repo/</url>
+    </repository>
+    <snapshotRepository>
+      <id>localhost</id>
+      <url>file://${basedir}/target/snapshot-repo/</url>
+    </snapshotRepository>
+  </distributionManagement>
+
+</project>
+

Added: openejb/trunk/openejb3/examples/decorators/src/main/java/org/superbiz/cdi/decorators/AccessDeniedException.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/decorators/src/main/java/org/superbiz/cdi/decorators/AccessDeniedException.java?rev=1134423&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/decorators/src/main/java/org/superbiz/cdi/decorators/AccessDeniedException.java
(added)
+++ openejb/trunk/openejb3/examples/decorators/src/main/java/org/superbiz/cdi/decorators/AccessDeniedException.java
Fri Jun 10 19:29:24 2011
@@ -0,0 +1,29 @@
+/**
+ * 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.superbiz.cdi.decorators;
+
+import javax.ejb.ApplicationException;
+
+/**
+* @version $Revision$ $Date$
+*/
+@ApplicationException
+public class AccessDeniedException extends RuntimeException {
+    public AccessDeniedException(String s) {
+        super(s);
+    }
+}

Added: openejb/trunk/openejb3/examples/decorators/src/main/java/org/superbiz/cdi/decorators/Calculator.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/decorators/src/main/java/org/superbiz/cdi/decorators/Calculator.java?rev=1134423&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/decorators/src/main/java/org/superbiz/cdi/decorators/Calculator.java
(added)
+++ openejb/trunk/openejb3/examples/decorators/src/main/java/org/superbiz/cdi/decorators/Calculator.java
Fri Jun 10 19:29:24 2011
@@ -0,0 +1,33 @@
+/**
+ * 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.superbiz.cdi.decorators;
+
+/**
+* @version $Revision$ $Date$
+*/
+public interface Calculator {
+
+    public int add(int a, int b);
+
+    public int subtract(int a, int b);
+
+    public int multiply(int a, int b);
+
+    public int divide(int a, int b);
+
+    public int remainder(int a, int b);
+}

Added: openejb/trunk/openejb3/examples/decorators/src/main/java/org/superbiz/cdi/decorators/CalculatorBean.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/decorators/src/main/java/org/superbiz/cdi/decorators/CalculatorBean.java?rev=1134423&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/decorators/src/main/java/org/superbiz/cdi/decorators/CalculatorBean.java
(added)
+++ openejb/trunk/openejb3/examples/decorators/src/main/java/org/superbiz/cdi/decorators/CalculatorBean.java
Fri Jun 10 19:29:24 2011
@@ -0,0 +1,51 @@
+/**
+ * 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.superbiz.cdi.decorators;
+
+import javax.annotation.Resource;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateless;
+import javax.enterprise.inject.Produces;
+
+@Stateless
+public class CalculatorBean implements Calculator {
+
+    @Produces
+    @Resource
+    private SessionContext sessionContext;
+
+    public int add(int a, int b) {
+        return a + b;
+    }
+
+    public int subtract(int a, int b) {
+        return a - b;
+    }
+
+    public int multiply(int a, int b) {
+        return a * b;
+    }
+
+    public int divide(int a, int b) {
+        return a / b;
+    }
+
+    public int remainder(int a, int b) {
+        return a % b;
+    }
+
+}

Added: openejb/trunk/openejb3/examples/decorators/src/main/java/org/superbiz/cdi/decorators/CalculatorLogging.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/decorators/src/main/java/org/superbiz/cdi/decorators/CalculatorLogging.java?rev=1134423&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/decorators/src/main/java/org/superbiz/cdi/decorators/CalculatorLogging.java
(added)
+++ openejb/trunk/openejb3/examples/decorators/src/main/java/org/superbiz/cdi/decorators/CalculatorLogging.java
Fri Jun 10 19:29:24 2011
@@ -0,0 +1,61 @@
+/**
+ * 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.superbiz.cdi.decorators;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.ejb.ApplicationException;
+import javax.inject.Inject;
+import java.util.logging.Logger;
+
+@Decorator
+public class CalculatorLogging implements Calculator {
+
+    private Logger logger = Logger.getLogger("Calculator");
+
+    @Inject
+    @Delegate
+    private Calculator calculator;
+
+    @Override
+    public int add(int a, int b) {
+        logger.fine(String.format("add(%s, %s)", a, b));
+        return calculator.add(a, b);
+    }
+
+    @Override
+    public int subtract(int a, int b) {
+        return calculator.subtract(a, b);
+    }
+
+    @Override
+    public int multiply(int a, int b) {
+        logger.finest(String.format("multiply(%s, %s)", a, b));
+        return calculator.multiply(a, b);
+    }
+
+    @Override
+    public int divide(int a, int b) {
+        return calculator.divide(a, b);
+    }
+
+    @Override
+    public int remainder(int a, int b) {
+        logger.info(String.format("remainder(%s, %s)", a, b));
+        return calculator.remainder(a, b);
+    }
+}

Added: openejb/trunk/openejb3/examples/decorators/src/main/java/org/superbiz/cdi/decorators/CalculatorSecurity.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/decorators/src/main/java/org/superbiz/cdi/decorators/CalculatorSecurity.java?rev=1134423&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/decorators/src/main/java/org/superbiz/cdi/decorators/CalculatorSecurity.java
(added)
+++ openejb/trunk/openejb3/examples/decorators/src/main/java/org/superbiz/cdi/decorators/CalculatorSecurity.java
Fri Jun 10 19:29:24 2011
@@ -0,0 +1,63 @@
+/**
+ * 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.superbiz.cdi.decorators;
+
+import javax.annotation.Resource;
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.ejb.SessionContext;
+import javax.inject.Inject;
+
+@Decorator
+public class CalculatorSecurity implements Calculator {
+
+    @Inject
+    @Delegate
+    private Calculator calculator;
+
+    @Inject
+    private SessionContext sessionContext;
+
+    @Override
+    public int add(int a, int b) {
+        return calculator.add(a, b);
+    }
+
+    @Override
+    public int subtract(int a, int b) {
+        // Caller must pass a security check to call subtract
+        if (!sessionContext.isCallerInRole("Manager")) throw new AccessDeniedException(sessionContext.getCallerPrincipal().getName());
+
+        return calculator.subtract(a, b);
+    }
+
+    @Override
+    public int multiply(int a, int b) {
+        return calculator.multiply(a, b);
+    }
+
+    @Override
+    public int divide(int a, int b) {
+        return calculator.divide(a, b);
+    }
+
+    @Override
+    public int remainder(int a, int b) {
+        return calculator.remainder(a, b);
+    }
+
+}

Added: openejb/trunk/openejb3/examples/decorators/src/main/resources/META-INF/beans.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/decorators/src/main/resources/META-INF/beans.xml?rev=1134423&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/decorators/src/main/resources/META-INF/beans.xml (added)
+++ openejb/trunk/openejb3/examples/decorators/src/main/resources/META-INF/beans.xml Fri Jun
10 19:29:24 2011
@@ -0,0 +1,10 @@
+<beans>
+  <!--
+  Explicitly declaring decorators is required by the CDI specification.
+  The order decorators are listed in the xml is the order in which they are invoked.
+  -->
+   <decorators>
+      <class>org.superbiz.cdi.decorators.CalculatorSecurity</class>
+      <class>org.superbiz.cdi.decorators.CalculatorLogging</class>
+   </decorators>
+</beans>

Added: openejb/trunk/openejb3/examples/decorators/src/test/java/org/superbiz/cdi/decorators/CalculatorTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/decorators/src/test/java/org/superbiz/cdi/decorators/CalculatorTest.java?rev=1134423&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/decorators/src/test/java/org/superbiz/cdi/decorators/CalculatorTest.java
(added)
+++ openejb/trunk/openejb3/examples/decorators/src/test/java/org/superbiz/cdi/decorators/CalculatorTest.java
Fri Jun 10 19:29:24 2011
@@ -0,0 +1,116 @@
+/**
+ * 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.superbiz.cdi.decorators;
+
+import junit.framework.TestCase;
+
+import javax.annotation.security.RunAs;
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import javax.ejb.embeddable.EJBContainer;
+import java.util.concurrent.Callable;
+
+public class CalculatorTest extends TestCase {
+
+    @EJB
+    private Calculator calculator;
+
+    @EJB
+    private ManagerBean manager;
+
+    /**
+     * Bootstrap the Embedded EJB Container
+     *
+     * @throws Exception
+     */
+    protected void setUp() throws Exception {
+        EJBContainer.createEJBContainer().getContext().bind("inject", this);
+    }
+
+    /**
+     * Test Add method
+     */
+    public void testAdd() {
+
+        assertEquals(10, calculator.add(4, 6));
+
+    }
+
+    /**
+     * Test Subtract method
+     */
+    public void testSubtract() {
+
+        try {
+            calculator.subtract(4, 6);
+
+            fail("AccessDeniedException should have been thrown for unauthenticated access");
+        } catch (AccessDeniedException expected) {
+            // pass
+        }
+
+        final int result = manager.call(new Callable<Integer>() {
+            public Integer call() {
+                return calculator.subtract(4, 6);
+            }
+        });
+
+        assertEquals(-2, result);
+
+    }
+
+    /**
+     * Test Multiply method
+     */
+    public void testMultiply() {
+
+        assertEquals(24, calculator.multiply(4, 6));
+
+    }
+
+    /**
+     * Test Divide method
+     */
+    public void testDivide() {
+
+        assertEquals(2, calculator.divide(12, 6));
+
+    }
+
+    /**
+     * Test Remainder method
+     */
+    public void testRemainder() {
+
+        assertEquals(4, calculator.remainder(46, 6));
+
+    }
+
+    @Stateless
+    @RunAs("Manager")
+    public static class ManagerBean {
+
+        public <V> V call(Callable<V> callable) {
+            try {
+                return callable.call();
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+        }
+
+    }
+}

Modified: openejb/trunk/openejb3/examples/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/pom.xml?rev=1134423&r1=1134422&r2=1134423&view=diff
==============================================================================
--- openejb/trunk/openejb3/examples/pom.xml (original)
+++ openejb/trunk/openejb3/examples/pom.xml Fri Jun 10 19:29:24 2011
@@ -76,6 +76,7 @@
     <module>movies-complete</module>
     <module>schedule-methods-meta</module>
     <module>testing-security-meta</module>
+    <module>decorators</module>
   </modules>
   <profiles>
     <profile>



Mime
View raw message