Skip to content

Rapid development of Alfresco repository extensions in Java. Deploy your code in seconds, not minutes. Life is too short for endless server restarts.

License

Notifications You must be signed in to change notification settings

tgeens/dynamic-extensions-for-alfresco

 
 

Repository files navigation

Dynamic Extensions for Alfresco

Rapid development of Alfresco repository extensions in Java. Deploy your code in seconds, not minutes. Life is too short for endless server restarts.

Dynamic Extensions adds an OSGi container to the Alfresco repository, enabling live deployment of Java code, with no need to restart the server. Alfresco itself is not "OSGi-fied" in any way; the OSGi container runs on top of the core Alfresco platform.

Upcoming 1.0.0 release

Important note: due to the project ownership change, the base package structure has changed. Simply replacing nl.runnable.alfresco with com.github.dynamicextensionsalfresco will make any previous extension compatible with the 1.0.0 release.

You can test snapshot releases by changing the plugin version and group:

buildscript {
  repositories { maven { url 'https://raw.github.com/laurentvdl/dynamic-extensions-for-alfresco/mvn-repo/' } }
  dependencies {
    classpath group: 'com.github.dynamicextensionsalfresco', name: 'gradle-plugin', version: '1.0.0-SNAPSHOT'
  }
}

Latest release: Milestone 6

Features:

  • REST endpoint for restarting the OSGi framework: /service/dynamic-extensions/osgi/restart
  • auto refresh system package cache when WEB-INF/lib has changed
  • runtime MODE (Production/Dev) is replaced with individual settings in osgi-container.properties (also visible in control-panel)
  • Uri handlers can now return the template to use as a String return value
  • auto configuration of Alfresco-Spring-Configuration if not specified has Bundle header
  • new webscript-support module for the AbstractBundleResourceHandler (no more need to import control-panel)
  • Scala 2.10.3 is now included by default to ease deployment of Scala based extensions

Fixes in this milestone:

  • integration: fallback to jar content scanning when MANIFEST.MF fails to parse (Vaadin jar)
  • gradle-plugin: allow override of "Import-Package"
  • fix duplicate WebScript ID detection: make sure you Uri methods have a unique name (no overloading)

Internal:

  • moved from Maven to Gradle: use "gradlew(.sh|.bat)" script to build the project

Removed:

  • Felix file install: bundles can now only be installed either via classpath or using the REST API

Many thanks to Laurens Fridael for his great work on Dynamic Extensions. May his work live long and prosper at its new home.

Installing Dynamic Extensions

Dynamic Extensions is distributed as an Alfresco Module Package (AMP).

Supported Alfresco versions

Dynamic Extensions is developed and tested against:

  • Alfresco Enterprise 4.1
  • Alfresco Enterprise 4.2

Dynamic Extensions is also known to work on:

  • Alfresco Enterprise 4.0
  • Alfresco Community 4.0
  • Alfresco Community 4.2

Dynamic Extensions also works with older versions of Alfresco, but some features are not supported.

  • Alfresco Community 3.4. (Known issue #56)

Example extension code

This example Web Script examines a node and passes information to a Freemarker template:

@Component
@WebScript
public ExampleWebScript {

  @Autowired
  private NodeService nodeService;
  
  @Uri("/show-node")
  // Example: http://localhost/alfresco/service/show-node?nodeRef=workspace://SpacesStore/12345
  public Map<String, Object> displayNodeName(@RequestParam NodeRef nodeRef) {
    Map<String, Object> model = new HashMap<String, Object>();
    model.put("properties", nodeService.getProperties(nodeRef));    
    return model; // Model is passed to Freemarker template.
  }
}

Note that this is an annotation Web Script. These types of Web Script are configured through Java annotations instead of *.desc.xml descriptors. Annotation Web Scripts are similar to Spring MVC's annotation-based controllers.

Here's the accompanying Freemarker template fragment:

<table>
  <#list properties?keys as name>    
    <tr>
      <th>${name}</th>
      <td>${properties[name]!''}</td>
    </tr>
  </#list>
</table>

This is all the code that is required; there's no need for Spring XML config or Web Script XML descriptors. Hot-reloading and reducing configuration overhead are not particularly novel concepts in the Java development world at large. Essentially, Dynamic Extensions modernizes the development of Alfresco repository extensions.

The example above may be trivial, but the point is that, behind the scenes, services are still wired together through Spring and handled by the Web Script framework. Conceptually there is no real difference between a Dynamic Extension and a regular Alfresco extension. There's just less overhead and more convenience.

Creating your own Alfresco extensions

The example Dynamic Extension provides a good starting point for creating your own extensions.

Clone the example repo and explore it. Here are some pointers to get you going:

See also: Gradle plugin for building your own repository extensions

Barcelona 2013 presentation

One hour presentation on using and exploring Dynamic Extensions for Alfresco

About

Rapid development of Alfresco repository extensions in Java. Deploy your code in seconds, not minutes. Life is too short for endless server restarts.

Resources

License

Stars

Watchers