[jboss-cvs] JBossAS SVN: r66904 - in projects/microcontainer/trunk/docs/examples/User_Guide: gettingStarted and 11 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Nov 9 04:57:14 EST 2007


Author: newtonm
Date: 2007-11-09 04:57:13 -0500 (Fri, 09 Nov 2007)
New Revision: 66904

Added:
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/auditAspect/
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/auditAspect/pom.xml
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/commandLineClient/
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/commandLineClient/pom.xml
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/commandLineClient/src/main/java/org/jboss/example/client/Client.java
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/commandLineClient/src/test/resources/service-beans.xml
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/distributions/
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/pom.xml
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/main/java/org/jboss/example/service/Address.java
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/main/java/org/jboss/example/service/Employee.java
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/main/java/org/jboss/example/service/HRManager.java
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/main/resources/META-INF/jboss-beans.xml
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerAgeBasedTestCase.java
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerLocationBasedTestCase.java
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerTestCase.java
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerTestSuite.java
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/util/SalaryStrategyTestSuite.java
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/resources/log4j.properties
Removed:
   projects/microcontainer/trunk/docs/examples/User_Guide/auditAspect/
   projects/microcontainer/trunk/docs/examples/User_Guide/commandLineClient/
   projects/microcontainer/trunk/docs/examples/User_Guide/distributions/
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/auditAspect/pom.xml
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/commandLineClient/pom.xml
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/commandLineClient/src/main/assembly/
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/commandLineClient/src/main/java/org/jboss/example/client/Client.java
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/pom.xml
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/main/java/org/jboss/example/service/Address.java
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/main/java/org/jboss/example/service/Employee.java
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/main/java/org/jboss/example/service/HRManager.java
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/main/resources/META-INF/jboss-beans.xml
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerAgeBasedTestCase.java
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerLocationBasedTestCase.java
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerTestCase.java
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerTestSuite.java
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/util/SalaryStrategyTestSuite.java
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/resources/log4j.properties
   projects/microcontainer/trunk/docs/examples/User_Guide/humanResourcesService/
Log:
Moved Getting Started examples into their own directory.

Copied: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/auditAspect (from rev 66769, projects/microcontainer/trunk/docs/examples/User_Guide/auditAspect)

Deleted: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/auditAspect/pom.xml
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/auditAspect/pom.xml	2007-11-06 13:25:19 UTC (rev 66769)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/auditAspect/pom.xml	2007-11-09 09:57:13 UTC (rev 66904)
@@ -1,43 +0,0 @@
-<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.jboss.microcontainer.examples</groupId>
-  <artifactId>auditAspect</artifactId>
-  <packaging>jar</packaging>
-  <version>1.0.0</version>
-  <name>Audit Aspect</name>
-  <description>An auditing aspect that keeps a log of actions performed.</description>
-
-  <dependencies>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>3.8.1</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.jboss.aop</groupId>
-      <artifactId>jboss-aop</artifactId>
-      <version>2.0.0-SNAPSHOT</version>
-      <scope>compile</scope>
-    </dependency>
-  </dependencies>
-    
-  <build>
-    <plugins> 
-      <plugin>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <configuration>
-          <source>1.5</source>
-          <target>1.5</target>
-          <debug>true</debug>
-          <showDeprecation>true</showDeprecation>
-          <showWarnings>true</showWarnings>
-          <optimize>true</optimize>
-        </configuration>
-      </plugin>  
-    </plugins>
-  </build>
-
-</project>

Copied: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/auditAspect/pom.xml (from rev 66902, projects/microcontainer/trunk/docs/examples/User_Guide/auditAspect/pom.xml)
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/auditAspect/pom.xml	                        (rev 0)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/auditAspect/pom.xml	2007-11-09 09:57:13 UTC (rev 66904)
@@ -0,0 +1,43 @@
+<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.jboss.microcontainer.examples</groupId>
+  <artifactId>auditAspect</artifactId>
+  <packaging>jar</packaging>
+  <version>1.0.0</version>
+  <name>Audit Aspect</name>
+  <description>An auditing aspect that keeps a log of actions performed.</description>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.jboss.aop</groupId>
+      <artifactId>jboss-aop</artifactId>
+      <version>2.0.0-SNAPSHOT</version>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+    
+  <build>
+    <plugins> 
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+          <debug>true</debug>
+          <showDeprecation>true</showDeprecation>
+          <showWarnings>true</showWarnings>
+          <optimize>true</optimize>
+        </configuration>
+      </plugin>  
+    </plugins>
+  </build>
+
+</project>

Copied: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/commandLineClient (from rev 66729, projects/microcontainer/trunk/docs/examples/User_Guide/commandLineClient)

Deleted: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/commandLineClient/pom.xml
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/commandLineClient/pom.xml	2007-11-05 12:49:05 UTC (rev 66729)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/commandLineClient/pom.xml	2007-11-09 09:57:13 UTC (rev 66904)
@@ -1,74 +0,0 @@
-<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.jboss.microcontainer.examples</groupId>
-  <artifactId>client</artifactId>
-  <packaging>jar</packaging>
-  <version>1.0.0</version>
-  <name>Client</name>
-  <description>A simple command line client that uses the Human Resources Service.</description>
-
-  <dependencies>
-    <dependency>
-      <groupId>org.jboss.microcontainer</groupId>
-      <artifactId>jboss-kernel</artifactId>
-      <version>2.0.0-SNAPSHOT</version>
-      <scope>compile</scope>      
-    </dependency>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>3.8.1</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.jboss.microcontainer.examples</groupId>
-      <artifactId>humanResourcesService</artifactId>
-      <version>1.0.0</version>
-      <scope>compile</scope>
-    </dependency>
-  </dependencies>
-    
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-jar-plugin</artifactId>
-        <configuration>
-          <archive>
-            <addMavenDescriptor>false</addMavenDescriptor>
-            <manifest>
-              <mainClass>org.jboss.example.client.Client</mainClass>
-              <addClasspath>true</addClasspath>
-              <classpathPrefix>lib</classpathPrefix>  
-            </manifest>
-            <manifestEntries>
-              <Class-Path>. ./deploy/humanResourcesService-1.0.0.jar ./deploy/humanResourcesService-1.0.0.jar/ lib/jboss-common-logging-log4j-2.0.4.GA.jar lib/log4j-1.2.14.jar</Class-Path>
-            </manifestEntries>
-          </archive>
-        </configuration>
-      </plugin>
-      <plugin>
-        <artifactId>maven-assembly-plugin</artifactId>
-        <configuration>
-          <descriptors>
-            <descriptor>src/main/assembly/dist.xml</descriptor>
-          </descriptors>
-        </configuration>
-      </plugin>	 
-      <plugin>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <configuration>
-          <source>1.5</source>
-          <target>1.5</target>
-          <debug>true</debug>
-          <showDeprecation>true</showDeprecation>
-          <showWarnings>true</showWarnings>
-          <optimize>true</optimize>
-        </configuration>
-      </plugin>  
-    </plugins>
-  </build>
-
-</project>

