Yes you can write your own custom classes.
The two context files I mentioned:
spring-surf-script-services-context.xml
spring-surf-template-services-context.xml
all contain example bean definitions.
For example, to add a JavaScript root scoped object you need to extend the 'baseScriptExtension' bean:
Code:
<bean id="example" parent="baseScriptExtension" class="org.mycompany.ExampleExtension">
<property name="extensionName">
<value>example</value>
</property>
</bean>
And the extensionName will be the identifier of your root scoped object accessible in web-tier JavaScript.
The Java class itself should extend:
Code:
org.springframework.extensions.webscripts.processor.BaseProcessorExtension
To add root objects in the FreeMarker templating model it is the same pattern:
Code:
<bean id="example" parent="baseTemplateExtension" class="org.yourclasspath.ExampleExtension">
<property name="extensionName">
<value>example</value>
</property>
</bean>
Extend the same class as above.
Hope this helps!
Kev