Jason, There's an easier way to get DSpace to use a custom org.dspace.content.Item class, without even messing around with existing Maven settings for DSpace 1.5.x. You can just add your custom org.dspace.content.Item class to the Web Application's modules "overlay" directory.
For example, since you are using the XMLUI, you'd want to use the following modules "overlay" directory: [dspace-src]/dspace/modules/xmlui/ Use the normal Maven folder structure to add the source code of your custom class to the above directory. So, under that directory add the following directory structure with your Item.java source code: /src/main/java/org/dspace/content/Item.java (Yea, it's a really long sub-directory, but Maven expects that "/src/main/java/" structure) Now, rebuild DSpace with 'mvn package'. What happens now is that the default dspace-xmlui.war will be "overlayed" with whatever source code you've placed in [dspace-src]/dspace/modules/xmlui/. This is essentially using the concept of Maven WAR Overlays, which is configured by default in DSpace 1.5.x. For more info on Maven WAR Overlays see: http://maven.apache.org/plugins/maven-war-plugin/overlays.html In the end, you should see that your custom 'Item.java' will be compiled into the "WEB-INF/classes/org/dspace/content/Item.class" of your XMLUI web application. Since Java should check for classes in the webapp's WEB-INF/classes *before* looking at the [dspace]/lib/*.jar, your custom Item class will be found *before* the default one in dspace-api.jar. I've tried this out...it all seems to work fine for me. Give it a try, and let us know if it's not what you're looking for. - Tim -- Tim Donohue Research Programmer, IDEALS http://www.ideals.uiuc.edu/ University of Illinois [email protected] | (217) 333-4648 Jason Gum wrote: > Hi all, > > What I am trying to do: > Call methods in my customized Item.java class. > > Background: > I have added a getViews() method and overwritten the toString() method > in the Item class located at > dspace-api/src/main/java/org/dspace/content/Item.java. > I have sucessfully modified the ItemViewer class to display " > division.addPara("Views:" + item.toString() ); ". > If I change the above modification so item.toString() becomes > item.getViews(), maven will not compile ItemViewer.java because it > cannot find the getViews() method since it is looking for getViews() in > the original Item class instead of mine. > Pottinger, Hardy J. suggest I put > <dependency> > <groupId>org.dspace</groupId> > <artifactId>dspace-api</artifactId> > </dependency> > into the pom.xml file in the proper module in this case the one for > xmlui, but it still would not compile. > Robin Taylor suggest I put my Item.java into dspace\modules\xmlui\ but > I am hestitant to do this because Item.java is part of the dspace-api > not the xmlui. > > If I leave the modification to ItemViewer as item.toString(), maven will > compile it because item.toString is in both the original and my version > of Item.java. > If I deploy the changes to Tomcat and go to view the item I see > "Views:org.dspace.content.i...@7413e8" instead of "Views:TEST 3" on the > page because the webapps\xmlui\WEB-INF\lib\dspace-api-1.5.1.jar contains > the original Item.class. > I have the dspace-api folder next to the dspace folder. > Maven package creates a dspace-api/target/dspace-api-1.5.2-SNAPSHOT.jar. > This jar does contain my customized item.class. > If I take the item.class from this jar and manually insert it into the > Tomcat 6.0\webapps\xmlui\WEB-INF\lib\dspace-api-1.5.1.jar, ItemViewer > correcty displays "Views:TEST 3". > > So even though dspace-api-1.5.2-SNAPSHOT.jar contains my modified > item.class. The jar never seems to be used by maven to compile or added > the the webapp lib. > > I am using WinXP, Eclipse, Tomcat 6.0, and Dspace 1.5.1. > > > > Sincerely, > > Jason Gum > > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > > > ------------------------------------------------------------------------ > > _______________________________________________ > DSpace-tech mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/dspace-tech ------------------------------------------------------------------------------ _______________________________________________ DSpace-tech mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/dspace-tech

