[jboss-cvs] JBossAS SVN: r82903 - in projects/ejb3/trunk/docs/tutorial: jboss_deployment_descriptor and 8 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jan 15 07:44:04 EST 2009


Author: jaikiran
Date: 2009-01-15 07:44:04 -0500 (Thu, 15 Jan 2009)
New Revision: 82903

Added:
   projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/
   projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/META-INF/
   projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/META-INF/ejb-jar.xml
   projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/META-INF/jaas-test-config.xml
   projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/META-INF/jboss-service.xml
   projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/META-INF/jboss.xml
   projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/build.xml
   projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/jndi.properties
   projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/log4j.xml
   projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/pom.xml
   projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/roles-default.properties
   projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/roles-test.properties
   projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/
   projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/
   projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/jboss/
   projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/jboss/tutorial/
   projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/jboss/tutorial/jboss_deployment_descriptor/
   projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/jboss/tutorial/jboss_deployment_descriptor/bean/
   projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/jboss/tutorial/jboss_deployment_descriptor/bean/ShoppingCart.java
   projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/jboss/tutorial/jboss_deployment_descriptor/bean/ShoppingCartBean.java
   projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/jboss/tutorial/jboss_deployment_descriptor/bean/StatelessTest.java
   projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/jboss/tutorial/jboss_deployment_descriptor/bean/StatelessTestBean.java
   projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/jboss/tutorial/jboss_deployment_descriptor/client/
   projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/jboss/tutorial/jboss_deployment_descriptor/client/Client.java
   projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/users-default.properties
   projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/users-test.properties
Log:
Working version of the JBoss Deployment Descriptors tutorial for JBossAS-5.0 GA

Added: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/META-INF/ejb-jar.xml
===================================================================
--- projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/META-INF/ejb-jar.xml	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/META-INF/ejb-jar.xml	2009-01-15 12:44:04 UTC (rev 82903)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ejb-jar
+        xmlns="http://java.sun.com/xml/ns/javaee"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+                            http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
+        version="3.0">
+   <description>JBoss Stateful Session Bean Tutorial</description>
+   <display-name>JBoss Stateful Session Bean Tutorial</display-name>
+   <enterprise-beans>
+      <session>
+         <ejb-name>ShoppingCartBean</ejb-name>
+         <business-remote>org.jboss.tutorial.jboss_deployment_descriptor.bean.ShoppingCart</business-remote>
+         <ejb-class>org.jboss.tutorial.jboss_deployment_descriptor.bean.ShoppingCartBean</ejb-class>
+         <session-type>Stateful</session-type>
+         <remove-method>
+            <bean-method>
+               <method-name>checkout</method-name>
+            </bean-method>
+            <retain-if-exception>false</retain-if-exception>
+         </remove-method>
+         <transaction-type>Container</transaction-type>
+      </session>
+   </enterprise-beans>
+   <assembly-descriptor>
+        <method-permission>
+            <role-name>shopper</role-name>
+            <method>
+                <ejb-name>ShoppingCartBean</ejb-name>
+                <method-name>buy</method-name>
+            </method>
+        </method-permission>
+        <method-permission>
+            <role-name>clerk</role-name>
+            <method>
+                <ejb-name>ShoppingCartBean</ejb-name>
+                <method-name>priceCheck</method-name>
+            </method>
+        </method-permission>
+
+   </assembly-descriptor>
+</ejb-jar>


Property changes on: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/META-INF/ejb-jar.xml
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/META-INF/jaas-test-config.xml
===================================================================
--- projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/META-INF/jaas-test-config.xml	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/META-INF/jaas-test-config.xml	2009-01-15 12:44:04 UTC (rev 82903)
@@ -0,0 +1,27 @@
+<?xml version='1.0'?>
+<!DOCTYPE policy PUBLIC
+      "-//JBoss//DTD JBOSS Security Config 3.0//EN"
+      "http://www.jboss.org/j2ee/dtd/security_config.dtd">
+<policy>
+
+    <application-policy name = "tutorial-test">
+       <authentication>
+          <login-module code = "org.jboss.security.auth.spi.UsersRolesLoginModule"
+             flag = "required">
+             <module-option name="usersProperties">users-test.properties</module-option>
+             <module-option name="rolesProperties">roles-test.properties</module-option>
+          </login-module>
+       </authentication>
+    </application-policy>
+
+   <application-policy name = "tutorial-default">
+      <authentication>
+         <login-module code = "org.jboss.security.auth.spi.UsersRolesLoginModule"
+            flag = "required">
+            <module-option name="usersProperties">users-default.properties</module-option>
+            <module-option name="rolesProperties">roles-default.properties</module-option>
+         </login-module>
+      </authentication>
+   </application-policy>
+
+</policy>