Copied: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/commandLineClient/pom.xml (from rev 66816, projects/microcontainer/trunk/docs/examples/User_Guide/commandLineClient/pom.xml)
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/commandLineClient/pom.xml	                        (rev 0)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/commandLineClient/pom.xml	2007-11-09 09:57:13 UTC (rev 66904)
@@ -0,0 +1,58 @@
+<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.jboss.microcontainer.examples</groupId>
+  <artifactId>client</artifactId>
+  <packaging>jar</packaging>
+  <version>1.0.0</version>
+  <name>Client</name>
+  <description>A simple command line client that uses the Human Resources Service.</description>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.jboss.microcontainer</groupId>
+      <artifactId>jboss-kernel</artifactId>
+      <version>2.0.0-SNAPSHOT</version>
+      <scope>compile</scope>      
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.microcontainer.examples</groupId>
+      <artifactId>humanResourcesService</artifactId>
+      <version>1.0.0</version>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+    
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+          <debug>true</debug>
+          <showDeprecation>true</showDeprecation>
+          <showWarnings>true</showWarnings>
+          <optimize>true</optimize>
+        </configuration>
+      </plugin> 
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <configuration>
+          <archive>
+            <addMavenDescriptor>false</addMavenDescriptor>
+          </archive>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

Deleted: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/commandLineClient/src/main/java/org/jboss/example/client/Client.java
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/commandLineClient/src/main/java/org/jboss/example/client/Client.java	2007-11-05 12:49:05 UTC (rev 66729)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/commandLineClient/src/main/java/org/jboss/example/client/Client.java	2007-11-09 09:57:13 UTC (rev 66904)
@@ -1,182 +0,0 @@
-package org.jboss.example.client;
-
-import java.io.IOException;
-import java.net.URL;
-import java.text.ParseException;
-import java.util.Date;
-import java.util.Set;
-
-import org.jboss.example.service.Address;
-import org.jboss.example.service.Employee;
-import org.jboss.example.service.HRManager;
-import org.jboss.example.service.util.AgeBasedSalaryStrategy;
-import org.jboss.example.service.util.LocationBasedSalaryStrategy;
-import org.jboss.example.service.util.SalaryStrategy;
-import org.jboss.kernel.Kernel;
-import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.kernel.spi.registry.KernelBus;
-import org.jboss.kernel.spi.registry.KernelRegistry;
-
-public class Client {
-    
-	private boolean useBus = false;
-	private URL url;
-	private UserInterface userInterface;
-	private HRManager manager;
-	
-	private EmbeddedBootstrap bootstrap;
-	private Kernel kernel;
-	private KernelRegistry registry;
-	private KernelBus bus;
-
-	private final static String HRSERVICE = "HRService";
-	private final static String EMPLOYEE = "org.jboss.example.service.Employee";
-
-	public static void main(String[] args) throws Exception {
-		if ((args.length == 1 && !args[0].equals("bus")) || args.length > 1) {
-			System.out.println("Usage: java -jar client-1.0.0.jar [bus]");
-			System.exit(1);
-		}
-
-		Client client = new Client(args.length == 1);
-		client.setUserInterface(new ConsoleInput(client));
-    }
-
-	public Client(final boolean useBus) throws Exception {
-		this.useBus = useBus;
-		
-		ClassLoader cl = Thread.currentThread().getContextClassLoader();
-		url = cl.getResource("META-INF/jboss-beans.xml");
-	
-		// Start JBoss Microcontainer
-		bootstrap = new EmbeddedBootstrap();
-		bootstrap.run();
-		
-		kernel = bootstrap.getKernel();
-		registry = kernel.getRegistry();
-		bus = kernel.getBus();		
- 	}
-	
-	public void setUserInterface(UserInterface userInterface) {
-		this.userInterface = userInterface;
-	}
-	
-	void deploy() {
-		bootstrap.deploy(url);
-		if (manager == null) {
-			KernelControllerContext context = (KernelControllerContext) registry.getEntry(HRSERVICE);
-			if (context != null) { manager = (HRManager) context.getTarget(); }
-		}
-	}
-	
-	void undeploy() {
-		bootstrap.undeploy(url);
-	}
-	
-	private Object invoke(String serviceName, String methodName, Object[] args, String[] types) {
-		Object result = null;
-		try {
-			result = bus.invoke(serviceName, methodName, args, types);
-		} catch (Throwable t) {
-			t.printStackTrace();
-		}	
-		return result;
-	}
-	
-	boolean addEmployee() throws ParseException, NumberFormatException, IllegalArgumentException, IOException {
-		Employee newEmployee = userInterface.getEmployee();		
-		Address address = userInterface.getAddress();
-		Date dateOfBirth = userInterface.getDateOfBirth();		
-		newEmployee.setAddress(address);
-		newEmployee.setDateOfBirth(dateOfBirth);
-		
-		if (useBus)
-			return (Boolean) invoke(HRSERVICE, "addEmployee", new Object[] {newEmployee}, new String[] {EMPLOYEE});
-		else
-			return manager.addEmployee(newEmployee);			
-	}
-	
-	@SuppressWarnings("unchecked")
-	Set<Employee> listEmployees() {			
-		if (useBus)
-			return (Set<Employee>) invoke(HRSERVICE, "getEmployees", new Object[] {}, new String[] {});
-		else
-			return manager.getEmployees();
-	}
-	
-	void removeEmployee() throws IllegalArgumentException, IOException {			
-		Employee employee = userInterface.getEmployee();
-		
-		if (useBus)
-			invoke(HRSERVICE, "removeEmployee", new Object[] {employee}, new String[] {EMPLOYEE});
-		else
-			manager.removeEmployee(employee);
-	}
-	
-	Integer getSalary() throws IllegalArgumentException, IOException {
-		Employee employee = userInterface.getEmployee();
-
-		if (useBus)
-			return(Integer) invoke(HRSERVICE, "getSalary", new Object[] {employee}, new String[] {EMPLOYEE});
-		else
-			return manager.getSalary(employee);
-	}
-	
-	void setSalary() throws NumberFormatException, IllegalArgumentException, IOException {
-		Employee employee = userInterface.getEmployee();	
-		Integer salary = userInterface.getSalary();		
-		
-		Employee actualEmployee;
-		if (useBus) {
-			actualEmployee = (Employee) invoke(HRSERVICE, "getEmployee", new Object[] {employee.getFirstName(), employee.getLastName()}, new String[] {"java.lang.String","java.lang.String"});	
-			invoke(HRSERVICE, "setSalary", new Object[] {actualEmployee, salary}, new String[] {EMPLOYEE, "java.lang.Integer"});	
-		} else {
-			actualEmployee = manager.getEmployee(employee.getFirstName(), employee.getLastName());
-			manager.setSalary(actualEmployee, salary);			
-		}			
-	}
-	
-	boolean toggleHiringFreeze() {
-		boolean hiringFreeze;
-		if (useBus) {
-			hiringFreeze = (Boolean) invoke(HRSERVICE, "isHiringFreeze", new Object[] {}, new String[] {});	
-			invoke(HRSERVICE, "setHiringFreeze", new Object[] {!hiringFreeze}, new String[] {"boolean"});	
-		} else {
-			hiringFreeze = manager.isHiringFreeze();
-			manager.setHiringFreeze(!hiringFreeze);
-		}
-		return !hiringFreeze;
-	}
-	
-	@SuppressWarnings("unchecked")
-	String printStatus() {
-		boolean hiringFreeze;
-		int totalEmployees;
-		SalaryStrategy salaryStrategy;
-		
-		if (useBus) {
-			hiringFreeze = (Boolean) invoke(HRSERVICE, "isHiringFreeze", new Object[] {}, new String[] {});
-			Set<Employee> employees = (Set<Employee>) invoke(HRSERVICE, "getEmployees", new Object[] {}, new String[] {});
-			totalEmployees = employees.size();				
-			salaryStrategy = (SalaryStrategy) invoke(HRSERVICE, "getSalaryStrategy", new Object[] {}, new String[] {});
-		} else {
-			hiringFreeze = manager.isHiringFreeze();
-			totalEmployees = manager.getEmployees().size();
-			salaryStrategy = manager.getSalaryStrategy();		
-		}	
-		
-		String strategy = "Unknown";
-		if (salaryStrategy == null) { strategy = "None"; }
-		else if (salaryStrategy instanceof AgeBasedSalaryStrategy ) { strategy = "AgeBased"; }
-		else if (salaryStrategy instanceof LocationBasedSalaryStrategy ) { strategy = "LocationBased"; }
-		
-		StringBuffer buffer = new StringBuffer();
-		buffer.append("Total number of employees: " + totalEmployees);
-		buffer.append("\nHiring Freeze: " + hiringFreeze);	
-		buffer.append("\nSalary Strategy: " + strategy);
-		if (salaryStrategy != null) {
-			buffer.append(" - MinSalary: " + salaryStrategy.getMinSalary() + " MaxSalary: " + salaryStrategy.getMaxSalary());
-		}
-		return buffer.toString();
-	}
-}

