You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2014/01/27 14:59:08 UTC
svn commit: r1561681 - in
/stanbol/trunk/development/archetypes/enhancement-engine/src/main/resources/archetype-resources/src/main:
java/ExampleEnhancer.java resources/OSGI-INF/metatype/metatype.properties
Author: rwesten
Date: Mon Jan 27 13:59:08 2014
New Revision: 1561681
URL: http://svn.apache.org/r1561681
Log:
STANBOL-1270: added an example for a custom property
Modified:
stanbol/trunk/development/archetypes/enhancement-engine/src/main/resources/archetype-resources/src/main/java/ExampleEnhancer.java
stanbol/trunk/development/archetypes/enhancement-engine/src/main/resources/archetype-resources/src/main/resources/OSGI-INF/metatype/metatype.properties
Modified: stanbol/trunk/development/archetypes/enhancement-engine/src/main/resources/archetype-resources/src/main/java/ExampleEnhancer.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/development/archetypes/enhancement-engine/src/main/resources/archetype-resources/src/main/java/ExampleEnhancer.java?rev=1561681&r1=1561680&r2=1561681&view=diff
==============================================================================
--- stanbol/trunk/development/archetypes/enhancement-engine/src/main/resources/archetype-resources/src/main/java/ExampleEnhancer.java (original)
+++ stanbol/trunk/development/archetypes/enhancement-engine/src/main/resources/archetype-resources/src/main/java/ExampleEnhancer.java Mon Jan 27 13:59:08 2014
@@ -55,6 +55,20 @@ public class ExampleEnhancer extends Abs
private static final Logger log = LoggerFactory.getLogger(ExampleEnhancer.class);
/**
+ * Configuration property for option 1
+ */
+ @Property(value=ExampleEnhancer.DEFAULT_OPTION1_VALUE)
+ public static final String EXAMPLE_CONFIG_OPTION1 = "${package}.option1";
+ /**
+ * The default value for EXAMPLE_CONFIG_OPTION1
+ */
+ public static final String DEFAULT_OPTION1_VALUE = "value1";
+ /**
+ * The value of option1
+ */
+ private String option1;
+
+ /**
* TODO: change to fit your engine. See constants defined in the
* ServiceProperties class
*/
@@ -77,13 +91,23 @@ public class ExampleEnhancer extends Abs
@SuppressWarnings("unchecked")
Dictionary<String, Object> properties = ce.getProperties();
//TODO: parse custom properties
+
+ //As Example we parse EXAMPLE_CONFIG_OPTION1 form the config
+ Object value = properties.get(EXAMPLE_CONFIG_OPTION1);
+ if(value == null || value.toString().isEmpty()){
+ option1 = DEFAULT_OPTION1_VALUE;
+ } else {
+ option1 = value.toString();
+ }
}
@Deactivate
protected void deactivate(ComponentContext context) {
log.info("deactivating {}: {}", getClass().getSimpleName(), getName());
//TODO: reset fields to default, close resources ...
- super.deactivate(context);
+ option1 = null;
+
+ super.deactivate(context); //call deactivate on the super class
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Modified: stanbol/trunk/development/archetypes/enhancement-engine/src/main/resources/archetype-resources/src/main/resources/OSGI-INF/metatype/metatype.properties
URL: http://svn.apache.org/viewvc/stanbol/trunk/development/archetypes/enhancement-engine/src/main/resources/archetype-resources/src/main/resources/OSGI-INF/metatype/metatype.properties?rev=1561681&r1=1561680&r2=1561681&view=diff
==============================================================================
--- stanbol/trunk/development/archetypes/enhancement-engine/src/main/resources/archetype-resources/src/main/resources/OSGI-INF/metatype/metatype.properties (original)
+++ stanbol/trunk/development/archetypes/enhancement-engine/src/main/resources/archetype-resources/src/main/resources/OSGI-INF/metatype/metatype.properties Mon Jan 27 13:59:08 2014
@@ -39,3 +39,7 @@ Engine Description generated for ${artif
#===============================================================================
# Special Properties and options used by this Enhancement Engine
#===============================================================================
+
+#here the opne for the example option
+${package}.option1.name=Example Option
+${package}.option1.description=Example that shows how to add custom options