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
CreateActions_it
CreateDAO_it
SpringControllers_it




JSPWiki v2.2.33

[RSS]


Hide Menu

CreateManager_it


Difference between version 4 and version 2:

At line 23 changed 1 line.
;:''Ciò potrebbe sembrare ridondante (perché tutti i test!), but these tests are GREAT to have 6 months down the road.''
;:''Ciò potrebbe sembrare ridondante (ma perché scrivere tutti i test!), ma è una GRAN cosa avere questi test quando sono passati 6 mesi dall'inizio dello sviluppo.''
At line 66 changed 1 line.
;:''...we create methods that begin with "test" (all lower case). As long as these methods are public, have a void return type and take no arguments, they will be called by our <junit> task in our Ant build.xml file. Here's some simple tests for testing CRUD. An important thing to remember is that each method (also known as a test), should be autonomous.''
;:''...crea dei metodi che inizino con "test" (tutto minuscolo). Se questi metodi sono pubblici, hanno un valore di ritorno void e non prendono argomenti, verranno richiamati dal task <junit> del build.xml di Ant. Qui sotto ci sono alcuni semplici test per verificare il CRUD. Una cosa importante da ricordare è che ogni metodo (noto anche come test), deve essere autonomo.''
At line 68 changed 1 line.
Add the following methods to your PersonManagerTest.java file:
Aggiungi i metodi seguenti al tuo file PersonManagerTest.java:
At line 127 changed 1 line.
This class won't compile at this point because we have not created our PersonManager interface.
A questo punto questa classe non compilerà perché non abbiamo ancora creato la nostra interfaccia PersonManager.
At line 129 changed 1 line.
;:%%(color: blue)''I think it's funny how I've followed so many patterns to allow __extendibility__ in AppFuse. In reality, on most projects I've been on - I learn so much in a year that I don't want to extend the architecture - I want to rewrite it. Hopefully by keeping AppFuse up to date with my perceived best practices, this won't happen as much. Each year will just be an upgrade to the latest AppFuse, rather than a re-write. ;-)''
;:%%(color: blue)''Credo sia divertente il fatto che abbia seguito così tanti pattern per permettere l'__estensibilità__ in AppFuse. In realtà, nella maggior parte dei progetti sui quali sono stato - imparo così tanto in un anno che non voglio estendere l'archiettura - la voglio riscrivere. Sperabilmente mantenendo aggiornato AppFuse con quelle che io ritengo le best practices, ciò non succederà così spesso. Ogni anno sarà solo un aggiornamento alla versione più recente di AppFuse, piuttosto che una sua riscrittura. ;-)''
At line 133 changed 1 line.
First off, create a PersonManager.java interface in the src/service/**/service directory and specify the basic CRUD methods for any implementation classes. ''I've eliminated the JavaDocs in the class below for display purposes.'' The ''setPersonDao()'' method is not used in most cases - its just exists so the PersonManagerTest can set the DAO on the interface.
Per primo, crea un'interfaccia PersonManager.java nella directory src/service/**/service e specifica i metodi CRUD di base in tutte le classi che la implementano. ''Ho rimosso i JavaDoc nella classe sotto per motivi di visualizzazione.'' Il metodo ''setPersonDao()'' nella maggior parte dei casi non è usato - esiste giusto per permettere al PersonManagerTest di poter impostare il DAO sull'interfaccia.
At line 135 changed 1 line.
;:%%(color: blue)''As usual, I usually duplicate (open → save as) an existing file (i.e. UserManager.java).''%%
;:%%(color: blue)''Come sempre, io di solito duplico (apri → registra come) un file esistente (i.e. UserManager.java).''%%
At line 152 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/impl and name it PersonManagerImpl.java. It should extend BaseManager and implement PersonManager.
Ora creiamo una classe PersonManagerImpl che implementi i metodi in PersonManager. Per far questo, crea una nuova classe in src/service/**/service/impl e chiamala PersonManagerImpl.java. Deve estendere BaseManager ed implementare PersonManager.
At line 183 changed 1 line.
One thing to note is the {{setPersonDao()}} method. This is used by Spring to bind the PersonDao to this Manager. This is configured in the applicationContext-service.xml file. We'll get to configuring that in Step 3[3]. You should be able to compile everything now using "ant compile-service".
Una cosa da notare è il metodo {{setPersonDao()}}. Questo è usato da Spring per legare il PersonDao a questo Manager. Ciò è configurato nel flie applicationContext-service.xml. Arriveremo a configurare quello nel Passo 3[3]. Dovresti riuscire a compilare tutto ora con "ant compile-service".
At line 185 changed 1 line.
Now you need to edit Spring's config file for our services layer so it will know about this new Manager.
Ora devi modificare il file di configurazione di Spring per il nostro strato servizi in modo che sappia dell'esistenza di questo nuovo Manager.
At line 189 changed 1 line.
To notify Spring of this our PersonManager interface and its 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.
Per notificare a Spring l'esistenza della nostra interfaccia PersonManager e della relativa implementazione, apri il file src/service/**/service/applicationContext-service.xml. Aggiungi quanto segue al termine di questo file.
At line 193 changed 4 lines.
<bean id="personManager" parent="txProxyTemplate">
<property name="target">
<bean class="org.appfuse.service.impl.PersonManagerImpl" autowire="byName"/>
</property>
<bean id="personManager" class="org.appfuse.service.impl.PersonManagerImpl">
<property name="personDao" ref="personDao"/>
At line 200 changed 1 line.
The "parent" attribute refers to a bean definition for a [TransactionProxyFactoryBean|http://www.springframework.org/docs/api/org/springframework/transaction/interceptor/TransactionProxyFactoryBean.html] that has all the basic transaction attributes set.
Questo bean deve avere un nome che termina con "Manager". Deve essere così, in quanto esiste un advice AOP che viene applicato su questo file per tutti i bean *Manager.
{{{<aop:advisor id="managerTx" advice-ref="txAdvice" pointcut="execution(* *..service.*Manager.*(..))" order="2"/>}}} Per ulteriori informazioni sulle transazioni con Spring, vedi [la documentazione di Spring|http://www.springframework.org/docs/reference/transaction.html].
At line 202 removed 1 line.
At line 205 changed 1 line.
Save all your edited files and try running __ant test-service -Dtestcase=PersonManager__.
Registra tutti i file da te modificati e prova ad eseguire __ant test-service -Dtestcase=PersonManager__.
At line 215 changed 1 line.
''Prossima Puntata:'' __Parte III:__ [Creating Actions and JSPs|CreateActions] - A HowTo for creating Actions and JSPs in the AppFuse architecture.
''Prossima Puntata:'' __Parte III:__ [Creare Action e JSP|CreateActions_it] - Un HowTo per la creazione di Action e JSP nell'architettura di AppFuse.

Back to CreateManager_it, or to the Page History.