Copied: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/commandLineClient/src/main/java/org/jboss/example/client/Client.java (from rev 66815, projects/microcontainer/trunk/docs/examples/User_Guide/commandLineClient/src/main/java/org/jboss/example/client/Client.java)
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/commandLineClient/src/main/java/org/jboss/example/client/Client.java	                        (rev 0)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/commandLineClient/src/main/java/org/jboss/example/client/Client.java	2007-11-09 09:57:13 UTC (rev 66904)
@@ -0,0 +1,184 @@
+package org.jboss.example.client;
+
+import java.io.IOException;
+import java.net.URL;
+import java.text.ParseException;
+import java.util.Date;
+import java.util.Set;
+
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.example.service.Address;
+import org.jboss.example.service.Employee;
+import org.jboss.example.service.HRManager;
+import org.jboss.example.service.util.AgeBasedSalaryStrategy;
+import org.jboss.example.service.util.LocationBasedSalaryStrategy;
+import org.jboss.example.service.util.SalaryStrategy;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.kernel.spi.registry.KernelBus;
+import org.jboss.kernel.spi.registry.KernelRegistry;
+
+public class Client {
+    
+	private boolean useBus = false;
+	private URL url;
+	private UserInterface userInterface;
+	private HRManager manager;
+	
+	private EmbeddedBootstrap bootstrap;
+	private Kernel kernel;
+	private KernelController controller;
+	private KernelBus bus;
+
+	private final static String HRSERVICE = "HRService";
+	private final static String EMPLOYEE = "org.jboss.example.service.Employee";
+
+	public static void main(String[] args) throws Exception {
+		if ((args.length == 1 && !args[0].equals("bus")) || args.length > 1) {
+			System.out.println("Usage: java -jar client-1.0.0.jar [bus]");
+			System.exit(1);
+		}
+
+		Client client = new Client(args.length == 1);
+		client.setUserInterface(new ConsoleInput(client));
+    }
+
+	public Client(final boolean useBus) throws Exception {
+		this.useBus = useBus;
+		
+		ClassLoader cl = Thread.currentThread().getContextClassLoader();
+		url = cl.getResource("service-beans.xml");
+	
+		// Start JBoss Microcontainer
+		bootstrap = new EmbeddedBootstrap();
+		bootstrap.run();
+		
+		kernel = bootstrap.getKernel();
+		controller = kernel.getController();
+		bus = kernel.getBus();		
+ 	}
+	
+	public void setUserInterface(UserInterface userInterface) {
+		this.userInterface = userInterface;
+	}
+	
+	void deploy() {
+		bootstrap.deploy(url);
+		if (manager == null) {
+			ControllerContext context = controller.getInstalledContext(HRSERVICE);
+			if (context != null) { manager = (HRManager) context.getTarget(); }
+		}
+	}
+	
+	void undeploy() {
+		bootstrap.undeploy(url);
+	}
+	
+	private Object invoke(String serviceName, String methodName, Object[] args, String[] types) {
+		Object result = null;
+		try {
+			result = bus.invoke(serviceName, methodName, args, types);
+		} catch (Throwable t) {
+			t.printStackTrace();
+		}	
+		return result;
+	}
+	
+	boolean addEmployee() throws ParseException, NumberFormatException, IllegalArgumentException, IOException {
+		Employee newEmployee = userInterface.getEmployee();		
+		Address address = userInterface.getAddress();
+		Date dateOfBirth = userInterface.getDateOfBirth();		
+		newEmployee.setAddress(address);
+		newEmployee.setDateOfBirth(dateOfBirth);
+		
+		if (useBus)
+			return (Boolean) invoke(HRSERVICE, "addEmployee", new Object[] {newEmployee}, new String[] {EMPLOYEE});
+		else
+			return manager.addEmployee(newEmployee);			
+	}
+	
+	@SuppressWarnings("unchecked")
+	Set<Employee> listEmployees() {			
+		if (useBus)
+			return (Set<Employee>) invoke(HRSERVICE, "getEmployees", new Object[] {}, new String[] {});
+		else
+			return manager.getEmployees();
+	}
+	
+	void removeEmployee() throws IllegalArgumentException, IOException {			
+		Employee employee = userInterface.getEmployee();
+		
+		if (useBus)
+			invoke(HRSERVICE, "removeEmployee", new Object[] {employee}, new String[] {EMPLOYEE});
+		else
+			manager.removeEmployee(employee);
+	}
+	
+	Integer getSalary() throws IllegalArgumentException, IOException {
+		Employee employee = userInterface.getEmployee();
+
+		if (useBus)
+			return(Integer) invoke(HRSERVICE, "getSalary", new Object[] {employee}, new String[] {EMPLOYEE});
+		else
+			return manager.getSalary(employee);
+	}
+	
+	void setSalary() throws NumberFormatException, IllegalArgumentException, IOException {
+		Employee employee = userInterface.getEmployee();	
+		Integer salary = userInterface.getSalary();		
+		
+		Employee actualEmployee;
+		if (useBus) {
+			actualEmployee = (Employee) invoke(HRSERVICE, "getEmployee", new Object[] {employee.getFirstName(), employee.getLastName()}, new String[] {"java.lang.String","java.lang.String"});	
+			invoke(HRSERVICE, "setSalary", new Object[] {actualEmployee, salary}, new String[] {EMPLOYEE, "java.lang.Integer"});	
+		} else {
+			actualEmployee = manager.getEmployee(employee.getFirstName(), employee.getLastName());
+			manager.setSalary(actualEmployee, salary);			
+		}			
+	}
+	
+	boolean toggleHiringFreeze() {
+		boolean hiringFreeze;
+		if (useBus) {
+			hiringFreeze = (Boolean) invoke(HRSERVICE, "isHiringFreeze", new Object[] {}, new String[] {});	
+			invoke(HRSERVICE, "setHiringFreeze", new Object[] {!hiringFreeze}, new String[] {"boolean"});	
+		} else {
+			hiringFreeze = manager.isHiringFreeze();
+			manager.setHiringFreeze(!hiringFreeze);
+		}
+		return !hiringFreeze;
+	}
+	
+	@SuppressWarnings("unchecked")
+	String printStatus() {
+		boolean hiringFreeze;
+		int totalEmployees;
+		SalaryStrategy salaryStrategy;
+		
+		if (useBus) {
+			hiringFreeze = (Boolean) invoke(HRSERVICE, "isHiringFreeze", new Object[] {}, new String[] {});
+			Set<Employee> employees = (Set<Employee>) invoke(HRSERVICE, "getEmployees", new Object[] {}, new String[] {});
+			totalEmployees = employees.size();				
+			salaryStrategy = (SalaryStrategy) invoke(HRSERVICE, "getSalaryStrategy", new Object[] {}, new String[] {});
+		} else {
+			hiringFreeze = manager.isHiringFreeze();
+			totalEmployees = manager.getEmployees().size();
+			salaryStrategy = manager.getSalaryStrategy();		
+		}	
+		
+		String strategy = "Unknown";
+		if (salaryStrategy == null) { strategy = "None"; }
+		else if (salaryStrategy instanceof AgeBasedSalaryStrategy ) { strategy = "AgeBased"; }
+		else if (salaryStrategy instanceof LocationBasedSalaryStrategy ) { strategy = "LocationBased"; }
+		
+		StringBuffer buffer = new StringBuffer();
+		buffer.append("Total number of employees: " + totalEmployees);
+		buffer.append("\nHiring Freeze: " + hiringFreeze);	
+		buffer.append("\nSalary Strategy: " + strategy);
+		if (salaryStrategy != null) {
+			buffer.append(" - MinSalary: " + salaryStrategy.getMinSalary() + " MaxSalary: " + salaryStrategy.getMaxSalary());
+		}
+		return buffer.toString();
+	}
+}

