Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
DYNAMIC EXTENSIONSEnabled by /“Rapid development of Alfresco repositoryextensions in Java. Deploy your code inseconds, not...
CREATING ALFRESCO EXTENSIONS1. code + spring xml + descriptor xml2. compile & jar3. create amp4. stop alfresco5. apply amp...
WHY ?Why cant I copy my code to the server and hit refresh ?
CLASS RELOADING IN JAVAthe JVM cannot reload classesbut it can reload Classloaders
HOW DO I DO THATload dynamic code via a new classloaderdiscard classloader when updatingUrlClassloader good starthow can I...
OSGIA Java module specification designed for continuesdeployment:reloading codeservice / class dependencies between module...
Combine Alfresco and OSGI: Dynamic Extensions
DEMO
WEBSCRIPTS@Component@WebScript(description = "Weather")@Authentication(AuthenticationType.GUEST)public class WeatherScript...
TEMPLATEWeatherScript.index.get.html.ftl<html><body>Hello ${name!"guest"}, the current temperature is ${temperature}.</bod...
WITHOUT TEMPLATE@Component@WebScript(description = "Time")@Authentication(AuthenticationType.GUEST)public class TimeScript...
BEHAVIOUR@Component@Behaviour("cm:content", event = Event.COMMIT)public class ChildCreation implementsNodeServicePolicies....
ACTIONS@ActionMethod(value = "destroy", applicableTypes = {"cm:content"})public void destroy(final NodeRef nodeRef) {nodeS...
NOW STOP RESTARTINGAND START CODINGLaurent Van der Linden / Xenit
Upcoming SlideShare
Loading in …5
×

Dynamic extension for alfresco

1,571 views

Published on

Dynamic extensions for Alfresco. Uses OSGI to dynamically deploy modules. Faster development time.

Published in: Technology

Dynamic extension for alfresco

  1. 1. DYNAMIC EXTENSIONSEnabled by /“Rapid development of Alfresco repositoryextensions in Java. Deploy your code inseconds, not minutes. Life is too short forendless server restarts.”dynamic-extensions-for-alfresco @LaurensFridael
  2. 2. CREATING ALFRESCO EXTENSIONS1. code + spring xml + descriptor xml2. compile & jar3. create amp4. stop alfresco5. apply amps6. start alfresco7. test your extension
  3. 3. WHY ?Why cant I copy my code to the server and hit refresh ?
  4. 4. CLASS RELOADING IN JAVAthe JVM cannot reload classesbut it can reload Classloaders
  5. 5. HOW DO I DO THATload dynamic code via a new classloaderdiscard classloader when updatingUrlClassloader good starthow can I reload modules ?
  6. 6. OSGIA Java module specification designed for continuesdeployment:reloading codeservice / class dependencies between modulesservice registry: whiteboard pattern
  7. 7. Combine Alfresco and OSGI: Dynamic Extensions
  8. 8. DEMO
  9. 9. WEBSCRIPTS@Component@WebScript(description = "Weather")@Authentication(AuthenticationType.GUEST)public class WeatherScript {@Autowired WeatherService weatherService;@Uri(value = "/weather", defaultFormat = "html")public Map<String, Object> index(final @RequestParam(required = false) String name) {return new HashMap<String,Object>() {{put("name", name);put("temperature", weatherService.getTemperature());}};}}
  10. 10. TEMPLATEWeatherScript.index.get.html.ftl<html><body>Hello ${name!"guest"}, the current temperature is ${temperature}.</body></html>
  11. 11. WITHOUT TEMPLATE@Component@WebScript(description = "Time")@Authentication(AuthenticationType.GUEST)public class TimeScript {@Autowired WeatherService weatherService;@Uri(value = "/time")public void index(WebscriptResponse response) {response.getWriter().write(new Date().toString());}}
  12. 12. BEHAVIOUR@Component@Behaviour("cm:content", event = Event.COMMIT)public class ChildCreation implementsNodeServicePolicies.OnCreateChildAssociationPolicy {@AssociationPolicy(association = "cm:contains")@Overridepublic void onCreateChildAssociation(ChildAssociationRef childAssociationRef, boolean newNode) {}}
  13. 13. ACTIONS@ActionMethod(value = "destroy", applicableTypes = {"cm:content"})public void destroy(final NodeRef nodeRef) {nodeService.addAspect(nodeRef, ContentModel.ASPECT_TEMPORARY, null);nodeService.deleteNode(nodeRef);}
  14. 14. NOW STOP RESTARTINGAND START CODINGLaurent Van der Linden / Xenit

×