xwiki-devs
Threads by month
- ----- 2026 -----
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
July 2009
- 35 participants
- 108 discussions
Hi
I think I am close having finished the Blog Upgrade to 2.0 Syntax. The only major issue I have is that if i have WYSIWYG as the default editor I cannot switch the editor because in the 2.0 WYSIWYG toolbar there is no SWITCH EDITOR icon.
This seems to be the default behavior in 2.0 which is fine for regular pages but in the Blog this is not working out because there is no way the user can switch between the editors because there is no 'Choose editor' panel.
Any way to reintroduce that SWITCH EDITOR icon onto the 2.0 Toolbar?
Cheers
Andreas Schaefer
CEO of Madplanet.com Inc.
EMail: andreas.schaefer(a)madplanet.com
schaefera(a)me.com
Twitter: andy_mpc
AIM: schaefera(a)me.com
3
6
Re: [xwiki-devs] [xwiki-notifications] r21967 - enterprise/trunk enterprise/trunk/wiki platform/core/trunk platform/core/trunk/xwiki-core platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/interna
by Thomas Mortagne 16 Jul '09
by Thomas Mortagne 16 Jul '09
16 Jul '09
Here is a first review try (pretty difficult to review all that). My
first replies was rejected by the mailing list because it was too
long...
[snip]
>Modified: platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/XWiki=
.java
>--- platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/XWiki.java =
2009-07-15 17:48:48 UTC (rev 21966)
>+++ platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/XWiki.java =
2009-07-15 18:57:45 UTC (rev 21967)
>@@ -91,6 +91,7 @@
> import org.xwiki.observation.event.DocumentSaveEvent;
> import org.xwiki.observation.event.DocumentUpdateEvent;
> import org.xwiki.query.QueryException;
>+import org.xwiki.rendering.macro.wikibridge.WikiMacroInitializer;
>
> import com.xpn.xwiki.api.Api;
> import com.xpn.xwiki.api.Document;
>@@ -775,6 +776,14 @@
> // Save the configured syntaxes
> String syntaxes =3D Param("xwiki.rendering.syntaxes", "xwiki/1.0")=
;
> this.configuredSyntaxes =3D Arrays.asList(StringUtils.split(syntax=
es, " ,"));
>+
>+ // Initialize all wiki macros
You should add a more consistent TODO here since it's a temporary hack
>+ try {
>+ WikiMacroInitializer wikiMacroInitializer =3D Utils.getCompon=
entManager().lookup(WikiMacroInitializer.class);
>+ wikiMacroInitializer.init();
>+ } catch (ComponentLookupException ex) {
>+ LOG.error("Error while initializing wiki macros", ex);
>+ }
> }
>
> public XWikiStoreInterface getNotCacheStore()
>
>Added: platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal=
/DefaultWikiMacroBuilder.java
>--- platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/De=
faultWikiMacroBuilder.java (rev 0)
>+++ platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/De=
faultWikiMacroBuilder.java 2009-07-15 18:57:45 UTC (rev 21967)
>@@ -0,0 +1,170 @@
>+/*
>+ * See the NOTICE file distributed with this work for additional
>+ * information regarding copyright ownership.
>+ *
>+ * This is free software; you can redistribute it and/or modify it
>+ * under the terms of the GNU Lesser General Public License as
>+ * published by the Free Software Foundation; either version 2.1 of
>+ * the License, or (at your option) any later version.
>+ *
>+ * This software is distributed in the hope that it will be useful,
>+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
>+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>+ * Lesser General Public License for more details.
>+ *
>+ * You should have received a copy of the GNU Lesser General Public
>+ * License along with this software; if not, write to the Free
>+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
>+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
>+ */
>+
>+package com.xpn.xwiki.internal;
>+
>+import java.util.ArrayList;
>+import java.util.List;
>+import java.util.Vector;
>+
>+import org.apache.commons.lang.StringUtils;
>+import org.xwiki.component.annotation.Component;
>+import org.xwiki.component.annotation.Requirement;
>+import org.xwiki.component.logging.AbstractLogEnabled;
>+import org.xwiki.component.manager.ComponentManager;
>+import org.xwiki.context.Execution;
>+import org.xwiki.rendering.macro.descriptor.MacroDescriptor;
>+import org.xwiki.rendering.macro.wikibridge.WikiMacro;
>+import org.xwiki.rendering.macro.wikibridge.WikiMacroBuilder;
>+import org.xwiki.rendering.macro.wikibridge.WikiMacroBuilderException;
>+import org.xwiki.rendering.macro.wikibridge.WikiMacroDescriptor;
>+import org.xwiki.rendering.macro.wikibridge.WikiMacroParameterDescriptor;
>+
>+import com.xpn.xwiki.XWikiContext;
>+import com.xpn.xwiki.XWikiException;
>+import com.xpn.xwiki.doc.XWikiDocument;
>+import com.xpn.xwiki.objects.BaseObject;
>+
>+/**
>+ * The default implementation of {@link WikiMacroBuilder}.
>+ *
>+ * @version $Id$
Looks like your svn client is not properly configured.
>+ * @since 2.0M2
>+ */
>+@Component
>+public class DefaultWikiMacroBuilder extends AbstractLogEnabled implement=
s WikiMacroBuilder
>+{
>+ /**
>+ * The {@link ComponentManager} component.
>+ */
>+ @Requirement
>+ private ComponentManager componentManager;
>+
>+ /**
>+ * The {@link Execution} component used for accessing XWikiContext.
>+ */
>+ @Requirement
>+ private Execution execution;
>+
>+ /**
>+ * Utility method for accessing XWikiContext.
>+ *
>+ * @return the XWikiContext.
>+ */
>+ private XWikiContext getContext()
>+ {
>+ return (XWikiContext) this.execution.getContext().getProperty("xw=
ikicontext");
>+ }
>+
>+ /**
>+ * {@inheritDoc}
>+ */
>+ public WikiMacro buildMacro(String documentName) throws WikiMacroBuil=
derException
>+ {
>+ XWikiDocument doc =3D null;
>+ try {
>+ doc =3D getContext().getWiki().getDocument(documentName, getC=
ontext());
>+ } catch (XWikiException ex) {
>+ throw new WikiMacroBuilderException(String.format(
>+ "Could not build macro from : [%s], unable to load docume=
nt", documentName), ex);
>+ }
>+ return buildMacro(doc);
>+ }
>+
>+ /**
>+ * Creates a {@link WikiMacro} from an {@link XWikiDocument} which co=
ntains a macro definition.
>+ *
>+ * @param doc the {@link XWikiDocument} to look for a macro definitio=
n.
>+ * @return a {@link WikiMacro} found inside the document.
>+ * @throws WikiMacroBuilderException invalid macro definition / no ma=
cro definition found.
>+ */
>+ private WikiMacro buildMacro(XWikiDocument doc) throws WikiMacroBuild=
erException
>+ {
>+ // Check whether this document contains a macro definition.
>+ BaseObject macroDefinition =3D doc.getObject(WIKI_MACRO_CLASS);
>+ if (null =3D=3D macroDefinition) {
>+ throw new WikiMacroBuilderException(String.format("No macro d=
efinition found in document : [%s]", doc
>+ .getFullName()));
>+ }
>+
>+ // Extract macro definition.
>+ String macroName =3D macroDefinition.getStringValue(MACRO_NAME_PR=
OPERTY);
>+ String macroDescription =3D macroDefinition.getStringValue(MACRO_=
DESCRIPTION_PROPERTY);
>+ String macroContent =3D macroDefinition.getStringValue(MACRO_CONT=
ENT_PROPERTY);
>+
>+ // Verify macro name.
>+ if (StringUtils.isEmpty(macroName)) {
>+ throw new WikiMacroBuilderException(String.format(
>+ "Incomplete macro definition in [%s], macro name is empty=
", doc.getFullName()));
>+ }
>+
>+ // Verify macro description.
>+ if (StringUtils.isEmpty(macroDescription)) {
>+ getLogger().warn(
>+ String.format("Incomplete macro definition in [%s], macro=
description is empty", doc.getFullName()));
>+ }
>+
>+ // Verify macro content.
>+ if (StringUtils.isEmpty(macroContent)) {
>+ throw new WikiMacroBuilderException(String.format(
>+ "Incomplete macro definition in [%s], macro content is em=
pty", doc.getFullName()));
>+ }
>+
>+ // Extract macro parameters.
>+ List<WikiMacroParameterDescriptor> parameterDescriptors =3D new A=
rrayList<WikiMacroParameterDescriptor>();
>+ Vector<BaseObject> macroParameters =3D doc.getObjects(WIKI_MACRO_=
PARAMETER_CLASS);
>+ if (null !=3D macroParameters) {
>+ for (BaseObject macroParameter : macroParameters) {
>+ // Vectors can contain null values
>+ if (null =3D=3D macroParameter) {
>+ continue;
>+ }
>+
>+ // Extract parameter definition.
>+ String parameterName =3D macroParameter.getStringValue(PA=
RAMETER_NAME_PROPERTY);
>+ String parameterDescription =3D macroParameter.getStringV=
alue(PARAMETER_DESCRIPTION_PROPERTY);
>+ boolean parameterMandatory =3D
>+ (macroParameter.getIntValue(PARAMETER_MANDATORY_PROPE=
RTY) =3D=3D 0) ? false : true;
>+
>+ // Verify parameter name.
>+ if (StringUtils.isEmpty(parameterName)) {
>+ throw new WikiMacroBuilderException(String.format(
>+ "Incomplete macro definition in [%s], macro param=
eter name is empty", doc.getFullName()));
>+ }
>+
>+ // Verify parameter description.
>+ if (StringUtils.isEmpty(parameterDescription)) {
>+ String errorMessage =3D "Incomplete macro definition =
in [%s], macro parameter description is empty";
>+ getLogger().warn(String.format(errorMessage, doc.getF=
ullName()));
>+ }
>+
>+ // Create the parameter descriptor.
>+ parameterDescriptors.add(new WikiMacroParameterDescriptor=
(parameterName, parameterDescription,
>+ parameterMandatory));
>+ }
>+ }
>+
>+ // Create the macro descriptor.
>+ MacroDescriptor macroDescriptor =3D new WikiMacroDescriptor(macro=
Description, parameterDescriptors);
>+
>+ // Create & return the macro.
>+ return new WikiMacro(macroName, macroDescriptor, macroContent, do=
c.getSyntaxId(), componentManager);
>+ }
>+}
>
>Added: platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal=
/DefaultWikiMacroInitializer.java
>--- platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/De=
faultWikiMacroInitializer.java (rev 0)
>+++ platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/De=
faultWikiMacroInitializer.java 2009-07-15 18:57:45 UTC (rev 21967)
>@@ -0,0 +1,122 @@
>+/*
>+ * See the NOTICE file distributed with this work for additional
>+ * information regarding copyright ownership.
>+ *
>+ * This is free software; you can redistribute it and/or modify it
>+ * under the terms of the GNU Lesser General Public License as
>+ * published by the Free Software Foundation; either version 2.1 of
>+ * the License, or (at your option) any later version.
>+ *
>+ * This software is distributed in the hope that it will be useful,
>+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
>+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>+ * Lesser General Public License for more details.
>+ *
>+ * You should have received a copy of the GNU Lesser General Public
>+ * License along with this software; if not, write to the Free
>+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
>+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
>+ */
>+package com.xpn.xwiki.internal;
>+
>+import java.util.Arrays;
>+import java.util.HashMap;
>+import java.util.List;
>+import java.util.Map;
>+
>+import org.xwiki.component.annotation.Component;
>+import org.xwiki.component.annotation.Requirement;
>+import org.xwiki.component.logging.AbstractLogEnabled;
>+import org.xwiki.context.Execution;
>+import org.xwiki.rendering.macro.wikibridge.WikiMacroInitializer;
>+import org.xwiki.rendering.macro.wikibridge.WikiMacro;
>+import org.xwiki.rendering.macro.wikibridge.WikiMacroBuilder;
>+import org.xwiki.rendering.macro.wikibridge.WikiMacroBuilderException;
>+import org.xwiki.rendering.macro.wikibridge.WikiMacroManager;
>+
>+import com.xpn.xwiki.XWikiContext;
>+import com.xpn.xwiki.XWikiException;
>+
>+/**
>+ * A {@link DefaultWikiMacroInitializer} providing wiki macros.
>+ *
>+ * @version $Id$
>+ * @since 2.0M2
>+ */
>+@Component
>+public class DefaultWikiMacroInitializer extends AbstractLogEnabled imple=
ments WikiMacroInitializer
>+{
>+ /**
>+ * Main wiki identifier.
>+ */
>+ private static final String MAIN_WIKI =3D "xwiki";
>+
>+ /**
>+ * The {@link WikiMacroBuilder} component.
>+ */
>+ @Requirement
>+ private WikiMacroBuilder wikiMacroBuilder;
>+
>+ /**
>+ * The {@link WikiMacroManager} component.
>+ */
>+ @Requirement
>+ private WikiMacroManager wikiMacroManager;
>+
>+ /**
>+ * The {@link Execution} component used for accessing XWikiContext.
>+ */
>+ @Requirement
>+ private Execution execution;
>+
>+ /**
>+ * Utility method for accessing XWikiContext.
>+ *
>+ * @return the XWikiContext.
>+ */
>+ private XWikiContext getContext()
>+ {
>+ return (XWikiContext) this.execution.getContext().getProperty("xw=
ikicontext");
>+ }
>+
>+ /**
>+ * {@inheritDoc}
>+ */
>+ public void init()
>+ {
>+ XWikiContext xcontext =3D getContext();
>+
>+ // Only consider the main wiki.
>+ xcontext.setDatabase(MAIN_WIKI);
>+
>+ // Search for all those documents with macro definitions.
>+ String sql =3D
>+ "select doc.fullName from XWikiDocument doc, BaseObject obj w=
here doc.fullName=3Dobj.name and obj.className=3D?";
>+ List<Object> wikiMacroDocs =3D null;
>+ try {
>+ wikiMacroDocs =3D
>+ xcontext.getWiki().getStore().search(sql, 0, 0, Arrays.as=
List("XWiki.WikiMacroClass"), xcontext);
>+ } catch (XWikiException ex) {
>+ getLogger().error("Error while searching for macro documents"=
, ex);
>+ return;
>+ }
>+
>+ // Build macros.
>+ Map<String, WikiMacro> wikiMacros =3D new HashMap<String, WikiMac=
ro>();
>+ for (Object obj : wikiMacroDocs) {
>+ String wikiMacroDoc =3D (String) obj;
>+ try {
>+ WikiMacro macro =3D wikiMacroBuilder.buildMacro(wikiMacro=
Doc);
>+ wikiMacros.put(wikiMacroDoc, macro);
>+ } catch (WikiMacroBuilderException ex) {
>+ // Just log the exception and skip to the next.
>+ getLogger().error(ex.getMessage(), ex);
>+ }
>+ }
>+
>+ // Register the wiki macros against WikiMacroManager.
>+ for (String documentName : wikiMacros.keySet()) {
>+ wikiMacroManager.registerWikiMacro(MAIN_WIKI + ":" + document=
Name, wikiMacros.get(documentName));
>+ }
>+ }
>+}
>
[snip]
>Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main=
/java/org/xwiki/rendering/block/AbstractBlock.java
>--- platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/=
org/xwiki/rendering/block/AbstractBlock.java 2009-07-15 17:48:48 UTC (rev =
21966)
>+++ platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/=
org/xwiki/rendering/block/AbstractBlock.java 2009-07-15 18:57:45 UTC (rev =
21967)
>@@ -26,7 +26,6 @@
> import java.util.List;
> import java.util.Map;
>
>-import org.apache.commons.beanutils.ConvertUtils;
> import org.apache.commons.lang.builder.EqualsBuilder;
> import org.apache.commons.lang.builder.HashCodeBuilder;
>
>@@ -240,24 +239,6 @@
> }
>
> /**
>- * Set a parameter on the current block. A parameter is any semantic =
data associated with a block. It can be used
>- * for various purposes and provide additional information to the ren=
derers/listeners. For example you can pass
>- * style information such as <code>style=3D"color:red"</code> (in tha=
t example the name would be <code>style</code>
>- * and the value <code>"color:red"</code>) to indicate that the curre=
nt block should be displayed in red.
>- * <p>
>- * Note that there are currently no well-defined known parameter name=
s and you'll need to check what the different
>- * renderers/listeners support to know what to use.
>- * </p>
>- *
>- * @param name the parameter's name
>- * @param value the parameter's value
>- */
>- public void setParameter(String name, Object value)
>- {
>- setParameter(name, ConvertUtils.convert(value));
>- }
>-
>- /**
> * Set several parameters at once.
> *
> * @param parameters the parameters to set
>
>Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main=
/java/org/xwiki/rendering/internal/macro/DefaultMacroManager.java
>--- platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/=
org/xwiki/rendering/internal/macro/DefaultMacroManager.java 2009-07-15 17=
:48:48 UTC (rev 21966)
>+++ platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/=
org/xwiki/rendering/internal/macro/DefaultMacroManager.java 2009-07-15 18=
:57:45 UTC (rev 21967)
>@@ -19,7 +19,6 @@
> */
> package org.xwiki.rendering.internal.macro;
>
>-import java.util.HashMap;
> import java.util.Map;
> import java.util.Set;
> import java.util.TreeSet;
>@@ -29,8 +28,6 @@
> import org.xwiki.component.logging.AbstractLogEnabled;
> import org.xwiki.component.manager.ComponentLookupException;
> import org.xwiki.component.manager.ComponentManager;
>-import org.xwiki.component.phase.Initializable;
>-import org.xwiki.component.phase.InitializationException;
> import org.xwiki.rendering.macro.Macro;
> import org.xwiki.rendering.macro.MacroLookupException;
> import org.xwiki.rendering.macro.MacroManager;
>@@ -46,26 +43,14 @@
> * @since 1.9M1
> */
> @Component
>-public class DefaultMacroManager extends AbstractLogEnabled implements Ma=
croManager, Initializable
>+public class DefaultMacroManager extends AbstractLogEnabled implements Ma=
croManager
> {
> /**
>- * Cache of macros for syntax-specific macros. Index is the syntax an=
d value is a Map with an index being the macro
>- * name the value the Macro.
>- */
>- protected Map<Syntax, Map<String, Macro< ? >>> syntaxSpecificMacros;
>-
>- /**
>- * Cache of macros for macros registered for all syntaxes. Index is t=
he syntax and value is a Map with an index
>- * being the macro name the value the Macro.
>- */
>- protected Map<String, Macro< ? >> allSyntaxesMacros;
>-
>- /**
> * Allows transforming a syntax specified as text into a {@link Syntax=
} object. Injected by the component manager
> * subsystem.
> */
> @Requirement
>- protected SyntaxFactory syntaxFactory;
>+ private SyntaxFactory syntaxFactory;
>
> /**
> * The component manager we use to lookup macro implementations regist=
ered as components.
>@@ -74,51 +59,44 @@
> private ComponentManager componentManager;
>
> /**
>- * Creates a new {@link DefaultMacroManager} instance.
>- */
>- public DefaultMacroManager()
>- {
>- // Create macro caches.
>- this.syntaxSpecificMacros =3D new HashMap<Syntax, Map<String, Mac=
ro< ? >>>();
>- this.allSyntaxesMacros =3D new HashMap<String, Macro< ? >>();
>- }
>-
>- /**
> * {@inheritDoc}
> *
>- * @see Initializable#initialize()
>+ * @see org.xwiki.rendering.macro.MacroManager#getMacroNames(Syntax)
> */
> @SuppressWarnings("unchecked")
>- public void initialize() throws InitializationException
>+ public Set<String> getMacroNames(Syntax syntax) throws MacroLookupExc=
eption
> {
>- // Find all registered macros
>+ Set<String> result =3D new TreeSet<String>();
>+
>+ // Lookup all registered macros
> Map<String, Macro> allMacros;
> try {
> allMacros =3D this.componentManager.lookupMap(Macro.class);
> } catch (ComponentLookupException e) {
>- throw new InitializationException("Failed to lookup Macros", =
e);
>+ throw new MacroLookupException("Failed to lookup Macros", e);
> }
>
>- // Now sort through the ones that are registered for a given synt=
ax and those registered for all syntaxes.
>+ // Loop through all the macros and filter those macros that will =
work with the given syntax.
> for (Map.Entry<String, Macro> entry : allMacros.entrySet()) {
>-
> // Verify if we have a syntax specified.
> String[] hintParts =3D entry.getKey().split("/");
> if (hintParts.length =3D=3D 3) {
> // We've found a macro registered for a given syntax
> String syntaxAsString =3D hintParts[1] + "/" + hintParts[2=
];
> String macroName =3D hintParts[0];
>- Syntax syntax;
>+ Syntax macroSyntax;
> try {
>- syntax =3D this.syntaxFactory.createSyntaxFromIdStrin=
g(syntaxAsString);
>+ macroSyntax =3D this.syntaxFactory.createSyntaxFromId=
String(syntaxAsString);
> } catch (ParseException e) {
>- throw new InitializationException("Failed to initiali=
ze Macro [" + macroName
>+ throw new MacroLookupException("Failed to initialize =
Macro [" + macroName
> + "] due to an invalid Syntax [" + syntaxAsString =
+ "]", e);
> }
>- registerMacroForSyntax(macroName, syntax, entry.getValue(=
));
>+ if (macroSyntax.equals(syntax)) {
>+ result.add(macroName);
>+ }
> } else if (hintParts.length =3D=3D 1) {
> // We've found a macro registered for all syntaxes
>- registerMacroForAllSyntaxes(hintParts[0], entry.getValue(=
));
>+ result.add(hintParts[0]);
> } else {
> // We ignore invalid macro descriptors but log it as warni=
ng.
> getLogger()
>@@ -131,55 +109,7 @@
> + "This macro will not be available in the sys=
tem.");
> }
> }
>- }
>
>- /**
>- * Register a macro for a specific syntax.
>- *
>- * @param macroName the name of the macro to register.
>- * @param syntax the syntax for which to register the macro. If null =
the macro is registered for all syntaxes.
>- * @param macro the macro to register
>- */
>- protected void registerMacroForSyntax(String macroName, Syntax syntax=
, Macro< ? > macro)
>- {
>- Map<String, Macro< ? >> macrosForSyntax =3D this.syntaxSpecificMa=
cros.get(syntax);
>- if (macrosForSyntax =3D=3D null) {
>- macrosForSyntax =3D new HashMap<String, Macro< ? >>();
>- this.syntaxSpecificMacros.put(syntax, macrosForSyntax);
>- }
>-
>- macrosForSyntax.put(macroName, macro);
>- }
>-
>- /**
>- * Register a macro for all syntaxes.
>- *
>- * @param macroName the name of the macro to register.
>- * @param macro the macro to register
>- */
>- protected void registerMacroForAllSyntaxes(String macroName, Macro< ?=
> macro)
>- {
>- this.allSyntaxesMacros.put(macroName, macro);
>- }
>-
>- /**
>- * {@inheritDoc}
>- *
>- * @see org.xwiki.rendering.macro.MacroManager#getMacroNames(Syntax)
>- */
>- public Set<String> getMacroNames(Syntax syntax)
>- {
>- Set<String> result =3D new TreeSet<String>();
>-
>- // first we put the macros that are not specific to any syntax.
>- result.addAll(this.allSyntaxesMacros.keySet());
>-
>- // then we add macros for this syntax in particular if any.
>- // if macro with same name is defined for both, the one specific =
to the desired syntax wins.
>- if (this.syntaxSpecificMacros.containsKey(syntax)) {
>- result.addAll(this.syntaxSpecificMacros.get(syntax).keySet())=
;
>- }
>-
> return result;
> }
>
>@@ -190,14 +120,19 @@
> */
> public Macro< ? > getMacro(String macroName, Syntax syntax) throws Mac=
roLookupException
> {
>- // First check in macros registered for all syntaxes
>- Map<String, Macro< ? >> macrosForSyntax =3D this.syntaxSpecificMa=
cros.get(syntax);
>- if (macrosForSyntax !=3D null && macrosForSyntax.containsKey(macr=
oName)) {
>- return macrosForSyntax.get(macroName);
>+ // First search for a macro registered for the given syntax.
>+ String macroHint =3D macroName + "/" + syntax.toIdString();
>+ try {
>+ return componentManager.lookup(Macro.class, macroHint);
>+ } catch (ComponentLookupException ex1) {
>+ // Now search for a macro registered for all syntaxes.
>+ try {
>+ return componentManager.lookup(Macro.class, macroName);
>+ } catch (ComponentLookupException ex2) {
>+ throw new MacroLookupException(String.format("No macro na=
med [%s] is available for syntax [%s].",
>+ macroName, syntax.toIdString()));
>+ }
> }
>-
>- // If not found, check in macros for all syntaxes
>- return this.getMacro(macroName);
> }
>
> /**
>@@ -207,11 +142,11 @@
> */
> public Macro< ? > getMacro(String macroName) throws MacroLookupExcepti=
on
> {
>- if (this.allSyntaxesMacros.containsKey(macroName)) {
>- return this.allSyntaxesMacros.get(macroName);
>+ try {
>+ return componentManager.lookup(Macro.class, macroName);
>+ } catch (ComponentLookupException ex) {
>+ throw new MacroLookupException(String.format("No macro named =
[%s] can be found.", macroName));
> }
>-
>- throw new MacroLookupException("No [" + macroName + "] could be f=
ound");
> }
>
> /**
>@@ -221,9 +156,14 @@
> */
> public boolean exists(String macroName, Syntax syntax)
> {
>- return this.syntaxSpecificMacros.get(syntax) !=3D null
>- && this.syntaxSpecificMacros.get(syntax).get(macroName) !=3D =
null;
>-
>+ String macroHint =3D macroName + "/" + syntax.toIdString();
>+ boolean hasMacro =3D true;
>+ try {
>+ componentManager.lookup(Macro.class, macroHint);
>+ } catch (ComponentLookupException ex) {
>+ hasMacro =3D false;
>+ }
>+ return hasMacro;
> }
>
> /**
>@@ -233,6 +173,12 @@
> */
> public boolean exists(String macroName)
> {
>- return this.allSyntaxesMacros.get(macroName) !=3D null;
>+ boolean hasMacro =3D true;
>+ try {
>+ componentManager.lookup(Macro.class, macroName);
>+ } catch (ComponentLookupException ex) {
>+ hasMacro =3D false;
>+ }
>+ return hasMacro;
> }
> }
>
[snip]
>Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main=
/java/org/xwiki/rendering/macro/AbstractMacro.java
>--- platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/=
org/xwiki/rendering/macro/AbstractMacro.java 2009-07-15 17:48:48 UTC (rev =
21966)
>+++ platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/=
org/xwiki/rendering/macro/AbstractMacro.java 2009-07-15 18:57:45 UTC (rev =
21967)
>@@ -19,9 +19,14 @@
> */
> package org.xwiki.rendering.macro;
>
>-import org.apache.commons.beanutils.ConvertUtils;
>-import org.apache.commons.beanutils.Converter;
>+import org.xwiki.component.annotation.Requirement;
> import org.xwiki.component.logging.AbstractLogEnabled;
>+import org.xwiki.component.phase.Initializable;
>+import org.xwiki.component.phase.InitializationException;
>+import org.xwiki.properties.BeanManager;
>+import org.xwiki.rendering.macro.descriptor.ContentDescriptor;
>+import org.xwiki.rendering.macro.descriptor.DefaultContentDescriptor;
>+import org.xwiki.rendering.macro.descriptor.DefaultMacroDescriptor;
> import org.xwiki.rendering.macro.descriptor.MacroDescriptor;
>
> /**
>@@ -29,9 +34,30 @@
> * @version $Id$
> * @since 1.5M2
> */
>-public abstract class AbstractMacro<P> extends AbstractLogEnabled impleme=
nts Macro<P>
>+public abstract class AbstractMacro<P> extends AbstractLogEnabled impleme=
nts Macro<P>, Initializable
> {
> /**
>+ * The {@link BeanManager} component.
>+ */
>+ @Requirement
>+ protected BeanManager beanManager;
>+
>+ /**
>+ * Macro description used to generate the macro descriptor.
>+ */
>+ private String description;
>+
>+ /**
>+ * Content descriptor used to generate the macro descriptor.
>+ */
>+ private ContentDescriptor contentDescriptor;
>+
>+ /**
>+ * Parameter bean class used to generate the macro descriptor.
>+ */
>+ private Class< ? > parametersBeanClass;
>+
>+ /**
> * The descriptor of the macro.
> */
> private MacroDescriptor macroDescriptor;
>@@ -42,28 +68,65 @@
> private int priority =3D 1000;
>
> /**
>- * @param macroDescriptor the {@link MacroDescriptor}.
>+ * Creates a new {@link Macro} instance.
>+ *
>+ * @param description a string describing this macro.
> */
>- public AbstractMacro(MacroDescriptor macroDescriptor)
>+ public AbstractMacro(String description)
> {
>- setDescriptor(macroDescriptor);
>+ this.description =3D description;
>+ this.contentDescriptor =3D new DefaultContentDescriptor();
>+ this.parametersBeanClass =3D Object.class;
> }
>+
>+ /**
>+ * Creates a new {@link Macro} instance.
>+ *
>+ * @param description a string describing this macro.
>+ * @param contentDescriptor {@link ContentDescriptor} for this macro.
>+ */
>+ public AbstractMacro(String description, ContentDescriptor contentDes=
criptor)
>+ {
>+ this(description);
>+ this.contentDescriptor =3D contentDescriptor;
>+ }
>+
>+ /**
>+ * Creates a new {@link Macro} instance.
>+ *
>+ * @param description a string describing this macro.
>+ * @param parametersBeanClass class of the parameters bean of this ma=
cro.
>+ */
>+ public AbstractMacro(String description, Class< ? > parametersBeanCl=
ass)
>+ {
>+ this(description);
>+ this.parametersBeanClass =3D parametersBeanClass;
>+ }
>
> /**
>- * Register a converter for a specific type used by the macro paramet=
ers bean.
>- * <p>
>- * Note: each enum type used has to be registered because BeanUtil do=
es not support generic types.
>+ * Creates a new {@link Macro} instance.
> *
>- * @param converter the BeanUtil {@link Converter}
>- * @param clazz the class for which to assign the {@link Converter}
>+ * @param description string describing this macro.
>+ * @param contentDescriptor the {@link ContentDescriptor} describing =
the content of this macro.
>+ * @param parametersBeanClass class of the parameters bean.
> */
>- protected void registerConverter(Converter converter, Class< ? > claz=
z)
>+ public AbstractMacro(String description, ContentDescriptor contentDes=
criptor, Class< ? > parametersBeanClass)
> {
>- ConvertUtils.register(converter, clazz);
>+ this(description, contentDescriptor);
>+ this.parametersBeanClass =3D parametersBeanClass;
> }
>
> /**
> * {@inheritDoc}
>+ */
>+ public void initialize() throws InitializationException
>+ {
>+ setDescriptor(new DefaultMacroDescriptor(description, contentDesc=
riptor, beanManager
>+ .getBeanDescriptor(parametersBeanClass)));
>+ }
>+
>+ /**
>+ * {@inheritDoc}
> *
> * @see org.xwiki.rendering.macro.Macro#getPriority()
> */
>@@ -73,13 +136,13 @@
> }
>
> /**
>- * @param priority the macro priority to use (lower means execute bef=
ore others)
>+ * @param priority the macro priority to use (lower means execute bef=
ore others)
> */
> public void setPriority(int priority)
> {
> this.priority =3D priority;
> }
>-
>+
> /**
> * {@inheritDoc}
> *
>@@ -89,7 +152,7 @@
> {
> return this.macroDescriptor;
> }
>-
>+
> /**
> * {@inheritDoc}
> *
>@@ -102,10 +165,11 @@
> }
> return this.getClass().getSimpleName().compareTo(macro.getClass().=
getSimpleName());
> }
>-
>+
> /**
> * Allows macro classes extending other macro classes to override the =
macro descriptor with their own.
>- * @param descriptor the overriding descriptor to set
>+ *
>+ * @param descriptor the overriding descriptor to set
> */
> protected void setDescriptor(MacroDescriptor descriptor)
> {
>
>Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main=
/java/org/xwiki/rendering/macro/AbstractNoParameterMacro.java
>--- platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/=
org/xwiki/rendering/macro/AbstractNoParameterMacro.java 2009-07-15 17=
:48:48 UTC (rev 21966)
>+++ platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/=
org/xwiki/rendering/macro/AbstractNoParameterMacro.java 2009-07-15 18=
:57:45 UTC (rev 21967)
>@@ -19,7 +19,6 @@
> */
> package org.xwiki.rendering.macro;
>
>-import org.xwiki.rendering.macro.descriptor.DefaultMacroDescriptor;
>
> /**
> * Base class for a macro which does not support any parameter.
>@@ -36,6 +35,6 @@
> */
> public AbstractNoParameterMacro(String description)
> {
>- super(new DefaultMacroDescriptor(description));
>+ super(description);
> }
> }
>
>Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main=
/java/org/xwiki/rendering/macro/descriptor/AbstractMacroDescriptor.java
>--- platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/=
org/xwiki/rendering/macro/descriptor/AbstractMacroDescriptor.java 2009-=
07-15 17:48:48 UTC (rev 21966)
>+++ platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/=
org/xwiki/rendering/macro/descriptor/AbstractMacroDescriptor.java 2009-=
07-15 18:57:45 UTC (rev 21967)
>@@ -19,18 +19,12 @@
> */
> package org.xwiki.rendering.macro.descriptor;
>
>-import java.beans.BeanInfo;
>-import java.beans.Introspector;
>-import java.beans.PropertyDescriptor;
>-import java.lang.annotation.Annotation;
>-import java.lang.reflect.Method;
> import java.util.Collections;
> import java.util.LinkedHashMap;
> import java.util.Map;
>
>-import org.xwiki.rendering.macro.descriptor.annotation.ParameterDescripti=
on;
>-import org.xwiki.rendering.macro.descriptor.annotation.ParameterHidden;
>-import org.xwiki.rendering.macro.descriptor.annotation.ParameterMandatory=
;
>+import org.xwiki.properties.BeanDescriptor;
>+import org.xwiki.properties.PropertyDescriptor;
>
> /**
> * Describe a macro.
>@@ -51,9 +45,9 @@
> private ContentDescriptor contentDescriptor;
>
> /**
>- * The class of the JAVA bean containing macro parameters.
>+ * The description of the parameters bean.
> */
>- private Class< ? > parametersBeanClass;
>+ private BeanDescriptor parametersBeanDescriptor;
>
> /**
> * A map containing the {@link ParameterDescriptor} for each parameter=
s supported for this macro.
>@@ -66,110 +60,32 @@
> /**
> * @param description the description of the macro.
> * @param contentDescriptor the description of the macro content. null=
indicate macro does not support content.
>- * @param parametersBeanClass the class of the JAVA bean containing m=
acro parameters.
>+ * @param parametersBeanDescriptor the description of the parameters =
bean or null if there are no parameters for
>+ * this macro.
> */
> public AbstractMacroDescriptor(String description, ContentDescriptor c=
ontentDescriptor,
>- Class< ? > parametersBeanClass)
>+ BeanDescriptor parametersBeanDescriptor)
> {
> this.description =3D description;
>- this.parametersBeanClass =3D parametersBeanClass;
> this.contentDescriptor =3D contentDescriptor;
>+ this.parametersBeanDescriptor =3D parametersBeanDescriptor;
> }
>
> /**
>- * Extract parameters informations from {@link #parametersBeanClass} =
and insert it in
>+ * Extract parameters informations from {@link #parametersBeanDescrip=
tor} and insert it in
> * {@link #parameterDescriptorMap}.
> *
> * @since 1.7M2
> */
> protected void extractParameterDescriptorMap()
> {
>- try {
>- BeanInfo beanInfo =3D Introspector.getBeanInfo(this.parameter=
sBeanClass);
>- PropertyDescriptor[] propertyDescriptors =3D beanInfo.getProp=
ertyDescriptors();
>- if (propertyDescriptors !=3D null) {
>- for (PropertyDescriptor propertyDescriptor : propertyDesc=
riptors) {
>- if (propertyDescriptor !=3D null) {
>- extractParameterDescriptor(propertyDescriptor, ge=
tParametersBeanClass().newInstance());
>- }
>- }
>- }
>- } catch (Exception e) {
>- // TODO: add error log here
>+ for (PropertyDescriptor propertyDescriptor : parametersBeanDescri=
ptor.getProperties()) {
>+ DefaultParameterDescriptor desc =3D new DefaultParameterDescr=
iptor(propertyDescriptor);
>+ this.parameterDescriptorMap.put(desc.getName().toLowerCase(),=
desc);
> }
> }
>
> /**
>- * Extract provided parameters informations and insert it in {@link #=
parameterDescriptorMap}.
>- *
>- * @param propertyDescriptor the JAVA bean property descriptor.
>- * @param defaultInstance the default instance of bean class.
>- * @since 1.7M2
>- */
>- protected void extractParameterDescriptor(PropertyDescriptor property=
Descriptor, Object defaultInstance)
>- {
>- DefaultParameterDescriptor desc =3D new DefaultParameterDescripto=
r();
>- desc.setName(propertyDescriptor.getName());
>- desc.setType(propertyDescriptor.getPropertyType());
>-
>- Method writeMethod =3D propertyDescriptor.getWriteMethod();
>-
>- if (writeMethod !=3D null) {
>- Method readMethod =3D propertyDescriptor.getReadMethod();
>-
>- // is parameter hidden
>- ParameterHidden parameterHidden =3D
>- extractParameterAnnotation(writeMethod, readMethod, Param=
eterHidden.class);
>-
>- if (parameterHidden =3D=3D null) {
>- // get parameter description
>- ParameterDescription parameterDescription =3D
>- extractParameterAnnotation(writeMethod, readMethod, P=
arameterDescription.class);
>-
>- desc.setDescription(parameterDescription !=3D null ? para=
meterDescription.value() : propertyDescriptor
>- .getShortDescription());
>-
>- // is parameter mandatory
>- ParameterMandatory parameterMandatory =3D
>- extractParameterAnnotation(writeMethod, readMethod, P=
arameterMandatory.class);
>-
>- desc.setMandatory(parameterMandatory !=3D null);
>-
>- // get default value
>- try {
>- desc.setDefaultValue(readMethod.invoke(defaultInstanc=
e));
>- } catch (Exception e) {
>- // TODO add some log.
>- }
>-
>- this.parameterDescriptorMap.put(desc.getName().toLowerCas=
e(), desc);
>- }
>- }
>- }
>-
>- /**
>- * Get the parameter annotation. Try first on the setter then on the =
getter if no annotation has been found.
>- *
>- * @param <T> the Class object corresponding to the annotation type.
>- * @param writeMethod the method that should be used to write the pro=
perty value.
>- * @param readMethod the method that should be used to read the prope=
rty value.
>- * @param annotationClass the Class object corresponding to the annot=
ation type.
>- * @return this element's annotation for the specified annotation typ=
e if present on this element, else null.
>- * @since 1.7
>- */
>- protected <T extends Annotation> T extractParameterAnnotation(Method =
writeMethod, Method readMethod,
>- Class<T> annotationClass)
>- {
>- T parameterDescription =3D writeMethod.getAnnotation(annotationCl=
ass);
>-
>- if (parameterDescription =3D=3D null && readMethod !=3D null) {
>- parameterDescription =3D readMethod.getAnnotation(annotationC=
lass);
>- }
>-
>- return parameterDescription;
>- }
>-
>- /**
> * {@inheritDoc}
> *
> * @see org.xwiki.rendering.macro.descriptor.MacroDescriptor#getConten=
tDescriptor()
>@@ -196,7 +112,7 @@
> */
> public Class< ? > getParametersBeanClass()
> {
>- return this.parametersBeanClass;
>+ return (null !=3D parametersBeanDescriptor) ? this.parametersBean=
Descriptor.getBeanClass() : Object.class;
> }
>
> /**
>@@ -206,6 +122,7 @@
> */
> public Map<String, ParameterDescriptor> getParameterDescriptorMap()
> {
>- return Collections.unmodifiableMap(this.parameterDescriptorMap);
>+ return (null !=3D parametersBeanDescriptor) ? Collections.unmodif=
iableMap(this.parameterDescriptorMap)
>+ : Collections.<String, ParameterDescriptor> emptyMap();
> }
> }
>
>Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main=
/java/org/xwiki/rendering/macro/descriptor/DefaultMacroDescriptor.java
>--- platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/=
org/xwiki/rendering/macro/descriptor/DefaultMacroDescriptor.java 2009-=
07-15 17:48:48 UTC (rev 21966)
>+++ platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/=
org/xwiki/rendering/macro/descriptor/DefaultMacroDescriptor.java 2009-=
07-15 18:57:45 UTC (rev 21967)
>@@ -19,6 +19,8 @@
> */
> package org.xwiki.rendering.macro.descriptor;
>
>+import org.xwiki.properties.BeanDescriptor;
>+
> /**
> * Describe a macro with no parameters.
> *
>@@ -32,41 +34,28 @@
> */
> public DefaultMacroDescriptor(String description)
> {
>- super(description, new DefaultContentDescriptor(), Object.class);
>+ super(description, new DefaultContentDescriptor(), null);
> }
>-
>+
> /**
> * @param description the description of the macro.
>- * @param parametersBeanClass the class of the JAVA bean containing m=
acro parameters.
>+ * @param contentDescriptor description of the macro content.
> */
>- public DefaultMacroDescriptor(String description, Class< ? > paramete=
rsBeanClass)
>- {
>- super(description, new DefaultContentDescriptor(), parametersBean=
Class);
>-
>- extractParameterDescriptorMap();
>- }
>-
>- /**
>- * @param description the description of the macro.
>- * @param contentDescriptor the description of the macro content. nul=
l indicate macro does not support content.
>- */
> public DefaultMacroDescriptor(String description, ContentDescriptor co=
ntentDescriptor)
> {
>- super(description, contentDescriptor, Object.class);
>-
>- extractParameterDescriptorMap();
>+ super(description, contentDescriptor, null);
> }
>
> /**
> * @param description the description of the macro.
> * @param contentDescriptor the description of the macro content. null=
indicate macro does not support content.
>- * @param parametersBeanClass the class of the JAVA bean containing m=
acro parameters.
>+ * @param parametersBeanDescriptor the description of the parameters =
bean.
> */
> public DefaultMacroDescriptor(String description, ContentDescriptor co=
ntentDescriptor,
>- Class< ? > parametersBeanClass)
>+ BeanDescriptor parametersBeanDescriptor)
> {
>- super(description, contentDescriptor, parametersBeanClass);
>-
>+ super(description, contentDescriptor, parametersBeanDescriptor);
>+
> extractParameterDescriptorMap();
>- }
>+ }
> }
>
>Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main=
/java/org/xwiki/rendering/macro/descriptor/DefaultParameterDescriptor.java
>--- platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/=
org/xwiki/rendering/macro/descriptor/DefaultParameterDescriptor.java 2009-=
07-15 17:48:48 UTC (rev 21966)
>+++ platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/=
org/xwiki/rendering/macro/descriptor/DefaultParameterDescriptor.java 2009-=
07-15 18:57:45 UTC (rev 21967)
>@@ -19,6 +19,8 @@
> */
> package org.xwiki.rendering.macro.descriptor;
>
>+import org.xwiki.properties.PropertyDescriptor;
>+
> /**
> * The default implementation of {@link ParameterDescriptor}.
> *
>@@ -28,31 +30,19 @@
> public class DefaultParameterDescriptor implements ParameterDescriptor
> {
> /**
>- * The name of the parameter.
>- */
>- private String name;
>-
>- /**
> * The description of the parameter.
> */
>- private String description;
>+ private PropertyDescriptor propertyDescriptor;
>
> /**
>- * The type of the parameter.
>- */
>- private Class< ? > type;
>-
>- /**
>- * The default value of the parameter.
>- */
>- private Object defaultValue;
>-
>- /**
>- * Indicate if the parameter is mandatory.
>+ * Creates a new {@link DefaultParameterDescriptor} instance using th=
e given {@link PropertyDescriptor}.
> *
>- * @since 1.7
>+ * @param propertyDescriptor The {@link PropertyDescriptor} instance.
> */
>- private boolean mandatory;
>+ public DefaultParameterDescriptor(PropertyDescriptor propertyDescript=
or)
>+ {
>+ this.propertyDescriptor =3D propertyDescriptor;
>+ }
>
> /**
> * {@inheritDoc}
>@@ -61,72 +51,40 @@
> */
> public String getName()
> {
>- return this.name;
>+ return propertyDescriptor.getName();
> }
>
> /**
>- * @param name the name of the parameter.
>- */
>- public void setName(String name)
>- {
>- this.name =3D name;
>- }
>-
>- /**
> * {@inheritDoc}
> *
> * @see org.xwiki.rendering.macro.descriptor.ParameterDescriptor#getDe=
scription()
> */
> public String getDescription()
> {
>- return this.description;
>+ return propertyDescriptor.getDescription();
> }
>
> /**
>- * @param description the description of the parameter.
>- */
>- public void setDescription(String description)
>- {
>- this.description =3D description;
>- }
>-
>- /**
> * {@inheritDoc}
> *
> * @see org.xwiki.rendering.macro.descriptor.ParameterDescriptor#getTy=
pe()
> */
> public Class< ? > getType()
> {
>- return this.type;
>+ return propertyDescriptor.getPropertyClass();
> }
>
> /**
>- * @param type the type of the parameter.
>- */
>- public void setType(Class< ? > type)
>- {
>- this.type =3D type;
>- }
>-
>- /**
> * {@inheritDoc}
> *
> * @see org.xwiki.rendering.macro.descriptor.ParameterDescriptor#getDe=
faultValue()
> */
> public Object getDefaultValue()
> {
>- return this.defaultValue;
>+ return propertyDescriptor.getDefaultValue();
> }
>
> /**
>- * @param defaultValue the default value of the parameter.
>- */
>- public void setDefaultValue(Object defaultValue)
>- {
>- this.defaultValue =3D defaultValue;
>- }
>-
>- /**
> * {@inheritDoc}
> *
> * @see org.xwiki.rendering.macro.descriptor.ParameterDescriptor#isMan=
datory()
>@@ -134,15 +92,6 @@
> */
> public boolean isMandatory()
> {
>- return this.mandatory;
>+ return propertyDescriptor.isMandatory();
> }
>-
>- /**
>- * @param mandatory indicate if the parameter is mandatory.
>- * @since 1.7
>- */
>- public void setMandatory(boolean mandatory)
>- {
>- this.mandatory =3D mandatory;
>- }
> }
>
[snip]
>Added: platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-re=
ndering-macro-wikibridge/src/main/java/org/xwiki/rendering/internal/macro/w=
ikibridge/DefaultWikiMacroManager.java
>--- platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rende=
ring-macro-wikibridge/src/main/java/org/xwiki/rendering/internal/macro/wiki=
bridge/DefaultWikiMacroManager.java (rev 0)
>+++ platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rende=
ring-macro-wikibridge/src/main/java/org/xwiki/rendering/internal/macro/wiki=
bridge/DefaultWikiMacroManager.java 2009-07-15 18:57:45 UTC (rev 219=
67)
>@@ -0,0 +1,108 @@
>+/*
>+ * See the NOTICE file distributed with this work for additional
>+ * information regarding copyright ownership.
>+ *
>+ * This is free software; you can redistribute it and/or modify it
>+ * under the terms of the GNU Lesser General Public License as
>+ * published by the Free Software Foundation; either version 2.1 of
>+ * the License, or (at your option) any later version.
>+ *
>+ * This software is distributed in the hope that it will be useful,
>+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
>+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>+ * Lesser General Public License for more details.
>+ *
>+ * You should have received a copy of the GNU Lesser General Public
>+ * License along with this software; if not, write to the Free
>+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
>+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
>+ */
>+
>+package org.xwiki.rendering.internal.macro.wikibridge;
>+
>+import java.util.HashMap;
>+import java.util.Map;
>+
>+import org.xwiki.component.annotation.Requirement;
>+import org.xwiki.component.descriptor.ComponentDescriptor;
>+import org.xwiki.component.descriptor.DefaultComponentDescriptor;
>+import org.xwiki.component.logging.AbstractLogEnabled;
>+import org.xwiki.component.manager.ComponentManager;
>+import org.xwiki.component.manager.ComponentRepositoryException;
>+import org.xwiki.rendering.macro.Macro;
>+import org.xwiki.rendering.macro.wikibridge.WikiMacro;
>+import org.xwiki.rendering.macro.wikibridge.WikiMacroManager;
>+
>+/**
>+ * Default implementation of {@link WikiMacroManager}.
>+ *
>+ * @version $Id$
>+ * @since 2.0M2
>+ */
>+public class DefaultWikiMacroManager extends AbstractLogEnabled implement=
s WikiMacroManager
>+{
>+ /**
>+ * The {@link ComponentManager} component.
>+ */
>+ @Requirement
>+ private ComponentManager componentManager;
>+
>+ /**
>+ * Map of wiki macros against document names. This is used to de-regi=
ster wiki macros when corresponding documents
>+ * are deleted.
>+ */
>+ @SuppressWarnings("unchecked")
>+ private Map<String, ComponentDescriptor<Macro>> wikiMacroMap;
>+
>+ /**
>+ * Creates a new {@link WikiMacroEventListener} component.
>+ */
>+ @SuppressWarnings("unchecked")
>+ public DefaultWikiMacroManager()
>+ {
>+ wikiMacroMap =3D new HashMap<String, ComponentDescriptor<Macro>>(=
);
>+ }
>+
>+ /**
>+ * {@inheritDoc}
>+ */
>+ public boolean hasWikiMacro(String documentName)
>+ {
>+ return (null !=3D wikiMacroMap.get(documentName));
>+ }
>+
>+ /**
>+ * {@inheritDoc}
>+ */
>+ @SuppressWarnings("unchecked")
>+ public void registerWikiMacro(String documentName, WikiMacro wikiMacr=
o)
>+ {
>+ DefaultComponentDescriptor<Macro> descriptor =3D new DefaultCompo=
nentDescriptor<Macro>();
>+ descriptor.setRole(Macro.class);
>+ descriptor.setRoleHint(wikiMacro.getName());
>+ try {
>+ componentManager.registerComponent(descriptor, wikiMacro);
>+ wikiMacroMap.put(documentName, descriptor);
>+ getLogger().info(
>+ String.format("Macro [%s] in [%s] successfully registered=
", wikiMacro.getName(), documentName));
>+ } catch (ComponentRepositoryException ex) {
>+ getLogger().error(
>+ String.format("Unable to register macro [%s] in [%s]", wi=
kiMacro.getName(), documentName), ex);
>+ }
>+ }
>+
>+ /**
>+ * {@inheritDoc}
>+ */
>+ @SuppressWarnings("unchecked")
>+ public void unregisterWikiMacro(String documentName)
>+ {
>+ ComponentDescriptor<Macro> macroDescriptor =3D wikiMacroMap.get(d=
ocumentName);
>+ componentManager.unregisterComponent(macroDescriptor.getRole(), m=
acroDescriptor.getRoleHint());
>+ wikiMacroMap.remove(documentName);
>+ getLogger()
>+ .info(
>+ String.format("Macro [%s] in [%s] successfully de-registe=
red", macroDescriptor.getRoleHint(),
>+ documentName));
>+ }
>+}
>
>Added: platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-re=
ndering-macro-wikibridge/src/main/java/org/xwiki/rendering/internal/macro/w=
ikibridge/WikiMacroEventListener.java
>--- platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rende=
ring-macro-wikibridge/src/main/java/org/xwiki/rendering/internal/macro/wiki=
bridge/WikiMacroEventListener.java (rev 0)
>+++ platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rende=
ring-macro-wikibridge/src/main/java/org/xwiki/rendering/internal/macro/wiki=
bridge/WikiMacroEventListener.java 2009-07-15 18:57:45 UTC (rev 21967)
>@@ -0,0 +1,141 @@
>+/*
>+ * See the NOTICE file distributed with this work for additional
>+ * information regarding copyright ownership.
>+ *
>+ * This is free software; you can redistribute it and/or modify it
>+ * under the terms of the GNU Lesser General Public License as
>+ * published by the Free Software Foundation; either version 2.1 of
>+ * the License, or (at your option) any later version.
>+ *
>+ * This software is distributed in the hope that it will be useful,
>+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
>+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>+ * Lesser General Public License for more details.
>+ *
>+ * You should have received a copy of the GNU Lesser General Public
>+ * License along with this software; if not, write to the Free
>+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
>+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
>+ */
>+
>+package org.xwiki.rendering.internal.macro.wikibridge;
>+
>+import java.util.ArrayList;
>+import java.util.List;
>+
>+import org.xwiki.bridge.DocumentAccessBridge;
>+import org.xwiki.component.annotation.Component;
>+import org.xwiki.component.annotation.Requirement;
>+import org.xwiki.component.logging.AbstractLogEnabled;
>+import org.xwiki.observation.EventListener;
>+import org.xwiki.observation.event.AbstractDocumentEvent;
>+import org.xwiki.observation.event.DocumentDeleteEvent;
>+import org.xwiki.observation.event.DocumentSaveEvent;
>+import org.xwiki.observation.event.DocumentUpdateEvent;
>+import org.xwiki.observation.event.Event;
>+import org.xwiki.rendering.macro.wikibridge.WikiMacro;
>+import org.xwiki.rendering.macro.wikibridge.WikiMacroBuilder;
>+import org.xwiki.rendering.macro.wikibridge.WikiMacroBuilderException;
>+import org.xwiki.rendering.macro.wikibridge.WikiMacroManager;
>+
>+/**
>+ * An {@link EventListener} responsible for dynamically registering / unr=
egistering / updating xwiki rendering macros
>+ * based on wiki macro create / delete / update actions.
>+ *
>+ * @version $Id$
>+ * @since 2.0M2
>+ */
>+@Component("wikimacrolistener")
>+public class WikiMacroEventListener extends AbstractLogEnabled implements=
EventListener
>+{
>+ /**
>+ * The {@link DocumentAccessBridge} component.
>+ */
>+ @Requirement
>+ private DocumentAccessBridge docBridge;
>+
>+ /**
>+ * The {@link WikiMacroBuilder} component.
>+ */
>+ @Requirement
>+ private WikiMacroBuilder macroBuilder;
>+
>+ /**
>+ * The {@link WikiMacroManager} component.
>+ */
>+ @Requirement
>+ private WikiMacroManager wikiMacroManager;
>+
>+ /**
>+ * {@inheritDoc}
>+ */
>+ public String getName()
>+ {
>+ return "wikimacrolistener";
>+ }
>+
>+ /**
>+ * {@inheritDoc}
>+ */
>+ public List<Event> getEvents()
>+ {
>+ List<Event> events =3D new ArrayList<Event>();
>+ events.add(new DocumentSaveEvent());
>+ events.add(new DocumentUpdateEvent());
>+ events.add(new DocumentDeleteEvent());
>+ return events;
>+ }
>+
>+ /**
>+ * {@inheritDoc}
>+ */
>+ public void onEvent(Event event, Object source, Object data)
>+ {
>+ if (event instanceof AbstractDocumentEvent) {
>+ // TODO: This approach towards extracting the document name d=
oesn't look right. But we cannot use
>+ // 'source' parameter without depending on xwiki-core. This m=
ust be fixed.
XWikiDocument implements DocumentModelBridge which mean source is also
a DocumentModelBridge, so yes you can access everything in
DocumentModelBridge api (which among other things mean the document
name)
>+ String documentName =3D ((AbstractDocumentEvent) event).getEv=
entFilter().getFilter();
>+
>+ // TODO: This needs to be discussed.
>+ if (!documentName.startsWith("xwiki:")) {
>+ getLogger().error("Wiki macro registration from virtual w=
ikis are not allowed");
>+ return;
>+ }
>+
>+ if (event instanceof DocumentSaveEvent || event instanceof Do=
cumentUpdateEvent) {
>+ // Unregister any existing macro registered under this do=
cument.
>+ if (wikiMacroManager.hasWikiMacro(documentName)) {
>+ wikiMacroManager.unregisterWikiMacro(documentName);
>+ }
>+
>+ // Check whether the given document has a wiki macro defi=
ned in it.
>+ String macroName =3D
>+ (String) docBridge.getProperty(documentName, WikiMacr=
oBuilder.WIKI_MACRO_CLASS, 0,
>+ WikiMacroBuilder.MACRO_NAME_PROPERTY);
>+
>+ if (null !=3D macroName) {
>+ // Attempt to build a wiki macro.
>+ WikiMacro wikiMacro =3D null;
>+ try {
>+ wikiMacro =3D macroBuilder.buildMacro(documentNam=
e);
>+ } catch (WikiMacroBuilderException ex) {
>+ getLogger().error(ex.getMessage());
>+ return;
>+ }
>+
>+ // Check if the user has programming rights before co=
ntinuing further.
>+ if (!docBridge.hasProgrammingRights()) {
>+ String errorMessage =3D "Unable to register macro=
[%s] due to insufficient privileges";
>+ getLogger().error(String.format(errorMessage, wik=
iMacro.getName()));
>+ return;
>+ }
>+
>+ // Register macro.
>+ wikiMacroManager.registerWikiMacro(documentName, wiki=
Macro);
>+ }
>+ } else if (event instanceof DocumentDeleteEvent && wikiMacroM=
anager.hasWikiMacro(documentName)) {
>+ wikiMacroManager.unregisterWikiMacro(documentName);
>+ }
>+ }
>+ }
>+}
>
>Added: platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-re=
ndering-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/wikibridge=
/WikiMacro.java
>--- platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rende=
ring-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/wikibridge/Wi=
kiMacro.java (rev 0)
>+++ platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rende=
ring-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/wikibridge/Wi=
kiMacro.java 2009-07-15 18:57:45 UTC (rev 21967)
>@@ -0,0 +1,242 @@
>+/*
>+ * See the NOTICE file distributed with this work for additional
>+ * information regarding copyright ownership.
>+ *
>+ * This is free software; you can redistribute it and/or modify it
>+ * under the terms of the GNU Lesser General Public License as
>+ * published by the Free Software Foundation; either version 2.1 of
>+ * the License, or (at your option) any later version.
>+ *
>+ * This software is distributed in the hope that it will be useful,
>+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
>+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>+ * Lesser General Public License for more details.
>+ *
>+ * You should have received a copy of the GNU Lesser General Public
>+ * License along with this software; if not, write to the Free
>+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
>+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
>+ */
>+
>+package org.xwiki.rendering.macro.wikibridge;
>+
>+import java.io.StringReader;
>+import java.util.HashMap;
>+import java.util.List;
>+import java.util.Map;
>+
>+import org.xwiki.component.manager.ComponentLookupException;
>+import org.xwiki.component.manager.ComponentManager;
>+import org.xwiki.context.Execution;
>+import org.xwiki.rendering.block.Block;
>+import org.xwiki.rendering.block.XDOM;
>+import org.xwiki.rendering.macro.Macro;
>+import org.xwiki.rendering.macro.MacroExecutionException;
>+import org.xwiki.rendering.macro.descriptor.MacroDescriptor;
>+import org.xwiki.rendering.macro.descriptor.ParameterDescriptor;
>+import org.xwiki.rendering.macro.parameter.MacroParameterException;
>+import org.xwiki.rendering.parser.ParseException;
>+import org.xwiki.rendering.parser.Parser;
>+import org.xwiki.rendering.parser.SyntaxFactory;
>+import org.xwiki.rendering.transformation.MacroTransformationContext;
>+import org.xwiki.rendering.transformation.Transformation;
>+import org.xwiki.rendering.util.ParserUtils;
>+
>+/**
>+ * A generic macro that parses content in a given syntax. The actual cont=
ent to be parsed is injected and the content
>+ * received when executing the macro is ignored This macro is meant to be=
registered dynamically against the component
>+ * manager, to allow its content definition outside java code itself (ret=
rieved from the Wiki for example).
>+ *
>+ * @version $Id$
>+ * @since 2.0M1
>+ */
>+public class WikiMacro implements Macro<WikiMacroParameters>
>+{
>+ /**
>+ * The key under which macro context will be available in the XwikiCo=
ntext for scripts.
>+ */
>+ private static final String MACRO_KEY =3D "macro";
>+
>+ /**
>+ * Macro hint for {@link Transformation} component.
>+ *
>+ * Same as MACRO_KEY (Check style fix)
>+ */
>+ private static final String MACRO_HINT =3D MACRO_KEY;
>+
>+ /**
>+ * The key under which macro body will be available inside macro cont=
ext.
>+ */
>+ private static final String MACRO_CONTENT_KEY =3D "content";
>+
>+ /**
>+ * The key under which macro parameters will be available inside macr=
o context.
>+ */
>+ private static final String MACRO_PARAMS_KEY =3D "params";
>+
>+ /**
>+ * The key under which macro transformation context will be available=
inside macro context.
>+ */
>+ private static final String MACRO_CONTEXT_KEY =3D "context";
>+
>+ /**
>+ * The {@link MacroDescriptor} for this macro.
>+ */
>+ private MacroDescriptor descriptor;
>+
>+ /**
>+ * Name of this macro.
>+ */
>+ private String macroName;
>+
>+ /**
>+ * Macro content.
>+ */
>+ private String content;
>+
>+ /**
>+ * Syntax id.
>+ */
>+ private String syntaxId;
>+
>+ /**
>+ * The component manager used to lookup other components.
>+ */
>+ private ComponentManager componentManager;
>+
>+ /**
>+ * Used to clean result of the parser syntax.
>+ */
>+ private ParserUtils parserUtils;
>+
>+ /**
>+ * Constructs a new {@link WikiMacro}.
>+ *
>+ * @param macroName name of the macro.
>+ * @param descriptor the {@link MacroDescriptor} describing this macr=
o.
>+ * @param macroContent macro content to be evaluated.
>+ * @param syntaxId syntax of the macroContent.
>+ * @param componentManager {@link ComponentManager} component used to=
look up for other components.
>+ */
>+ public WikiMacro(String macroName, MacroDescriptor descriptor, String=
macroContent, String syntaxId,
>+ ComponentManager componentManager)
>+ {
>+ this.macroName =3D macroName;
>+ this.descriptor =3D descriptor;
>+ this.content =3D macroContent;
>+ this.syntaxId =3D syntaxId;
>+ this.parserUtils =3D new ParserUtils();
>+ this.componentManager =3D componentManager;
>+ }
>+
>+ /**
>+ * {@inheritDoc}
>+ *
>+ * @see org.xwiki.rendering.macro.Macro#execute(Object, String, Macro=
TransformationContext)
>+ */
>+ @SuppressWarnings("unchecked")
>+ public List<Block> execute(WikiMacroParameters parameters, String mac=
roContent, MacroTransformationContext context)
>+ throws MacroExecutionException
>+ {
>+ // First verify that all mandatory parameters are provided.
>+ Map<String, ParameterDescriptor> parameterDescriptors =3D getDesc=
riptor().getParameterDescriptorMap();
>+ for (String parameterName : parameterDescriptors.keySet()) {
>+ ParameterDescriptor parameterDescriptor =3D parameterDescript=
ors.get(parameterName);
>+ if (parameterDescriptor.isMandatory() && (null =3D=3D paramet=
ers.get(parameterName))) {
>+ throw new MacroParameterException(String.format("Paramete=
r [%s] is mandatory", parameterName));
>+ }
>+ }
>+
>+ // Next, make sure no extra parameters are provided other than th=
ose defined by the macro.
>+ // Question: Do we need this check?
>+ for (String parameterName : parameters.getParameterNames()) {
>+ if (null =3D=3D parameterDescriptors.get(parameterName)) {
>+ throw new MacroParameterException(String.format("Unknown =
parameter : [%s]", parameterName));
>+ }
>+ }
>+
>+ // Parse the wiki macro content.
>+ XDOM xdom =3D null;
>+ try {
>+ Parser parser =3D componentManager.lookup(Parser.class, synta=
xId);
>+ xdom =3D parser.parse(new StringReader(this.content));
>+ } catch (ComponentLookupException ex) {
>+ throw new MacroExecutionException("Could not find a parser fo=
r macro content", ex);
>+ } catch (ParseException ex) {
>+ throw new MacroExecutionException("Error while parsing macro =
content", ex);
>+ }
>+
>+ // Set macro context inside XWikiContext.
>+ Map<String, Object> macroContext =3D new HashMap<String, Object>(=
);
>+ macroContext.put(MACRO_PARAMS_KEY, parameters);
>+ macroContext.put(MACRO_CONTENT_KEY, macroContent);
>+ macroContext.put(MACRO_CONTEXT_KEY, context);
>+ try {
>+ Execution execution =3D componentManager.lookup(Execution.cla=
ss);
>+ Map xwikiContext =3D (Map) execution.getContext().getProperty=
("xwikicontext");
>+ xwikiContext.put(MACRO_KEY, macroContext);
>+ } catch (ComponentLookupException ex) {
>+ throw new MacroExecutionException("Error while injecting macr=
o parameters", ex);
>+ }
>+
>+ // Perform internal macro transformations.
>+ try {
>+ SyntaxFactory syntaxFactory =3D componentManager.lookup(Synta=
xFactory.class);
>+ Transformation macroTransformation =3D componentManager.looku=
p(Transformation.class, MACRO_HINT);
>+ macroTransformation.transform(xdom, syntaxFactory.createSynta=
xFromIdString(syntaxId));
>+ } catch (Exception ex) {
>+ throw new MacroExecutionException("Error while performing int=
ernal macro transformations", ex);
>+ }
>+
>+ List<Block> result =3D xdom.getChildren();
>+ // If in inline mode remove any top level paragraph.
>+ if (context.isInline()) {
>+ this.parserUtils.removeTopLevelParagraph(result);
>+ }
>+
>+ return result;
>+ }
Did you take care of make sure the macro is executed with programming
rights ? As far as i can see in your code the document from where the
macro is called need to be be saved with programming right for the
macro to be executed with programming right so this will not work for
a normal user.
Note: programming right is working this way: first the author of
context document is tested for programming right, if there is no
context document then the context user is tested for programming
right. In your case i would say the best is to put the macro's
document as context document when before executing it so you have to
remember the document or at least its name in WikiMacro (which btw
even without this need would be logical).
>+
>+ /**
>+ * {@inheritDoc}
>+ */
>+ public MacroDescriptor getDescriptor()
>+ {
>+ return this.descriptor;
>+ }
>+
>+ /**
>+ * {@inheritDoc}
>+ */
>+ public int getPriority()
>+ {
>+ return 1000;
>+ }
>+
>+ /**
>+ * @return the name of this wiki macro.
>+ */
>+ public String getName()
>+ {
>+ return this.macroName;
>+ }
>+
>+ /**
>+ * {@inheritDoc}
>+ */
>+ public int compareTo(Macro< ? > macro)
>+ {
>+ if (getPriority() !=3D macro.getPriority()) {
>+ return getPriority() - macro.getPriority();
>+ }
>+ return this.getClass().getSimpleName().compareTo(macro.getClass()=
.getSimpleName());
>+ }
>+
>+ /**
>+ * {@inheritDoc}
>+ */
>+ public boolean supportsInlineMode()
>+ {
>+ return true;
>+ }
>+}
>
>Added: platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-re=
ndering-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/wikibridge=
/WikiMacroBuilder.java
>--- platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rende=
ring-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/wikibridge/Wi=
kiMacroBuilder.java (rev 0)
>+++ platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rende=
ring-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/wikibridge/Wi=
kiMacroBuilder.java 2009-07-15 18:57:45 UTC (rev 21967)
>@@ -0,0 +1,88 @@
>+/*
>+ * See the NOTICE file distributed with this work for additional
>+ * information regarding copyright ownership.
>+ *
>+ * This is free software; you can redistribute it and/or modify it
>+ * under the terms of the GNU Lesser General Public License as
>+ * published by the Free Software Foundation; either version 2.1 of
>+ * the License, or (at your option) any later version.
>+ *
>+ * This software is distributed in the hope that it will be useful,
>+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
>+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>+ * Lesser General Public License for more details.
>+ *
>+ * You should have received a copy of the GNU Lesser General Public
>+ * License along with this software; if not, write to the Free
>+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
>+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
>+ */
>+
>+package org.xwiki.rendering.macro.wikibridge;
>+
>+import org.xwiki.component.annotation.ComponentRole;
>+
>+/**
>+ * Component interface for defining wiki macro builders.
>+ *
>+ * @version $Id$
>+ * @since 2.0M2
>+ */
>+@ComponentRole
>+public interface WikiMacroBuilder
>+{
>+ /**
>+ * Constant for representing XWiki.WikiMacroClass xwiki class.
>+ */
>+ String WIKI_MACRO_CLASS =3D "XWiki.WikiMacroClass";
>+
>+ /**
>+ * Constant for representing macro name property.
>+ */
>+ String MACRO_NAME_PROPERTY =3D "name";
>+
>+ /**
>+ * Constant for representing macro name property.
>+ */
>+ String MACRO_DESCRIPTION_PROPERTY =3D "description";
>+
>+ /**
>+ * Constant for representing macro name property.
>+ */
>+ String MACRO_CONTENT_PROPERTY =3D "content";
>+
>+ /**
>+ * Constant for representing XWiki.WikiMacroParameterClass xwiki clas=
s.
>+ */
>+ String WIKI_MACRO_PARAMETER_CLASS =3D "XWiki.WikiMacroParameterClass"=
;
>+
>+ /**
>+ * Constant for representing parameter name property.
>+ *
>+ * Same as MACRO_NAME_PROPERTY (Check style Fix)
>+ */
>+ String PARAMETER_NAME_PROPERTY =3D MACRO_NAME_PROPERTY;
>+
>+ /**
>+ * Constant for representing parameter description property.
>+ *
>+ * Same as MACRO_DESCRIPTION_PROPERTY (Check style Fix)
>+ */
>+ String PARAMETER_DESCRIPTION_PROPERTY =3D MACRO_DESCRIPTION_PROPERTY;
>+
>+ /**
>+ * Constant for representing parameter mandatory property.
>+ */
>+ String PARAMETER_MANDATORY_PROPERTY =3D "mandatory";
All this has nothing to do here, the fact that it's stored in a
document object is an implementation detail. WikiMacroBuilder user
should not know that.
>+
>+ /**
>+ * Searches the given document for a wiki macro definition and tries =
to build a {@link WikiMacro} if a definition is
>+ * found.
>+ *
>+ * @param documentName name of the document to search for wiki macros=
.
>+ * @return a {@link WikiMacro} corresponding to the macro definition =
found.
>+ * @throws WikiMacroBuilderException if no macro definition is found =
or if an error is encountered while building
>+ * the macro.
>+ */
>+ WikiMacro buildMacro(String documentName) throws WikiMacroBuilderExce=
ption;
>+}
>
[snip]
>
>Added: platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-re=
ndering-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/wikibridge=
/WikiMacroDescriptor.java
>--- platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rende=
ring-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/wikibridge/Wi=
kiMacroDescriptor.java (rev 0)
>+++ platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rende=
ring-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/wikibridge/Wi=
kiMacroDescriptor.java 2009-07-15 18:57:45 UTC (rev 21967)
>@@ -0,0 +1,98 @@
>+/*
>+ * See the NOTICE file distributed with this work for additional
>+ * information regarding copyright ownership.
>+ *
>+ * This is free software; you can redistribute it and/or modify it
>+ * under the terms of the GNU Lesser General Public License as
>+ * published by the Free Software Foundation; either version 2.1 of
>+ * the License, or (at your option) any later version.
>+ *
>+ * This software is distributed in the hope that it will be useful,
>+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
>+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>+ * Lesser General Public License for more details.
>+ *
>+ * You should have received a copy of the GNU Lesser General Public
>+ * License along with this software; if not, write to the Free
>+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
>+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
>+ */
>+package org.xwiki.rendering.macro.wikibridge;
>+
>+import java.util.HashMap;
>+import java.util.List;
>+import java.util.Map;
>+
>+import org.xwiki.rendering.macro.descriptor.ContentDescriptor;
>+import org.xwiki.rendering.macro.descriptor.DefaultContentDescriptor;
>+import org.xwiki.rendering.macro.descriptor.MacroDescriptor;
>+import org.xwiki.rendering.macro.descriptor.ParameterDescriptor;
>+
>+/**
>+ * A {@link MacroDescriptor} for describing wiki macros.
>+ *
>+ * @version $Id$
>+ * @since 2.0M2
>+ */
>+public class WikiMacroDescriptor implements MacroDescriptor
>+{
>+ /**
>+ * Macro description.
>+ */
>+ private String description;
>+
>+ /**
>+ * Parameter descriptors.
>+ */
>+ private List<WikiMacroParameterDescriptor> parameterDescriptors;
>+
>+ /**
>+ * Creates a new {@link WikiMacroDescriptor} instance.
>+ *
>+ * @param description macro description.
>+ * @param parameterDescriptors parameter descriptors.
>+ */
>+ public WikiMacroDescriptor(String description, List<WikiMacroParamete=
rDescriptor> parameterDescriptors)
>+ {
>+ this.description =3D description;
>+ this.parameterDescriptors =3D parameterDescriptors;
>+ }
>+
>+ /**
>+ * {@inheritDoc}
>+ */
>+ public String getDescription()
>+ {
>+ return this.description;
>+ }
>+
>+ /**
>+ * {@inheritDoc}
>+ */
>+ public ContentDescriptor getContentDescriptor()
>+ {
>+ return new DefaultContentDescriptor();
>+ }
>+
>+ /**
>+ * {@inheritDoc}
>+ */
>+ public Class< ? > getParametersBeanClass()
>+ {
>+ return WikiMacroParameters.class;
>+ }
>+
>+ /**
>+ * {@inheritDoc}
>+ */
>+ public Map<String, ParameterDescriptor> getParameterDescriptorMap()
>+ {
>+ Map<String, ParameterDescriptor> descriptors =3D new HashMap<Stri=
ng, ParameterDescriptor>();
>+
>+ for (WikiMacroParameterDescriptor descriptor : parameterDescripto=
rs) {
>+ descriptors.put(descriptor.getName(), descriptor);
>+ }
>+
>+ return descriptors;
>+ }
>+}
>
>Added: platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-re=
ndering-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/wikibridge=
/WikiMacroInitializer.java
>--- platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rende=
ring-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/wikibridge/Wi=
kiMacroInitializer.java (rev 0)
>+++ platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rende=
ring-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/wikibridge/Wi=
kiMacroInitializer.java 2009-07-15 18:57:45 UTC (rev 21967)
>@@ -0,0 +1,37 @@
>+/*
>+ * See the NOTICE file distributed with this work for additional
>+ * information regarding copyright ownership.
>+ *
>+ * This is free software; you can redistribute it and/or modify it
>+ * under the terms of the GNU Lesser General Public License as
>+ * published by the Free Software Foundation; either version 2.1 of
>+ * the License, or (at your option) any later version.
>+ *
>+ * This software is distributed in the hope that it will be useful,
>+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
>+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>+ * Lesser General Public License for more details.
>+ *
>+ * You should have received a copy of the GNU Lesser General Public
>+ * License along with this software; if not, write to the Free
>+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
>+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
>+ */
>+package org.xwiki.rendering.macro.wikibridge;
>+
>+import org.xwiki.component.annotation.ComponentRole;
>+
>+/**
>+ * Responsible for registering wiki macros against the ComponentManager a=
t XE startup.
>+ *
>+ * @version $Id$
>+ * @since 2.0M2
>+ */
>+@ComponentRole
>+public interface WikiMacroInitializer
>+{
>+ /**
>+ * Initializes this {@link WikiMacroInitializer}'s macros and registe=
rs them against the ComponentManager.
>+ */
>+ void init();
>+}
>
>Added: platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-re=
ndering-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/wikibridge=
/WikiMacroManager.java
>--- platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rende=
ring-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/wikibridge/Wi=
kiMacroManager.java (rev 0)
>+++ platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rende=
ring-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/wikibridge/Wi=
kiMacroManager.java 2009-07-15 18:57:45 UTC (rev 21967)
>@@ -0,0 +1,56 @@
>+/*
>+ * See the NOTICE file distributed with this work for additional
>+ * information regarding copyright ownership.
>+ *
>+ * This is free software; you can redistribute it and/or modify it
>+ * under the terms of the GNU Lesser General Public License as
>+ * published by the Free Software Foundation; either version 2.1 of
>+ * the License, or (at your option) any later version.
>+ *
>+ * This software is distributed in the hope that it will be useful,
>+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
>+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>+ * Lesser General Public License for more details.
>+ *
>+ * You should have received a copy of the GNU Lesser General Public
>+ * License along with this software; if not, write to the Free
>+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
>+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
>+ */
>+package org.xwiki.rendering.macro.wikibridge;
>+
>+import org.xwiki.component.annotation.ComponentRole;
>+
>+/**
>+ * Component interface responsible for managing wiki macro instances.
>+ *
>+ * @version $Id$
>+ * @since 2.0M2
>+ */
>+@ComponentRole
>+public interface WikiMacroManager
>+{
>+ /**
>+ * Registers the given {@link WikiMacro} against ComponentManager and=
keeps a reference to it for future reference.
>+ *
>+ * @param documentName name of the document which contains the wiki m=
acro.
>+ * @param wikiMacro the {@link WikiMacro} instance.
>+ */
>+ void registerWikiMacro(String documentName, WikiMacro wikiMacro);
>+
>+ /**
>+ * Unregisters a wiki macro defined on the given document (if there i=
s one).
>+ *
>+ * @param documentName name of the document which contains the wiki m=
acro.
>+ */
>+ void unregisterWikiMacro(String documentName);
>+
>+ /**
>+ * Utility method for querying {@link WikiMacroManager} to see if the=
re is a {@link WikiMacro} already registered
>+ * for the given document.
>+ *
>+ * @param documentName name of the document which contains the wiki m=
acro.
>+ * @return true if there is already a macro registered under the give=
nd document name.
>+ */
>+ boolean hasWikiMacro(String documentName);
>+}
>
[snip]
1
0
16 Jul '09
Hi All,
I have completed the wiki macro bridge implementation and it's almost ready
to be comitted. However there were few design decisions taken that needs to
be discussed / debated a little here.
1. wiki macro Initialization on startup
This is about searching for existing wiki macro definition documents on XE
startup and registering them as macros. As you might already know I cannot
use the ApplicationStartupEvent for this purpose because at that time the
XWikiContext is not available. This is true for any module that requires
database access on XE startup. Currently this is not possible. The real
solution for this is the new model which will be ready on XE startup. But
until we have the new model there has to be a workaround for it. We found
two solutions:
- Initialize the XWiki on XE startup: Thomas says that this can be done by
implementing ApplicationContextListener and making few changes to
XWiki.initXWiki() method.
- Have a WikiMacroInitializer component which will be invoked at the end of
XWiki.initXWiki() method, like below:
<code>
// Initialize all wiki macros
try {
WikiMacroInitializer wikiMacroInitializer =
Utils.getComponentManager().lookup(WikiMacroInitializer.class);
wikiMacroInitializer.init();
} catch (ComponentLookupException ex) {
LOG.error("Error while initializing wiki macros", ex);
}
</code>
I went with the second approach because: It works, easy to implement, and we
have 2.0M2 due today or tomorrow. The approach thomas suggested sounds much
better than the approach I've taken but we don't know what problems it might
pose and I don't know whether I have enough time to implement it. May be we
can have it for 2.0M3.
2. wiki macros and virtual wikis
There is a problem with supporting wiki macros comming from multiple wikis
in a wiki farm. If a particular wiki is initialized at some point in time,
it could introduce a bunch of new macros all of a sudden and it might also
override some existing macros. For this reason we have restricted wiki
macros only for the main wiki, if you need to create a wiki macro it has to
be on the main wiki and you have to save it with programming rights. Note
however that this doesn't solve the overriding issue, an admin could easily
override an existing macro by defining a wiki macro with the same name, we
do not have any protection for this yet. Should we do something about it?
3. wiki macro parameter binding
It would be nice to define a wiki macro parameter named "param1" and refer
to it inside a script as $param1. We can do this easily but this allows wiki
macro authors to override default parameters like $xwiki, $context etc. So
the approach we took is to bind the parameters through the XWikiContext.
For an example, to refer macro parameters a wiki macro author will have to
say:
$context.macro.params.param1
-To acces macro content (body):
$context.macro.content
To access MacroTransformationContext:
$context.macro.context
So these are the design decisions we took during the development of the wiki
macro bridge. Please let us know what you think. We might not be able to
implement any big changes for 2.0M2 but we will be able to do it for 2.0M3,
otherwise we will have to delay wiki macro bridge till 2.0M3 ;(
Thanks.
- Asiri
2
3
Hi devs,
I have completed wiki macro bridge implementation but there are few things
that needs to be done inorder to commit it.
1. xwiki-properties module currently under sandbox (
http://svn.xwiki.org/svnroot/xwiki/sandbox/xwiki-core-properties/) need to
be moved into /platform/core/trunk/xwiki-properties
2. Need to commit the xwiki-application-wiki-macro-bridge under
/platform/xwiki-applications/trunk/wiki-macro-bridge. This application hosts
XWiki.WikiMacroClass and XWiki.WikiMacroParameterClass documents. For 2.0M3
we will remove this application and add initialization code that will
generate these two pages automatically.
3. Commit xwiki-core-rendering-macro-wikibridge under
/platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-wikibridge
4. Make necessary dependancy changes so that XE will bundled with wiki-macro
support by default.
Here is my +1 for all of above.
Note that this is a quite large commit (had to refactor macros to use
xwiki-properties), there might be few places where my code can be improved.
Any comments are welcome.
Thanks.
- Asiri
4
5
Re: [xwiki-devs] [xwiki-notifications] r21967 - enterprise/trunk enterprise/trunk/wiki platform/core/trunk platform/core/trunk/xwiki-core platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki platform/core/trunk/xwiki-core/src/main/java/com/xpn/
by Asiri Rathnayake 15 Jul '09
by Asiri Rathnayake 15 Jul '09
15 Jul '09
Hi,
On Thu, Jul 16, 2009 at 12:44 AM, Vincent Massol <vincent(a)massol.net> wrote:
> Hi Asiri,
>
> Good that there are progress on this!
>
> However I think you shouldn't have committed all this at once. There
> are several separate things in this huge commit. This makes it hard to
> review and errors may not be detected.
>
> I see at least 3 commits:
> - the xwiki-properties stuff
> - the wikibridge module
> - the wikibridge app
>
Yup, I already paid the price. I have forgotten a pom file :(
Thanks.
- Asiri
>
> What's done is done. Just some thoughts for the future. The release of
> 2.0M2 was 2 days ago and I'm back at work only next week so I won't
> have the time to review your patch unfortunately for 2.0M2. I hope
> someone will have the time to do so. And test it too.
>
> Thanks
> -Vincent
>
> On Jul 15, 2009, at 8:57 PM, asiri (SVN) wrote:
>
> > Author: asiri
> > Date: 2009-07-15 20:57:45 +0200 (Wed, 15 Jul 2009)
> > New Revision: 21967
> >
> > Added:
> > platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/
> > internal/DefaultWikiMacroBuilder.java
> > platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/
> > internal/DefaultWikiMacroInitializer.java
> > platform/core/trunk/xwiki-properties/
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/pom.xml
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/main/
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/main/java/
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/main/java/org/
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/main/java/org/xwiki/
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/internal/
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/
> > internal/macro/
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/
> > internal/macro/wikibridge/
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/
> > internal/macro/wikibridge/DefaultWikiMacroManager.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/
> > internal/macro/wikibridge/WikiMacroEventListener.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/
> > wikibridge/
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/
> > wikibridge/WikiMacro.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/
> > wikibridge/WikiMacroBuilder.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/
> > wikibridge/WikiMacroBuilderException.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/
> > wikibridge/WikiMacroDescriptor.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/
> > wikibridge/WikiMacroInitializer.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/
> > wikibridge/WikiMacroManager.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/
> > wikibridge/WikiMacroParameterDescriptor.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/
> > wikibridge/WikiMacroParameters.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/main/resources/
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/main/resources/META-INF/
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/main/resources/META-INF/components.txt
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/test/
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/test/java/
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/test/java/org/
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/test/java/org/xwiki/
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/test/java/org/xwiki/rendering/
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/test/java/org/xwiki/rendering/
> > RenderingTests.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/test/java/org/xwiki/rendering/internal/
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/test/java/org/xwiki/rendering/
> > internal/macro/
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/test/java/org/xwiki/rendering/
> > internal/macro/wikibridge/
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/test/java/org/xwiki/rendering/
> > internal/macro/wikibridge/MockWikiMacro.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/test/java/org/xwiki/rendering/macro/
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/test/java/org/xwiki/rendering/macro/
> > wikibridge/
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/test/java/org/xwiki/rendering/macro/
> > wikibridge/DefaultWikiMacroManagerTest.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/test/resources/
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/test/resources/META-INF/
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/test/resources/META-INF/components.txt
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-wikibridge/src/test/resources/wikimacro1.test
> > platform/xwiki-applications/trunk/wiki-macro-bridge/
> > platform/xwiki-applications/trunk/wiki-macro-bridge/src/
> > platform/xwiki-applications/trunk/wiki-macro-bridge/src/main/
> > platform/xwiki-applications/trunk/wiki-macro-bridge/src/main/
> > resources/
> > platform/xwiki-applications/trunk/wiki-macro-bridge/src/main/
> > resources/XWiki/
> > platform/xwiki-applications/trunk/wiki-macro-bridge/src/main/
> > resources/XWiki/WikiMacroClass.xml
> > platform/xwiki-applications/trunk/wiki-macro-bridge/src/main/
> > resources/XWiki/WikiMacroParameterClass.xml
> > Removed:
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/
> > java/org/xwiki/rendering/internal/util/ColorConverter.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/
> > java/org/xwiki/rendering/internal/util/EnumConverter.java
> > sandbox/xwiki-core-properties/
> > Modified:
> > enterprise/trunk/pom.xml
> > enterprise/trunk/wiki/pom.xml
> > platform/core/trunk/pom.xml
> > platform/core/trunk/xwiki-core/pom.xml
> > platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/
> > XWiki.java
> > platform/core/trunk/xwiki-core/src/main/resources/META-INF/
> > components.txt
> > platform/core/trunk/xwiki-core/src/test/java/com/xpn/xwiki/doc/
> > XWikiDocumentRenderingTest.java
> > platform/core/trunk/xwiki-core/src/test/java/com/xpn/xwiki/doc/
> > XWikiDocumentTest.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-api/pom.xml
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/
> > java/org/xwiki/rendering/block/AbstractBlock.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/
> > java/org/xwiki/rendering/internal/macro/DefaultMacroManager.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/
> > java/org/xwiki/rendering/internal/transformation/
> > MacroTransformation.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/
> > java/org/xwiki/rendering/macro/AbstractMacro.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/
> > java/org/xwiki/rendering/macro/AbstractNoParameterMacro.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/
> > java/org/xwiki/rendering/macro/descriptor/AbstractMacroDescriptor.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/
> > java/org/xwiki/rendering/macro/descriptor/DefaultMacroDescriptor.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/
> > java/org/xwiki/rendering/macro/descriptor/
> > DefaultParameterDescriptor.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/test/
> > java/org/xwiki/rendering/internal/macro/DefaultMacroManagerTest.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/test/
> > java/org/xwiki/rendering/macro/descriptor/
> > DefaultMacroDescriptorTest.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/pom.xml
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-box/src/main/java/org/xwiki/rendering/internal/macro/
> > box/DefaultBoxMacro.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-box/src/main/java/org/xwiki/rendering/macro/box/
> > AbstractBoxMacro.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-box/src/test/java/org/xwiki/rendering/macro/box/
> > TestBoxMacro.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-chart/src/main/java/org/xwiki/rendering/internal/
> > macro/chart/ChartMacro.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-code/src/main/java/org/xwiki/rendering/internal/
> > macro/code/CodeMacro.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-footnotes/
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-footnotes/src/main/java/org/xwiki/rendering/internal/
> > macro/footnote/FootnoteMacro.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-footnotes/src/main/java/org/xwiki/rendering/internal/
> > macro/footnote/PutFootnotesMacro.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-html/src/main/java/org/xwiki/rendering/internal/
> > macro/html/HTMLMacro.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-id/src/main/java/org/xwiki/rendering/internal/macro/
> > id/IdMacro.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-include/src/main/java/org/xwiki/rendering/internal/
> > macro/include/IncludeMacro.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-message/src/main/java/org/xwiki/rendering/internal/
> > macro/message/MessageMacro.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-rss/src/main/java/org/xwiki/rendering/internal/macro/
> > rss/RssMacro.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-script/src/main/java/org/xwiki/rendering/internal/
> > macro/script/DefaultScriptMacro.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-script/src/main/java/org/xwiki/rendering/macro/
> > script/AbstractJRSR223ScriptMacro.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-script/src/main/java/org/xwiki/rendering/macro/
> > script/AbstractScriptMacro.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-toc/src/main/java/org/xwiki/rendering/internal/macro/
> > toc/TocMacro.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-useravatar/src/main/java/org/xwiki/rendering/
> > internal/macro/useravatar/UserAvatarMacro.java
> > platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> > rendering-macro-velocity/src/main/java/org/xwiki/rendering/internal/
> > macro/velocity/VelocityMacro.java
> > platform/web/trunk/standard/pom.xml
> > platform/xwiki-applications/trunk/pom.xml
> > Log:
> > XWIKI-3171: Replace direct call to beanutil/convertutil with our own
> > BeanManager component
> > XWIKI-3213: Support creating wiki content based rendering macros
> >
> > * Implemented above feature (XWIKI-3213)
> >
> > * Please note that this is a huge patch (my biggest commit I think).
> > I might have done some mistakes so it could use some reviewing.
>
> _______________________________________________
> devs mailing list
> devs(a)xwiki.org
> http://lists.xwiki.org/mailman/listinfo/devs
>
1
0
Hi Asiri,
Good that there are progress on this!
However I think you shouldn't have committed all this at once. There
are several separate things in this huge commit. This makes it hard to
review and errors may not be detected.
I see at least 3 commits:
- the xwiki-properties stuff
- the wikibridge module
- the wikibridge app
What's done is done. Just some thoughts for the future. The release of
2.0M2 was 2 days ago and I'm back at work only next week so I won't
have the time to review your patch unfortunately for 2.0M2. I hope
someone will have the time to do so. And test it too.
Thanks
-Vincent
On Jul 15, 2009, at 8:57 PM, asiri (SVN) wrote:
> Author: asiri
> Date: 2009-07-15 20:57:45 +0200 (Wed, 15 Jul 2009)
> New Revision: 21967
>
> Added:
> platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/
> internal/DefaultWikiMacroBuilder.java
> platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/
> internal/DefaultWikiMacroInitializer.java
> platform/core/trunk/xwiki-properties/
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/pom.xml
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/main/
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/main/java/
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/main/java/org/
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/main/java/org/xwiki/
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/internal/
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/
> internal/macro/
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/
> internal/macro/wikibridge/
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/
> internal/macro/wikibridge/DefaultWikiMacroManager.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/
> internal/macro/wikibridge/WikiMacroEventListener.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/
> wikibridge/
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/
> wikibridge/WikiMacro.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/
> wikibridge/WikiMacroBuilder.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/
> wikibridge/WikiMacroBuilderException.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/
> wikibridge/WikiMacroDescriptor.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/
> wikibridge/WikiMacroInitializer.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/
> wikibridge/WikiMacroManager.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/
> wikibridge/WikiMacroParameterDescriptor.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/main/java/org/xwiki/rendering/macro/
> wikibridge/WikiMacroParameters.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/main/resources/
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/main/resources/META-INF/
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/main/resources/META-INF/components.txt
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/test/
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/test/java/
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/test/java/org/
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/test/java/org/xwiki/
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/test/java/org/xwiki/rendering/
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/test/java/org/xwiki/rendering/
> RenderingTests.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/test/java/org/xwiki/rendering/internal/
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/test/java/org/xwiki/rendering/
> internal/macro/
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/test/java/org/xwiki/rendering/
> internal/macro/wikibridge/
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/test/java/org/xwiki/rendering/
> internal/macro/wikibridge/MockWikiMacro.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/test/java/org/xwiki/rendering/macro/
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/test/java/org/xwiki/rendering/macro/
> wikibridge/
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/test/java/org/xwiki/rendering/macro/
> wikibridge/DefaultWikiMacroManagerTest.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/test/resources/
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/test/resources/META-INF/
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/test/resources/META-INF/components.txt
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-wikibridge/src/test/resources/wikimacro1.test
> platform/xwiki-applications/trunk/wiki-macro-bridge/
> platform/xwiki-applications/trunk/wiki-macro-bridge/src/
> platform/xwiki-applications/trunk/wiki-macro-bridge/src/main/
> platform/xwiki-applications/trunk/wiki-macro-bridge/src/main/
> resources/
> platform/xwiki-applications/trunk/wiki-macro-bridge/src/main/
> resources/XWiki/
> platform/xwiki-applications/trunk/wiki-macro-bridge/src/main/
> resources/XWiki/WikiMacroClass.xml
> platform/xwiki-applications/trunk/wiki-macro-bridge/src/main/
> resources/XWiki/WikiMacroParameterClass.xml
> Removed:
> platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/
> java/org/xwiki/rendering/internal/util/ColorConverter.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/
> java/org/xwiki/rendering/internal/util/EnumConverter.java
> sandbox/xwiki-core-properties/
> Modified:
> enterprise/trunk/pom.xml
> enterprise/trunk/wiki/pom.xml
> platform/core/trunk/pom.xml
> platform/core/trunk/xwiki-core/pom.xml
> platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/
> XWiki.java
> platform/core/trunk/xwiki-core/src/main/resources/META-INF/
> components.txt
> platform/core/trunk/xwiki-core/src/test/java/com/xpn/xwiki/doc/
> XWikiDocumentRenderingTest.java
> platform/core/trunk/xwiki-core/src/test/java/com/xpn/xwiki/doc/
> XWikiDocumentTest.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-api/pom.xml
> platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/
> java/org/xwiki/rendering/block/AbstractBlock.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/
> java/org/xwiki/rendering/internal/macro/DefaultMacroManager.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/
> java/org/xwiki/rendering/internal/transformation/
> MacroTransformation.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/
> java/org/xwiki/rendering/macro/AbstractMacro.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/
> java/org/xwiki/rendering/macro/AbstractNoParameterMacro.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/
> java/org/xwiki/rendering/macro/descriptor/AbstractMacroDescriptor.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/
> java/org/xwiki/rendering/macro/descriptor/DefaultMacroDescriptor.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/
> java/org/xwiki/rendering/macro/descriptor/
> DefaultParameterDescriptor.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/test/
> java/org/xwiki/rendering/internal/macro/DefaultMacroManagerTest.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/test/
> java/org/xwiki/rendering/macro/descriptor/
> DefaultMacroDescriptorTest.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/pom.xml
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-box/src/main/java/org/xwiki/rendering/internal/macro/
> box/DefaultBoxMacro.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-box/src/main/java/org/xwiki/rendering/macro/box/
> AbstractBoxMacro.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-box/src/test/java/org/xwiki/rendering/macro/box/
> TestBoxMacro.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-chart/src/main/java/org/xwiki/rendering/internal/
> macro/chart/ChartMacro.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-code/src/main/java/org/xwiki/rendering/internal/
> macro/code/CodeMacro.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-footnotes/
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-footnotes/src/main/java/org/xwiki/rendering/internal/
> macro/footnote/FootnoteMacro.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-footnotes/src/main/java/org/xwiki/rendering/internal/
> macro/footnote/PutFootnotesMacro.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-html/src/main/java/org/xwiki/rendering/internal/
> macro/html/HTMLMacro.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-id/src/main/java/org/xwiki/rendering/internal/macro/
> id/IdMacro.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-include/src/main/java/org/xwiki/rendering/internal/
> macro/include/IncludeMacro.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-message/src/main/java/org/xwiki/rendering/internal/
> macro/message/MessageMacro.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-rss/src/main/java/org/xwiki/rendering/internal/macro/
> rss/RssMacro.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-script/src/main/java/org/xwiki/rendering/internal/
> macro/script/DefaultScriptMacro.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-script/src/main/java/org/xwiki/rendering/macro/
> script/AbstractJRSR223ScriptMacro.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-script/src/main/java/org/xwiki/rendering/macro/
> script/AbstractScriptMacro.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-toc/src/main/java/org/xwiki/rendering/internal/macro/
> toc/TocMacro.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-useravatar/src/main/java/org/xwiki/rendering/
> internal/macro/useravatar/UserAvatarMacro.java
> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
> rendering-macro-velocity/src/main/java/org/xwiki/rendering/internal/
> macro/velocity/VelocityMacro.java
> platform/web/trunk/standard/pom.xml
> platform/xwiki-applications/trunk/pom.xml
> Log:
> XWIKI-3171: Replace direct call to beanutil/convertutil with our own
> BeanManager component
> XWIKI-3213: Support creating wiki content based rendering macros
>
> * Implemented above feature (XWIKI-3213)
>
> * Please note that this is a huge patch (my biggest commit I think).
> I might have done some mistakes so it could use some reviewing.
1
0
Hello everyone,
I was looking forward to use the live table component, but it seems that you can only use it with Xwiki 1.9. I have xwiki 1.8, and I was wondering if it is possible to import only this component, instead of having the overhead of updating all xwiki just to use this component.
So, is it possible to import/install this component in version 1.8? If it is, how can I do it?
Thanks in advance!
BR,
Roney Castro
Business Efficiency Trainee
Gemalto
Tel: +55 11 5105-7670 - +55 11 7535-4135
Fax: +55 11 5105-7600
Av. das Nações Unidas, 12495, 8º Andar
05425-070 - São Paulo - SP - Brasil
roney.castro(a)gemalto.com<mailto:[email protected]>
www.gemalto.com<http://www.gemalto.com>
[cid:[email protected]]
2
2
Re: [xwiki-devs] [xwiki-notifications] r21952 - in platform/core/trunk: xwiki-component/xwiki-component-api/src/main/java/org/xwiki/component/manager xwiki-component/xwiki-component-default xwiki-component/xwiki-component-default/src/main/java/org/xw
by Thomas Mortagne 15 Jul '09
by Thomas Mortagne 15 Jul '09
15 Jul '09
On Wed, Jul 15, 2009 at 15:48, Vincent Massol<vincent(a)massol.net> wrote:
>
> On Jul 15, 2009, at 2:57 PM, tmortagne (SVN) wrote:
>
>> Author: tmortagne
>> Date: 2009-07-15 14:57:40 +0200 (Wed, 15 Jul 2009)
>> New Revision: 21952
>>
>> Added:
>> platform/core/trunk/xwiki-component/xwiki-component-
>> default/.checkstyle
>> Modified:
>> platform/core/trunk/xwiki-component/xwiki-component-api/src/main/
>> java/org/xwiki/component/manager/ComponentEventManager.java
>> platform/core/trunk/xwiki-component/xwiki-component-api/src/main/
>> java/org/xwiki/component/manager/ComponentManager.java
>> platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/embed/EmbeddableComponentManager.java
>> platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/internal/RoleHint.java
>> platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/manager/
>> AbstractComponentDescriptorEvent.java
>> platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/manager/
>> ComponentDescriptorAddedEvent.java
>> platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/manager/
>> ComponentDescriptorRemovedEvent.java
>> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-include/src/test/java/org/xwiki/rendering/internal/
>> macro/IncludeMacroTest.java
>> Log:
>> XWIKI-4077: Component Manager should generate event when the
>> component is registered instead of initialized
>> XWIKI-4081: Add way to unregister component
>> XWIKI-4082: Add way to directly provide the component instance when
>> register it
>> * fixed some wrong javadoc/codestyle
>> * put back test on Class name instead of reference inside embedded
>> CM implementation
>
> [snip]
>
>> Added: platform/core/trunk/xwiki-component/xwiki-component-
>> default/.checkstyle
>> ===================================================================
>> --- platform/core/trunk/xwiki-component/xwiki-component-
>> default/.checkstyle (rev 0)
>> +++ platform/core/trunk/xwiki-component/xwiki-component-
>> default/.checkstyle 2009-07-15 12:57:40 UTC (rev 21952)
>> @@ -0,0 +1,7 @@
>> +<?xml version="1.0" encoding="UTF-8"?>
>> +
>> +<fileset-config file-format-version="1.2.0" simple-config="true">
>> + <fileset name="all" enabled="true" check-config-name="xwiki"
>> local="false">
>> + <file-match-pattern match-pattern="." include-pattern="true"/>
>> + </fileset>
>> +</fileset-config>
>
> it's back, hehe ;)
crap i did exactly the same mistake and forgot to pout it as ignore.
Would be greate to have to "put this as ignore instead of versionned".
>
> -Vincent
> _______________________________________________
> devs mailing list
> devs(a)xwiki.org
> http://lists.xwiki.org/mailman/listinfo/devs
>
--
Thomas Mortagne
1
0
Re: [xwiki-devs] [xwiki-notifications] r21953 - in platform/web/trunk: . standard/src/main/webapp/templates
by Vincent Massol 15 Jul '09
by Vincent Massol 15 Jul '09
15 Jul '09
On Jul 15, 2009, at 3:32 PM, mflorea (SVN) wrote:
> Author: mflorea
> Date: 2009-07-15 15:32:17 +0200 (Wed, 15 Jul 2009)
> New Revision: 21953
>
> Modified:
> platform/web/trunk/pom.xml
> platform/web/trunk/standard/src/main/webapp/templates/macros.vm
> platform/web/trunk/standard/src/main/webapp/templates/
> wysiwyginput.vm
> Log:
> XWIKI-4090: Upgrade to GWT 1.6.4
> * Renamed GWT module from "com.xpn.xwiki.wysiwyg.Wysiwyg" to
> "xwe" (XWiki WYSIWYG Editor)
personally I 'm not very fond of "cryptic" names. Why not instead:
org.xwiki.<module name>.wysiwyg.editor
or
org.xwiki.<module name>.editor.wysiwyg
or
org.xwiki.<module name>.editor.gwt
or something else
BTW what's the module name? web?
[snip]
Thanks
-Vincent
2
1
Re: [xwiki-devs] [xwiki-notifications] r21910 - in platform/core/trunk: xwiki-cache/xwiki-cache-tests/src/main/java/org/xwiki/cache/tests xwiki-component/xwiki-component-api/src/main/java/org/xwiki/component/manager xwiki-component/xwiki-component-de
by Thomas Mortagne 15 Jul '09
by Thomas Mortagne 15 Jul '09
15 Jul '09
On Mon, Jul 13, 2009 at 22:44, Vincent Massol<vincent(a)massol.net> wrote:
> Hi Thomas,
>
> On Jul 13, 2009, at 3:20 PM, tmortagne (SVN) wrote:
>
>> Author: tmortagne
>> Date: 2009-07-13 15:20:03 +0200 (Mon, 13 Jul 2009)
>> New Revision: 21910
>>
>> Added:
>> platform/core/trunk/xwiki-component/xwiki-component-
>> default/.checkstyle
>> platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/manager/
>> AbstractComponentDescriptorEvent.java
>> platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/manager/
>> ComponentDescriptorRemovedEvent.java
>> Modified:
>> platform/core/trunk/xwiki-cache/xwiki-cache-tests/src/main/java/
>> org/xwiki/cache/tests/AbstractTestCache.java
>> platform/core/trunk/xwiki-component/xwiki-component-api/src/main/
>> java/org/xwiki/component/manager/ComponentEventManager.java
>> platform/core/trunk/xwiki-component/xwiki-component-api/src/main/
>> java/org/xwiki/component/manager/ComponentManager.java
>> platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/embed/EmbeddableComponentManager.java
>> platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/internal/DefaultComponentManager.java
>> platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/internal/
>> StackingComponentEventManager.java
>> platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/manager/
>> ComponentDescriptorAddedEvent.java
>> platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> test/java/org/xwiki/component/embed/
>> EmbeddableComponentManagerTest.java
>> platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> test/java/org/xwiki/component/manager/
>> ComponentDescriptorAddedEventTest.java
>> platform/core/trunk/xwiki-core/src/test/java/com/xpn/xwiki/test/
>> AbstractBridgedXWikiComponentTestCase.java
>> platform/core/trunk/xwiki-plexus/src/main/java/org/xwiki/plexus/
>> manager/PlexusComponentManager.java
>> platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/test/
>> java/org/xwiki/rendering/internal/parser/XWikiLinkParserTest.java
>> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-groovy/src/test/java/org/xwiki/rendering/macro/
>> groovy/RenderingTests.java
>> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-html/src/test/java/org/xwiki/rendering/
>> HTMLMacroTest.java
>> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-include/src/test/java/org/xwiki/rendering/internal/
>> macro/IncludeMacroTest.java
>> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-rss/src/test/java/org/xwiki/rendering/
>> RenderingTests.java
>> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-script/src/test/java/org/xwiki/rendering/macro/
>> script/RenderingTests.java
>> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-velocity/src/test/java/org/xwiki/rendering/macro/
>> velocity/RenderingTests.java
>> platform/core/trunk/xwiki-shared-tests/src/main/java/org/xwiki/
>> test/MockConfigurationSource.java
>> platform/core/trunk/xwiki-shared-tests/src/main/java/org/xwiki/
>> test/XWikiComponentInitializer.java
>> Log:
>> XWIKI-4077: Component Manager should generate event when the
>> component is registered instead of initialized
>> XWIKI-4081: Add way to unregister component
>> XWIKI-4082: Add way to directly provide the component instance when
>> register it
>
> General comments:
> - Would be great if you could separate code reformatting from code
> changes. It makes it hard to read (I didn't read the commit fully as a
> consequence).
> - The code style has broken my styles in lots of places (see below for
> some comments, I haven't commented every single place it broke
> voluntary formatting).
>
> I'd like to vote for not applying code style blindly in the future. It
> breaks styles in lots of places and I hate it when I spend a good
> amount of my time to align code properly and it breaks it for
> producing suboptimal styling...
>
>> Modified: platform/core/trunk/xwiki-cache/xwiki-cache-tests/src/main/
>> java/org/xwiki/cache/tests/AbstractTestCache.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-cache/xwiki-cache-tests/src/main/java/
>> org/xwiki/cache/tests/AbstractTestCache.java 2009-07-13 11:47:52 UTC
>> (rev 21909)
>> +++ platform/core/trunk/xwiki-cache/xwiki-cache-tests/src/main/java/
>> org/xwiki/cache/tests/AbstractTestCache.java 2009-07-13 13:20:03 UTC
>> (rev 21910)
>> @@ -25,6 +25,7 @@
>> import org.jmock.Mock;
>> import org.xwiki.cache.CacheFactory;
>> import org.xwiki.cache.CacheManager;
>> +import org.xwiki.component.descriptor.DefaultComponentDescriptor;
>> import org.xwiki.configuration.ConfigurationSource;
>> import org.xwiki.test.AbstractXWikiComponentTestCase;
>>
>> @@ -81,8 +82,12 @@
>> Mock mockConfigurationSource =
>> mock(ConfigurationSource.class);
>>
>> mockConfigurationSource
>> .stubs().method("getProperty").with(eq("cache.defaultCache"),
>> ANYTHING).will(
>> returnValue(this.roleHint));
>> -
>> getComponentManager().registerComponent(ConfigurationSource.class,
>> "xwikiproperties",
>> - mockConfigurationSource.proxy());
>> +
>> + DefaultComponentDescriptor<ConfigurationSource> descriptor =
>> + new DefaultComponentDescriptor<ConfigurationSource>();
>> + descriptor.setRole(ConfigurationSource.class);
>> + descriptor.setRoleHint("xwikiproperties");
>> + getComponentManager().registerComponent(descriptor,
>> (ConfigurationSource) mockConfigurationSource.proxy());
>
> Maybe we'll need to find an easier way. Like creating a component
> descriptor automatically (without dependencies set). I see below that
> it adds a lot of code.
I prefer having a clean api, i we want a helper we can add one
somewhere but the api sould not contains 20 methods doing exactly the
same thing. We could simply add constructors to
DefaultComponentDescriptor.
>
> [snip]
>
>> }
>>
>> /**
>> @@ -111,7 +116,7 @@
>> */
>> public CacheFactory getCacheFactory() throws Exception
>> {
>> - CacheManager cacheManager = (CacheManager)
>> getComponentManager().lookup(CacheManager.class);
>> + CacheManager cacheManager =
>> getComponentManager().lookup(CacheManager.class);
>>
>> CacheFactory factory = cacheManager.getCacheFactory();
>>
>>
>> Modified: platform/core/trunk/xwiki-component/xwiki-component-api/
>> src/main/java/org/xwiki/component/manager/ComponentEventManager.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-component/xwiki-component-api/src/main/
>> java/org/xwiki/component/manager/ComponentEventManager.java
>> 2009-07-13 11:47:52 UTC (rev 21909)
>> +++ platform/core/trunk/xwiki-component/xwiki-component-api/src/main/
>> java/org/xwiki/component/manager/ComponentEventManager.java
>> 2009-07-13 13:20:03 UTC (rev 21910)
>> @@ -26,18 +26,26 @@
>> * Manages Component Events (when a component instance is created
>> for example). It's recommended that implementations
>> * use the Observation module to send the events. We're introducing
>> this level of indirection in order to be able to
>> * perform some processing before the events are fired. For example
>> one implementation may want to stack the events
>> - * before sending them.
>> - *
>> + * before sending them.
>> + *
>> * @version $Id$
>> * @since 2.0M1
>> */
>> public interface ComponentEventManager
>> {
>> /**
>> - * Notify all listeners that a component with the passed
>> descriptor has been instantiated.
>> + * Notify all listeners that a component with the passed
>> descriptor has been registered.
>> *
>> - * @param <T> the component role type
>> * @param descriptor the descriptor for the instantiated component
>> + * @since 2.0M1
>> */
>> - <T> void notify(ComponentDescriptor<T> descriptor);
>> + void notifyComponentRegistered(ComponentDescriptor< ? >
>> descriptor);
>> +
>> + /**
>> + * Notify all listeners that a component with the passed
>> descriptor has been unregistered.
>> + *
>> + * @param descriptor the descriptor for the instantiated
>> component
>> + * @since 2.0M1
>> + */
>> + void notifyComponentUnregistered(ComponentDescriptor< ? >
>> descriptor);
>
> This doesn't look like it's been added in 2.0M1... ;)
Fixed
>
> [snip]
>
>> Added: platform/core/trunk/xwiki-component/xwiki-component-
>> default/.checkstyle
>> ===================================================================
>> --- platform/core/trunk/xwiki-component/xwiki-component-
>> default/.checkstyle (rev 0)
>> +++ platform/core/trunk/xwiki-component/xwiki-component-
>> default/.checkstyle 2009-07-13 13:20:03 UTC (rev 21910)
>> @@ -0,0 +1,10 @@
>> +<?xml version="1.0" encoding="UTF-8"?>
>> +
>> +<fileset-config file-format-version="1.2.0" simple-config="true">
>> + <fileset name="all" enabled="true" check-config-name="xwiki"
>> local="false">
>> + <file-match-pattern match-pattern="." include-pattern="true"/>
>> + </fileset>
>> + <filter name="FilesFromPackage" enabled="true">
>> + <filter-data value="src/test/java"/>
>> + </filter>
>> +</fileset-config>
>
> This seems to have been added by error.
Fixed
>
> [snip]
>
>> /**
>> * {@inheritDoc}
>> + *
>> * @see ComponentManager#getComponentDescriptorList(Class)
>> */
>> @SuppressWarnings("unchecked")
>> public <T> List<ComponentDescriptor<T>>
>> getComponentDescriptorList(Class<T> role)
>> {
>> - synchronized(this) {
>> + synchronized (this) {
>> List<ComponentDescriptor<T>> results = new
>> ArrayList<ComponentDescriptor<T>>();
>> for (Map.Entry<RoleHint< ? >, ComponentDescriptor< ? >>
>> entry : this.descriptors.entrySet()) {
>> - if
>> (entry.getKey().getRole().getName().equals(role.getName())) {
>> + if (entry.getKey().getRole() == role) {
>
> I'm not sure about this change. I don't know why you've changed it.
>
> I think what you've done may fail if the classes have been loaded from
> a different class loader. Have you found a place in the Java spec
> mentioning that equals for Class will always compare the class name
> and not the class refefence?
>
> note: I've seen you've changed this in lots of place so it's important
> to be sure about what you're doing. I had done it this way to be on
> the safe side and so that it'll always work.
Since the idea is that EmbededCM is supposed to be a temporary and
unit test need and we don't have multiple classloader use case yet,
comparing strings look very expensive compared to reference
comparison. Also there was code which does not take care of that like
the one testing for LogEnabled so it can't really work and whithout
explicit comment or unit test I was not sure it was really a strong
goal... I'm reverting the code with some comments.
>
> [snip]
>
>> - &&
>> List.class.isAssignableFrom(dependency.getMappingType()))
>> - {
>> + if ((dependency.getMappingType() != null) &&
>> List.class.isAssignableFrom(dependency.getMappingType())) {
>> fieldValue = lookupList(dependency.getRole());
>> } else if ((dependency.getMappingType() != null)
>> - &&
>> Map.class.isAssignableFrom(dependency.getMappingType()))
>> - {
>> + &&
>> Map.class.isAssignableFrom(dependency.getMappingType())) {
>> fieldValue = lookupMap(dependency.getRole());
>> } else {
>> fieldValue = lookup(dependency.getRole(),
>> dependency.getRoleHint());
>> }
>> -
>> +
>> // Set the field by introspection
>> if (fieldValue != null) {
>> ReflectionUtils.setFieldValue(instance,
>> dependency.getName(), fieldValue);
>> @@ -313,16 +344,15 @@
>> if
>> (LogEnabled.class.isAssignableFrom(descriptor.getImplementation())) {
>> ((LogEnabled) instance).enableLogging(new
>> CommonsLoggingLogger(instance.getClass()));
>> }
>> -
>> +
>> // Composable
>> // Only support Composable for classes implementing
>> ComponentManager since for all other components
>> // they should have ComponentManager injected.
>> - if
>> (ComponentManager
>> .class.isAssignableFrom(descriptor.getImplementation())
>> - &&
>> Composable.class.isAssignableFrom(descriptor.getImplementation()))
>> - {
>> + if
>> (ComponentManager
>> .class.isAssignableFrom(descriptor.getImplementation())
>> + &&
>> Composable.class.isAssignableFrom(descriptor.getImplementation())) {
>> ((Composable) instance).compose(this);
>> }
>
> note that these code style changes are not respecting what we had
> decided, ie that for long lines the wrapped line will be formatted as:
>
>
> if (.....
> && .....)
> {
> whatever
> }
>
>
>
>
>> -
>> +
>> // Initializable
>> if
>> (Initializable
>> .class.isAssignableFrom(descriptor.getImplementation())) {
>> ((Initializable) instance).initialize();
>>
>> Modified: platform/core/trunk/xwiki-component/xwiki-component-
>> default/src/main/java/org/xwiki/component/internal/
>> DefaultComponentManager.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/internal/DefaultComponentManager.java
>> 2009-07-13 11:47:52 UTC (rev 21909)
>> +++ platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/internal/DefaultComponentManager.java
>> 2009-07-13 13:20:03 UTC (rev 21910)
>> @@ -31,8 +31,8 @@
>> import org.xwiki.component.manager.ComponentRepositoryException;
>>
>> /**
>> - * Wraps the Component Manager in a component so that components
>> requiring the component Manager can
>> - * have it injected automatically.
>> + * Wraps the Component Manager in a component so that components
>> requiring the component Manager can have it injected
>> + * automatically.
>> *
>> * @version $Id$
>> * @since 2.0M1
>> @@ -47,6 +47,7 @@
>>
>> /**
>> * {@inheritDoc}
>> + *
>> * @see Composable#compose(ComponentManager)
>> */
>> public void compose(ComponentManager componentManager)
>> @@ -56,15 +57,17 @@
>>
>> /**
>> * {@inheritDoc}
>> + *
>> * @see ComponentManager#getComponentDescriptor(Class, String)
>> */
>> public <T> ComponentDescriptor<T>
>> getComponentDescriptor(Class<T> role, String roleHint)
>> {
>> return this.componentManager.getComponentDescriptor(role,
>> roleHint);
>> }
>> -
>> +
>> /**
>> * {@inheritDoc}
>> + *
>> * @see ComponentManager#getComponentDescriptorList(Class)
>> */
>> public <T> List<ComponentDescriptor<T>>
>> getComponentDescriptorList(Class<T> role)
>> @@ -74,6 +77,7 @@
>>
>> /**
>> * {@inheritDoc}
>> + *
>> * @see ComponentManager#lookup(Class, String)
>> */
>> public <T> T lookup(Class<T> role, String roleHint) throws
>> ComponentLookupException
>> @@ -83,6 +87,7 @@
>>
>> /**
>> * {@inheritDoc}
>> + *
>> * @see ComponentManager#lookup(Class)
>> */
>> public <T> T lookup(Class<T> role) throws ComponentLookupException
>> @@ -92,6 +97,7 @@
>>
>> /**
>> * {@inheritDoc}
>> + *
>> * @see ComponentManager#lookupList(Class)
>> */
>> public <T> List<T> lookupList(Class<T> role) throws
>> ComponentLookupException
>> @@ -101,6 +107,7 @@
>>
>> /**
>> * {@inheritDoc}
>> + *
>> * @see ComponentManager#lookupMap(Class)
>> */
>> public <T> Map<String, T> lookupMap(Class<T> role) throws
>> ComponentLookupException
>> @@ -110,6 +117,7 @@
>>
>> /**
>> * {@inheritDoc}
>> + *
>> * @see ComponentManager#registerComponent(ComponentDescriptor)
>> */
>> public <T> void registerComponent(ComponentDescriptor<T>
>> componentDescriptor) throws ComponentRepositoryException
>> @@ -119,6 +127,29 @@
>>
>> /**
>> * {@inheritDoc}
>> + *
>> + * @see
>> org
>> .xwiki
>> .component
>> .manager
>> .ComponentManager
>> #registerComponent(org.xwiki.component.descriptor.ComponentDescriptor,
>> + * java.lang.Object)
>> + */
>
> Is this valid javadoc? I doubt it.
Why this would not be valid ?
Note that this wrapping on each dot is because of the mail, it's not
like that in the real source.
>
>> + public <T> void registerComponent(ComponentDescriptor<T>
>> componentDescriptor, T componentInstance)
>> + throws ComponentRepositoryException
>> + {
>> +
>> this.componentManager.registerComponent(componentDescriptor,
>> componentInstance);
>> + }
>> +
>> + /**
>> + * {@inheritDoc}
>> + *
>> + * @see
>> org
>> .xwiki
>> .component
>> .manager.ComponentManager#unregisterComponent(java.lang.Class,
>> java.lang.String)
>> + */
>> + public void unregisterComponent(Class< ? > role, String roleHint)
>> + {
>> + this.componentManager.unregisterComponent(role, roleHint);
>> + }
>> +
>> + /**
>> + * {@inheritDoc}
>> + *
>> * @see ComponentManager#release(Object)
>> */
>> public <T> void release(T component) throws
>> ComponentLifecycleException
>> @@ -128,6 +159,7 @@
>>
>> /**
>> * {@inheritDoc}
>> + *
>> * @see ComponentManager#hasComponent(Class, String)
>> */
>> public <T> boolean hasComponent(Class<T> role, String roleHint)
>> @@ -137,6 +169,7 @@
>>
>> /**
>> * {@inheritDoc}
>> + *
>> * @see ComponentManager#hasComponent(Class)
>> */
>> public <T> boolean hasComponent(Class<T> role)
>> @@ -146,6 +179,7 @@
>>
>> /**
>> * {@inheritDoc}
>> + *
>> * @see
>> ComponentManager#setComponentEventManager(ComponentEventManager)
>> */
>> public void setComponentEventManager(ComponentEventManager
>> eventManager)
>>
>> Modified: platform/core/trunk/xwiki-component/xwiki-component-
>> default/src/main/java/org/xwiki/component/internal/
>> StackingComponentEventManager.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/internal/
>> StackingComponentEventManager.java 2009-07-13 11:47:52 UTC (rev 21909)
>> +++ platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/internal/
>> StackingComponentEventManager.java 2009-07-13 13:20:03 UTC (rev 21910)
>> @@ -23,13 +23,15 @@
>>
>> import org.xwiki.component.descriptor.ComponentDescriptor;
>> import org.xwiki.component.manager.ComponentDescriptorAddedEvent;
>> +import org.xwiki.component.manager.ComponentDescriptorRemovedEvent;
>> import org.xwiki.component.manager.ComponentEventManager;
>> import org.xwiki.observation.ObservationManager;
>> +import org.xwiki.observation.event.Event;
>>
>> /**
>> - * Allow stacking component events and flush them whenever the user
>> of this class wants to. This is used for example
>> - * at application initialization time when we don't want to send
>> events before the Application Context has been
>> - * initialized since components subscribing to these events may
>> want to use the Application Context.
>> + * Allow stacking component events and flush them whenever the user
>> of this class wants to. This is used for example at
>> + * application initialization time when we don't want to send
>> events before the Application Context has been initialized
>> + * since components subscribing to these events may want to use the
>> Application Context.
>> *
>> * @version $Id$
>> * @since 2.0M1
>> @@ -37,48 +39,78 @@
>> public class StackingComponentEventManager implements
>> ComponentEventManager
>> {
>> private ObservationManager observationManager;
>> -
>> - private Stack<ComponentDescriptor< ? >> events = new
>> Stack<ComponentDescriptor< ? >>();
>> -
>> +
>> + private Stack<ComponentEventEntry> events = new
>> Stack<ComponentEventEntry>();
>> +
>> private boolean shouldStack = true;
>> -
>> +
>> /**
>> * {@inheritDoc}
>> - * @see ComponentEventManager#notify(ComponentDescriptor)
>> + *
>> + * @see
>> org
>> .xwiki
>> .component
>> .manager
>> .ComponentEventManager
>> #notifyComponentRegistered
>> (org.xwiki.component.descriptor.ComponentDescriptor)
>> */
>> - public <T> void notify(ComponentDescriptor< T > descriptor)
>> + public void notifyComponentRegistered(ComponentDescriptor< ? >
>> descriptor)
>> {
>> - if (this.shouldStack) {
>> - synchronized (this) {
>> - this.events.push(descriptor);
>> - }
>> - } else {
>> - notifyInternal(descriptor);
>> - }
>> + notifyComponentEvent(new
>> ComponentDescriptorAddedEvent(descriptor.getRole(),
>> descriptor.getRoleHint()),
>> + descriptor);
>> }
>> -
>> +
>> + /**
>> + * {@inheritDoc}
>> + *
>> + * @see
>> org
>> .xwiki
>> .component
>> .manager
>> .ComponentEventManager
>> #notifyComponentUnregistered
>> (org.xwiki.component.descriptor.ComponentDescriptor)
>> + */
>> + public void notifyComponentUnregistered(ComponentDescriptor< ?
>> > descriptor)
>> + {
>> + notifyComponentEvent(new
>> ComponentDescriptorRemovedEvent(descriptor.getRole(),
>> descriptor.getRoleHint()),
>> + descriptor);
>> + }
>> +
>> public synchronized void flushEvents()
>> {
>> - while(!this.events.isEmpty()) {
>> - notifyInternal(events.remove(0));
>> + for (ComponentEventEntry entry : this.events) {
>> + sendEvent(entry.event, entry.descriptor);
>> }
>> }
>> -
>> +
>> public void shouldStack(boolean shouldStack)
>> {
>> this.shouldStack = shouldStack;
>> }
>> -
>> +
>> public void setObservationManager(ObservationManager
>> observationManager)
>> {
>> this.observationManager = observationManager;
>> }
>>
>> - private void notifyInternal(ComponentDescriptor< ? > descriptor)
>> + private void notifyComponentEvent(Event event,
>> ComponentDescriptor< ? > descriptor)
>> {
>> + if (this.shouldStack) {
>> + synchronized (this) {
>> + this.events.push(new ComponentEventEntry(event,
>> descriptor));
>> + }
>> + } else {
>> + sendEvent(event, descriptor);
>> + }
>> + }
>> +
>> + private void sendEvent(Event event, ComponentDescriptor< ? >
>> descriptor)
>> + {
>> if (this.observationManager != null) {
>> - ComponentDescriptorAddedEvent event = new
>> ComponentDescriptorAddedEvent(descriptor.getRole());
>> this.observationManager.notify(event, this, descriptor);
>> }
>> }
>> +
>> + static class ComponentEventEntry
>> + {
>> + public Event event;
>> +
>> + public ComponentDescriptor< ? > descriptor;
>> +
>> + public ComponentEventEntry(Event event,
>> ComponentDescriptor< ? > descriptor)
>> + {
>> + this.event = event;
>> + this.descriptor = descriptor;
>> + }
>> + }
>> }
>>
>>
>> Property changes on: platform/core/trunk/xwiki-component/xwiki-
>> component-default/src/main/java/org/xwiki/component/internal/
>> StackingComponentEventManager.java
>> ___________________________________________________________________
>> Name: svn:keywords
>> - Id
>>
>> Added: platform/core/trunk/xwiki-component/xwiki-component-default/
>> src/main/java/org/xwiki/component/manager/
>> AbstractComponentDescriptorEvent.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/manager/
>> AbstractComponentDescriptorEvent.java (rev 0)
>> +++ platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/manager/
>> AbstractComponentDescriptorEvent.java 2009-07-13 13:20:03 UTC (rev
>> 21910)
>> @@ -0,0 +1,100 @@
>> +/*
>> + * See the NOTICE file distributed with this work for additional
>> + * information regarding copyright ownership.
>> + *
>> + * This is free software; you can redistribute it and/or modify it
>> + * under the terms of the GNU Lesser General Public License as
>> + * published by the Free Software Foundation; either version 2.1 of
>> + * the License, or (at your option) any later version.
>> + *
>> + * This software is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>> + * Lesser General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU Lesser General Public
>> + * License along with this software; if not, write to the Free
>> + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
>> + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
>> + */
>> +package org.xwiki.component.manager;
>> +
>> +import org.xwiki.observation.event.Event;
>> +
>> +/**
>> + * Base class for events about components descriptors.
>> + *
>> + * @version $Id$
>> + * @since 2.0M1
>
> 2.0M2?
Fixed
>
> [snip]
>
>
>
>> + */
>> +public abstract class AbstractComponentDescriptorEvent implements
>> Event
>> +{
>> + private Class< ? > role;
>> +
>> + private String roleHint;
>> +
>> + /**
>> + * Watches all roles (whenever a component is added it'll
>> trigger this event).
>> + */
>> + public AbstractComponentDescriptorEvent()
>> + {
>> + this.role = null;
>> + }
>> +
>> + /**
>> + * @param role the component role to watch (all components
>> matching this role will trigger this event)
>> + */
>> + public AbstractComponentDescriptorEvent(Class< ? > role)
>> + {
>> + this.role = role;
>> + }
>> +
>> + /**
>> + * @param role the component role/rolehint to watch
>> + */
>> + public AbstractComponentDescriptorEvent(Class< ? > role, String
>> roleHint)
>> + {
>> + this.role = role;
>> + this.roleHint = roleHint;
>> + }
>> +
>> + /**
>> + * @return the component's role being watched or null if all
>> components registrations are watched
>> + */
>> + public Class< ? > getRole()
>> + {
>> + return this.role;
>> + }
>> +
>> + /**
>> + * @return the component's role hint being watched or null if
>> all role's components registrations are watched
>> + */
>> + public String getRoleHint()
>> + {
>> + return this.roleHint;
>> + }
>> +
>> + /**
>> + * {@inheritDoc}
>> + *
>> + * @see
>> org.xwiki.observation.event.Event#matches(java.lang.Object)
>> + */
>> + public boolean matches(Object otherEvent)
>> + {
>> + boolean result = false;
>> +
>> + if (otherEvent instanceof AbstractComponentDescriptorEvent) {
>> + // If we're watching all roles return a match
>> + if (getRole() == null) {
>> + result = true;
>> + } else {
>> + AbstractComponentDescriptorEvent event =
>> (AbstractComponentDescriptorEvent) otherEvent;
>> + if (getRole() == event.getRole()) {
>> + result = getRoleHint() == null ||
>> getRoleHint().equals(event.getRoleHint());
>> + }
>> + }
>> + }
>> +
>> + return result;
>> + }
>> +}
>>
>>
>> Property changes on: platform/core/trunk/xwiki-component/xwiki-
>> component-default/src/main/java/org/xwiki/component/manager/
>> AbstractComponentDescriptorEvent.java
>> ___________________________________________________________________
>> Name: svn:mime-type
>> + text/plain
>> Name: svn:keywords
>> + Id
>> Name: svn:eol-style
>> + native
>>
>> Modified: platform/core/trunk/xwiki-component/xwiki-component-
>> default/src/main/java/org/xwiki/component/manager/
>> ComponentDescriptorAddedEvent.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/manager/
>> ComponentDescriptorAddedEvent.java 2009-07-13 11:47:52 UTC (rev 21909)
>> +++ platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/manager/
>> ComponentDescriptorAddedEvent.java 2009-07-13 13:20:03 UTC (rev 21910)
>> @@ -27,54 +27,45 @@
>> * @version $Id$
>> * @since 2.0M1
>> */
>> -public class ComponentDescriptorAddedEvent implements Event
>> +public class ComponentDescriptorAddedEvent extends
>> AbstractComponentDescriptorEvent
>> {
>> - private Class< ? > role;
>> -
>> /**
>> * Watches all roles (whenever a component is added it'll
>> trigger this event).
>> */
>> public ComponentDescriptorAddedEvent()
>> {
>> - this.role = null;
>> +
>> }
>> -
>> +
>> /**
>> * @param role the component role to watch (all components
>> matching this role will trigger this event)
>> */
>> public ComponentDescriptorAddedEvent(Class< ? > role)
>> {
>> - this.role = role;
>> + super(role);
>> }
>> -
>> +
>> /**
>> - * @return the component's role being watched or null if all
>> component registrations are watched
>> + * @param role the component role/rolehint to watch
>> */
>> - public Class< ? > getRole()
>> + public ComponentDescriptorAddedEvent(Class< ? > role, String
>> roleHint)
>> {
>> - return this.role;
>> + super(role, roleHint);
>> }
>> -
>> +
>> /**
>> * {@inheritDoc}
>> + *
>> * @see Event#matches(Object)
>> */
>> public boolean matches(Object otherEvent)
>> {
>> boolean result = false;
>> -
>> +
>> if
>> (ComponentDescriptorAddedEvent
>> .class.isAssignableFrom(otherEvent.getClass())) {
>> - // If we're watching all roles return a match
>> - if (getRole() == null) {
>> - result = true;
>> - } else {
>> - ComponentDescriptorAddedEvent event =
>> (ComponentDescriptorAddedEvent) otherEvent;
>> - if
>> (getRole().getName().equals(event.getRole().getName())) {
>> - result = true;
>> - }
>> - }
>> + result = super.matches(otherEvent);
>> }
>> -
>> - return result;
>> +
>> + return result;
>> }
>> }
>>
>> Added: platform/core/trunk/xwiki-component/xwiki-component-default/
>> src/main/java/org/xwiki/component/manager/
>> ComponentDescriptorRemovedEvent.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/manager/
>> ComponentDescriptorRemovedEvent.java (rev 0)
>> +++ platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> main/java/org/xwiki/component/manager/
>> ComponentDescriptorRemovedEvent.java 2009-07-13 13:20:03 UTC (rev
>> 21910)
>> @@ -0,0 +1,69 @@
>> +/*
>> + * See the NOTICE file distributed with this work for additional
>> + * information regarding copyright ownership.
>> + *
>> + * This is free software; you can redistribute it and/or modify it
>> + * under the terms of the GNU Lesser General Public License as
>> + * published by the Free Software Foundation; either version 2.1 of
>> + * the License, or (at your option) any later version.
>> + *
>> + * This software is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>> + * Lesser General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU Lesser General Public
>> + * License along with this software; if not, write to the Free
>> + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
>> + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
>> + */
>> +package org.xwiki.component.manager;
>> +
>> +/**
>> + * Event sent to tell that a new Component Descriptor has been
>> unregistered.
>> + *
>> + * @version $Id$
>> + * @since 2.0M2
>> + */
>> +public class ComponentDescriptorRemovedEvent extends
>> AbstractComponentDescriptorEvent
>> +{
>> + /**
>> + * Watches all roles (whenever a component is added it'll
>> trigger this event).
>> + */
>> + public ComponentDescriptorRemovedEvent()
>> + {
>> +
>> + }
>
> This needs a comment to explain why it's empty since empty blocks
> trigger a checkstyle exception.
It's empty because there is nothing to do here and no it's not a
checkstyle error in empty constructors according to the mvn
checkstyle:check.
>
> [snip]
>
>
>
>> +
>> + /**
>> + * @param role the component role to watch (all components
>> matching this role will trigger this event)
>> + */
>> + public ComponentDescriptorRemovedEvent(Class< ? > role)
>> + {
>> + super(role);
>> + }
>> +
>> + /**
>> + * @param role the component role/rolehint to watch
>> + */
>> + public ComponentDescriptorRemovedEvent(Class< ? > role, String
>> roleHint)
>> + {
>> + super(role, roleHint);
>> + }
>> +
>> + /**
>> + * {@inheritDoc}
>> + *
>> + * @see
>> org
>> .xwiki
>> .component
>> .manager.AbstractComponentDescriptorEvent#matches(java.lang.Object)
>> + */
>> + public boolean matches(Object otherEvent)
>> + {
>> + boolean result = false;
>> +
>> + if
>> (ComponentDescriptorRemovedEvent
>> .class.isAssignableFrom(otherEvent.getClass())) {
>> + result = super.matches(otherEvent);
>> + }
>> +
>> + return result;
>> + }
>> +}
>>
>>
>> Property changes on: platform/core/trunk/xwiki-component/xwiki-
>> component-default/src/main/java/org/xwiki/component/manager/
>> ComponentDescriptorRemovedEvent.java
>> ___________________________________________________________________
>> Name: svn:mime-type
>> + text/plain
>> Name: svn:keywords
>> + Id
>> Name: svn:eol-style
>> + native
>>
>> Modified: platform/core/trunk/xwiki-component/xwiki-component-
>> default/src/test/java/org/xwiki/component/embed/
>> EmbeddableComponentManagerTest.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> test/java/org/xwiki/component/embed/
>> EmbeddableComponentManagerTest.java 2009-07-13 11:47:52 UTC (rev
>> 21909)
>> +++ platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> test/java/org/xwiki/component/embed/
>> EmbeddableComponentManagerTest.java 2009-07-13 13:20:03 UTC (rev
>> 21910)
>> @@ -26,6 +26,7 @@
>> import org.junit.Test;
>> import org.xwiki.component.descriptor.ComponentDescriptor;
>> import org.xwiki.component.descriptor.DefaultComponentDescriptor;
>> +import org.xwiki.component.manager.ComponentLookupException;
>>
>> /**
>> * Unit tests for {@link EmbeddableComponentManager}.
>> @@ -38,20 +39,20 @@
>> public static interface Role
>> {
>> }
>> -
>> +
>> public static class RoleImpl implements Role
>> {
>> }
>> -
>> +
>> public static class OtherRoleImpl implements Role
>> {
>> }
>> -
>> +
>> @Test
>> public void testGetComponentDescriptorList() throws Exception
>> {
>> EmbeddableComponentManager ecm = new
>> EmbeddableComponentManager();
>> -
>> +
>> DefaultComponentDescriptor<Role> d1 = new
>> DefaultComponentDescriptor<Role>();
>> d1.setRole(Role.class);
>> d1.setRoleHint("hint1");
>> @@ -61,13 +62,13 @@
>> d2.setRole(Role.class);
>> d2.setRoleHint("hint2");
>> ecm.registerComponent(d2);
>> -
>> +
>> List<ComponentDescriptor<Role>> cds =
>> ecm.getComponentDescriptorList(Role.class);
>> Assert.assertEquals(2, cds.size());
>> Assert.assertTrue(cds.contains(d1));
>> Assert.assertTrue(cds.contains(d2));
>> }
>> -
>> +
>> @Test
>> public void testRegisterComponentOverExistingOne() throws
>> Exception
>> {
>> @@ -79,14 +80,50 @@
>> ecm.registerComponent(d1);
>>
>> Object instance = ecm.lookup(Role.class);
>> - Assert.assertEquals(RoleImpl.class.getName(),
>> instance.getClass().getName());
>> -
>> + Assert.assertSame(RoleImpl.class, instance.getClass());
>> +
>> DefaultComponentDescriptor<Role> d2 = new
>> DefaultComponentDescriptor<Role>();
>> d2.setRole(Role.class);
>> d2.setImplementation(OtherRoleImpl.class);
>> ecm.registerComponent(d2);
>>
>> instance = ecm.lookup(Role.class);
>> - Assert.assertEquals(OtherRoleImpl.class.getName(),
>> instance.getClass().getName());
>> + Assert.assertSame(OtherRoleImpl.class, instance.getClass());
>> }
>> +
>> + @Test
>> + public void testRegisterComponentInstance() throws Exception
>> + {
>> + EmbeddableComponentManager ecm = new
>> EmbeddableComponentManager();
>> +
>> + DefaultComponentDescriptor<Role> d1 = new
>> DefaultComponentDescriptor<Role>();
>> + d1.setRole(Role.class);
>> + d1.setImplementation(RoleImpl.class);
>> + Role instance = new RoleImpl();
>> + ecm.registerComponent(d1, instance);
>> +
>> + Assert.assertSame(instance, ecm.lookup(Role.class));
>> + }
>> +
>> + @Test
>> + public void testUnregisterComponent() throws Exception
>> + {
>> + EmbeddableComponentManager ecm = new
>> EmbeddableComponentManager();
>> +
>> + DefaultComponentDescriptor<Role> d1 = new
>> DefaultComponentDescriptor<Role>();
>> + d1.setRole(Role.class);
>> + d1.setImplementation(RoleImpl.class);
>> + ecm.registerComponent(d1);
>> +
>> + Assert.assertSame(RoleImpl.class,
>> ecm.lookup(Role.class).getClass());
>> +
>> + ecm.unregisterComponent(d1.getRole(), d1.getRoleHint());
>> +
>> + try {
>> + ecm.lookup(d1.getRole());
>> + Assert.fail("Should have thrown a
>> ComponentLookupException");
>> + } catch (ComponentLookupException e) {
>> + // expected
>> + }
>> + }
>> }
>>
>> Modified: platform/core/trunk/xwiki-component/xwiki-component-
>> default/src/test/java/org/xwiki/component/manager/
>> ComponentDescriptorAddedEventTest.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> test/java/org/xwiki/component/manager/
>> ComponentDescriptorAddedEventTest.java 2009-07-13 11:47:52 UTC (rev
>> 21909)
>> +++ platform/core/trunk/xwiki-component/xwiki-component-default/src/
>> test/java/org/xwiki/component/manager/
>> ComponentDescriptorAddedEventTest.java 2009-07-13 13:20:03 UTC (rev
>> 21910)
>> @@ -38,34 +38,36 @@
>> private static class Dummy
>> {
>> }
>> -
>> +
>> @Test
>> public void testMatchesAllComponentRoles()
>> {
>> ComponentDescriptorAddedEvent event = new
>> ComponentDescriptorAddedEvent();
>> // Note: We use any class for the test but it's supposed to
>> be a component role class.
>> - Assert.assertTrue(event.matches(new
>> ComponentDescriptorAddedEvent(Dummy.class)));
>> + Assert.assertTrue(event.matches(new
>> ComponentDescriptorAddedEvent(Dummy.class, "rolehint")));
>> }
>>
>> @Test
>> public void testMatchesWhenDifferentEvent()
>> {
>> ComponentDescriptorAddedEvent event = new
>> ComponentDescriptorAddedEvent();
>> - Assert.assertFalse(event.matches(new Event() {
>> + Assert.assertFalse(event.matches(new Event()
>> + {
>> public boolean matches(Object otherEvent)
>> {
>> return false;
>> }
>> }));
>> }
>> -
>> +
>> @Test
>> public void testMatchesWhenSpecificRoleSpecified()
>> {
>> // Note: We use any class for the test but it's supposed to
>> be a component role class.
>> ComponentDescriptorAddedEvent event = new
>> ComponentDescriptorAddedEvent(Dummy.class);
>> - Assert.assertTrue(event.matches(new
>> ComponentDescriptorAddedEvent(Dummy.class)));
>> + Assert.assertTrue(event.matches(new
>> ComponentDescriptorAddedEvent(Dummy.class, "rolehint")));
>> // Use a different class so that it doesn't match
>> - Assert.assertFalse(event.matches(new
>> ComponentDescriptorAddedEvent(ComponentDescriptorAddedEvent.class)));
>> + Assert.assertFalse(event.matches(new
>> ComponentDescriptorAddedEvent(ComponentDescriptorAddedEvent.class,
>> + "rolehint")));
>> }
>> }
>>
>> Modified: platform/core/trunk/xwiki-core/src/test/java/com/xpn/xwiki/
>> test/AbstractBridgedXWikiComponentTestCase.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-core/src/test/java/com/xpn/xwiki/test/
>> AbstractBridgedXWikiComponentTestCase.java 2009-07-13 11:47:52 UTC
>> (rev 21909)
>> +++ platform/core/trunk/xwiki-core/src/test/java/com/xpn/xwiki/test/
>> AbstractBridgedXWikiComponentTestCase.java 2009-07-13 13:20:03 UTC
>> (rev 21910)
>> @@ -20,6 +20,7 @@
>> package com.xpn.xwiki.test;
>>
>> import org.jmock.Mock;
>> +import org.xwiki.component.descriptor.DefaultComponentDescriptor;
>> import org.xwiki.component.manager.ComponentManager;
>> import org.xwiki.container.Container;
>> import org.xwiki.context.Execution;
>> @@ -67,7 +68,9 @@
>>
>> Mock mockCoreConfiguration = mock(CoreConfiguration.class);
>>
>> mockCoreConfiguration
>> .stubs().method("getDefaultDocumentSyntax").will(returnValue("xwiki/
>> 1.0"));
>> -
>> getComponentManager().registerComponent(CoreConfiguration.class,
>> mockCoreConfiguration.proxy());
>> + DefaultComponentDescriptor<CoreConfiguration> descriptor =
>> new DefaultComponentDescriptor<CoreConfiguration>();
>> + descriptor.setRole(CoreConfiguration.class);
>> + getComponentManager().registerComponent(descriptor,
>> (CoreConfiguration) mockCoreConfiguration.proxy());
>> }
>>
>> @Override
>>
>> Modified: platform/core/trunk/xwiki-plexus/src/main/java/org/xwiki/
>> plexus/manager/PlexusComponentManager.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-plexus/src/main/java/org/xwiki/plexus/
>> manager/PlexusComponentManager.java 2009-07-13 11:47:52 UTC (rev
>> 21909)
>> +++ platform/core/trunk/xwiki-plexus/src/main/java/org/xwiki/plexus/
>> manager/PlexusComponentManager.java 2009-07-13 13:20:03 UTC (rev
>> 21910)
>> @@ -52,6 +52,7 @@
>>
>> /**
>> * {@inheritDoc}
>> + *
>> * @see ComponentManager#hasComponent(Class, String)
>> */
>> public <T> boolean hasComponent(Class<T> role, String roleHint)
>> @@ -61,6 +62,7 @@
>>
>> /**
>> * {@inheritDoc}
>> + *
>> * @see ComponentManager#hasComponent(Class)
>> */
>> public <T> boolean hasComponent(Class<T> role)
>> @@ -73,7 +75,8 @@
>> *
>> * @see org.xwiki.component.manager.ComponentManager#lookup(Class)
>> */
>> - public <T> T lookup(Class< T > role) throws
>> ComponentLookupException
>> + @SuppressWarnings("unchecked")
>> + public <T> T lookup(Class<T> role) throws
>> ComponentLookupException
>> {
>> T result;
>> try {
>> @@ -90,7 +93,8 @@
>> *
>> * @see
>> org.xwiki.component.manager.ComponentManager#lookup(Class, String)
>> */
>> - public <T> T lookup(Class< T > role, String roleHint) throws
>> ComponentLookupException
>> + @SuppressWarnings("unchecked")
>> + public <T> T lookup(Class<T> role, String roleHint) throws
>> ComponentLookupException
>> {
>> T result;
>> try {
>> @@ -108,7 +112,8 @@
>> *
>> * @see
>> org.xwiki.component.manager.ComponentManager#lookupMap(Class)
>> */
>> - public <T> Map<String, T> lookupMap(Class< T > role) throws
>> ComponentLookupException
>> + @SuppressWarnings("unchecked")
>> + public <T> Map<String, T> lookupMap(Class<T> role) throws
>> ComponentLookupException
>> {
>> Map<String, T> result;
>> try {
>> @@ -125,7 +130,8 @@
>> *
>> * @see
>> org.xwiki.component.manager.ComponentManager#lookupList(Class)
>> */
>> - public <T> List< T > lookupList(Class< T > role) throws
>> ComponentLookupException
>> + @SuppressWarnings("unchecked")
>> + public <T> List<T> lookupList(Class<T> role) throws
>> ComponentLookupException
>> {
>> List<T> result;
>> try {
>> @@ -156,8 +162,7 @@
>> *
>> * @see
>> org
>> .xwiki
>> .component
>> .manager
>> .ComponentManager
>> #registerComponent(org.xwiki.component.descriptor.ComponentDescriptor)
>> */
>> - public <T> void registerComponent(ComponentDescriptor<T>
>> componentDescriptor)
>> - throws ComponentRepositoryException
>> + public <T> void registerComponent(ComponentDescriptor<T>
>> componentDescriptor) throws ComponentRepositoryException
>> {
>> org.codehaus.plexus.component.repository.ComponentDescriptor
>> pcd =
>> createPlexusComponentDescriptor(componentDescriptor);
>> @@ -169,22 +174,37 @@
>> }
>> }
>>
>> + public <T> void registerComponent(ComponentDescriptor<T>
>> componentDescriptor, T componentInstance)
>> + throws ComponentRepositoryException
>> + {
>> + // TODO: find what to do here
>> + throw new RuntimeException("Not implemented");
>> + }
>> +
>> + public void unregisterComponent(Class< ? > role, String roleHint)
>> + {
>> + // TODO: find what to do here
>> + throw new RuntimeException("Not implemented");
>> + }
>> +
>> /**
>> * {@inheritDoc}
>> + *
>> * @see ComponentManager#getComponentDescriptor(Class, String)
>> * @since 2.0M1
>> */
>> - public <T> ComponentDescriptor<T> getComponentDescriptor(Class<
>> T > role, String roleHint)
>> + public <T> ComponentDescriptor<T>
>> getComponentDescriptor(Class<T> role, String roleHint)
>> {
>> - return createXWikiComponentDescriptor(
>> -
>> this.plexusContainer.getComponentDescriptor(role.getName(),
>> roleHint));
>> + return
>> createXWikiComponentDescriptor
>> (this.plexusContainer.getComponentDescriptor(role.getName(),
>> roleHint));
>> }
>> -
>> +
>> /**
>> * {@inheritDoc}
>> + *
>> * @see ComponentManager#getComponentDescriptorList(Class)
>> * @since 2.0M1
>> */
>> + @SuppressWarnings("unchecked")
>> public <T> List<ComponentDescriptor<T>>
>> getComponentDescriptorList(Class<T> role)
>> {
>>
>> List<org.codehaus.plexus.component.repository.ComponentDescriptor>
>> pcds =
>> @@ -194,11 +214,13 @@
>> for
>> (org.codehaus.plexus.component.repository.ComponentDescriptor pcd :
>> pcds) {
>> results.add((ComponentDescriptor<T>)
>> createXWikiComponentDescriptor(pcd));
>> }
>> +
>> return results;
>> }
>>
>> /**
>> * {@inheritDoc}
>> + *
>> * @see
>> ComponentManager#setComponentEventManager(ComponentEventManager)
>> */
>> public void setComponentEventManager(ComponentEventManager
>> eventManager)
>> @@ -206,23 +228,24 @@
>> // Do nothing since there's no hook to get Plexus Events.
>> }
>>
>> + @SuppressWarnings("unchecked")
>> private <T> ComponentDescriptor<T> createXWikiComponentDescriptor(
>> org.codehaus.plexus.component.repository.ComponentDescriptor
>> pcd)
>> {
>> DefaultComponentDescriptor<T> descriptor = null;
>> -
>> +
>> if (pcd != null) {
>> descriptor = new DefaultComponentDescriptor<T>();
>> descriptor.setImplementation((Class< ? extends T>)
>> loadClass(pcd.getImplementation()));
>> descriptor.setRoleHint(pcd.getRoleHint());
>> descriptor.setRole((Class<T>) loadClass(pcd.getRole()));
>> -
>> +
>> if ("per-lookup".equals(pcd.getInstantiationStrategy())) {
>>
>> descriptor
>> .setInstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP);
>> } else {
>>
>> descriptor
>> .setInstantiationStrategy(ComponentInstantiationStrategy.SINGLETON);
>> }
>> -
>> +
>> // Copy dependencies
>> for (ComponentRequirement requirement :
>> (List<ComponentRequirement>) pcd.getRequirements()) {
>> DefaultComponentDependency dependency = new
>> DefaultComponentDependency();
>> @@ -230,18 +253,18 @@
>> dependency.setRoleHint(requirement.getRoleHint());
>>
>> dependency
>> .setMappingType(loadClass(requirement.getFieldMappingType()));
>> dependency.setName(requirement.getFieldName());
>> -
>> +
>> // TODO: Handle specific hints when we move to a
>> more recent Plexus version.
>> // See createPlexusComponentDescriptor
>> descriptor.addComponentDependency(dependency);
>> }
>> }
>> -
>> - return descriptor;
>> +
>> + return descriptor;
>> }
>> -
>> +
>> private
>> org.codehaus.plexus.component.repository.ComponentDescriptor
>> createPlexusComponentDescriptor(
>> - ComponentDescriptor<?> componentDescriptor)
>> + ComponentDescriptor< ? > componentDescriptor)
>> {
>> org.codehaus.plexus.component.repository.ComponentDescriptor
>> pcd =
>> new
>> org.codehaus.plexus.component.repository.ComponentDescriptor();
>> @@ -249,7 +272,7 @@
>> pcd.setRole(componentDescriptor.getRole().getName());
>> pcd.setRoleHint(componentDescriptor.getRoleHint());
>>
>> pcd
>> .setImplementation(componentDescriptor.getImplementation().getName());
>> -
>> +
>> switch (componentDescriptor.getInstantiationStrategy()) {
>> case PER_LOOKUP:
>> pcd.setInstantiationStrategy("per-lookup");
>> @@ -258,22 +281,19 @@
>> pcd.setInstantiationStrategy("singleton");
>> }
>>
>> - Collection<ComponentDependency<?>> componentDependencies =
>> componentDescriptor.getComponentDependencies();
>> - for (ComponentDependency<?> dependency :
>> componentDependencies) {
>> + Collection<ComponentDependency< ? >> componentDependencies
>> = componentDescriptor.getComponentDependencies();
>> + for (ComponentDependency< ? > dependency :
>> componentDependencies) {
>> ComponentRequirement requirement;
>> -
>> +
>> // Handles several hints in case of lists (collections
>> or maps)
>> if
>> (Collection.class.isAssignableFrom(dependency.getMappingType())
>> - ||
>> Map.class.isAssignableFrom(dependency.getMappingType()))
>> - {
>> + ||
>> Map.class.isAssignableFrom(dependency.getMappingType())) {
>> // TODO: Uncomment when we move to a more recent
>> Plexus version which implements
>> // ComponentRequirementList.
>> /*
>> - String[] hints = dependency.getHints();
>> - if (hints != null && hints.length > 0) {
>> -
>> ((ComponentRequirementList
>> )requirement).setRoleHints(Arrays.asList(hints));
>> - }
>> - */
>> + * String[] hints = dependency.getHints(); if
>> (hints != null && hints.length > 0) {
>> + *
>> ((ComponentRequirementList
>> )requirement).setRoleHints(Arrays.asList(hints)); }
>> + */
>> requirement = new ComponentRequirement();
>> } else {
>> requirement = new ComponentRequirement();
>> @@ -283,7 +303,7 @@
>> requirement.setRoleHint(dependency.getRoleHint());
>>
>> requirement
>> .setFieldMappingType(dependency.getMappingType().getName());
>> requirement.setFieldName(dependency.getName());
>> -
>> +
>> pcd.addRequirement(requirement);
>> }
>>
>>
>> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-api/
>> src/test/java/org/xwiki/rendering/internal/parser/
>> XWikiLinkParserTest.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/test/
>> java/org/xwiki/rendering/internal/parser/XWikiLinkParserTest.java
>> 2009-07-13 11:47:52 UTC (rev 21909)
>> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/test/
>> java/org/xwiki/rendering/internal/parser/XWikiLinkParserTest.java
>> 2009-07-13 13:20:03 UTC (rev 21910)
>> @@ -20,6 +20,8 @@
>> package org.xwiki.rendering.internal.parser;
>>
>> import org.jmock.Mock;
>> +import org.xwiki.component.descriptor.ComponentInstantiationStrategy;
>> +import org.xwiki.component.descriptor.DefaultComponentDescriptor;
>> import org.xwiki.rendering.listener.Link;
>> import org.xwiki.rendering.listener.LinkType;
>> import org.xwiki.rendering.parser.LinkParser;
>> @@ -36,9 +38,15 @@
>> {
>> // Create a Mock WikiModel implementation so that the link
>> parser works in wiki mode
>> Mock mockWikiModel = mock(WikiModel.class);
>> - getComponentManager().registerComponent(WikiModel.class,
>> mockWikiModel.proxy());
>> - LinkParser parser =
>> getComponentManager().lookup(LinkParser.class, "xwiki/2.0");
>>
>> + DefaultComponentDescriptor<WikiModel> componentDescriptor =
>> new DefaultComponentDescriptor<WikiModel>();
>> + componentDescriptor.setRole(WikiModel.class);
>> +
>> componentDescriptor
>> .setInstantiationStrategy(ComponentInstantiationStrategy.SINGLETON);
>> + componentDescriptor.setImplementation(null);
>> +
>> +
>> getComponentManager().registerComponent(componentDescriptor,
>> (WikiModel) mockWikiModel.proxy());
>> + LinkParser parser =
>> getComponentManager().lookup(LinkParser.class, "xwiki/2.0");
>> +
>> Link link = parser.parse("");
>> assertEquals("", link.getReference());
>> assertEquals("Reference = []", link.toString());
>> @@ -85,7 +93,7 @@
>> assertEquals("mailto:[email protected]", link.getReference());
>> assertEquals(LinkType.URI, link.getType());
>> assertEquals("Reference = [mailto:[email protected]]",
>> link.toString());
>> -
>> +
>> // Verify image: URI is recognized
>> link = parser.parse("image:some:content");
>> assertEquals("image:some:content", link.getReference());
>> @@ -97,13 +105,13 @@
>> assertEquals("attach:some:content", link.getReference());
>> assertEquals(LinkType.URI, link.getType());
>> assertEquals("Reference = [attach:some:content]",
>> link.toString());
>> -
>> +
>> // Verify that unknown URIs are ignored
>> // Note: We consider that myxwiki is the wiki name and http://xwiki.org
>> is the page name
>> link = parser.parse("mywiki:http://xwiki.org");
>> assertEquals("mywiki:http://xwiki.org", link.getReference());
>> assertEquals(LinkType.DOCUMENT, link.getType());
>> assertEquals("Reference = [mywiki:http://xwiki.org]",
>> link.toString());
>> -
>> +
>> + }
>> }
>> -}
>>
>> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/
>> xwiki-rendering-macro-groovy/src/test/java/org/xwiki/rendering/macro/
>> groovy/RenderingTests.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-groovy/src/test/java/org/xwiki/rendering/macro/
>> groovy/RenderingTests.java 2009-07-13 11:47:52 UTC (rev 21909)
>> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-groovy/src/test/java/org/xwiki/rendering/macro/
>> groovy/RenderingTests.java 2009-07-13 13:20:03 UTC (rev 21910)
>> @@ -28,6 +28,7 @@
>> import org.jmock.Expectations;
>> import org.jmock.Mockery;
>> import org.xwiki.bridge.DocumentAccessBridge;
>> +import org.xwiki.component.descriptor.DefaultComponentDescriptor;
>> import org.xwiki.component.embed.EmbeddableComponentManager;
>> import org.xwiki.rendering.scaffolding.RenderingTestSuite;
>> import org.xwiki.script.ScriptContextManager;
>> @@ -61,18 +62,32 @@
>>
>> // Document Access Bridge Mock
>> final DocumentAccessBridge mockDocumentAccessBridge =
>> context.mock(DocumentAccessBridge.class);
>> - context.checking(new Expectations() {{
>> -
>> allowing(mockDocumentAccessBridge).hasProgrammingRights();
>> will(returnValue(true));
>> - }});
>> -
>> componentManager.registerComponent(DocumentAccessBridge.class,
>> mockDocumentAccessBridge);
>> -
>> + context.checking(new Expectations()
>> + {
>> + {
>> +
>> allowing(mockDocumentAccessBridge).hasProgrammingRights();
>> + will(returnValue(true));
>> + }
>> + });
>
> hmmm this is not following the recommended code style for
> expectations. See jmock.org`
>
> Can you please revert all these style changes?
>
> side note: This why I never apply code style blindly. It'll always
> break stuff you've done voluntarily.
>
>
>
>> + DefaultComponentDescriptor<DocumentAccessBridge>
>> descriptorDAB =
>> + new DefaultComponentDescriptor<DocumentAccessBridge>();
>> + descriptorDAB.setRole(DocumentAccessBridge.class);
>> + componentManager.registerComponent(descriptorDAB,
>> mockDocumentAccessBridge);
>> +
>> // Script Context Mock
>> final ScriptContextManager mockScriptContextManager =
>> context.mock(ScriptContextManager.class);
>> final SimpleScriptContext scriptContext = new
>> SimpleScriptContext();
>> scriptContext.setAttribute("var", "value",
>> ScriptContext.ENGINE_SCOPE);
>> - context.checking(new Expectations() {{
>> - allowing(mockScriptContextManager).getScriptContext();
>> will(returnValue(scriptContext));
>> - }});
>> -
>> componentManager.registerComponent(ScriptContextManager.class,
>> mockScriptContextManager);
>> + context.checking(new Expectations()
>> + {
>> + {
>> +
>> allowing(mockScriptContextManager).getScriptContext();
>> + will(returnValue(scriptContext));
>> + }
>> + });
>> + DefaultComponentDescriptor<ScriptContextManager>
>> descriptorSCM =
>> + new DefaultComponentDescriptor<ScriptContextManager>();
>> + descriptorSCM.setRole(ScriptContextManager.class);
>> + componentManager.registerComponent(descriptorSCM,
>> mockScriptContextManager);
>> }
>> }
>>
>> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/
>> xwiki-rendering-macro-html/src/test/java/org/xwiki/rendering/
>> HTMLMacroTest.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-html/src/test/java/org/xwiki/rendering/
>> HTMLMacroTest.java 2009-07-13 11:47:52 UTC (rev 21909)
>> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-html/src/test/java/org/xwiki/rendering/
>> HTMLMacroTest.java 2009-07-13 13:20:03 UTC (rev 21910)
>> @@ -24,7 +24,7 @@
>> import org.junit.Test;
>> import org.xwiki.bridge.DocumentAccessBridge;
>> import org.xwiki.bridge.DocumentNameSerializer;
>> -import org.xwiki.component.embed.EmbeddableComponentManager;
>> +import org.xwiki.component.descriptor.DefaultComponentDescriptor;
>> import org.xwiki.rendering.internal.macro.html.HTMLMacro;
>> import org.xwiki.rendering.macro.Macro;
>> import org.xwiki.rendering.macro.MacroExecutionException;
>> @@ -52,13 +52,19 @@
>> {
>> super.setUp();
>>
>> - DocumentAccessBridge dab =
>> this.context.mock(DocumentAccessBridge.class);
>> - ((EmbeddableComponentManager)
>> getComponentManager()).registerComponent(DocumentAccessBridge.class,
>> dab);
>> -
>> - DocumentNameSerializer dns =
>> this.context.mock(DocumentNameSerializer.class);
>> - ((EmbeddableComponentManager)
>> getComponentManager
>> ()).registerComponent(DocumentNameSerializer.class, dns);
>> + DocumentAccessBridge mockDocumentAccessBridge =
>> this.context.mock(DocumentAccessBridge.class);
>> + DefaultComponentDescriptor<DocumentAccessBridge>
>> descriptorDAB =
>> + new DefaultComponentDescriptor<DocumentAccessBridge>();
>> + descriptorDAB.setRole(DocumentAccessBridge.class);
>> + getComponentManager().registerComponent(descriptorDAB,
>> mockDocumentAccessBridge);
>> +
>> + DocumentNameSerializer mockDocumentNameSerializer =
>> this.context.mock(DocumentNameSerializer.class);
>> + DefaultComponentDescriptor<DocumentNameSerializer>
>> descriptorDNS =
>> + new DefaultComponentDescriptor<DocumentNameSerializer>();
>> + descriptorDNS.setRole(DocumentNameSerializer.class);
>> + getComponentManager().registerComponent(descriptorDNS,
>> mockDocumentNameSerializer);
>> }
>> -
>> +
>> /**
>> * Verify that inline HTML macros with non inline content
>> generate an exception.
>> */
>>
>> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/
>> xwiki-rendering-macro-include/src/test/java/org/xwiki/rendering/
>> internal/macro/IncludeMacroTest.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-include/src/test/java/org/xwiki/rendering/internal/
>> macro/IncludeMacroTest.java 2009-07-13 11:47:52 UTC (rev 21909)
>> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-include/src/test/java/org/xwiki/rendering/internal/
>> macro/IncludeMacroTest.java 2009-07-13 13:20:03 UTC (rev 21910)
>> @@ -24,6 +24,7 @@
>>
>> import org.jmock.Mock;
>> import org.xwiki.bridge.DocumentAccessBridge;
>> +import org.xwiki.component.descriptor.DefaultComponentDescriptor;
>> import org.xwiki.rendering.block.Block;
>> import org.xwiki.rendering.internal.macro.include.IncludeMacro;
>> import
>> org.xwiki.rendering.internal.transformation.MacroTransformation;
>> @@ -47,23 +48,25 @@
>> public class IncludeMacroTest extends AbstractRenderingTestCase
>> {
>> private Mock mockDocumentAccessBridge;
>> -
>> +
>> @Override
>> protected void registerComponents() throws Exception
>> {
>> this.mockDocumentAccessBridge =
>> mock(DocumentAccessBridge.class);
>> -
>> getComponentManager().registerComponent(DocumentAccessBridge.class,
>> this.mockDocumentAccessBridge.proxy());
>> +
>> + DefaultComponentDescriptor<DocumentAccessBridge> descriptor =
>> + new DefaultComponentDescriptor<DocumentAccessBridge>();
>> + descriptor.setRole(DocumentAccessBridge.class);
>> + getComponentManager().registerComponent(descriptor,
>> + (DocumentAccessBridge)
>> this.mockDocumentAccessBridge.proxy());
>> }
>>
>> public void testIncludeMacroWithNewContext() throws Exception
>> {
>> - String expected = "beginDocument\n"
>> - + "beginMacroMarkerStandalone [velocity] [] [$myvar]\n"
>> - + "beginParagraph\n"
>> - + "onWord [hello]\n"
>> - + "endParagraph\n"
>> - + "endMacroMarkerStandalone [velocity] [] [$myvar]\n"
>> - + "endDocument";
>> + String expected =
>> + "beginDocument\n" + "beginMacroMarkerStandalone
>> [velocity] [] [$myvar]\n" + "beginParagraph\n"
>> + + "onWord [hello]\n" + "endParagraph\n" +
>> "endMacroMarkerStandalone [velocity] [] [$myvar]\n"
>> + + "endDocument";
>
> I much prefer my version. Can you please rollback? Again an example
> why applying code style automatically sucks :)
>
>>
>> // Since it's not in the same context, we verify that a
>> Velocity variable set in the including page is not
>> // seen in the included page.
>> @@ -88,21 +91,19 @@
>>
>> // Create a Macro transformation context with the Macro
>> transformation object defined so that the include
>> // macro can transform included page which is using a new
>> context.
>> - MacroTransformation macroTransformation =
>> + MacroTransformation macroTransformation =
>> (MacroTransformation)
>> getComponentManager().lookup(Transformation.class, "macro");
>> MacroTransformationContext context = new
>> MacroTransformationContext();
>> context.setMacroTransformation(macroTransformation);
>> -
>> +
>> List<Block> blocks = macro.execute(parameters, null, context);
>>
>> assertBlocks(expected, blocks);
>> }
>> -
>> +
>> public void testIncludeMacroWithCurrentContext() throws Exception
>> {
>> - String expected = "beginDocument\n"
>> - + "onMacroStandalone [someMacro] []\n"
>> - + "endDocument";
>> + String expected = "beginDocument\n" + "onMacroStandalone
>> [someMacro] []\n" + "endDocument";
>
> again
>
>>
>> IncludeMacro macro = (IncludeMacro)
>> getComponentManager().lookup(Macro.class, "include");
>>
>> mockDocumentAccessBridge
>> .expects(once()).method("isDocumentViewable").will(returnValue(true));
>> @@ -119,7 +120,7 @@
>>
>> assertBlocks(expected, blocks);
>> }
>> -
>> +
>> public void testIncludeMacroWithNoDocumentSpecified() throws
>> Exception
>> {
>> IncludeMacro macro = (IncludeMacro)
>> getComponentManager().lookup(Macro.class, "include");
>> @@ -129,8 +130,8 @@
>> macro.execute(parameters, null, new
>> MacroTransformationContext());
>> fail("An exception should have been thrown");
>> } catch (MacroExecutionException expected) {
>> - assertEquals("You must specify a 'document' parameter
>> pointing to the document to include.",
>> - expected.getMessage());
>> + assertEquals("You must specify a 'document' parameter
>> pointing to the document to include.", expected
>> + .getMessage());
>
> again a brilliant example why it sucks... :(
>
> My version is much nicer.
>
>> }
>> }
>> }
>>
>> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/
>> xwiki-rendering-macro-rss/src/test/java/org/xwiki/rendering/
>> RenderingTests.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-rss/src/test/java/org/xwiki/rendering/
>> RenderingTests.java 2009-07-13 11:47:52 UTC (rev 21909)
>> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-rss/src/test/java/org/xwiki/rendering/
>> RenderingTests.java 2009-07-13 13:20:03 UTC (rev 21910)
>> @@ -22,11 +22,12 @@
>> import junit.framework.Test;
>> import junit.framework.TestCase;
>>
>> +import org.jmock.Expectations;
>> +import org.jmock.Mockery;
>> +import org.xwiki.bridge.SkinAccessBridge;
>> +import org.xwiki.component.descriptor.DefaultComponentDescriptor;
>> import org.xwiki.rendering.scaffolding.RenderingTestSuite;
>> import org.xwiki.test.ComponentManagerTestSetup;
>> -import org.xwiki.bridge.SkinAccessBridge;
>> -import org.jmock.Mockery;
>> -import org.jmock.Expectations;
>>
>> /**
>> * All Rendering integration tests defined in text files using a
>> special format.
>> @@ -39,21 +40,27 @@
>> public static Test suite() throws Exception
>> {
>> RenderingTestSuite suite = new RenderingTestSuite("Test RSS
>> Macro");
>> -
>> +
>> suite.addTestsFromResource("macrorss1", true);
>> suite.addTestsFromResource("macrorss2", true);
>>
>> ComponentManagerTestSetup setup = new
>> ComponentManagerTestSetup(suite);
>>
>> Mockery context = new Mockery();
>> - final SkinAccessBridge mockSkinBridge =
>> context.mock(SkinAccessBridge.class);
>> -
>> setup
>> .getComponentManager().registerComponent(SkinAccessBridge.class,
>> mockSkinBridge);
>>
>> - context.checking(new Expectations() {{
>> -
>> allowing(mockSkinBridge).getSkinFile(with(any(String.class)));
>> - will(returnValue("/xwiki/skins/albatross/icons/black-
>> rss.png"));
>> - }});
>> -
>> + final SkinAccessBridge mockSkinAccessBridge =
>> context.mock(SkinAccessBridge.class);
>> + DefaultComponentDescriptor<SkinAccessBridge> descriptorSAB
>> = new DefaultComponentDescriptor<SkinAccessBridge>();
>> + descriptorSAB.setRole(SkinAccessBridge.class);
>> +
>> setup.getComponentManager().registerComponent(descriptorSAB,
>> mockSkinAccessBridge);
>> +
>> + context.checking(new Expectations()
>> + {
>> + {
>> +
>> allowing(mockSkinAccessBridge).getSkinFile(with(any(String.class)));
>> + will(returnValue("/xwiki/skins/albatross/icons/
>> black-rss.png"));
>> + }
>> + });
>> +
>> return setup;
>> }
>> }
>>
>> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/
>> xwiki-rendering-macro-script/src/test/java/org/xwiki/rendering/macro/
>> script/RenderingTests.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-script/src/test/java/org/xwiki/rendering/macro/
>> script/RenderingTests.java 2009-07-13 11:47:52 UTC (rev 21909)
>> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-script/src/test/java/org/xwiki/rendering/macro/
>> script/RenderingTests.java 2009-07-13 13:20:03 UTC (rev 21910)
>> @@ -25,6 +25,7 @@
>> import org.jmock.Expectations;
>> import org.jmock.Mockery;
>> import org.xwiki.bridge.DocumentAccessBridge;
>> +import org.xwiki.component.descriptor.DefaultComponentDescriptor;
>> import org.xwiki.component.embed.EmbeddableComponentManager;
>> import org.xwiki.rendering.scaffolding.RenderingTestSuite;
>> import org.xwiki.test.ComponentManagerTestSetup;
>> @@ -45,22 +46,30 @@
>> suite.addTestsFromResource("macroscript2", true);
>> suite.addTestsFromResource("macroscript3", true);
>> suite.addTestsFromResource("macroscript4", true);
>> -
>> +
>> ComponentManagerTestSetup testSetup = new
>> ComponentManagerTestSetup(suite);
>> setUpMocks(testSetup.getComponentManager());
>>
>> return testSetup;
>> }
>> -
>> +
>> public static void setUpMocks(EmbeddableComponentManager
>> componentManager)
>> {
>> Mockery context = new Mockery();
>>
>> // Document Access Bridge Mock setup
>> final DocumentAccessBridge mockDocumentAccessBridge =
>> context.mock(DocumentAccessBridge.class);
>> - context.checking(new Expectations() {{
>> -
>> allowing(mockDocumentAccessBridge).hasProgrammingRights();
>> will(returnValue(true));
>> - }});
>> -
>> componentManager.registerComponent(DocumentAccessBridge.class,
>> mockDocumentAccessBridge);
>> + context.checking(new Expectations()
>> + {
>> + {
>> +
>> allowing(mockDocumentAccessBridge).hasProgrammingRights();
>> + will(returnValue(true));
>> + }
>> + });
>> +
>> + DefaultComponentDescriptor<DocumentAccessBridge>
>> descriptorDAB =
>> + new DefaultComponentDescriptor<DocumentAccessBridge>();
>> + descriptorDAB.setRole(DocumentAccessBridge.class);
>> + componentManager.registerComponent(descriptorDAB,
>> mockDocumentAccessBridge);
>> }
>> }
>>
>> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/
>> xwiki-rendering-macro-velocity/src/test/java/org/xwiki/rendering/
>> macro/velocity/RenderingTests.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-velocity/src/test/java/org/xwiki/rendering/macro/
>> velocity/RenderingTests.java 2009-07-13 11:47:52 UTC (rev 21909)
>> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-
>> rendering-macro-velocity/src/test/java/org/xwiki/rendering/macro/
>> velocity/RenderingTests.java 2009-07-13 13:20:03 UTC (rev 21910)
>> @@ -24,6 +24,7 @@
>>
>> import org.jmock.Mockery;
>> import org.xwiki.bridge.DocumentAccessBridge;
>> +import org.xwiki.component.descriptor.DefaultComponentDescriptor;
>> import org.xwiki.component.embed.EmbeddableComponentManager;
>> import org.xwiki.rendering.scaffolding.RenderingTestSuite;
>> import org.xwiki.test.ComponentManagerTestSetup;
>> @@ -64,6 +65,9 @@
>>
>> // Document Access Bridge Mock
>> final DocumentAccessBridge mockDocumentAccessBridge =
>> context.mock(DocumentAccessBridge.class);
>> -
>> componentManager.registerComponent(DocumentAccessBridge.class,
>> mockDocumentAccessBridge);
>> + DefaultComponentDescriptor<DocumentAccessBridge>
>> descriptorDAB =
>> + new DefaultComponentDescriptor<DocumentAccessBridge>();
>> + descriptorDAB.setRole(DocumentAccessBridge.class);
>> + componentManager.registerComponent(descriptorDAB,
>> mockDocumentAccessBridge);
>> }
>> }
>>
>> Modified: platform/core/trunk/xwiki-shared-tests/src/main/java/org/
>> xwiki/test/MockConfigurationSource.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-shared-tests/src/main/java/org/xwiki/
>> test/MockConfigurationSource.java 2009-07-13 11:47:52 UTC (rev 21909)
>> +++ platform/core/trunk/xwiki-shared-tests/src/main/java/org/xwiki/
>> test/MockConfigurationSource.java 2009-07-13 13:20:03 UTC (rev 21910)
>> @@ -23,8 +23,6 @@
>> import java.util.List;
>> import java.util.Properties;
>>
>> -import org.xwiki.component.descriptor.ComponentDescriptor;
>> -import org.xwiki.component.descriptor.DefaultComponentDescriptor;
>> import org.xwiki.configuration.ConfigurationSource;
>>
>> /**
>>
>> Modified: platform/core/trunk/xwiki-shared-tests/src/main/java/org/
>> xwiki/test/XWikiComponentInitializer.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-shared-tests/src/main/java/org/xwiki/
>> test/XWikiComponentInitializer.java 2009-07-13 11:47:52 UTC (rev
>> 21909)
>> +++ platform/core/trunk/xwiki-shared-tests/src/main/java/org/xwiki/
>> test/XWikiComponentInitializer.java 2009-07-13 13:20:03 UTC (rev
>> 21910)
>> @@ -24,6 +24,7 @@
>> import java.net.MalformedURLException;
>> import java.net.URL;
>>
>> +import org.xwiki.component.descriptor.DefaultComponentDescriptor;
>> import org.xwiki.component.embed.EmbeddableComponentManager;
>> import org.xwiki.configuration.ConfigurationSource;
>> import org.xwiki.container.ApplicationContext;
>> @@ -32,13 +33,18 @@
>> import org.xwiki.context.ExecutionContext;
>> import org.xwiki.context.ExecutionContextManager;
>>
>> +/**
>> + * Initialize a component manager used in unit tests.
>> + *
>> + * @version $Id$
>> + */
>> public class XWikiComponentInitializer
>> {
>> private EmbeddableComponentManager componentManager;
>>
>> /**
>> - * This method should be called before {@link
>> #initializeExecution()} since some components will require the
>> Container
>> - * component to be set up (for example to access resource such
>> as the XWikiconfiguration file).
>> + * This method should be called before {@link
>> #initializeExecution()} since some components will require the
>> + * Container component to be set up (for example to access
>> resource such as the XWikiconfiguration file).
>> */
>> public void initializeContainer() throws Exception
>> {
>> @@ -67,15 +73,24 @@
>> }
>> });
>> }
>> -
>> +
>> public void initializeConfigurationSource() throws Exception
>> {
>> // Register the mock configuration source for different
>> roles so that tests always use the mock
>> ConfigurationSource mockSource = new
>> MockConfigurationSource();
>> -
>> getComponentManager().registerComponent(ConfigurationSource.class,
>> mockSource);
>> -
>> getComponentManager().registerComponent(ConfigurationSource.class,
>> "xwikiproperties", mockSource);
>> +
>> + DefaultComponentDescriptor<ConfigurationSource> descriptor;
>> +
>> + descriptor = new
>> DefaultComponentDescriptor<ConfigurationSource>();
>> + descriptor.setRole(ConfigurationSource.class);
>> + getComponentManager().registerComponent(descriptor,
>> mockSource);
>> +
>> + descriptor = new
>> DefaultComponentDescriptor<ConfigurationSource>();
>> + descriptor.setRole(ConfigurationSource.class);
>> + descriptor.setRoleHint("xwikiproperties");
>> + getComponentManager().registerComponent(descriptor,
>> mockSource);
>> }
>> -
>> +
>> public void initializeExecution() throws Exception
>> {
>> // Initialize the Execution Context
>> @@ -85,11 +100,11 @@
>> ExecutionContext ec = new ExecutionContext();
>>
>> // Make sure we push this empty context in the Execution
>> component before we call the initialization
>> - // so that we don't get any NPE if some initializer code
>> asks to get the Execution Context. This
>> + // so that we don't get any NPE if some initializer code
>> asks to get the Execution Context. This
>> // happens for example with the Velocity Execution Context
>> initializer which in turns calls the Velocity
>> // Context initializers and some of them look inside the
>> Execution Context.
>> execution.setContext(ec);
>> -
>> +
>> ecm.initialize(ec);
>> }
>
> Thanks
> -Vincent
>
> _______________________________________________
> devs mailing list
> devs(a)xwiki.org
> http://lists.xwiki.org/mailman/listinfo/devs
>
--
Thomas Mortagne
2
1