Copied: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/commandLineClient/src/test/resources/service-beans.xml (from rev 66769, projects/microcontainer/trunk/docs/examples/User_Guide/commandLineClient/src/test/resources/service-beans.xml)
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/commandLineClient/src/test/resources/service-beans.xml	                        (rev 0)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/commandLineClient/src/test/resources/service-beans.xml	2007-11-09 09:57:13 UTC (rev 66904)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:jboss:bean-deployer:2.0 bean-deployer_2_0.xsd"
+            xmlns="urn:jboss:bean-deployer:2.0">
+
+   <bean name="HRService" class="org.jboss.example.service.HRManager"/>
+      
+</deployment>

Copied: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/distributions (from rev 66816, projects/microcontainer/trunk/docs/examples/User_Guide/distributions)

Copied: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService (from rev 66642, projects/microcontainer/trunk/docs/examples/User_Guide/humanResourcesService)

Deleted: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/pom.xml
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/humanResourcesService/pom.xml	2007-11-01 08:03:42 UTC (rev 66642)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/pom.xml	2007-11-09 09:57:13 UTC (rev 66904)
@@ -1,43 +0,0 @@
-<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.jboss.microcontainer.examples</groupId>
-  <artifactId>humanResourcesService</artifactId>
-  <packaging>jar</packaging>
-  <version>1.0.0</version>
-  <name>Human Resources Service</name>
-  <description>A simple service created using a POJO.</description>
-
-
-  <build>
-    <plugins>
-      <plugin>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <configuration>
-          <source>1.5</source>
-          <target>1.5</target>
-          <showDeprecation>true</showDeprecation>
-          <showWarnings>true</showWarnings>
-          <optimize>true</optimize>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-     
-  <dependencies>
-    <dependency>
-      <groupId>org.jboss.microcontainer</groupId>
-      <artifactId>jboss-kernel</artifactId>
-      <version>2.0.0-SNAPSHOT</version>
-      <scope>test</scope>      
-    </dependency>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>3.8.1</version>
-      <scope>test</scope>
-    </dependency>
-  </dependencies>
-
-</project>

