<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic TransactionService and ServiceRegistry - Spring injection in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/transactionservice-and-serviceregistry-spring-injection/m-p/70390#M45406</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I need to write a Java package in order to manipulate Alfresco repository objects in custom ways. I am just creating a custom Java package and I want to have a reference to alfresco services (nodeService, …) inside my Java classes, so I am going to direct inject Alfresco beans into my classes. Because I need to manage all the task in a transactional way, I need a reference to TransactionService into my classes. I was thinking about direct injecting a TransactionService bean into my classes, but it failed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My questions are the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1) &lt;/SPAN&gt;&lt;STRONG&gt;how to direct inject TransactionService into my classes (if possible)?&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;2) &lt;/SPAN&gt;&lt;STRONG&gt;Instead of TransactionService is it possible to direct inject the ServiceRegistry bean?&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I followed the FirstFoundationClient example, but it creates a new ApplicationContext, on the contrary I want to use the ApplicationContext already created during the Alfresco boot.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried the write a Java bean and direct inject the TransactionComponent and the AuthenticationComponentImpl beans. My bean has an init() method as the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;public void init ()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; try {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;transactionService.getUserTransaction().begin();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} catch (NotSupportedException e) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// TODO Auto-generated catch block&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e.printStackTrace();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} catch (SystemException e) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// TODO Auto-generated catch block&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e.printStackTrace();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;this.authenticationService.authenticate("admin", "admin".toCharArray());&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It works fine but I would like to know if this is the correct way to go on or not.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks to all.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sergio&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 31 Jan 2007 09:22:21 GMT</pubDate>
    <dc:creator>sergio</dc:creator>
    <dc:date>2007-01-31T09:22:21Z</dc:date>
    <item>
      <title>TransactionService and ServiceRegistry - Spring injection</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/transactionservice-and-serviceregistry-spring-injection/m-p/70390#M45406</link>
      <description>Hi all.I need to write a Java package in order to manipulate Alfresco repository objects in custom ways. I am just creating a custom Java package and I want to have a reference to alfresco services (nodeService, …) inside my Java classes, so I am going to direct inject Alfresco beans into my classes</description>
      <pubDate>Wed, 31 Jan 2007 09:22:21 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/transactionservice-and-serviceregistry-spring-injection/m-p/70390#M45406</guid>
      <dc:creator>sergio</dc:creator>
      <dc:date>2007-01-31T09:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: TransactionService and ServiceRegistry - Spring injection</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/transactionservice-and-serviceregistry-spring-injection/m-p/70391#M45407</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Sergio,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Injecting the ServiceRegistry is a good idea as it gives you easy access to a number of fundamental services.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To inject the service your bean should look something like this …&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;&lt;BR /&gt;package com.mystuff;&lt;BR /&gt;&lt;BR /&gt;public MyBean&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private ServiceRegistry serviceRegistry;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; public void setServiceRegistry(ServiceRegistry serviceRegistry)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.serviceRegistry = serviceRegistry;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; ….&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;.. and the associated Spring config for the bean would look something like this …&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;…&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;bean id="myBean" class="com.mystuff.MyBean"&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="serviceRegitry"&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ref bean="ServiceRegistry"/&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/property&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; …&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/bean&amp;gt;&lt;BR /&gt;…&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;You wouldn't start a user transaction in the init method of bean since is a singleton instance and makes no sense.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Instead start and stop the user transactions in each method.&amp;nbsp; Use the TransactionUtil class to help with this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Roy&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Feb 2007 13:35:26 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/transactionservice-and-serviceregistry-spring-injection/m-p/70391#M45407</guid>
      <dc:creator>rwetherall</dc:creator>
      <dc:date>2007-02-01T13:35:26Z</dc:date>
    </item>
    <item>
      <title>Re: TransactionService and ServiceRegistry - Spring injection</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/transactionservice-and-serviceregistry-spring-injection/m-p/70392#M45408</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Many thanks Roy.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hear from you soon,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sergio&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Feb 2007 13:52:12 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/transactionservice-and-serviceregistry-spring-injection/m-p/70392#M45408</guid>
      <dc:creator>sergio</dc:creator>
      <dc:date>2007-02-01T13:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: TransactionService and ServiceRegistry - Spring injection</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/transactionservice-and-serviceregistry-spring-injection/m-p/70393#M45409</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Roy.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Once I have created a class direct injected with basic Alfresco services, the next step is to be able to use that class as a web service published into Alfresco like any other Alfresco WS.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1) &lt;/SPAN&gt;&lt;STRONG&gt;created a .wsdl file for the class&lt;/STRONG&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2) &lt;/SPAN&gt;&lt;STRONG&gt;copied the .class file with its own package into the Alfresco \lib folder&lt;/STRONG&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3) &lt;/SPAN&gt;&lt;STRONG&gt;modified the server-config.wsdd Alfresco file including the reference to the new web service&lt;/STRONG&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4) &lt;/SPAN&gt;&lt;STRONG&gt;copied the .wsdl file into the \alfresco\wsdl folder&lt;/STRONG&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;5) &lt;/SPAN&gt;&lt;STRONG&gt;direct injected into the .class file nodeService bean using Spring through a -context.xml file&lt;/STRONG&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The bean is loaded fine, but when I try to call the web service using a client the nodeService - initially correctly loaded - seems to be null and everything goes wrong.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I suppose that when the ws is called by the client, a new instance of the Java class is created, so I am not able to point to the fisrt instance of the Java class initially loaded as a Spring bean. As a consequence, I am not able to use the nodeService (and whatever Alfresco service) via the web service.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is a big problem for me, and I have no idea how to resolve it. The web service should be able to run inside the same context initially created during the boot of Alfresco. In this way, I would be able to direct inject into my web service whatever parameter I want just only during the Alfresco start-up.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I will appreciate a lot any help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;All the best,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sergio&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Feb 2007 14:52:42 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/transactionservice-and-serviceregistry-spring-injection/m-p/70393#M45409</guid>
      <dc:creator>sergio</dc:creator>
      <dc:date>2007-02-01T14:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: TransactionService and ServiceRegistry - Spring injection</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/transactionservice-and-serviceregistry-spring-injection/m-p/70394#M45410</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Sergio,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What have you done about generating you're server side and client stubs from the WSDL?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Once you have the server stubs you can base your web service implementation on them.&amp;nbsp; I presume this is how you are working?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Roy&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Feb 2007 10:38:22 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/transactionservice-and-serviceregistry-spring-injection/m-p/70394#M45410</guid>
      <dc:creator>rwetherall</dc:creator>
      <dc:date>2007-02-06T10:38:22Z</dc:date>
    </item>
  </channel>
</rss>

