On 10/24/2012 04:40 PM, Mark H. Wood wrote:
On Thu, Oct 18, 2012 at 09:37:51AM +0200, Joachim Bingel wrote:
as mentioned in previous posts of mine to this list, I have written a
class that implements the org.dspace.identifier.IdentifierProvider
interface for DSpace 3.0. Now that this is complete and I have
successfully set up 3.0-rc1, I'm looking to use my own class instead of
the default one. How do I do this?
If you're adding a new identifier type, just include its bean
definition.  If you're providing a different implementation of Handles
then I think you'd need to comment out the stock Handle provider bean.
You mean include its name in the identifier-service.xml? Well that's what I did right? (See the enclosed file). I'm afraid I don't quite understand what you mean by 'include bean definition' and how to do so.

Still, the way I try to inject the bean leaves me with a ClassNotFoundException, even though my JAR is in the CLASSPATH and in [dspace]/lib. Do I have to somehow tell DSpace/Spring explicitly where to find it?
I have set the class attribute to the package+name of my class for the
respective bean in both
[dspace-src]/dspace-api/target/classes/spring/spring-dspace-core-services.xml
and
[dspace-src]/dspace/target/dspace3.0-rc1-build/config/spring/api/identifier-service.xml
(on this note, why does the same stuff get defined in these two
different files?)
I created a new spring-dspace-addon-identifier-services.xml and placed
it in [dspace-src]/dspace-api/src/main/resources/spring, whence it
will be copied to [dspace-src]/target/classes/spring/ by Maven.  That
gets it tucked into lib/dspace-api-VERSION.jar where Spring can find
it.
I checked out the latest version of the code from git this morning and the file you mentioned is not included.
I defined bean properties for things that shouldn't really be in the
code, but which are unlikely to change -- they're just externalized
constants.  Things that each installation would need to change are
fetched from [dspace]/config/** so that they're easy to adjust.

I should say that I'm still early in development and had not actually
installed and run this very incomplete code until just now.  But the
XMLUI starts without complaint by Tomcat.

Running 'ant update' and restarting Tomcat results in an error, the
Tomcat log says:
<<Cannot find class [de.mannheim.ids.pid.dspace.IDSIdentifierProvider]
for bean with name 'org.dspace.identifier.IdentifierService' defined in
file [/var/opt/ds
pace/config/spring/api/identifier-service.xml]; nested exception is
java.lang.ClassNotFoundException>>

... and a lot more, all related to the problem that the class cannot be
found.
The class is in the classpath and building worked, too. I presume I did
something wrong with the Bean definition (I'm very very new to the
Spring framework), right? The identifier-service.xml is attached. Also,
what annotation do I have to set in the code of my class? Basically I
adopted all the @Autowired/@Required/... annotation from
IdentifierProviderImpl.java.
I found that declaring any autowiring on my provider caused circular
reference problems when Spring instantiates the provider.  I left
@Required on the property setters and took out both @Autowired and
<bean autowire>.  The IdentifierService gets itself autowired with a
list of providers and then injects itself into each as parent.

Another confession:  I'm also quite new to Spring, so anything I do
with it that works probably owes a lot to luck.

Here's my bean declaration:
... and that's for the spring-dspace-addon-identifier-services.xml, right? :)



<?xml version="1.0" encoding="UTF-8"?>
<!--

     The contents of this file are subject to the license and copyright
     detailed in the LICENSE and NOTICE files at the root of the source
     tree and available online at

     http://www.dspace.org/license/

-->
<beans xmlns="http://www.springframework.org/schema/beans";
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xsi:schemaLocation="http://www.springframework.org/schema/beans
         http://www.springframework.org/schema/beans/spring-beans-3.0.xsd";>

     <bean id="org.dspace.identifier.DataCiteIdentifierProvider"
         class="org.dspace.identifier.DataCiteIdentifierProvider"
         scope='singleton'>
             <property name="configurationService"
                 ref="org.dspace.services.ConfigurationService"/>
             <property name='EZID_SCHEME' value='https'/>
             <property name='EZID_HOST' value='n2t.net'/>
             <property name='EZID_PATH' value='/ezid/shoulder/'/>
             <property name='crosswalk'>
                 <map>
                     <entry key='datacite.creator' value='dc.creator.author'/>
                     <entry key='datacite.title' value='dc.title'/>
                     <entry key='datacite.publisher' value='dc.publisher'/>
                     <entry key='datacite.publicationyear' 
value='dc.date.published'/>
                 </map>
             </property>
     </bean>
</beans>

<?xml version="1.0" encoding="UTF-8"?>
<!--

     Copyright (c) 2002-2010, DuraSpace.  All rights reserved
     Licensed under the DuraSpace License.

     A copy of the DuraSpace License has been included in this
     distribution and is available at: http://www.dspace.org/license

-->
<beans xmlns="http://www.springframework.org/schema/beans";
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xsi:schemaLocation="http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans-2.5.xsd";>

     <!-- Identifier Service Application Interface.  Will be autowired with
          any Identifier Providers present in Spring context.
     -->
     <!-- bean id="org.dspace.identifier.IdentifierService"
           class="org.dspace.identifier.IdentifierServiceImpl"
           autowire="byType"
           scope="singleton"/ -->

     <bean id="org.dspace.identifier.IdentifierService"
           class="de.mannheim.ids.pid.dspace.IDSIdentifierProvider"
           autowire="byType"
           scope="singleton"/>

    <!-- provider for using the versioned handle identifier instead of the default 
one. -->
     <!--<bean id="org.dspace.identifier.HandleIdentifierProvider" 
class="org.dspace.identifier.VersionedHandleIdentifierProvider"-->
           <!--scope="singleton">-->
         <!--<property name="configurationService" 
ref="org.dspace.services.ConfigurationService"/>-->
     <!--</bean>-->

</beans>


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Dspace-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dspace-devel



------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct


_______________________________________________
Dspace-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dspace-devel


--
Joachim Bingel
Institut für Deutsche Sprache, Zentrale Forschung
R5, 6-13, 68161 Mannheim
+49 - (0)621-1581-456 | http://www.ids-mannheim.de

<?xml version="1.0" encoding="UTF-8"?>
<!--

    Copyright (c) 2002-2010, DuraSpace.  All rights reserved
    Licensed under the DuraSpace License.

    A copy of the DuraSpace License has been included in this
    distribution and is available at: http://www.dspace.org/license

-->
<beans xmlns="http://www.springframework.org/schema/beans";
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
       xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd";>

    <!-- Identifier Service Application Interface.  Will be autowired with
         any Identifier Providers present in Spring context.
    -->
    <bean id="org.dspace.identifier.IdentifierService"
          class="org.dspace.identifier.IdentifierServiceImpl"
          autowire="byType"
          scope="singleton"/>


   <!-- provider for using the versioned handle identifier instead of the default one. -->
    <bean id="org.dspace.identifier.HandleIdentifierProvider" 
          class="de.mannheim.ids.pid.dspace.IDSIdentifierProvider"      
	  scope="singleton">
        <!--<property name="configurationService" ref="org.dspace.services.ConfigurationService"/>-->
    </bean>

    <!--<bean id="org.dspace.identifier.HandleIdentifierProvider" class="org.dspace.identifier.VersionedHandleIdentifierProvider"-->
          <!--scope="singleton">-->
        <!--<property name="configurationService" ref="org.dspace.services.ConfigurationService"/>-->
    <!--</bean>-->
</beans>
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Dspace-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dspace-devel

Reply via email to