Property changes on: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/META-INF/jaas-test-config.xml
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/META-INF/jboss-service.xml
===================================================================
--- projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/META-INF/jboss-service.xml	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/META-INF/jboss-service.xml	2009-01-15 12:44:04 UTC (rev 82903)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <!-- The custom JAAS login configuration service that installs 
+       a Configuration capable of dynamically updating the
+       config settings
+   -->
+   <mbean code="org.jboss.security.auth.login.DynamicLoginConfig"
+         name="jboss.tutorial:service=DynamicLoginConfig">
+      <attribute name="AuthConfig">META-INF/jaas-test-config.xml</attribute>
+      <depends optional-attribute-name="LoginConfigService">
+         jboss.security:service=XMLLoginConfig
+      </depends>
+      <depends optional-attribute-name="SecurityManagerService">
+         jboss.security:service=JaasSecurityManager
+      </depends>
+   </mbean>
+
+</server>


Property changes on: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/META-INF/jboss-service.xml
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/META-INF/jboss.xml
===================================================================
--- projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/META-INF/jboss.xml	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/META-INF/jboss.xml	2009-01-15 12:44:04 UTC (rev 82903)
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<jboss
+        xmlns="http://www.jboss.com/xml/ns/javaee"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee
+                            http://www.jboss.org/j2ee/schema/jboss_5_0.xsd"
+        version="3.0">
+    <security-domain>tutorial-default</security-domain>
+	<enterprise-beans>
+    	<session>
+         	<ejb-name>ShoppingCartBean</ejb-name>
+         	<jndi-name>ShoppingCart</jndi-name>
+         	<clustered>true</clustered>
+	        <cluster-config>
+            	<partition-name>DefaultPartition</partition-name>
+            	<load-balance-policy>org.jboss.ha.framework.interfaces.RandomRobin</load-balance-policy>
+         	</cluster-config>
+    	   	<security-domain>tutorial-test</security-domain>
+      	</session>
+        <session>
+         	<ejb-name>StatelessTestBean</ejb-name>
+         	<jndi-name>StatelessTest</jndi-name>
+      	</session>
+   	</enterprise-beans>
+</jboss>


Property changes on: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/META-INF/jboss.xml
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/build.xml
===================================================================
--- projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/build.xml	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/build.xml	2009-01-15 12:44:04 UTC (rev 82903)
@@ -0,0 +1,89 @@
+<?xml version="1.0"?>
+
+<!-- ======================================================================= -->
+<!-- JBoss build file                                                       -->
+<!-- ======================================================================= -->
+
+<project name="JBoss" default="ejbjar" basedir=".">
+
+   	<property environment="env"/>
+   	<property name="src.dir" value="${basedir}/src"/>
+	<property name="jboss.home" value="${env.JBOSS_HOME}"/>
+	<property name="jboss.server.config" value="all"/>
+	<property name="build.dir" value="${basedir}/build"/>
+	<property name="build.classes.dir" value="${build.dir}/classes"/>
+	<property name="build.artifact" value="jboss-ejb3-tutorial-jboss_deployment_descriptor.jar"/>
+
+   <!-- Build classpath -->
+   <path id="classpath">
+      <!-- So that we can get jndi.properties for InitialContext -->
+      <pathelement location="${basedir}"/>
+   		<!-- Most of jboss classes -->
+      <fileset dir="${jboss.home}/client">
+         <include name="**/jbossall-client.jar"/>
+      </fileset>
+   	
+      <pathelement location="${build.classes.dir}"/>
+   </path>
+
+   <property name="build.classpath" refid="classpath"/>
+
+   <!-- =================================================================== -->
+   <!-- Prepares the build directory                                        -->
+   <!-- =================================================================== -->
+   <target name="prepare">
+      <mkdir dir="${build.dir}"/>
+      <mkdir dir="${build.classes.dir}"/>
+   </target>
+
+   <!-- =================================================================== -->
+   <!-- Compiles the source code                                            -->
+   <!-- =================================================================== -->
+   <target name="compile" depends="prepare">
+      <javac srcdir="${src.dir}"
+         destdir="${build.classes.dir}"
+         debug="on"
+         deprecation="on"
+         optimize="off"
+         includes="**">
+         <classpath refid="classpath"/>
+      </javac>
+   </target>
+
+   <target name="ejbjar" depends="compile">
+		<jar jarfile="build/${build.artifact}">
+ 			<fileset dir="${build.classes.dir}">
+				<include name="**/*.class"/>
+ 			</fileset>
+			<fileset dir=".">
+				<include name="*.properties"/>
+			</fileset>							        
+			<fileset dir=".">
+				<include name="META-INF/*.xml"/>
+			</fileset>
+		</jar>
+      
+      <copy file="build/${build.artifact}" todir="${jboss.home}/server/${jboss.server.config}/deploy"/>
+   </target>
+
+   <target name="run">
+      <java classname="org.jboss.tutorial.jboss_deployment_descriptor.client.Client" fork="yes" dir=".">
+         <classpath refid="classpath"/>
+      </java>
+   </target>
+
+   <!-- =================================================================== -->
+   <!-- Cleans up generated stuff                                           -->
+   <!-- =================================================================== -->
+   <target name="clean.db">
+      <delete dir="${jboss.home}/server/${jboss.server.config}/data/hypersonic"/>
+   </target>
+
+   <target name="clean">
+      <delete dir="${build.dir}"/>
+      <delete file="${jboss.home}/server/${jboss.server.config}/deploy/${build.artifact}"/>
+   </target>
+
+
+</project>
+


