opendj-config-maven-plugin/src/main/java/org/forgerock/opendj/maven/OpendjConfigMojo.java
@@ -60,6 +60,17 @@ private String packageName; /** * Package name for which artifacts are generated. * <p> * This relative path is used to locate xml definition files and to locate * generated artifacts. * * @parameter default-value="true" * @required */ private Boolean isExtension; /** * Root directory where definitions of configuration as xml files are * located. * @@ -372,8 +383,18 @@ xsltLibrary.setGroupId("saxon"); xsltLibrary.setArtifactId("saxon"); xsltLibrary.setVersion(SAXON_LIBRARY_VERSION); List<Dependency> deps = new ArrayList<Dependency>(); deps.add(xsltLibrary); if (isExtension) { Dependency opendjConfig = new Dependency(); opendjConfig.setGroupId("org.forgerock.opendj"); opendjConfig.setArtifactId("opendj-config"); opendjConfig.setVersion("3.0.0-SNAPSHOT"); deps.add(opendjConfig); } return plugin(groupId("org.codehaus.mojo"), artifactId("xml-maven-plugin"), version(getXmlMavenPluginVersion()), deps); } opendj-config/pom.xml
@@ -189,7 +189,8 @@ <goal>generate</goal> </goals> <configuration> <packageName>org.forgerock.opendj.server.config</packageName> <packageName>org.forgerock.opendj.server.config</packageName> <isExtension>false</isExtension> </configuration> </execution> </executions> opendj-server-example-plugin/README
New file @@ -0,0 +1,47 @@ This folder contains source code for an example "Hello World" style plugin. It features a plugin which has a configurable message (the default being "Hello World") which is displayed as a notice message when OpenDJ directory server is started. In order to build and use this example plugin, perform the following steps while the server is stopped: 1. Then unzip the example-plugin.zip (in place): unzip example-plugin.zip 2. Go into the example-plugin source folder: cd example-plugin 3. And build the plugin (this requires Ant version 7 and Xalan-Java): ant install If this step fails for you as is, you can find Ant 7 and Xalan-Java in the OpenDJ ext/ directory after checking the source out with Subversion. Substitute your full path to OpenDJ sources for /src in the following command: /src/ext/ant/bin/ant -Dxalan.directory=/src/ext/xalan-j/ install 4. This will copy the following files into the parent OpenDJ installation: lib/extensions/example-plugin.jar config/example-plugin.ldif config/schema/99-example-plugin.ldif 5. Add the plugin's config to the server configuration. cd ../bin ./start-ds ./dsconfig -h `hostname` -p 4444 -D "cn=Directory Manager" -w password create-plugin --plugin-name "Example Plugin" --type example --set enabled:true --set plugin-type:startup --set java-class:com.example.opends.ExamplePlugin -X -n 6. Restart the server and look for the "hello world" notice in the start up log: ./stop-ds --restart opendj-server-example-plugin/pom.xml
New file @@ -0,0 +1,142 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- ! CDDL HEADER START ! ! The contents of this file are subject to the terms of the ! Common Development and Distribution License, Version 1.0 only ! (the "License"). You may not use this file except in compliance ! with the License. ! ! You can obtain a copy of the license at legal-notices/CDDLv1_0.txt ! or http://forgerock.org/license/CDDLv1.0.html. ! See the License for the specific language governing permissions ! and limitations under the License. ! ! When distributing Covered Code, include this CDDL HEADER in each ! file and include the License file at legal-notices/CDDLv1_0.txt. ! If applicable, add the following below this CDDL HEADER, with the ! fields enclosed by brackets "[]" replaced with your own identifying ! information: ! Portions Copyright [yyyy] [name of copyright owner] ! ! CDDL HEADER END ! ! Copyright 2014 ForgeRock AS ! --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <artifactId>opendj-project</artifactId> <groupId>org.forgerock.opendj</groupId> <version>3.0.0-SNAPSHOT</version> </parent> <artifactId>opendj-server-example-plugin</artifactId> <name>Example OpenDJ Server Plugin</name> <description> An example OpenDJ Server plugin illustrating how custom components may be developed for OpenDJ. </description> <packaging>jar</packaging> <dependencies> <dependency> <groupId>org.forgerock.opendj</groupId> <artifactId>opendj-core</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>org.forgerock.opendj</groupId> <artifactId>opendj-config</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>org.forgerock.commons</groupId> <artifactId>i18n-slf4j</artifactId> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.forgerock.commons</groupId> <artifactId>i18n-maven-plugin</artifactId> <executions> <execution> <phase>generate-sources</phase> <goals> <goal>generate-messages</goal> </goals> <configuration> <messageFiles> <messageFile>com/example/opendj/example_plugin.properties</messageFile> </messageFiles> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.forgerock.opendj</groupId> <artifactId>opendj-config-maven-plugin</artifactId> <version>3.0.0-SNAPSHOT</version> <executions> <execution> <id>generate-config</id> <phase>generate-sources</phase> <goals> <goal>generate</goal> </goals> <configuration> <packageName>com.example.opendj</packageName> <xslDir>config/stylesheets</xslDir> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <executions> <execution> <id>make-assembly</id> <phase>package</phase> <goals> <goal>single</goal> </goals> <configuration> <appendAssemblyId>false</appendAssemblyId> <descriptors> <descriptor>src/main/assembly/descriptor.xml</descriptor> </descriptors> </configuration> </execution> </executions> </plugin> </plugins> </build> <reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-project-info-reports-plugin</artifactId> <reportSets> <reportSet> <reports> <report>dependencies</report> </reports> </reportSet> </reportSets> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> </plugin> </plugins> </reporting> </project> opendj-server-example-plugin/src/main/assembly/config/example-plugin.ldif
New file @@ -0,0 +1,10 @@ dn: cn=Example Plugin,cn=Plugins,cn=config objectClass: top objectClass: ds-cfg-plugin objectClass: ds-cfg-example-plugin cn: Example Plugin ds-cfg-enabled: true ds-cfg-java-class: com.example.opends.ExamplePlugin ds-cfg-plugin-type: startup ds-cfg-example-plugin-message: Hello World opendj-server-example-plugin/src/main/assembly/config/schema/99-example-plugin.ldif
New file @@ -0,0 +1,37 @@ # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License, Version 1.0 only # (the "License"). You may not use this file except in compliance # with the License. # # You can obtain a copy of the license at legal-notices/CDDLv1_0.txt # or http://forgerock.org/license/CDDLv1.0.html. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at legal-notices/CDDLv1_0.txt. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: # Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright 2008 Sun Microsystems, Inc. # # # This file contains the attribute type and objectclass definitions for use # with the Directory Server configuration. dn: cn=schema objectClass: top objectClass: ldapSubentry objectClass: subschema attributeTypes: ( ds-cfg-example-plugin-message-oid NAME 'ds-cfg-example-plugin-message' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'OpenDS Directory Server' ) objectClasses: ( ds-cfg-example-plugin-oid NAME 'ds-cfg-example-plugin' SUP ds-cfg-plugin STRUCTURAL MAY ( ds-cfg-example-plugin-message ) X-ORIGIN 'OpenDS Directory Server' ) opendj-server-example-plugin/src/main/assembly/descriptor.xml
New file @@ -0,0 +1,77 @@ <?xml version="1.0"?> <!-- ! CDDL HEADER START ! ! The contents of this file are subject to the terms of the ! Common Development and Distribution License, Version 1.0 only ! (the "License"). You may not use this file except in compliance ! with the License. ! ! You can obtain a copy of the license at legal-notices/CDDLv1_0.txt ! or http://forgerock.org/license/CDDLv1.0.html. ! See the License for the specific language governing permissions ! and limitations under the License. ! ! When distributing Covered Code, include this CDDL HEADER in each ! file and include the License file at legal-notices/CDDLv1_0.txt. ! If applicable, add the following below this CDDL HEADER, with the ! fields enclosed by brackets "[]" replaced with your own identifying ! information: ! Portions Copyright [yyyy] [name of copyright owner] ! ! CDDL HEADER END ! ! Copyright 2014 ForgeRock AS ! --> <assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"> <id>opendj-server-example-plugin</id> <formats> <format>zip</format> </formats> <fileSets> <fileSet> <directory>${project.basedir}</directory> <outputDirectory>/</outputDirectory> <directoryMode>755</directoryMode> <fileMode>644</fileMode> <includes> <include>README</include> <include>LICENSE</include> <include>NOTICE</include> </includes> </fileSet> <fileSet> <directory>${project.parent.parent.basedir}/legal-notices</directory> <outputDirectory>legal-notices</outputDirectory> <directoryMode>0755</directoryMode> <fileMode>0644</fileMode> </fileSet> <fileSet> <directory>${project.parent.parent.basedir}</directory> <outputDirectory>/</outputDirectory> <directoryMode>755</directoryMode> <fileMode>644</fileMode> <includes> <include>*.png</include> </includes> </fileSet> <fileSet> <directory>src/main/assembly/config</directory> <outputDirectory>config</outputDirectory> <directoryMode>0755</directoryMode> <fileMode>0755</fileMode> <lineEnding>unix</lineEnding> </fileSet> <fileSet> <directory>${project.build.directory}</directory> <outputDirectory>lib/extensions</outputDirectory> <includes> <include>*.jar</include> </includes> </fileSet> </fileSets> </assembly> opendj-server-example-plugin/src/main/java/com/example/opendj/ExamplePlugin.java
New file @@ -0,0 +1,139 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt * or http://forgerock.org/license/CDDLv1.0.html. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at legal-notices/CDDLv1_0.txt. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: * Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END * * * Copyright 2006-2008 Sun Microsystems, Inc. * Portions copyright 2014 ForgeRock AS. */ package com.example.opendj; import static com.example.opendj.ExamplePluginMessages.*; import java.util.List; import java.util.Set; import org.forgerock.i18n.LocalizableMessage; import org.forgerock.opendj.config.server.ConfigChangeResult; import org.forgerock.opendj.config.server.ConfigException; import org.forgerock.opendj.config.server.ConfigurationChangeListener; import org.forgerock.opendj.ldap.ResultCode; import org.forgerock.opendj.server.config.meta.PluginCfgDefn.PluginType; import org.opends.server.types.InitializationException; /** * The example plugin implementation class. This plugin will output the * configured message to the error log during server start up. */ public class ExamplePlugin implements ConfigurationChangeListener<ExamplePluginCfg> { // The current configuration. private ExamplePluginCfg config; /** * Default constructor. */ public ExamplePlugin() { // No implementation required. } /** * Performs any initialization necessary for this plugin. This will be * called as soon as the plugin has been loaded and before it is registered * with the server. * * @param pluginTypes * The set of plugin types that indicate the ways in which this * plugin will be invoked. * @param configuration * The configuration for this plugin. * @throws ConfigException * If the provided entry does not contain a valid configuration * for this plugin. * @throws InitializationException * If a problem occurs while initializing the plugin that is not * related to the server configuration. */ @Override() public void initializePlugin(Set<PluginType> pluginTypes, ExamplePluginCfg configuration) throws ConfigException, InitializationException { // This plugin may only be used as a server startup plugin. for (PluginType t : pluginTypes) { switch (t) { case STARTUP: // This is fine. break; default: LocalizableMessage message = SEVERE_ERR_INITIALIZE_PLUGIN.get(String.valueOf(t)); throw new ConfigException(message); } } // Register change listeners. These are not really necessary for // this plugin since it is only used during server start-up. configuration.addExampleChangeListener(this); // Save the configuration. this.config = configuration; } /** * Performs any processing that should be done when the Directory Server is * in the process of starting. This method will be called after virtually * all other initialization has been performed but before the connection * handlers are started. * * @return The result of the startup plugin processing. */ @Override public PluginResult.Startup doStartup() { // Log the provided message. LocalizableMessage message = NOTICE_DO_STARTUP.get(String.valueOf(config.getMessage())); logError(message); return PluginResult.Startup.continueStartup(); } public ConfigChangeResult applyConfigurationChange(ExamplePluginCfg config) { // The new configuration has already been validated. // Log a message to say that the configuration has changed. This // isn't necessary, but we'll do it just to show that the change // has taken effect. LocalizableMessage message = NOTICE_APPLY_CONFIGURATION_CHANGE.get(String.valueOf(this.config.getMessage()), String.valueOf(config.getMessage())); logError(message); // Update the configuration. this.config = config; // Update was successfull, no restart required. return new ConfigChangeResult(ResultCode.SUCCESS, false); } public boolean isConfigurationChangeAcceptable(ExamplePluginCfg config, List<LocalizableMessage> messages) { // The only thing that can be validated here is the plugin's // message. However, it is always going to be valid, so let's // always return true. return true; } } opendj-server-example-plugin/src/main/java/com/example/opendj/package-info.java
New file @@ -0,0 +1,35 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt * or http://forgerock.org/license/CDDLv1.0.html. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at legal-notices/CDDLv1_0.txt. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: * Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END * * * Copyright 2008 Sun Microsystems, Inc. * Portions copyright 2014 ForgeRock AS. */ /** * Example OpenDJ Hello World plugin implementation classes. * <p> * This package contains the classes which implement the example * plugin. */ package com.example.opendj; opendj-server-example-plugin/src/main/resources/com/example/opendj/example_plugin.properties
New file @@ -0,0 +1,27 @@ # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License, Version 1.0 only # (the "License"). You may not use this file except in compliance # with the License. # # You can obtain a copy of the license at legal-notices/CDDLv1_0.txt # or http://forgerock.org/license/CDDLv1.0.html. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at legal-notices/CDDLv1_0.txt. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: # Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # Copyright 2006-2008 Sun Microsystems, Inc. # Portions copyright 2014 ForgeRock AS. SEVERE_ERR_INITIALIZE_PLUGIN_1="Invalid plugin type %s for the example plugin. NOTICE_DO_STARTUP_2=Example plugin message '%s'. NOTICE_APPLY_CONFIGURATION_CHANGE_3="Example plugin message has been changed \ from '%s' to '%s'. opendj-server-example-plugin/src/main/resources/com/example/opendj/example_plugin_fr.properties
New file @@ -0,0 +1,27 @@ # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License, Version 1.0 only # (the "License"). You may not use this file except in compliance # with the License. # # You can obtain a copy of the license at legal-notices/CDDLv1_0.txt # or http://forgerock.org/license/CDDLv1.0.html. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at legal-notices/CDDLv1_0.txt. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: # Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # Copyright 2006-2008 Sun Microsystems, Inc. # Portions copyright 2014 ForgeRock AS. SEVERE_ERR_INITIALIZE_PLUGIN_1="Type de plugin invalide %s pour le plugin d'exemple. NOTICE_DO_STARTUP_2=Message du plugin d'exemple '%s'. NOTICE_APPLY_CONFIGURATION_CHANGE_3="Le message du plugin d'exemple a été modifié \ de '%s' en '%s'. opendj-server-example-plugin/src/main/resources/config/xml/ExamplePluginConfiguration.xml
New file @@ -0,0 +1,37 @@ <?xml version="1.0" encoding="utf-8"?> <adm:managed-object name="example-plugin" plural-name="example-plugins" package="com.example.opendj" extends="plugin" parent-package="org.opends.server.admin.std" xmlns:adm="http://opendj.forgerock.org/admin" xmlns:ldap="http://opendj.forgerock.org/admin-ldap"> <adm:synopsis>An example "Hello World" plugin.</adm:synopsis> <adm:profile name="ldap"> <ldap:object-class> <ldap:name>ds-cfg-example-plugin</ldap:name> <ldap:superior>ds-cfg-plugin</ldap:superior> </ldap:object-class> </adm:profile> <adm:property-override name="java-class"> <adm:default-behavior> <adm:defined> <adm:value>com.example.opendj.ExamplePlugin</adm:value> </adm:defined> </adm:default-behavior> </adm:property-override> <adm:property name="message"> <adm:synopsis>The message to be logged.</adm:synopsis> <adm:default-behavior> <adm:defined> <adm:value>Hello World</adm:value> </adm:defined> </adm:default-behavior> <adm:syntax> <adm:string /> </adm:syntax> <adm:profile name="ldap"> <ldap:attribute> <ldap:name>ds-cfg-example-plugin-message</ldap:name> </ldap:attribute> </adm:profile> </adm:property> </adm:managed-object> opendj-server-example-plugin/src/main/resources/config/xml/Package.xml
New file @@ -0,0 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <adm:package name="com.example.opends" xmlns:adm="http://www.opends.org/admin" xmlns:ldap="http://www.opends.org/admin-ldap"> <adm:synopsis>Example OpenDS Hello World plugin.</adm:synopsis> </adm:package> opendj-server-example-plugin/src/site/xdoc/index.xml.vm
New file @@ -0,0 +1,108 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- ! CCPL HEADER START ! ! This work is licensed under the Creative Commons ! Attribution-NonCommercial-NoDerivs 3.0 Unported License. ! To view a copy of this license, visit ! http://creativecommons.org/licenses/by-nc-nd/3.0/ ! or send a letter to Creative Commons, 444 Castro Street, ! Suite 900, Mountain View, California, 94041, USA. ! ! You can also obtain a copy of the license at ! trunk/opendj3/legal-notices/CC-BY-NC-ND.txt. ! See the License for the specific language governing permissions ! and limitations under the License. ! ! If applicable, add the following below this CCPL HEADER, with the fields ! enclosed by brackets "[]" replaced with your own identifying information: ! Portions Copyright [yyyy] [name of copyright owner] ! ! CCPL HEADER END ! ! Copyright 2014 ForgeRock AS ! --> <document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd"> <properties> <title>About ${project.name}</title> <author email="opendj-dev@forgerock.org">${project.organization.name}</author> </properties> <body> <section name="About ${project.name}"> <p> ${project.description} </p> </section> <section name="Documentation for ${project.name}"> <p> Javadoc for this module can be found <a href="apidocs/index.html">here</a>. </p> </section> <section name="Get ${project.name}"> <p> Start developing your applications by obtaining ${project.name} using any of the following methods: </p> <subsection name="Maven"> <p> By far the simplest method is to develop your application using Maven and add the following settings to your <b>pom.xml</b>: </p> <source><repositories> <repository> <id>forgerock-staging-repository</id> <name>ForgeRock Release Repository</name> <url>${mavenRepoReleases}</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> <repository> <id>forgerock-snapshots-repository</id> <name>ForgeRock Snapshot Repository</name> <url>${mavenRepoSnapshots}</url> <releases> <enabled>false</enabled> </releases> </repository> </repositories> ... <dependencies> <dependency> <groupId>${project.groupId}</groupId> <artifactId>${project.artifactId}</artifactId> <version>${project.version}</version> </dependency> </dependencies></source> </subsection> <subsection name="Download"> <p> If you are not using Maven then you will need to download a pre-built binary from the ForgeRock Maven repository, along with any compile time <a href="dependencies.html">dependencies</a>: </p> <ul> <li><a href="${mavenRepoReleases}/org/forgerock/opendj/${project.artifactId}">Stable releases</a></li> <li><a href="${mavenRepoSnapshots}/org/forgerock/opendj/${project.artifactId}/${project.version}">Latest development snapshot</a></li> </ul> </subsection> <subsection name="Build"> <p> For the DIY enthusiasts you can build it yourself by checking out the latest code using <a href="source-repository.html">Subversion</a> and building it with Maven 3. </p> </subsection> </section> <section name="Getting started"> <p> The following example shows how ${project.name} may be used: </p> <source>TODO</source> </section> </body> </document>