Copied: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/pom.xml (from rev 66782, projects/microcontainer/trunk/docs/examples/User_Guide/humanResourcesService/pom.xml)
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/pom.xml	                        (rev 0)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/pom.xml	2007-11-09 09:57:13 UTC (rev 66904)
@@ -0,0 +1,51 @@
+<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.jboss.microcontainer.examples</groupId>
+  <artifactId>humanResourcesService</artifactId>
+  <packaging>jar</packaging>
+  <version>1.0.0</version>
+  <name>Human Resources Service</name>
+  <description>A simple service created using a POJO.</description>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.jboss.microcontainer</groupId>
+      <artifactId>jboss-kernel</artifactId>
+      <version>2.0.0-SNAPSHOT</version>
+      <scope>test</scope>      
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <resources>
+      <resource>
+        <directory>src/main/resources</directory>
+    	<excludes>
+    	  <exclude>META-INF/*</exclude>
+    	</excludes>
+      </resource>
+    </resources>
+    
+    <plugins>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+          <showDeprecation>true</showDeprecation>
+          <showWarnings>true</showWarnings>
+          <optimize>true</optimize>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

Deleted: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/main/java/org/jboss/example/service/Address.java
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/humanResourcesService/src/main/java/org/jboss/example/service/Address.java	2007-11-01 08:03:42 UTC (rev 66642)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/main/java/org/jboss/example/service/Address.java	2007-11-09 09:57:13 UTC (rev 66904)
@@ -1,33 +0,0 @@
-package org.jboss.example.service;
-
-public class Address {
-
-	private int number;
-	private String street;
-	private String city;
-	
-	public Address(int number, String street, String city) {
-		this.number = number;
-		this.street = street;
-		this.city = city;
-	}
-	
-	public int getNumber() {
-		return number;
-	}
-	public void setNumber(int number) {
-		this.number = number;
-	}
-	public String getStreet() {
-		return street;
-	}
-	public void setStreet(String street) {
-		this.street = street;
-	}
-	public String getCity() {
-		return city;
-	}
-	public void setCity(String city) {
-		this.city = city;
-	}
-}

Copied: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/main/java/org/jboss/example/service/Address.java (from rev 66685, projects/microcontainer/trunk/docs/examples/User_Guide/humanResourcesService/src/main/java/org/jboss/example/service/Address.java)
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/main/java/org/jboss/example/service/Address.java	                        (rev 0)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/main/java/org/jboss/example/service/Address.java	2007-11-09 09:57:13 UTC (rev 66904)
@@ -0,0 +1,38 @@
+package org.jboss.example.service;
+
+public class Address {
+
+	private int number;
+	private String street;
+	private String city;
+	
+	public Address(int number, String street, String city) {
+		this.number = number;
+		this.street = street;
+		this.city = city;
+	}
+	
+	public int getNumber() {
+		return number;
+	}
+	public void setNumber(int number) {
+		this.number = number;
+	}
+	public String getStreet() {
+		return street;
+	}
+	public void setStreet(String street) {
+		this.street = street;
+	}
+	public String getCity() {
+		return city;
+	}
+	public void setCity(String city) {
+		this.city = city;
+	}
+	
+	@Override
+	public String toString() {
+		return number + " " + street + ", " + city;
+	}
+}

Deleted: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/main/java/org/jboss/example/service/Employee.java
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/humanResourcesService/src/main/java/org/jboss/example/service/Employee.java	2007-11-01 08:03:42 UTC (rev 66642)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/main/java/org/jboss/example/service/Employee.java	2007-11-09 09:57:13 UTC (rev 66904)
@@ -1,74 +0,0 @@
-package org.jboss.example.service;
-
-import java.util.Date;
-
-public class Employee {
-
-	private String firstName;
-	private String lastName;
-	private Date dateOfBirth;
-	private Address address;
-	
-	public Employee(String firstName, String lastName) {
-		this.firstName = firstName;
-		this.lastName = lastName;
-	}
-	
-	public String getFirstName() {
-		return firstName;
-	}
-	public void setFirstName(String firstName) {
-		this.firstName = firstName;
-	}
-	public String getLastName() {
-		return lastName;
-	}
-	public void setLastName(String lastName) {
-		this.lastName = lastName;
-	}
-	public Date getDateOfBirth() {
-		return dateOfBirth;
-	}
-	public void setDateOfBirth(Date dateOfBirth) {
-		this.dateOfBirth = dateOfBirth;
-	}
-	public Address getAddress() {
-		return address;
-	}
-	public void setAddress(Address address) {
-		this.address = address;
-	}
-	
-	@Override
-	public int hashCode() {
-		final int prime = 31;
-		int result = 1;
-		result = prime * result
-				+ ((firstName == null) ? 0 : firstName.hashCode());
-		result = prime * result
-				+ ((lastName == null) ? 0 : lastName.hashCode());
-		return result;
-	}
-	
-	@Override
-	public boolean equals(Object obj) {
-		if (this == obj)
-			return true;
-		if (obj == null)
-			return false;
-		if (getClass() != obj.getClass())
-			return false;
-		final Employee other = (Employee) obj;
-		if (firstName == null) {
-			if (other.firstName != null)
-				return false;
-		} else if (!firstName.equals(other.firstName))
-			return false;
-		if (lastName == null) {
-			if (other.lastName != null)
-				return false;
-		} else if (!lastName.equals(other.lastName))
-			return false;
-		return true;
-	}
-}

Copied: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/main/java/org/jboss/example/service/Employee.java (from rev 66685, projects/microcontainer/trunk/docs/examples/User_Guide/humanResourcesService/src/main/java/org/jboss/example/service/Employee.java)
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/main/java/org/jboss/example/service/Employee.java	                        (rev 0)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/main/java/org/jboss/example/service/Employee.java	2007-11-09 09:57:13 UTC (rev 66904)
@@ -0,0 +1,86 @@
+package org.jboss.example.service;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public class Employee {
+
+	private String firstName;
+	private String lastName;
+	private Date dateOfBirth;
+	private Address address;
+	
+	public Employee(String firstName, String lastName) {
+		this.firstName = firstName;
+		this.lastName = lastName;
+	}
+	
+	public String getFirstName() {
+		return firstName;
+	}
+	public void setFirstName(String firstName) {
+		this.firstName = firstName;
+	}
+	public String getLastName() {
+		return lastName;
+	}
+	public void setLastName(String lastName) {
+		this.lastName = lastName;
+	}
+	public Date getDateOfBirth() {
+		return dateOfBirth;
+	}
+	public void setDateOfBirth(Date dateOfBirth) {
+		this.dateOfBirth = dateOfBirth;
+	}
+	public Address getAddress() {
+		return address;
+	}
+	public void setAddress(Address address) {
+		this.address = address;
+	}
+	
+	@Override
+	public int hashCode() {
+		final int prime = 31;
+		int result = 1;
+		result = prime * result
+				+ ((firstName == null) ? 0 : firstName.hashCode());
+		result = prime * result
+				+ ((lastName == null) ? 0 : lastName.hashCode());
+		return result;
+	}
+	
+	@Override
+	public boolean equals(Object obj) {
+		if (this == obj)
+			return true;
+		if (obj == null)
+			return false;
+		if (getClass() != obj.getClass())
+			return false;
+		final Employee other = (Employee) obj;
+		if (firstName == null) {
+			if (other.firstName != null)
+				return false;
+		} else if (!firstName.equals(other.firstName))
+			return false;
+		if (lastName == null) {
+			if (other.lastName != null)
+				return false;
+		} else if (!lastName.equals(other.lastName))
+			return false;
+		return true;
+	}
+	
+	@Override
+	public String toString() {
+		SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
+		StringBuffer buffer = new StringBuffer();
+		
+		buffer.append("(" + firstName + " " + lastName + ", ");
+		buffer.append(address + " - " + formatter.format(dateOfBirth) + ")");
+		
+		return buffer.toString();
+	}
+}

Deleted: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/main/java/org/jboss/example/service/HRManager.java
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/humanResourcesService/src/main/java/org/jboss/example/service/HRManager.java	2007-11-01 08:03:42 UTC (rev 66642)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/main/java/org/jboss/example/service/HRManager.java	2007-11-09 09:57:13 UTC (rev 66904)
@@ -1,80 +0,0 @@
-package org.jboss.example.service;
-
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.jboss.example.service.util.SalaryStrategy;
-
-/**
- * An HRManager (Human Resource Manager) keeps track
- * of a set of employees and their associated salaries.
- */
-public class HRManager {
-    
-	private static final Integer STANDARD_SALARY = 10000;
-	
-	private Map<Employee, Integer> employees;
-	 
-	private boolean hiringFreeze = false;
-	
-	private SalaryStrategy salaryStrategy = null;
-	
-	public HRManager() {
-		employees =  new ConcurrentHashMap<Employee, Integer>();
- 	}
-	
-	public boolean addEmployee(Employee employee) {
-		if (hiringFreeze == false) {
-			employees.put(employee, STANDARD_SALARY);
-		}
-		
-		return (hiringFreeze == false);
-	}
-	
-	public Set<Employee> getEmployees() {
-		return employees.keySet();
-	}
-	
-	public Employee getEmployee(String firstName, String lastName) {
-		Set<Employee> employees = getEmployees();
-		for (Employee employee : employees) {
-			if (employee.getFirstName().equals(firstName)
-					&& employee.getLastName().equals(lastName)) {
-				return employee;
-			}
-		}
-		
-		return null;
-	}
-	
-	public void removeEmployee(Employee employee) {
-		employees.remove(employee);
-	}
-	
-	public Integer getSalary(Employee employee) {
-		return employees.get(employee);
-	}
-	
-	public void setSalary(Employee employee, Integer salary) {
-		
-		int adjustedSalary = salary;
-		
-		if (salaryStrategy != null) {
-			adjustedSalary = salaryStrategy.checkSalary(employee, salary);
-		}
-		employees.put(employee, adjustedSalary);
-	}
-
-	public boolean isHiringFreeze() {
-		return hiringFreeze;
-	}
-
-	public void setHiringFreeze(boolean hiringFreeze) {
-		this.hiringFreeze = hiringFreeze;
-	}
-
-	public void setSalaryStrategy(SalaryStrategy salaryStrategy) {
-		this.salaryStrategy = salaryStrategy;
-	}
-}