Property changes on: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/build.xml
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/jndi.properties
===================================================================
--- projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/jndi.properties	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/jndi.properties	2009-01-15 12:44:04 UTC (rev 82903)
@@ -0,0 +1,3 @@
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
+java.naming.provider.url=localhost


Property changes on: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/jndi.properties
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/log4j.xml
===================================================================
--- projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/log4j.xml	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/log4j.xml	2009-01-15 12:44:04 UTC (rev 82903)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!--                                                                       -->
+<!--  Log4j Configuration                                                  -->
+<!--                                                                       -->
+<!-- ===================================================================== -->
+
+<!-- $Id: log4j.xml 32809 2005-06-24 04:49:29Z bill $ -->
+
+<!--
+   | For more configuration infromation and examples see the Jakarta Log4j
+   | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+   
+<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+      <param name="Target" value="System.out"/>
+      <param name="Threshold" value="INFO"/>
+
+      <layout class="org.apache.log4j.PatternLayout">
+         <!-- The default pattern: Date Priority [Category] Messagen -->
+         <!--
+         <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+         -->
+         <param name="ConversionPattern" value="%-5p %d{dd-MM HH:mm:ss,SSS} (%F:%M:%L)  -%m%n"/>
+      </layout>
+</appender>
+
+   <root>
+      <appender-ref ref="CONSOLE"/>
+   </root>
+
+</log4j:configuration>


Property changes on: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/log4j.xml
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/pom.xml
===================================================================
--- projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/pom.xml	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/pom.xml	2009-01-15 12:44:04 UTC (rev 82903)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<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">
+
+   
+  <!-- Model Version -->
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.jboss.ejb3</groupId>
+    <artifactId>jboss-ejb3-tutorial-common</artifactId>
+    <version>0.1.0-SNAPSHOT</version>
+    <relativePath>../common/</relativePath>
+  </parent>
+
+  <properties>
+    <ejb3.tutorial.client>org.jboss.tutorial.jboss_deployment_descriptor.client.Client</ejb3.tutorial.client>
+  </properties>
+
+
+  <artifactId>jboss-ejb3-tutorial-jboss_deployment_descriptor</artifactId>
+  <version>0.1.0-SNAPSHOT</version>
+  <packaging>jar</packaging>
+  <name>Using JBoss deployment descriptors in EJB3</name>
+  <url>http://labs.jboss.com/jbossejb3/</url>
+  <description>
+    Tutorial explaining how to use (optional) JBoss deployment descriptors in EJB3
+  </description>
+  
+  
+  
+  
+
+
+</project>

Added: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/roles-default.properties
===================================================================
--- projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/roles-default.properties	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/roles-default.properties	2009-01-15 12:44:04 UTC (rev 82903)
@@ -0,0 +1 @@
+bill2=shopper


Property changes on: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/roles-default.properties
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/roles-test.properties
===================================================================
--- projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/roles-test.properties	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/roles-test.properties	2009-01-15 12:44:04 UTC (rev 82903)
@@ -0,0 +1 @@
+bill=shopper


