Previous versions of REM supported extensions by generating *-em.war extension archives and installing them directly into the main rem.war file. If you have developed one of these types of extensions, it is still supported, but it is also quite straight forward to convert it into a plugin.

To convert your extension into a plugin:

1

Open your extension’s build.properties and add:

plugin.version=<Version of your plugin>
plugin.description=<Short description of your plugin>

For example:

plugin.version=1.0
plugin.description=Example Element Manager Plugin

2

Open your extension’s build/compile.xml Ant build script in an editor and make the following changes.

-        <zip destfile="${artifacts}/example-em.zip">
+        <jar destfile="${artifacts}/example-em.em.jar">
             <fileset dir="${target}/war" includes="example/**"/>
             <fileset dir="${basedir}/war" includes="example.html"/>
             <zipfileset prefix="WEB-INF/lib" file="${jars}/example-em-server.jar"/>
-        </zip>
+            <manifest>
+                <attribute name="Short-Name" value="example"/>
+                <attribute name="Version" value="${plugin.version}"/>
+                <attribute name="Description" value="${plugin.description}"/>
+            </manifest>
+        </jar>

The Short-Name attribute value should match the name of your extension without the -em suffix.

3

Open your extension’s main ServletModule (for example, src/com/opencloud/rem/example/server/ExampleServletModule.java) and remove these lines:

        // Guice-enabled RemoteServiceServlet
        serve("/example/GWT.rpc").with(GuiceRemoteServiceServlet.class);

4

Open your extension’s DevModeGuiceServletConfig (for example, src/com/opencloud/rem/example/dev/server/ExampleDevModeGuiceServletConfig.java) and add an inline ServletModule like this:

        return Guice.createInjector(new ServletModule() {
            @Override
            protected void configureServlets() {
                serve("/example/GWT.rpc").with(GuiceRemoteServiceServlet.class);
            }
        }, /* other modules as before */);

Your extension is now a REM Plugin.

5

(Optional)

If your main ServletModule doesn’t have any serve() or filter() calls left in it, then it can be changed into a simple Module.

  • rename it from *ServletModule.java to *Module.java.

  • instead of extending com.google.inject.servlet.ServletModule, change it to extend com.google.inject.AbstractModule.

  • change the configureServlets() method to configure().

  • edit your extension class (for example, src/com/opencloud/rem/example/server/ExampleExtension.java) and move your module from getServletModule() to getOtherModules().

For example:

     public ServletModule getServletModule() {
-        return new ExampleServletModule();
+        return null;
     }

     public Module[] getOtherModules() {
-        return new Module[] { };
+        return new Module[] { new ExampleModule() };
     }
Previous page