Sakai Tool Naming Tips

11
Creative Commons Attribution-NonCommercial-ShareA like 2.5 License Sakai Programmer's Café Sakai Tool Naming Tips Aaron Zeckoski [email protected]

description

Sakai Tool Naming Tips. Aaron Zeckoski [email protected]. Many tools exist in a typical Sakai installation As a developer, you have to be careful when working in a large scale environment The primary issue is with naming collisions - PowerPoint PPT Presentation

Transcript of Sakai Tool Naming Tips

Page 1: Sakai Tool Naming Tips

Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License

Sakai Programmer's Café

Sakai Tool Naming Tips

Aaron [email protected]

Page 2: Sakai Tool Naming Tips

2

Sakai tool environment• Many tools exist in a typical Sakai

installation– As a developer, you have to be careful when

working in a large scale environment

• The primary issue is with naming collisions– Some names must be unique in the Sakai

instance (not used by any other installed tools)

• Tools have many interconnections and use a custom request cycle so some programming practices must be followed

Page 3: Sakai Tool Naming Tips

3

Namespace collisions

• Most namespace collisions will cause an error to occur on tomcat startup

• Typically you will see that part of the spring tree died and therefore all spring beans are destroyed

• Sometimes Sakai will still load but the offending tool will not

• Tip: Watch tomcat logs when starting up new tools

URL: http://bugs.sakaiproject.org/confluence/display/BOOT/Sakai+app+and+tool+naming+tips

Page 4: Sakai Tool Naming Tips

4

Sakai tool xml file naming

• The tool id (e.g. sakai.tasklist) in the tool xml file must be unique– Typical id is sakai.toolname– Tool xml file located in tool/src/webapp/tools/

• Typical filename is sakai.toolname.xml

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

<registration>

<tool id="sakai.tasklist"

title="Programmer's Cafe - Task List"

description="Programmer's Cafe - Task List">

<category name="course" />

<category name="project" />

</tool>

</registration>

Page 5: Sakai Tool Naming Tips

5

Sakai project.xml naming

• The id (e.g. sakai-tasklist-tool) in each project.xml file must be unique– Typical id is sakai-toolname-location– Maven project.xml files are located throughout

a typical Sakai app

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

<project>

<pomVersion>3</pomVersion>

<extend>../../master/project.xml</extend>

<name>Programmer's Cafe - Task List</name>

<groupId>sakaiproject</groupId>

<id>sakai-tasklist-tool</id>

<currentVersion>${sakai.version}</currentVersion>

...

Page 6: Sakai Tool Naming Tips

6

Spring bean naming

• The id (e.g. org.sakaiproject.logic.CrudPlusLogic) of each bean in components.xml must be unique– Convention for the id is to use the fully qualified

classpath of the interface for the class– component.xml must be located in

impl/pack/src/webapp/WEB-INF/

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

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"

"http://www.springframework.org/dtd/spring-beans.dtd">

<beans>

<bean id="org.sakaiproject.crudplus.logic.CrudPlusLogic"

class="org.sakaiproject.crudplus.logic.impl.CrudPlusLogicImpl"

init-method="init">

</beans>

Page 7: Sakai Tool Naming Tips

7

Database table naming

• Database table names have to be unique since Sakai shares a common schema (or database)

• Convention is to prefix the table name with the tool name (e.g. TOOLNAME_TABLE)– Good names:

• SAM_ANSWER, EVAL_ANSWER, GB_GRADES

– Bad names:• ANSWER, GRADE, CONFIG

Page 8: Sakai Tool Naming Tips

8

Hibernate HBM files

• All Hibernate HBM files have to have unique names since Sakai uses one common Hibernate SessionFactory

• Convention is to prefix the hbm filename with the tool name (e.g. ToolnameItem.hbm.xml)– Good names:

• EvalAnswer.hbm.xml, TasklistTask.hbm.xml

– Bad names:• Answer.hbm.xml, Task.hbm.xml, Item.hbm.xml

Page 9: Sakai Tool Naming Tips

9

Hibernate Persistent Classnames

• All Hibernate persistent classes must have unique classnames (this does not include the fully qualified classpath)

• Convention is to prefix the class name with the tool name (e.g. ToolnameItem.java)– Good:

• EvalAnswer.java, TasklistTask.java

– Bad:• Answer.java, Task.java

Page 10: Sakai Tool Naming Tips

10

web.xml servlet name

• The servlet-name in the web.xml file must match the tool id from the tool xml file– web.xml is located in

tool/src/webapp/WEB-INF– If this does not match you will get an

uninformative NPE (Null Pointer Exception) in the tomcat log and the tool will fail to load

<servlet>

<servlet-name>sakai.tasklist</servlet-name>

<servlet-class>org.sakaiproject.tool.tasklist.TasklistTool</servlet-class>

<load-on-startup>1</load-on-startup>

</servlet>

Page 11: Sakai Tool Naming Tips

11

Questions?