Property changes on: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/roles-test.properties
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/jboss/tutorial/jboss_deployment_descriptor/bean/ShoppingCart.java
===================================================================
--- projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/jboss/tutorial/jboss_deployment_descriptor/bean/ShoppingCart.java	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/jboss/tutorial/jboss_deployment_descriptor/bean/ShoppingCart.java	2009-01-15 12:44:04 UTC (rev 82903)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.tutorial.jboss_deployment_descriptor.bean;
+
+import java.util.HashMap;
+import javax.ejb.Remove;
+
+public interface ShoppingCart
+{
+   void buy(String product, int quantity);
+   
+   void priceCheck(String product);
+
+   HashMap<String, Integer> getCartContents();
+
+   void checkout();
+}


Property changes on: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/jboss/tutorial/jboss_deployment_descriptor/bean/ShoppingCart.java
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/jboss/tutorial/jboss_deployment_descriptor/bean/ShoppingCartBean.java
===================================================================
--- projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/jboss/tutorial/jboss_deployment_descriptor/bean/ShoppingCartBean.java	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/jboss/tutorial/jboss_deployment_descriptor/bean/ShoppingCartBean.java	2009-01-15 12:44:04 UTC (rev 82903)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.tutorial.jboss_deployment_descriptor.bean;
+
+import java.io.Serializable;
+import java.util.HashMap;
+
+public class ShoppingCartBean implements ShoppingCart, Serializable
+{
+   private HashMap<String, Integer> cart = new HashMap<String, Integer>();
+
+   public void buy(String product, int quantity)
+   {
+      if (cart.containsKey(product))
+      {
+         int currq = cart.get(product);
+         currq += quantity;
+         cart.put(product, currq);
+      }
+      else
+      {
+         cart.put(product, quantity);
+      }
+   }
+   
+   public void priceCheck(String product)
+   {
+      // dummy
+   }
+
+   public HashMap<String, Integer> getCartContents()
+   {
+      return cart;
+   }
+
+   public void checkout()
+   {
+      System.out.println("To be implemented");
+   }
+}


Property changes on: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/jboss/tutorial/jboss_deployment_descriptor/bean/ShoppingCartBean.java
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/jboss/tutorial/jboss_deployment_descriptor/bean/StatelessTest.java
===================================================================
--- projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/jboss/tutorial/jboss_deployment_descriptor/bean/StatelessTest.java	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/jboss/tutorial/jboss_deployment_descriptor/bean/StatelessTest.java	2009-01-15 12:44:04 UTC (rev 82903)
@@ -0,0 +1,27 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.tutorial.jboss_deployment_descriptor.bean;
+
+public interface StatelessTest
+{
+   void testSecurity();
+}


Property changes on: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/jboss/tutorial/jboss_deployment_descriptor/bean/StatelessTest.java
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/jboss/tutorial/jboss_deployment_descriptor/bean/StatelessTestBean.java
===================================================================
--- projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/jboss/tutorial/jboss_deployment_descriptor/bean/StatelessTestBean.java	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/jboss/tutorial/jboss_deployment_descriptor/bean/StatelessTestBean.java	2009-01-15 12:44:04 UTC (rev 82903)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.tutorial.jboss_deployment_descriptor.bean;
+
+import javax.annotation.security.RunAs;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+
+ at Stateless
+ at Remote(StatelessTest.class)
+ at RunAs("shopper")
+public class StatelessTestBean
+   implements StatelessTest
+{
+   public void testSecurity()
+   {
+      System.out.println("Successfully accessed SLSB in tutorial-default security domain");
+   }
+}


