Date: Fri, 29 Mar 2024 02:44:54 -0400 (EDT) Message-ID: <294946330.29906.1711694694248@lyrasis1-roc-mp1> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_29905_1381423774.1711694694248" ------=_Part_29905_1381423774.1711694694248 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
The DSpace Spring Service Manager supports overriding configuration at m= any levels.
Configuring Addons to support Spring happens at two levels. Default Spri= ng configuration is available in the DSpace JAR or WAR resources directory = and allows the addon developer to inject configuration into the service man= ager at load time. The second level is in the deployed [dspace]/config/spri= ng directory where configurations can be provided on a addon module by addo= n module basis.
This latter method requires the addon to implement a SpringLoader to ide= ntify the location to look for Spring configuration and a place configurati= on files into that location. This can be seen inside the current [dspace-so= urce]/config/modules/spring.cfg
The ordering of the loading of Spring configuration is the following:
There are 2 ways to create a new Spring addon: a new Spring file can be = located in the resources directory or in the configuration [dspace]/config/= spring directory. A Spring file can also be located in both of these locati= ons but the configuration directory gets preference and will override any c= onfigurations located in the resources directory.
In the resources directory of a certain module, a Spring file can be add=
ed if it matches the following pattern: "spring/spring-dspace-addon-*-servi=
ces.xml". An example of this can be found in the dspace-discovery-solr bloc=
k in the DSpace trunk. (spring-dspace-addon-discovery-services.xml)
Wherever this jar is loaded (JSPUI module, XMLUI module, DSpace command li=
ne, ...) the Spring files will be processed into services.
This directory has the following subdirectories in which Spring files ca= n be placed:
The reason why there is a separate directory is that if a service cannot= be loaded, which would the case for the configurable workflow (the JSPUI w= ould not be able to retrieve the XMLUI interface classes), the kernel will = crash and DSpace will not start.
Configuring an additional subdirectory for a custom module
So you need to indeed create a new directory in [dspace]/config/spring. = Next you need to create a class that inherits from the "org.dspace.kernel.c= onfig.SpringLoader". This class only contains one method named getResourceP= aths(). What we do now at the moment is implement this in the following man= ner:
@Overri= de public String[] getResourcePaths(ConfigurationService configurationService)= { StringBuffer filePath =3D new StringBuffer(); filePath.append(configurationService.getProperty("dspace.dir")); filePath.append(File.separator); filePath.append("config"); filePath.append(File.separator); filePath.append("spring"); filePath.append(File.separator); filePath.append("{module.name}"); //Fill in the module name in this st= ring filePath.append(File.separator); try { //By adding the XML_SUFFIX here it doesn't matter if there should= be some kind of spring.xml.old file in there it will only load in the acti= ve ones. return new String[]{new File(filePath.toString()).toURI().toURL()= .toString() + XML_SUFFIX}; } catch (MalformedURLException e) { return new String[0]; } }
After the class has been created you will also need to add it to the "sp=
ringloader.modules" property located in the [dspace]/config/modules/spring.=
cfg.
The Spring service manager will check this property to ensure that only th=
e interface implementations which it can find the class for are loaded in.<=
/p>
By doing this way we give some flexibility to the developers so that the= y can always create their own Spring modules and then Spring will not crash= when it can't find a certain class.
Please see the following tutorials:
Please see the following tutorials:
Please see Architectural Overview here: DSpace Services Framework
Please see the DS= pace Services Framework
Several good Spring / DSpace Services Tutorials are already available:= p>