cancel
Showing results for 
Search instead for 
Did you mean: 

java backed webscripts or spring dependency injection

cookie
Champ in-the-making
Champ in-the-making
Hi every one
Im using spring in my application and also needs to use alfresco services in my application , Im confused that how I Use spring Injection to get alfresco services?is spring injection as same as java backed web scripts or not?
can I use alfresco services in my application directly or I should add my codes as an amp file to alfresco?
thanks
5 REPLIES 5

kaynezhang
World-Class Innovator
World-Class Innovator
If you want to use alfresco services your my application directly ,you should  embed Alfresco into your application,make your application and Alfresco reside in the same process.It is not recommended ,you should consider other remote apis(opencmis,webscript)

If you really want to embed alfresco in to your application
There are many options you can inject alfresco services to you bean.
You can just inject alfresco service bean you want to refer to
for example authenticationService

in your java class import org.alfresco.service.cmr.security.AuthenticationService
   <bean id="yourbeanid" class="com.**.YourClass" >
      <property name="authenticationService" ref="authenticationService" />
..
   </bean>

Or you can inject ServiceRegistry to you bean ,from ServiceRegistry you can get all public service api.this option is recommended

in your java clss import org.alfresco.service.ServiceRegistry;
in spring configuration file config bean
   <bean id="yourbeanid" class="com.**.YourClass" >
   <property name="serviceRegistry" ref="ServiceRegistry" />
   </bean>

cookie
Champ in-the-making
Champ in-the-making
thanks a lot for your answer
as I see you mean If I want to use alfresco services directly I can use ServiceRegistry or Spring dependency injection , then I should make an AMP file of my codes and embed it in my alfresco war file
if I want to use services remotely I should use other remote APIs like  opencmis or webscripts

kaynezhang
World-Class Innovator
World-Class Innovator
Yes that is it

abreums
Champ in-the-making
Champ in-the-making
I'm trying to instantiate Alfresco-Spring-Context embedded in my Spring project. I did as #kaynezhang suggested but I couldn't get it working. I'm having problems with jars dependencies in eclipse. How should I build dependencies with SDK Alfresco-Embedded ?

Thx for any help.

kaynezhang
World-Class Innovator
World-Class Innovator
You  can refer to http://wiki.alfresco.com/wiki/Alfresco_SDK_4.0 on how to set up alfresco eclipse project for embedded use.