Copied: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/main/java/org/jboss/example/service/HRManager.java (from rev 66685, projects/microcontainer/trunk/docs/examples/User_Guide/humanResourcesService/src/main/java/org/jboss/example/service/HRManager.java)
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/main/java/org/jboss/example/service/HRManager.java	                        (rev 0)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/main/java/org/jboss/example/service/HRManager.java	2007-11-09 09:57:13 UTC (rev 66904)
@@ -0,0 +1,84 @@
+package org.jboss.example.service;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.jboss.example.service.util.SalaryStrategy;
+
+/**
+ * An HRManager (Human Resource Manager) keeps track
+ * of a set of employees and their associated salaries.
+ */
+public class HRManager {
+    
+	private static final Integer STANDARD_SALARY = 10000;
+	
+	private Map<Employee, Integer> employees;
+	 
+	private boolean hiringFreeze = false;
+	
+	private SalaryStrategy salaryStrategy = null;
+	
+	public HRManager() {
+		employees =  new ConcurrentHashMap<Employee, Integer>();
+ 	}
+	
+	public boolean addEmployee(Employee employee) {
+		if (hiringFreeze == false) {
+			employees.put(employee, STANDARD_SALARY);
+		}
+		
+		return (hiringFreeze == false);
+	}
+	
+	public Set<Employee> getEmployees() {
+		return employees.keySet();
+	}
+	
+	public Employee getEmployee(String firstName, String lastName) {
+		Set<Employee> employees = getEmployees();
+		for (Employee employee : employees) {
+			if (employee.getFirstName().equals(firstName)
+					&& employee.getLastName().equals(lastName)) {
+				return employee;
+			}
+		}
+		
+		return null;
+	}
+	
+	public void removeEmployee(Employee employee) {
+		employees.remove(employee);
+	}
+	
+	public Integer getSalary(Employee employee) {
+		return employees.get(employee);
+	}
+	
+	public void setSalary(Employee employee, Integer salary) {
+		
+		int adjustedSalary = salary;
+		
+		if (salaryStrategy != null) {
+			adjustedSalary = salaryStrategy.checkSalary(employee, salary);
+		}
+		employees.put(employee, adjustedSalary);
+	}
+
+	public boolean isHiringFreeze() {
+		return hiringFreeze;
+	}
+
+	public void setHiringFreeze(boolean hiringFreeze) {
+		this.hiringFreeze = hiringFreeze;
+	}
+	
+	public SalaryStrategy getSalaryStrategy() {
+		return salaryStrategy;
+	}
+
+	public void setSalaryStrategy(SalaryStrategy salaryStrategy) {
+		this.salaryStrategy = salaryStrategy;
+	}
+}

Deleted: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/main/resources/META-INF/jboss-beans.xml
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/humanResourcesService/src/main/resources/META-INF/jboss-beans.xml	2007-11-01 08:03:42 UTC (rev 66642)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/main/resources/META-INF/jboss-beans.xml	2007-11-09 09:57:13 UTC (rev 66904)
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-            xsi:schemaLocation="urn:jboss:bean-deployer:2.0 bean-deployer_2_0.xsd"
-            xmlns="urn:jboss:bean-deployer:2.0">
-
-   <bean name="HumanResources" class="org.jboss.example.service.Manager"/>
-      
-</deployment>

Copied: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/main/resources/META-INF/jboss-beans.xml (from rev 66645, projects/microcontainer/trunk/docs/examples/User_Guide/humanResourcesService/src/main/resources/META-INF/jboss-beans.xml)
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/main/resources/META-INF/jboss-beans.xml	                        (rev 0)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/main/resources/META-INF/jboss-beans.xml	2007-11-09 09:57:13 UTC (rev 66904)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:jboss:bean-deployer:2.0 bean-deployer_2_0.xsd"
+            xmlns="urn:jboss:bean-deployer:2.0">
+
+   <bean name="HRService" class="org.jboss.example.service.HRManager"/>
+      
+</deployment>

