You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2008/10/21 15:27:37 UTC
svn commit: r706621 - in
/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src:
main/java/org/apache/geronimo/gshell/wisdom/completer/
main/java/org/apache/geronimo/gshell/wisdom/config/
main/resources/org/apache/geronimo/gshell/wisdom/config/ te...
Author: jdillon
Date: Tue Oct 21 06:27:36 2008
New Revision: 706621
URL: http://svn.apache.org/viewvc?rev=706621&view=rev
Log:
Add custom bundle support
Added:
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/java/org/apache/geronimo/gshell/wisdom/config/DummyBundle.java (contents, props changed)
- copied, changed from r706614, geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/java/org/apache/geronimo/gshell/wisdom/config/DummyAction.java
Modified:
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/completer/CommandsCompleter.java
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/config/PluginParser.java
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/org/apache/geronimo/gshell/wisdom/config/wisdom-gshell.xsd
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/resources/org/apache/geronimo/gshell/wisdom/config/PluginParserTest-context.xml
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/resources/org/apache/geronimo/gshell/wisdom/registry/CommandResolverImplTest-context.xml
Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/completer/CommandsCompleter.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/completer/CommandsCompleter.java?rev=706621&r1=706620&r2=706621&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/completer/CommandsCompleter.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/completer/CommandsCompleter.java Tue Oct 21 06:27:36 2008
@@ -64,6 +64,10 @@
this.commandRegistry = commandRegistry;
}
+ //
+ // FIXME: This does not properly complete when in a command group :-(
+ //
+
@PostConstruct
public void init() throws Exception {
// Populate the initial list of completers from the currently registered commands
Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/config/PluginParser.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/config/PluginParser.java?rev=706621&r1=706620&r2=706621&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/config/PluginParser.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/config/PluginParser.java Tue Oct 21 06:27:36 2008
@@ -64,6 +64,8 @@
private static final String COMMAND_TEMPLATE_SUFFIX = "CommandTemplate";
+ private static final String BUNDLE = "bundle";
+
private static final String COMMAND_BUNDLE = "command-bundle";
private static final String NAME = "name";
@@ -273,13 +275,20 @@
BeanDefinitionBuilder plugin = parsePlugin(element);
- Map<String,BeanDefinitionHolder> bundles = parseCommandBundles(element);
-
ManagedMap bundleIdMap = new ManagedMap();
+
+ Map<String,BeanDefinitionHolder> bundles = parseBundles(element);
+ for (Map.Entry<String,BeanDefinitionHolder> entry : bundles.entrySet()) {
+ // noinspection unchecked
+ bundleIdMap.put(entry.getKey(), entry.getValue().getBeanName());
+ }
+
+ bundles = parseCommandBundles(element);
for (Map.Entry<String,BeanDefinitionHolder> entry : bundles.entrySet()) {
// noinspection unchecked
bundleIdMap.put(entry.getKey(), entry.getValue().getBeanName());
}
+
plugin.addPropertyValue("bundleIdMap", bundleIdMap);
return plugin;
@@ -308,6 +317,34 @@
}
//
+ // <gshell:bundle>
+ //
+
+ private Map<String,BeanDefinitionHolder> parseBundles(final Element element) {
+ assert element != null;
+
+ log.trace("Parse bundles; element: {}", element);
+
+ Map<String,BeanDefinitionHolder> bundles = new LinkedHashMap<String,BeanDefinitionHolder>();
+ List<Element> children = getChildElements(element, BUNDLE);
+
+ for (Element child : children) {
+ String name = child.getAttribute(NAME);
+ BeanDefinitionHolder holder = parseBeanDefinitionElement(child);
+ holder.getBeanDefinition().getConstructorArgumentValues().addIndexedArgumentValue(0, name);
+
+ // Generate id and register the bean
+ BeanDefinition def = holder.getBeanDefinition();
+ String id = resolveId(child, def);
+ holder = register(def, id);
+
+ bundles.put(name, holder);
+ }
+
+ return bundles;
+ }
+
+ //
// <gshell:command-bundle>
//
Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/org/apache/geronimo/gshell/wisdom/config/wisdom-gshell.xsd
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/org/apache/geronimo/gshell/wisdom/config/wisdom-gshell.xsd?rev=706621&r1=706620&r2=706621&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/org/apache/geronimo/gshell/wisdom/config/wisdom-gshell.xsd (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/org/apache/geronimo/gshell/wisdom/config/wisdom-gshell.xsd Tue Oct 21 06:27:36 2008
@@ -44,12 +44,34 @@
</xsd:annotation>
<xsd:sequence>
<xsd:element ref="beans:description" minOccurs="0" maxOccurs="1"/>
- <xsd:element ref="command-bundle" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:choice minOccurs="0" maxOccurs="unbounded">
+ <xsd:element ref="bundle" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element ref="command-bundle" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:choice>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required"/>
</xsd:complexType>
</xsd:element>
+ <xsd:element name="bundle">
+ <xsd:complexType>
+ <xsd:annotation>
+ <xsd:documentation>
+ Defines a bundle.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexContent>
+ <xsd:extension base="beans:identifiedType">
+ <xsd:group ref="beans:beanElements"/>
+ <xsd:attributeGroup ref="beans:beanAttributes"/>
+ <!--
+ FIXME: Need to make 'name' required, but for not don't bother.
+ -->
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
<xsd:element name="command-bundle">
<xsd:complexType>
<xsd:annotation>
Copied: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/java/org/apache/geronimo/gshell/wisdom/config/DummyBundle.java (from r706614, geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/java/org/apache/geronimo/gshell/wisdom/config/DummyAction.java)
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/java/org/apache/geronimo/gshell/wisdom/config/DummyBundle.java?p2=geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/java/org/apache/geronimo/gshell/wisdom/config/DummyBundle.java&p1=geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/java/org/apache/geronimo/gshell/wisdom/config/DummyAction.java&r1=706614&r2=706621&rev=706621&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/java/org/apache/geronimo/gshell/wisdom/config/DummyAction.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/java/org/apache/geronimo/gshell/wisdom/config/DummyBundle.java Tue Oct 21 06:27:36 2008
@@ -24,26 +24,34 @@
import org.apache.geronimo.gshell.command.CommandAction;
import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.notification.Notification;
+import org.apache.geronimo.gshell.application.plugin.bundle.Bundle;
/**
* ???
*
* @version $Rev$ $Date$
*/
-public class DummyAction
- implements CommandAction
+public class DummyBundle
+ implements Bundle
{
- private String text;
+ private String name;
- public String getText() {
- return text;
+ public DummyBundle(final String name) {
+ this.name = name;
}
- public void setText(String text) {
- this.text = text;
+ public void disable() throws Exception {
+
+ }
+
+ public void enable() throws Exception {
+ }
+
+ public String getName() {
+ return name;
}
- public Object execute(CommandContext context) throws Notification, Exception {
- return null;
+ public boolean isEnabled() {
+ return false;
}
}
\ No newline at end of file
Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/java/org/apache/geronimo/gshell/wisdom/config/DummyBundle.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/java/org/apache/geronimo/gshell/wisdom/config/DummyBundle.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/java/org/apache/geronimo/gshell/wisdom/config/DummyBundle.java
------------------------------------------------------------------------------
svn:mergeinfo =
Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/java/org/apache/geronimo/gshell/wisdom/config/DummyBundle.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/resources/org/apache/geronimo/gshell/wisdom/config/PluginParserTest-context.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/resources/org/apache/geronimo/gshell/wisdom/config/PluginParserTest-context.xml?rev=706621&r1=706620&r2=706621&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/resources/org/apache/geronimo/gshell/wisdom/config/PluginParserTest-context.xml (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/resources/org/apache/geronimo/gshell/wisdom/config/PluginParserTest-context.xml Tue Oct 21 06:27:36 2008
@@ -119,6 +119,10 @@
</gshell:completers>
</gshell:command>
</gshell:command-bundle>
+
+ <gshell:bundle name="customBundle" class="org.apache.geronimo.gshell.wisdom.config.DummyBundle">
+ <!-- TODO -->
+ </gshell:bundle>
</gshell:plugin>
<!--
Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/resources/org/apache/geronimo/gshell/wisdom/registry/CommandResolverImplTest-context.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/resources/org/apache/geronimo/gshell/wisdom/registry/CommandResolverImplTest-context.xml?rev=706621&r1=706620&r2=706621&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/resources/org/apache/geronimo/gshell/wisdom/registry/CommandResolverImplTest-context.xml (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/resources/org/apache/geronimo/gshell/wisdom/registry/CommandResolverImplTest-context.xml Tue Oct 21 06:27:36 2008
@@ -29,6 +29,10 @@
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
+ <bean id="org.apache.commons.vfs.provider.FileReplicator" class="org.apache.commons.vfs.impl.DefaultFileReplicator">
+ <constructor-arg value="${basedir}/target/tmp"/>
+ </bean>
+
<bean id="xstore" class="org.apache.geronimo.gshell.xstore.XStoreImpl">
<constructor-arg ref="fileSystemAccess"/>
<property name="rootUri" value="file:${basedir}/target/xstore"/>