http://www.springframework.org - evodion

helpflightInternet και Εφαρμογές Web

10 Νοε 2013 (πριν από 3 χρόνια και 5 μήνες)

79 εμφανίσεις

 
 
  !
"

 
#$%%&#'&
($ 
  !
 
 

) #*'+
, #- *'
,. /) )'

 '/ #
(##'
, #012(## / '
345 6
& #'*7
89/411
(##  

-'#

:;% !
, #.'<=9
0#/1'
9'9'
  !
 
 
>
0! #*'
,.%>?4
4!
,(*'?4@.

  





, #"&?79A
,A%B # 
94%411(##
*'
, #&B2 C
  !
 
 
A
 #*' 

 
,    

411 

D #/
& ##E;
9&

4.;
##&

FF#;
#;/411&

G'E#4&(
'D;
E#;D';  
&

 ;/'
##';
&
  !
 
 
B
#*' 36

 
 

# #

H## #
#(:

##E
/ &3*
E#/48F! F%?
##&)D#
&6
  !
 
 
I
#2J
,(: 1'&
,2J.#$

14..9428

1Action
,*'9/
? 9
/(## 
&
, 7' #$1'<'
#(:#&
  !
 
 
C
) #''+
,0 #$

G
, '#;K
3*6

(F:*'
, # :E;J (F:
'
,'(#4
(#)'9

 ( -;
,' 
>
:;(:
,8 L1'7
' (##.:F4F&
  !
 
 

#F

 
  !
 
 
M
G
GG
    
,.8:G4J0
#4JG'<#/
*'&
, 
$8@/@
;
     !  "#
,8*9G
98:&8
E#9( 7'9GJ
(:G&0#9
.
*'9-9 9
4JF K' !$ &
,9  
!" 
# $ !" &
  !
 
 
"
G
GG3&6
% 

'( 7'0

-'#G (##'

L: ;! ##

<9FF8

) 'G

   '
  !
 
 
""
G
.*
,&   0 #
,'   (.*;/ 
7979*'*

"


,1&   < 
N-J8?J1<beans>
'&
,8?J17<bean>J1

id3name6 ; 

class #;;O
  !
 
 
"
.*J0
,.#3 K6
<beans>
<bean id=“dataSource”class=“...ClientDataSource”>
<property name=“server”value=“localhost”/>
<property name=“port”value=“1234”/>
</bean>
<bean id=“supplierDAO”class=“...SupplierDAO”>
<property name=“dataSource”ref=“dataSource”/>
</bean>
</beans>
,  
,(:;#3scope=PprototypeQ6
  !
 
 
">
.*
03&6
(0?9
<beans>
<bean id=“supplierDAO”class=“...SupplierDAO”>
<property name=“dataSource”>
<bean class=“...ClientDataSource”>
<property name=“server”value=“localhost”/>
<property name=“port”value=“1234”/>
</bean>
</property>
</bean>
</beans>
  !
 
 
"A
.*
03&6
(0
0'J(3GK6
<bean id=“dataSource”class=“...ClientDataSource”>
<constructor-argvalue=“localhost”/>
<constructor-argvalue=“1234”/>
</bean>
<bean id=“supplierDAO”class=“...SupplierDAO”>
<constructor-argref=“dataSource”/>
</bean>
<bean id=“dataSource”class=“...ClientDataSource”>
<constructor-argtype=“String”value=“localhost”/>
<constructor-argtype=“int”value=“1234”/>
</bean>
<bean id=“dataSource”class=“...ClientDataSource”>
<constructor-argindex=“0”value=“localhost”/>
<constructor-argindex=“1”value=“1234”/>
</bean>
  !
 
 
"B
.*
03&6
G3-/ /#/:#6
<bean id="myList" class="MyList">
<property name="list">
<list>
<value>First List Entry</value>
<value>Second List Entry</value>
</list>
</property>
</bean>
<bean id="myMap" class="MyMap">
<constructor-arg>
<map>
<entry key="1" value="Hello"/>
<entry key="2" value="World"/>
</map>
</constructor-arg>
</bean>
  !
 
 
"I
.*
03&6
R;
<bean id=“supplierDAO"
class=“...SupplierDAO"
init-method="init"
destroy-method="cleanup"/>
public class SupplierDAO{
public void init() {...}
public void destroy() {...}
}
  !
 
 
"C
.*
03&6
*;
<!--static factory methode-->
<bean id="exampleBean"
class="ExampleBean2"
factory-method="createInstance"/>
<!--instance factory methode-->
<bean id="myFactoryBean" class="MyFactory"/>
<bean id="exampleBean"
factory-bean="myFactoryBean"
factory-method="createInstance"/>
  !
 
 
"
.*
03&6
(



;2

; ;#




<beans>
<bean id=“dataSource”class=“...ClientDataSource”>
<property name=“server”value=“localhost”/>
<property name=“port”value=“1527”/>
</bean>
<bean id=“supplierDAO”
class=“...SupplierDAO”
autowire=“byName”/>
<!--property dataSourcewill be set by autowiring-->
</beans>
  !
 
 
"M
.*
.9
9
public void main(Object[] args)
{
Ressourceresource =
new FileSystemRessource("beans.xml");
BeanFactoryfactory = new XmlBeanFactory(ressource);
Object o = factory.getBean("myBean");
}
public void main(Object[] args)
{
ApplicationContextcontext =
new FileSystemXmlApplicationContexxt("beans.xml");
Object o = context.getBean("myBean");
}
  !
 
 

(F:3(#JF:6
,=#
O(#'3GG
G69 /
 4J0G
#&



-

'


  !
 
 
"
#(F:J(
,1' #!  
('7&

(($#
  *'7

.($

(?($
3' ?<' 
96

(J71E#
  !
 
 

#(F:
:/(
,1) */<.
(939&.&
%&'  $ 6&
,1'' (:
39&.&$  $ (6
  !
 
 
>
#(F:?
,(% 0
#!  :F4F&
,.=(F:< 
#&
,F!G-.
 '/(
F39
F'6&
  !
 
 
A
#(F:3&6
,:J#'(F:

8 

;

-
,:(F:

(

G

G;
  !
 
 
B
#(F:
.#
<beans>
<bean id="idMyBean" class=“sampleaop.MyBean" />
<bean id="idMyDAOBean" class=“sampleaop.MyDAOBean" />
<bean id="idMyAdvice" class=“...MyMethodInterceptor" />
<bean id="idMyPointcut"
class="org.springframework.aop.support.JdkRegexpMethodPointcut">
<property name="pattern" value=".*aop.MyBe.*" />
</bean>
<bean class="org.springframework.aop.support.DefaultPointcutAdvisor">
<property name="advice" ref="idMyAdvice" />
<property name="pointcut" ref="idMyPointcut" />
</bean>
<bean class="org.springframework...autoproxy.DefaultAdvisorAutoProxyCreator"
/>
</beans>
  !
 
 
I
( -;
# ( '< 


,4 (/48.G/

8(
,48.G/! /48F/ #-'/.

1/

?
,14./)  /?/!%.#
  !
 
 
C
( -;
+*$

'P#Q428

( 99(:

) '

?'#< 

 
  !
 
 

8(F K
,8(1E#J!/
48.G/! /48F/ 

'1E#/<
*L

=;%J.L'
,=8(F#
##J0

9&.&4  #/!  #/
4 #

F#919
  !
 
 
M
8(F K.#
public class ExampleJdbcDaoextends JdbcDaoSupport
{
public void clearDatabase() throws DataAccessException
{
getJdbcTemplate().update("DELETEFROM imagedb");
}
public void deleteImage(intimageId) throws DataAccessException
{
getJdbcTemplate().update("DELETEFROM imagedbWHERE id=?",
new Object[] {new Integer(imageId)});
}
public intgetNrOfImages() throws DataAccessException
{
return getJdbcTemplate().
queryForInt("SELECTCOUNT(*) FROM imagedb");
}
}
  !
 
 
>
#)  
, # L'9
 /) )'/4 */ #;/
=;) *'
,(  #) 
*'J
,%
  !
 
 
>"
#)  
#=G
,8 #=G*' 
J '<
?) J=GJ(
, #=G0#  #
.

( #.'L #=G
0#") 

#=G'#'L
3(## 6
  !
 
 
>
#=G
0;
  
#
org.springframework.web.servlet.mvc.Controller
ModelAndViewhandleRequest(request,response)
8.GJ 
(&
% 
#
org.springframework.web.servlet.mvc.View
void render(model, request, response)
=G<) '&#
<? 
( 8&
, 
8< java.util.Map
=9=<&
S4 :$<jsp:useBean/> <
 #
  !
 
 
>>
#)  $*'
#'9)) *'
$
-'# #. 
G%(J9$
WebApplicationContextUtils
.getWebApplicationContext(servletContext)
.getBean(PbeanNameQ)
0G%(J9
) *' #.*;
19 #:E
) *'0
< 9
9
%  '
8#;K
  !
 
 
>A
#19
,':J:K'/
"&>&/E
834J0#6 ;9
&887
1':< /
8':'J
;0919 &
,1# #:K'
9/#0
8;J80#
 ;9&
,(.#:;J0#
?E#9&
  !
 
 
>B
#193&6
, 
)  -*  .
,8 
publicinterfacePaymentService{
...
publicabstractOrderResponseElement
authorizeAndCapture(...)
throwsPaymentException;
...
}
  !
 
 
>I
#193&6
, 
)  -*  .
,8= J('
publicclassBuySomethingAction
extendsAuthorizedDispatchAction
{
/** Thepaymentinterfaceservice. */
private PaymentServicepaymentService;
...
...
try{
paymentResponse=
paymentService.authorizeAndCapture(...);
} catch (PaymentExceptione) {...}
...
}
  !
 
 
>C
#193&6
,
/ 
* "applicationContext-
struts.xml#
,' 8;
('
<beans>
...
<beanname="/BuySomething“
class="...BuySomethingAction">
<propertyname="paymentService" ref="paymentService" />
...
</bean>
<beanid="paymentService“
class="...PaymentServiceMockImpl">
<description>
ThePaymentService Dummy Service
</description>
</bean>
...
</beans>
  !
 
 
>
#193&6
,*-/ 
* "struts-config.xml#
<struts-config>
<plug-inclassName="org.springframework.web.struts.ContextLoaderPlugIn">
<set-propertyproperty="contextConfigLocation“
value="...,classpath:applicationContext-struts.xml" />
</plug-in>
...
<action
path="/BuySomething"
type="org.springframework.web.struts.DelegatingActionProxy"
name="buysomethingform"
parameter="method"
...>
...
<forwardname="BuySomethingPayment“
path="/buy/BuySomethingPayment.jsp" />
...
</action>
...
</struts-config>
  !
 
 
>M
#193&6
,'   
-/ 
*
,:'8
<beanid="paymentService"
class="...PaymentServiceImpl">
<description>TheREALPaymentService</description>
<propertyname="urlString"
value="${paymentInstance.urlString}" />
<propertyname="merchantID"
value="${paymentInstance.merchantID}" />
<propertyname="terminalID"
value="${paymenInstance.terminalID}" />
...
</bean>
  !
 
 
A
#:K% 
#*' #J ;J # 
#$%%&#'&%% #J=GJ
#J ;J#%E&
# ;
#8(F#
=
#$%%&9 &%;%)'&K#+#T
#?#
 #;#
#
#$%%J&%%KJ#&
  !
 
 
A"
#*'% #??
The Official Spring Reference Manual
http://www.springframework.org/docs/reference/
Introduction to Spring by Rod Johnson
http://www.theserverside.com/articles/article.tss->
?l=SpringFramework
Spring in Action
by Craig Walls and Ryan Breidenbach
Pro Spring
by Rob Harropand Jan Machacek
J2EE Without EJB
by Rod Johnson and JuergenHoller
Expert One-on-One J2EE Design and Development
by Rod
Johnson
Better, Faster, Lighter Java
by Bruce Tate and Justin Gehtland
  !
 
 
A
*9

59S


7


  7

('9#91''

=< '0

F<'
:K'3'969 

<#K'