Deleted: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerAgeBasedTestCase.java
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerAgeBasedTestCase.java	2007-11-01 08:03:42 UTC (rev 66642)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerAgeBasedTestCase.java	2007-11-09 09:57:13 UTC (rev 66904)
@@ -1,28 +0,0 @@
-package org.jboss.example.service;
-
-import org.jboss.example.service.HRManager;
-
-public class HRManagerAgeBasedTestCase extends HRManagerTest
-{	
-    public HRManagerAgeBasedTestCase(String name) {
-		super(name);
-	}
-
-	public void testSalaryStrategy() throws Exception {
-		HRManager manager = (HRManager) getBean("HRService");
-		assertNotNull(manager);
-		assertEquals(false, manager.isHiringFreeze());
-		assertEquals(true, manager.addEmployee(bob));
-		assertEquals((Integer) 10000, manager.getSalary(bob));
-		
-		// Test setting a salary using an age based salary strategy
-		Employee employee = manager.getEmployee("Bob", "Smith");
-		assertNotNull(employee);
-		
-		manager.setSalary(employee, 600);		
-		assertEquals((Integer) 1000, manager.getSalary(employee));
-		
-		manager.setSalary(employee, 90000);
-		assertEquals((Integer) 80000, manager.getSalary(employee));
-	}
-}

Copied: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerAgeBasedTestCase.java (from rev 66643, projects/microcontainer/trunk/docs/examples/User_Guide/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerAgeBasedTestCase.java)
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerAgeBasedTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerAgeBasedTestCase.java	2007-11-09 09:57:13 UTC (rev 66904)
@@ -0,0 +1,29 @@
+package org.jboss.example.service;
+
+import org.jboss.example.service.HRManager;
+
+public class HRManagerAgeBasedTestCase extends HRManagerTest
+{	
+    public HRManagerAgeBasedTestCase(String name) {
+		super(name);
+	}
+
+	public void testSalaryStrategy() throws Exception {
+		HRManager manager = (HRManager) getBean("HRService");
+		assertNotNull(manager);
+
+		assertEquals(false, manager.isHiringFreeze());
+		assertEquals(true, manager.addEmployee(bob));
+		assertEquals((Integer) 10000, manager.getSalary(bob));
+		
+		// Test setting a salary using an age based salary strategy
+		Employee employee = manager.getEmployee("Bob", "Smith");
+		assertNotNull(employee);
+		
+		manager.setSalary(employee, 600);		
+		assertEquals((Integer) 1000, manager.getSalary(employee));
+		
+		manager.setSalary(employee, 90000);
+		assertEquals((Integer) 80000, manager.getSalary(employee));
+	}
+}

Deleted: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerLocationBasedTestCase.java
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerLocationBasedTestCase.java	2007-11-01 08:03:42 UTC (rev 66642)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerLocationBasedTestCase.java	2007-11-09 09:57:13 UTC (rev 66904)
@@ -1,28 +0,0 @@
-package org.jboss.example.service;
-
-import org.jboss.example.service.HRManager;
-
-public class HRManagerLocationBasedTestCase extends HRManagerTest
-{	
-    public HRManagerLocationBasedTestCase(String name) {
-		super(name);
-	}
-
-	public void testSalaryStrategy() throws Exception {
-		HRManager manager = (HRManager) getBean("HRService");
-		assertNotNull(manager);
-		assertEquals(false, manager.isHiringFreeze());
-		assertEquals(true, manager.addEmployee(rebecca));
-		assertEquals((Integer) 10000, manager.getSalary(rebecca));
-		
-		// Test setting a salary using a location based salary strategy
-		Employee employee = manager.getEmployee("Rebecca", "Jones");
-		assertNotNull(employee);
-		
-		manager.setSalary(employee, 15000);		
-		assertEquals((Integer) 20000, manager.getSalary(employee));
-		
-		manager.setSalary(employee, 71000);
-		assertEquals((Integer) 70000, manager.getSalary(employee));
-	}
-}

Copied: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerLocationBasedTestCase.java (from rev 66643, projects/microcontainer/trunk/docs/examples/User_Guide/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerLocationBasedTestCase.java)
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerLocationBasedTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerLocationBasedTestCase.java	2007-11-09 09:57:13 UTC (rev 66904)
@@ -0,0 +1,29 @@
+package org.jboss.example.service;
+
+import org.jboss.example.service.HRManager;
+
+public class HRManagerLocationBasedTestCase extends HRManagerTest
+{	
+    public HRManagerLocationBasedTestCase(String name) {
+		super(name);
+	}
+
+	public void testSalaryStrategy() throws Exception {
+		HRManager manager = (HRManager) getBean("HRService");
+		assertNotNull(manager);
+
+		assertEquals(false, manager.isHiringFreeze());
+		assertEquals(true, manager.addEmployee(rebecca));
+		assertEquals((Integer) 10000, manager.getSalary(rebecca));
+		
+		// Test setting a salary using a location based salary strategy
+		Employee employee = manager.getEmployee("Rebecca", "Jones");
+		assertNotNull(employee);
+		
+		manager.setSalary(employee, 15000);		
+		assertEquals((Integer) 20000, manager.getSalary(employee));
+		
+		manager.setSalary(employee, 71000);
+		assertEquals((Integer) 70000, manager.getSalary(employee));
+	}
+}

Deleted: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerTestCase.java
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerTestCase.java	2007-11-01 08:03:42 UTC (rev 66642)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerTestCase.java	2007-11-09 09:57:13 UTC (rev 66904)
@@ -1,37 +0,0 @@
-package org.jboss.example.service;
-
-import org.jboss.example.service.HRManager;
-
-public class HRManagerTestCase extends HRManagerTest
-{	
-    public HRManagerTestCase(String name) {
-		super(name);
-	}
-
-	public void testHiringFiring() throws Exception {
-		HRManager manager = (HRManager) getBean("HRService");
-		assertNotNull(manager);
-
-		// Test add and remove (with and without a hiring freeze)
-		assertEquals(true, manager.isHiringFreeze());
-		assertEquals(false, manager.addEmployee(bob));
-		assertEquals(0, manager.getEmployees().size());
-		
-		manager.setHiringFreeze(false);
-		
-		assertEquals(false, manager.isHiringFreeze());
-		assertEquals(true, manager.addEmployee(bob));
-		assertEquals(1, manager.getEmployees().size());
-		assertEquals((Integer) 10000, manager.getSalary(bob));
-		
-		// Test setting a salary without using a salary strategy
-		Employee employee = manager.getEmployee("Bob", "Smith");
-		assertNotNull(employee);
-		manager.setSalary(employee, 600);
-		
-		assertEquals((Integer) 600, manager.getSalary(employee));
-		
-		manager.removeEmployee(bob);
-		assertEquals(0, manager.getEmployees().size());	
-	}
-}

