Raible's Wiki

Raible Designs
Wiki Home
News
Recent Changes

AppFuse

Homepage
  - Korean
  - Chinese
  - Italian
  - Japanese

QuickStart Guide
  - Chinese
  - French
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish
  - Japanese

User Guide
  - Korean
  - Chinese

Tutorials
  - Chinese
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish

FAQ
  - Korean

Latest Downloads

Other Applications

Struts Resume
Security Example
Struts Menu

Set your name in
UserPreferences


Referenced by
Articles
Articles_pt
CreateActions
CreateDAO
CreateDAO_sp
CreateDAOiBATIS
CreateDAOiBATIS_ko
CreateManager_es
JSFBeans
SpringControllers
...and 3 more




JSPWiki v2.2.33

[RSS]


Hide Menu

CreateManager


Difference between version 68 and version 67:

At line 65 changed 1 line.
person = (Person) mgr.getPerson("1");
person = mgr.getPerson("1");
At line 67 changed 2 lines.
assertTrue("person.firstName not null",
person.getFirstName() != null);
assertNotNull(person.getFirstName());
At line 72 changed 2 lines.
person = (Person) mgr.getPerson("1");
String name = person.getFirstName();
person = mgr.getPerson("1");
At line 76 changed 5 lines.
person = (Person) mgr.savePerson(person);
assertTrue("name updated", person.getFirstName().equals("test"));
person.setFirstName(name);
mgr.savePerson(person);
person = mgr.savePerson(person);
assertEquals(person.getFirstName(), "test");
At line 87 changed 3 lines.
person = (Person) mgr.savePerson(person);
assertTrue(person.getFirstName().equals("Bill"));
assertTrue(person.getId() != null);
person = mgr.savePerson(person);
assertEquals(person.getFirstName(), "Bill"));
assertNotNull(person.getId());
At line 91 changed 4 lines.
if (log.isDebugEnabled()) {
log.debug("removing person, personId: " +
person.getId());
}
log.debug("removing person, personId: " + person.getId());
At line 98 changed 1 line.
assertNull(mgr.getPerson(person.getId().toString()));
try {
person = mgr.getPerson(person.getId().toString());
fail("Person found in database");
} catch (DataAccessException dae) {
log.debug("Expected exception: " + dae.getMessage());
assertNotNull(dae);
}
At line 121 removed 1 line.
At line 123 removed 1 line.
At line 125 changed 3 lines.
public Person savePerson(Object person);
public Person savePerson(Person person);
At line 132 changed 1 line.
Now let's create a PersonManagerImpl class that implements the methods in PersonManager. To do this, create a new class in src/service/**/service and name it PersonManagerImpl.java. It should extend BaseManager and implement PersonManager.
Now let's create a PersonManagerImpl class that implements the methods in PersonManager. To do this, create a new class in src/service/**/service/impl and name it PersonManagerImpl.java. It should extend BaseManager and implement PersonManager.
At line 136 changed 1 line.
package org.appfuse.service;
package org.appfuse.service.impl;
At line 138 removed 3 lines.
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
At line 134 added 1 line.
import org.appfuse.service.PersonManager;
At line 146 removed 4 lines.
/**
* @author mraible
* @version $Revision: $ $Date: May 25, 2004 11:46:54 PM $
*/
At line 151 removed 1 line.
private static Log log = LogFactory.getLog(PersonManagerImpl.class);
At line 166 changed 1 line.
public Person savePerson(Object person) {
public Person savePerson(Person person) {
At line 168 changed 1 line.
return (Person) person;
return person;
At line 191 changed 1 line.
To notify Spring of this our PersonManager interface and it's implementation, open the src/service/**/service/applicationContext-service.xml file. In here, you will see an existing configuration for the UserManager. You should be able to copy that and change a few things to get the XML fragment below. Add the following to the bottom of this file.
To notify Spring of this our PersonManager interface and it's implementation, open the src/service/**/service/applicationContext-service.xml file. In here, you should see a commented out definition for the "personManager" bean. Uncomment this, or add the following to the bottom of this file.
At line 195 changed 3 lines.
<!-- Person Manager -->
<bean id="personManagerTarget" class="org.appfuse.service.PersonManagerImpl" singleton="false">
<property name="personDao"><ref bean="personDAO"/></property>
<bean id="personManager" parent="txProxyTemplate">
<property name="target">
<bean class="org.appfuse.service.impl.PersonManagerImpl" autowire="true"/>
</property>
At line 199 removed 8 lines.
<!-- Transaction declarations for business services. To apply a generic transaction proxy to
all managers, you might look into using the BeanNameAutoProxyCreator -->
<bean id="personManager" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager"><ref bean="transactionManager"/></property>
<property name="target"><ref local="personManagerTarget"/></property>
<property name="transactionAttributeSource"><ref local="defaultTxAttributes"/></property>
</bean>
At line 209 changed 1 line.
''Note: [I|DaveKeller] had SAX throw an error because defaultTxAttributes was not defined so I replaced the transactionAttributeSource with this instead, which allowed my unit test to run successfully.''
The "parent" attribute refers to a bean definition for a TransactionProxyFactoryBean that has all the basic transaction attributes set.
At line 211 removed 1 line.
[{Java2HtmlPlugin
At line 213 removed 9 lines.
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
}]

Back to CreateManager, or to the Page History.