Property changes on: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/jboss/tutorial/jboss_deployment_descriptor/bean/StatelessTestBean.java
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/jboss/tutorial/jboss_deployment_descriptor/client/Client.java
===================================================================
--- projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/jboss/tutorial/jboss_deployment_descriptor/client/Client.java	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/jboss/tutorial/jboss_deployment_descriptor/client/Client.java	2009-01-15 12:44:04 UTC (rev 82903)
@@ -0,0 +1,153 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.tutorial.jboss_deployment_descriptor.client;
+
+import java.util.HashMap;
+
+import javax.ejb.NoSuchEJBException;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import org.jboss.security.SecurityAssociation;
+import org.jboss.security.SimplePrincipal;
+import org.jboss.security.client.SecurityClient;
+import org.jboss.security.client.SecurityClientFactory;
+import org.jboss.tutorial.jboss_deployment_descriptor.bean.ShoppingCart;
+import org.jboss.tutorial.jboss_deployment_descriptor.bean.StatelessTest;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision: 61136 $
+ */
+public class Client
+{
+   public static void main(String[] args) throws Exception
+   {
+      testShoppingCart();
+      testStateless();
+   }
+
+   private static void testShoppingCart() throws Exception
+   {
+      // Establish the proxy with an incorrect security identity
+      SecurityClient securityClient = SecurityClientFactory.getSecurityClient();
+      securityClient.setSimple("bill", "incorrectpassword");
+      securityClient.login();
+      
+      Context ctx = new InitialContext();
+      ShoppingCart cart = (ShoppingCart) ctx.lookup("ShoppingCart");
+
+      System.out.println("Attempting to buy 1 memory stick with incorrect password");
+      try
+      {
+         cart.buy("Memory stick", 1);
+         throw new RuntimeException("ERROR - User with incorrect password was able to access the bean");
+      }
+      catch (javax.ejb.EJBAccessException e)
+      {
+         System.out.println("Caught javax.ejb.EJBAccessException as expected");
+      }
+
+      System.out.println("Setting user/password");
+      securityClient.logout();
+      
+      securityClient.setSimple("bill", "password-test");
+      securityClient.login();
+
+      System.out.println("bill is a shopper, so is allowed to buy");
+      System.out.println("Buying 1 memory stick");
+      cart.buy("Memory stick", 1);
+      System.out.println("Buying another memory stick");
+      cart.buy("Memory stick", 1);
+
+      System.out.println("Buying a laptop");
+      cart.buy("Laptop", 1);
+
+      System.out.println("Print cart:");
+      HashMap<String, Integer> fullCart = cart.getCartContents();
+      for (String product : fullCart.keySet())
+      {
+         System.out.println(fullCart.get(product) + "     " + product);
+      }
+
+      System.out.println("bill is not a clerk, so is not allowed to price check");
+      try
+      {
+         cart.priceCheck("Laptop");
+         throw new RuntimeException("ERROR - User with insufficient access rights allowed to access bean method");
+      }
+      catch (javax.ejb.EJBAccessException ex)
+      {
+         System.out.println("Caught EJBAccessException as expected");
+      }
+
+      System.out.println("Checkout");
+      cart.checkout();
+
+      System.out.println("Should throw an object not found exception by invoking on cart after @Remove method");
+      try
+      {
+         cart.getCartContents();
+         throw new RuntimeException("ERROR - Bean not discarded");
+      }
+      catch (NoSuchEJBException e)
+      {
+         System.out.println("Successfully caught no such object exception.");
+      }
+      
+      // logout the user
+      securityClient.logout();
+   }
+
+   private static void testStateless() throws Exception
+   {
+      InitialContext jndiContext = new InitialContext();
+      StatelessTest stateless = (StatelessTest) jndiContext.lookup("StatelessTest");
+
+      SecurityClient securityClient = SecurityClientFactory.getSecurityClient();
+      securityClient.setSimple("bill2", "invalidpassword");
+      securityClient.login();
+      
+      try
+      {
+         stateless.testSecurity();
+         throw new RuntimeException("ERROR - User with incorrect password accessed the bean");
+      }
+      catch (javax.ejb.EJBAccessException e)
+      {
+         System.out.println("Caught javax.ejb.EJBAccessException, for SLSB, as expected");
+      }
+
+      // logout and login back with correct credentials
+      System.out.println("Now passing the correct user/password to access the SLSB");
+      securityClient.logout();
+      securityClient.setSimple("bill2", "password-default");
+      securityClient.login();
+      
+      // call the bean method
+      stateless.testSecurity();
+
+      System.out.println("Successfully accessed SLSB");
+   }
+}


Property changes on: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/src/org/jboss/tutorial/jboss_deployment_descriptor/client/Client.java
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/users-default.properties
===================================================================
--- projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/users-default.properties	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/users-default.properties	2009-01-15 12:44:04 UTC (rev 82903)
@@ -0,0 +1,2 @@
+bill2=password-default
+


Property changes on: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/users-default.properties
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/users-test.properties
===================================================================
--- projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/users-test.properties	                        (rev 0)
+++ projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/users-test.properties	2009-01-15 12:44:04 UTC (rev 82903)
@@ -0,0 +1,2 @@
+bill=password-test
+


Property changes on: projects/ejb3/trunk/docs/tutorial/jboss_deployment_descriptor/users-test.properties
___________________________________________________________________
Name: svn:executable
   + *




More information about the jboss-cvs-commits mailing list