Copied: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerTestCase.java (from rev 66643, projects/microcontainer/trunk/docs/examples/User_Guide/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerTestCase.java)
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerTestCase.java	2007-11-09 09:57:13 UTC (rev 66904)
@@ -0,0 +1,37 @@
+package org.jboss.example.service;
+
+import org.jboss.example.service.HRManager;
+
+public class HRManagerTestCase extends HRManagerTest
+{	
+    public HRManagerTestCase(String name) {
+		super(name);
+	}
+
+	public void testHiringFiring() throws Exception {
+		HRManager manager = (HRManager) getBean("HRService");
+		assertNotNull(manager);
+
+		// Test add and remove (with and without a hiring freeze)
+		assertEquals(true, manager.isHiringFreeze());
+		assertEquals(false, manager.addEmployee(bob));
+		assertEquals(0, manager.getEmployees().size());
+		
+		manager.setHiringFreeze(false);		
+		assertEquals(false, manager.isHiringFreeze());
+
+		assertEquals(true, manager.addEmployee(bob));
+		assertEquals(1, manager.getEmployees().size());
+		assertEquals((Integer) 10000, manager.getSalary(bob));
+		
+		// Test setting a salary without using a salary strategy
+		Employee employee = manager.getEmployee("Bob", "Smith");
+		assertNotNull(employee);
+
+		manager.setSalary(employee, 600);		
+		assertEquals((Integer) 600, manager.getSalary(employee));
+		
+		manager.removeEmployee(bob);
+		assertEquals(0, manager.getEmployees().size());	
+	}
+}

Deleted: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerTestSuite.java
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerTestSuite.java	2007-11-01 08:03:42 UTC (rev 66642)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerTestSuite.java	2007-11-09 09:57:13 UTC (rev 66904)
@@ -1,26 +0,0 @@
-package org.jboss.example.service;
-
-import org.jboss.example.service.util.SalaryStrategyTestSuite;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
-public class HRManagerTestSuite extends TestSuite
-{
-   public static void main(String[] args) {
-      TestRunner.run(suite());
-   }
-
-   public static Test suite() {
-      TestSuite suite = new TestSuite("Human Resources Manager Tests");
-      
-      suite.addTestSuite(HRManagerTestCase.class);
-      suite.addTestSuite(HRManagerAgeBasedTestCase.class);
-      suite.addTestSuite(HRManagerLocationBasedTestCase.class);
-      
-      suite.addTest(SalaryStrategyTestSuite.suite());
-      
-      return suite;
-   }
-}

Copied: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerTestSuite.java (from rev 66643, projects/microcontainer/trunk/docs/examples/User_Guide/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerTestSuite.java)
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerTestSuite.java	                        (rev 0)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/HRManagerTestSuite.java	2007-11-09 09:57:13 UTC (rev 66904)
@@ -0,0 +1,26 @@
+package org.jboss.example.service;
+
+import org.jboss.example.service.util.SalaryStrategyTestSuite;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+public class HRManagerTestSuite extends TestSuite
+{
+   public static void main(String[] args) {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite() {
+      TestSuite suite = new TestSuite("HRManager Tests");
+      
+      suite.addTestSuite(HRManagerTestCase.class);
+      suite.addTestSuite(HRManagerAgeBasedTestCase.class);
+      suite.addTestSuite(HRManagerLocationBasedTestCase.class);
+      
+      suite.addTest(SalaryStrategyTestSuite.suite());
+      
+      return suite;
+   }
+}

Deleted: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/util/SalaryStrategyTestSuite.java
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/humanResourcesService/src/test/java/org/jboss/example/service/util/SalaryStrategyTestSuite.java	2007-11-01 08:03:42 UTC (rev 66642)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/util/SalaryStrategyTestSuite.java	2007-11-09 09:57:13 UTC (rev 66904)
@@ -1,24 +0,0 @@
-package org.jboss.example.service.util;
-
-import org.jboss.example.service.util.AgeBasedSalaryTestCase;
-import org.jboss.example.service.util.LocationBasedSalaryTestCase;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
-public class SalaryStrategyTestSuite extends TestSuite
-{
-   public static void main(String[] args) {
-      TestRunner.run(suite());
-   }
-
-   public static Test suite() {
-      TestSuite suite = new TestSuite("Salary Strategy Unit Tests");
-      
-      suite.addTestSuite(AgeBasedSalaryTestCase.class);
-      suite.addTestSuite(LocationBasedSalaryTestCase.class);
-      
-      return suite;
-   }
-}

Copied: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/util/SalaryStrategyTestSuite.java (from rev 66643, projects/microcontainer/trunk/docs/examples/User_Guide/humanResourcesService/src/test/java/org/jboss/example/service/util/SalaryStrategyTestSuite.java)
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/util/SalaryStrategyTestSuite.java	                        (rev 0)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/java/org/jboss/example/service/util/SalaryStrategyTestSuite.java	2007-11-09 09:57:13 UTC (rev 66904)
@@ -0,0 +1,24 @@
+package org.jboss.example.service.util;
+
+import org.jboss.example.service.util.AgeBasedSalaryTestCase;
+import org.jboss.example.service.util.LocationBasedSalaryTestCase;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+public class SalaryStrategyTestSuite extends TestSuite
+{
+   public static void main(String[] args) {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite() {
+      TestSuite suite = new TestSuite("SalaryStrategy Tests");
+      
+      suite.addTestSuite(AgeBasedSalaryTestCase.class);
+      suite.addTestSuite(LocationBasedSalaryTestCase.class);
+      
+      return suite;
+   }
+}

Deleted: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/resources/log4j.properties
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/humanResourcesService/src/test/resources/log4j.properties	2007-11-01 08:03:42 UTC (rev 66642)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/resources/log4j.properties	2007-11-09 09:57:13 UTC (rev 66904)
@@ -1,7 +0,0 @@
-log4j.rootLogger=DEBUG, stdout
-
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-# Pattern to output the caller's file name and line number.
-log4j.appender.stdout.layout.ConversionPattern=MC Examples %5p [%d{dd-MM-yyyy HH:mm:ss}] %c{1} - %m%n
-

Copied: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/resources/log4j.properties (from rev 66644, projects/microcontainer/trunk/docs/examples/User_Guide/humanResourcesService/src/test/resources/log4j.properties)
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/resources/log4j.properties	                        (rev 0)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/humanResourcesService/src/test/resources/log4j.properties	2007-11-09 09:57:13 UTC (rev 66904)
@@ -0,0 +1,8 @@
+log4j.rootLogger=DEBUG, stdout
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+
+# Pattern to output the caller's file name and line number.
+log4j.appender.stdout.layout.ConversionPattern=HRService %5p [%d{dd-MM-yyyy HH:mm:ss}] %c{1} - %m%n
+




More information about the jboss-cvs-commits mailing list