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
- 9399 discussions
14 Jul '09
Someone would need to try this version to see if it works and then we
could upgrade our version maybe.
-Vincent
Begin forwarded message:
> From: Dennis Lundberg <dennisl(a)apache.org>
> Date: July 14, 2009 3:54:40 PM CEDT
> To: announce(a)maven.apache.org, Maven Users List <users(a)maven.apache.org
> >
> Cc: Maven Developers List <dev(a)maven.apache.org>
> Subject: [ANN] Maven Checkstyle Plugin 2.3 Released
> Reply-To: "Maven Users List" <users(a)maven.apache.org>
>
> The Maven team is pleased to announce the release of the Maven
> Checkstyle Plugin, version 2.3
>
> The Checkstyle plugin generates report regarding the code style used
> by
> the developers.
>
> Important note: This version of the plugin uses Checkstyle 4.4.
> Version
> 2.3 will be the last version of Maven Checkstyle Plugin that will
> run on
> Java 1.4. The next version of Maven Checkstyle Plugin will be upgraded
> to Checkstyle 5 and will therefor require Java 5 to run.
>
> http://maven.apache.org/plugins/maven-checkstyle-plugin/
>
> You should specify the version in your project's plugin configuration:
>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-checkstyle-plugin</artifactId>
> <version>2.3</version>
> </plugin>
>
>
> Release Notes - Maven 2.x Checkstyle Plugin - Version 2.3
>
> ** Improvement
> * [MCHECKSTYLE-101] - Skip should skip everything including the
> Velocity initialization
> * [MCHECKSTYLE-110] - option to output violations to the console
> when using chekstyle:check
> * [MCHECKSTYLE-114] - Add an ASF-compliant source release assembly
>
> ** New Feature
> * [MCHECKSTYLE-113] - Set the number of accepted violations for
> checkstyle:check
>
> ** Task
> * [MCHECKSTYLE-98] - Maven Checkstyle is too strict and not follow
> Maven's team conventions!
>
>
> Enjoy,
>
> -The Maven team
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe(a)maven.apache.org
> For additional commands, e-mail: users-help(a)maven.apache.org
>
1
0
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.
[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... ;)
[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.
[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.
[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.
> + 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?
[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.
[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
4
7
Hi
I just uploaded an XAR export onto this JIRA report:
http://jira.xwiki.org/jira/secure/ManageAttachments.jspa?id=26378
It contains the changed documents supporting 2.0 syntax. For now the upgraded pages contain the suffix '2' including the WebHome which is called 'WebHome2'. To check out what I did please open this page 'Blog/WebHome2' to view the Blog.
To test it out download the attached file and import it (it will not overwrite any Blog documents).
I have 2 major issues so far:
1) The post is not displayed correctly (there is some mixup with Velocity and the startmacro and stopmacro comment.
2) The Categories / Archive Panel cannot be upgraded to 2.0 Syntax because the Panel is still in 1.0 syntax. I don't know how to resolve that except keeping the panel and the code pages available in 1.0 syntax.
I would appreciate if anyone could help me on number 1) because I don't know where start looking right now.
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
2
3
Hello Devs,
I want to store lucene index in database.is it possible to store lucene
index in database and make search on that index.
in short storing index in bd and access it from db.
BR,
Sayeem
3
2
[xwiki-devs] [VOTE] Add unregister component descriptor and register component instance to component manager API
by Thomas Mortagne 13 Jul '09
by Thomas Mortagne 13 Jul '09
13 Jul '09
H devs,
To implements wiki macros Adiri need componenet manager to support two
new things:
- unregister a component descriptor: when a wiki macro is removed and
does not exists anymore it you not be listed in components. This will
be also needed for application manager to be able to uninstall
application containing components.
- register component instance: wiki macro are based on WikiMacro
implementation of Macro component interface but with different datas
depending of the macro, to register this kind of macro as component we
need to be able to directly register the instance to use and not let
the component manager do the instantiation form the descriptor since
we cant add custom datas in component descriptor
Here is my +1 for both.
--
Thomas Mortagne
5
9
[xwiki-devs] possible small problem with import/export & virtual wiki & copy doc after import
by Pascal Voitot 13 Jul '09
by Pascal Voitot 13 Jul '09
13 Jul '09
Hello,
I use virtual wikis and I have created a XAR by exporting from one wiki and
then importing the XAR into another wiki.
Then I choose a doc in the new wiki and I just want to copy it into another
document in the same wiki and it gives "Successfully copied" but when I
access the new doc, it says "your doc doesn't exist" and it is really
empty... No error anywhere...
After comparing with other documents I could copy without any problem, I
discovered that my doc has a parent such as "oldwiki:MySpace.MyParentDoc"
instead of "newwiki:MySpace.MyParentDoc". (I didn't set the parent using
virtual wikis explicitely, it was created by the wiki like that)
So apparently, the export keeps the parent name with wiki relationship. As
the export is just a raw serialization of the document structure, it is not
really surprising.
And the copy function fails to copy the document without any error.
regards
Pascal
1
0
Hello,
maybe I'm a bit stupid but I tried using the Groovy Console app
it works perfectly but it requires loading/saving scripts into
XWiki.ConsoleScriptClass.
But where is this class because I can't find it?
Moreover, when a script is stored in one object of this class, how to use
it? Is there a kind of extension such as jsx or ssx?
regards
Pascal
1
0
http://www.xwiki.org/xwiki/bin/view/Main/ProductDocumentation
gives velocity error...
Pascal
2
1
Re: [xwiki-devs] [Proposal] Unification of input/output syntaxes (was Re: [xwiki-notifications] r21811 - in platform: core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/api core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/doc core/trunk/xwiki-core/sr
by Thomas Mortagne 11 Jul '09
by Thomas Mortagne 11 Jul '09
11 Jul '09
On Sat, Jul 11, 2009 at 10:09, Vincent Massol<vincent(a)massol.net> wrote:
> Summarizing (I've now understood):
> - We have input syntaxes (parser syntaxes) and output syntaxes
> (renderer syntaxes)
>
> Proposal
> =======
>
> a- we rename SyntaxFactory.getAvailableSyntaxes() in
> getAvailableInputSyntaxes() (or getAvailableParserSyntaxes())
+1 , since it's in rendering module we should always use same
vocabulary so +1 for getAvailableParserSyntaxes
> b- we add SyntaFactory.getAvailableOutputSyntaxes() (or
> getAvailableRendererSyntaxes())
+1 for getAvailableRendererSyntaxes
> c- (optional) we add a Renderer.getSyntax() interface method (for
> later use when renderers will be components)
let's wait for when we will make renderers componenents since it
depends on how we do that exactly
> d- we rename Document/XWikiDocument/XWiki methods for getting syntaxes
> to use Input/Ouput (or Parser/Renderer) in their names.
+1
>
> Note that b) means that we'll hardcode the list of available renderer
> syntaxes but that's ok for now (this is hat is currently done in
> PrintRendererFactory). This will be made dynamic when Renderer are
> made components.
The advantage of putting this in PrintRendererFactory is that you have
less chance to forget to update the list when you add a new renderer
but i doubt we will add one before making renderers real components
actually so i guess it ok.
>
> WDYT?
>
> Thanks
> -Vincent
>
> On Jul 10, 2009, at 6:49 PM, Thomas Mortagne wrote:
>
>> On Fri, Jul 10, 2009 at 09:41, Vincent Massol<vincent(a)massol.net>
>> wrote:
>>>
>>> On Jul 4, 2009, at 2:44 PM, tmortagne (SVN) wrote:
>>>
>>>> Author: tmortagne
>>>> Date: 2009-07-04 14:44:30 +0200 (Sat, 04 Jul 2009)
>>>> New Revision: 21811
>>>>
>>>> Modified:
>>>> Â platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/api/
>>>> Document.java
>>>> Â platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/api/
>>>> XWiki.java
>>>> Â platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/doc/
>>>> XWikiDocument.java
>>>> Â platform/core/trunk/xwiki-core/src/test/java/com/xpn/xwiki/api/
>>>> XWikiTest.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/internal/renderer/
>>>> DefaultPrintRendererFactory.java
>>>> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/
>>>> java/org/xwiki/rendering/parser/Syntax.java
>>>> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/
>>>> java/org/xwiki/rendering/parser/SyntaxType.java
>>>> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/
>>>> java/org/xwiki/rendering/renderer/PrintRendererFactory.java
>>>> Â platform/web/trunk/standard/src/main/webapp/templates/
>>>> contentview.vm
>>>> Â platform/web/trunk/standard/src/main/webapp/templates/plain.vm
>>>> Log:
>>>> XWIKI-4042: Add a way to choose the renderer when viewing a page
>>>
>>>>
>>>> Modified: platform/core/trunk/xwiki-core/src/main/java/com/xpn/
>>>> xwiki/
>>>> api/Document.java
>>>> ===================================================================
>>>> --- platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/api/
>>>> Document.java 2009-07-04 12:42:14 UTC (rev 21810)
>>>> +++ platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/api/
>>>> Document.java 2009-07-04 12:44:30 UTC (rev 21811)
>>>> @@ -37,6 +37,7 @@
>>>> import org.suigeneris.jrcs.diff.DifferentiationFailedException;
>>>> import org.suigeneris.jrcs.diff.delta.Delta;
>>>> import org.suigeneris.jrcs.rcs.Version;
>>>> +import org.xwiki.rendering.parser.Syntax;
>>>>
>>>> import com.xpn.xwiki.XWiki;
>>>> import com.xpn.xwiki.XWikiContext;
>>>> @@ -473,6 +474,16 @@
>>>> Â Â }
>>>>
>>>> Â Â /**
>>>> + Â Â * @param targetSyntax the syntax in which render the document
>>>> content
>>>> + Â Â * @return the rendered content
>>>> + Â Â * @throws XWikiException error when rendering content
>>>> + Â Â */
>>>> + Â Â public String getRenderedContent(Syntax targetSyntax) throws
>>>> XWikiException
>>>> + Â Â {
>>>> + Â Â Â Â return this.doc.getRenderedContent(targetSyntax,
>>>> getXWikiContext());
>>>> + Â Â }
>>>
>>> Since this is for Velocity, isn't it better to use a syntax Id String
>>> instead of a Syntax object which is hard to construct from velocity?
>>
>> The problem is that it was not easy to find a right signature since
>> there is already getRenderedContent taking string fo the parser
>> syntax. Since anyway it's necessary to give a supported syntax by
>> looking at existing one it was easier to not have to directly give the
>> found valid syntax object.
>>
>>>
>>>> +
>>>> + Â Â /**
>>>> Â Â Â * return a escaped version of the content of this document
>>>> Â Â Â */
>>>> Â Â public String getEscapedContent() throws XWikiException
>>>>
>>>> Modified: platform/core/trunk/xwiki-core/src/main/java/com/xpn/
>>>> xwiki/
>>>> api/XWiki.java
>>>> ===================================================================
>>>> --- platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/api/
>>>> XWiki.java   2009-07-04 12:42:14 UTC (rev 21810)
>>>> +++ platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/api/
>>>> XWiki.java   2009-07-04 12:44:30 UTC (rev 21811)
>>>> @@ -30,6 +30,8 @@
>>>> import org.apache.commons.logging.LogFactory;
>>>> import org.suigeneris.jrcs.diff.delta.Chunk;
>>>> import org.xwiki.query.QueryManager;
>>>> +import org.xwiki.rendering.parser.Syntax;
>>>> +import org.xwiki.rendering.renderer.PrintRendererFactory;
>>>>
>>>> import com.xpn.xwiki.XWikiContext;
>>>> import com.xpn.xwiki.XWikiException;
>>>> @@ -2685,4 +2687,42 @@
>>>> Â Â {
>>>> Â Â Â Â return this.xwiki.getDefaultDocumentSyntax();
>>>> Â Â }
>>>> +
>>>> + Â Â /**
>>>> + Â Â * Find the corresponding available renderer syntax.
>>>> + Â Â * <p>
>>>> + Â Â * If <code>syntaxVersion</code> is null the last version of
>>>> the available provided syntax type is returned.
>>>> + Â Â *
>>>> + Â Â * @param syntaxType the syntax type
>>>> + Â Â * @param syntaxVersion the syntax version
>>>> + Â Â * @return the available corresponding {@link Syntax}. Null if
>>>> no available renderer can be found.
>>>> + Â Â */
>>>> + Â Â public Syntax getAvailableRendererSyntax(String syntaxType,
>>>> String syntaxVersion)
>>>> + Â Â {
>>>> + Â Â Â Â Syntax syntax = null;
>>>> +
>>>> + Â Â Â Â PrintRendererFactory printRendererFactory =
>>>> + Â Â Â Â Â Â (PrintRendererFactory)
>>>> Utils.getComponent(PrintRendererFactory.class);
>>>> +
>>>> + Â Â Â Â List<Syntax> availableSyntaxes =
>>>> printRendererFactory.getAvailableSyntaxes();
>>>
>>> We already have the notion of available syntaxes in the
>>> SyntaxFactory.
>>
>> No, we have the notion of available parsers, the method name is just
>> wrong in SyntaxFactory... The only place where we know the available
>> renderers is the PrintRendererFactory since it's impossible to get all
>> renderers otherwise until renderer are made components.
>>
>>> I don't understand why we need to have them in the
>>> PrintRendererFactory (which is not supposed to return syntaxes BTW,
>>> it's only supposed to return PrintRenderer(s).
>>>
>>>> +
>>>> + Â Â Â Â for (Syntax availableSyntax : availableSyntaxes) {
>>>
>>> Why not instead do:
>>> SyntaxType syntaxType = SyntaxType.getSyntaxType(syntaxTypeAsString);
>>>
>>> And then (when syntaxVersion != null):
>>> Syntax syntax = new Syntax(syntaxType, syntaxVersion);
>>>
>>> And then:
>>> syntaxFatory.getAvailableSyntaxes().contains(syntax)
>>
>> It's not that simple since we have to support the use case where
>> syntaxVersion is not given (which is most of the time).
>>
>>>
>>> hmmm.... Actually thinking more about it, I believe this whole code
>>> should be moved out of XWikiDocument and instead go in the rendering
>>> module in SyntaxFactory.
>>
>> Again in SyntaxFactory you have no idea what are the available
>> renderers syntaxes and here we don't care about parsers.
>> Until we have clean renderer componet my goal was to put as less as
>> possible temporary code in rendering module.
>>
>>>
>>>> + Â Â Â Â Â Â if (syntaxVersion != null) {
>>>> + Â Â Â Â Â Â Â Â if
>>>> (availableSyntax.getType().toIdString().equalsIgnoreCase(syntaxType)
>>>> + Â Â Â Â Â Â Â Â Â Â &&
>>>> availableSyntax.getVersion().equals(syntaxVersion)) {
>>>> + Â Â Â Â Â Â Â Â Â Â syntax = availableSyntax;
>>>> + Â Â Â Â Â Â Â Â Â Â break;
>>>> + Â Â Â Â Â Â Â Â }
>>>> + Â Â Â Â Â Â } else {
>>>> + Â Â Â Â Â Â Â Â // TODO: improve version comparaison since it does
>>>> not work when comparing 2.0 and 10.0 for example. We
>>>> + Â Â Â Â Â Â Â Â // should have a Version which implements
>>>> Comparable like we have SyntaxId in Syntax
>>>> + Â Â Â Â Â Â Â Â if
>>>> (availableSyntax.getType().toIdString().equalsIgnoreCase(syntaxType)
>>>> + Â Â Â Â Â Â Â Â Â Â && (syntax == null ||
>>>> availableSyntax.getVersion().compareTo(syntax.getVersion()) > 0)) {
>>>> + Â Â Â Â Â Â Â Â Â Â syntax = availableSyntax;
>>>> + Â Â Â Â Â Â Â Â }
>>>> + Â Â Â Â Â Â }
>>>> + Â Â Â Â }
>>>> +
>>>> + Â Â Â Â return syntax;
>>>> + Â Â }
>>>> }
>>>
>>> [snip]
>>>>
>>>> Â Â /**
>>>> + Â Â * @return the syntax of the document
>>>> + Â Â */
>>>> + Â Â private Syntax getSyntax()
>>>> + Â Â {
>>>> + Â Â Â Â Syntax syntax = null;
>>>> +
>>>> + Â Â Â Â String syntaxId = getDefaultDocumentSyntax();
>>>> + Â Â Â Â try {
>>>> + Â Â Â Â Â Â syntax =
>>>> this.syntaxFactory.createSyntaxFromIdString(getSyntaxId());
>>>
>>> Shouldn't we save the Syntax object instead of syntaxId in
>>> XWikiDocument so that we don't perform the conversion every time
>>> getSyntax is called?
>>
>> I did not planed to refactor the whole XWikiDocument, i just done what
>> was needed but at some point yes we should have Syntax and XDOM
>> instead of the syntax/content strings :)
>>
>>>
>>>> + Â Â Â Â } catch (ParseException e) {
>>>> + Â Â Â Â Â Â LOG.error("Failed to genrate Syntax object for syntax
>>>> identifier [" + syntaxId + "] in page ["
>>>
>>> Typo: generate
>>>
>>>> + Â Â Â Â Â Â Â Â + getDocumentName() + "]", e);
>>>> +
>>>> + Â Â Â Â Â Â syntaxId = getDefaultDocumentSyntax();
>>>
>>> I don't understand this line above, it's the same as the one a few
>>> lines above.
>>>
>>>> + Â Â Â Â Â Â try {
>>>> + Â Â Â Â Â Â Â Â syntax =
>>>> this
>>>> .syntaxFactory.createSyntaxFromIdString(getDefaultDocumentSyntax());
>>>
>>> It seems you're not using the syntaxId variable.
>>
>> Yes it's an error, I added the variables when added the error message
>> and forgot to change the "real" code properly.
>>
>>>
>>>> + Â Â Â Â Â Â } catch (ParseException e1) {
>>>> + Â Â Â Â Â Â Â Â LOG.error("Failed to genrate default Syntax object.
>>>> The defautlt syntax id in [" + syntaxId + "]", e);
>>>
>>> same typo
>>>
>>> [snip]
>>>
>>>> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-api/
>>>> pom.xml
>>>> ===================================================================
>>>> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-api/pom.xml
>>>> 2009-07-04 12:42:14 UTC (rev 21810)
>>>> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-api/pom.xml
>>>> 2009-07-04 12:44:30 UTC (rev 21811)
>>>> @@ -187,7 +187,9 @@
>>>> Â Â Â Â Â Â Â Â <!-- Excludes for the 2.0 M2 release. Once it's
>>>> released remove them. -->
>>>> Â Â Â Â Â Â Â Â <exclude>org/xwiki/rendering/macro/MacroManager</
>>>> exclude>
>>>> Â Â Â Â Â Â Â Â <exclude>org/xwiki/rendering/macro/MacroSource</
>>>> exclude>
>>>> - Â Â Â Â Â Â Â Â <exclude>org/xwiki/rendering/macro/
>>>> AbstractMacroSource</exclude>
>>>> + Â Â Â Â Â Â Â Â <exclude>org/xwiki/rendering/macro/
>>>> AbstractMacroSource</exclude>
>>>> + Â Â Â Â Â Â Â Â <!-- Seems clirr plugin consider adding new API as
>>>> an error (which I don't understand). -->
>>>
>>> It doesn't normally (it' considered as an INFO level) unless it
>>> breaks
>>> binary compatibility. But I don't know why in your case (would need
>>> to
>>> check more the code, i'm only looking at the svn diff).
>>
>> If you remove this the plugin clearly say that there is an error and
>> it also clearly say that the error is that there is new api in
>> PrintRendererFactory. Maybe the error message is wrong but i check and
>> rechecked and this is the only difference.
>>
>>>
>>>> + Â Â Â Â Â Â Â Â <exclude>org/xwiki/rendering/renderer/
>>>> PrintRendererFactory</exclude>
>>>> Â Â Â Â Â Â Â </excludes>
>>>> Â Â Â Â Â Â </configuration>
>>>> Â Â Â Â Â </execution>
>>>>
>>>> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-api/
>>>> src/main/java/org/xwiki/rendering/internal/renderer/
>>>> DefaultPrintRendererFactory.java
>>>> ===================================================================
>>>> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/
>>>> main/
>>>> java/org/xwiki/rendering/internal/renderer/
>>>> DefaultPrintRendererFactory.java    2009-07-04 12:42:14 UTC (rev
>>>> 21810)
>>>> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/
>>>> main/
>>>> java/org/xwiki/rendering/internal/renderer/
>>>> DefaultPrintRendererFactory.java    2009-07-04 12:44:30 UTC (rev
>>>> 21811)
>>>> @@ -19,6 +19,10 @@
>>>> Â */
>>>> package org.xwiki.rendering.internal.renderer;
>>>>
>>>> +import java.util.Arrays;
>>>> +import java.util.Collections;
>>>> +import java.util.List;
>>>> +
>>>> import org.xwiki.component.annotation.Component;
>>>> import org.xwiki.component.annotation.Requirement;
>>>> import org.xwiki.rendering.parser.Syntax;
>>>> @@ -43,6 +47,10 @@
>>>> @Component
>>>> public class DefaultPrintRendererFactory implements
>>>> PrintRendererFactory
>>>> {
>>>> + Â Â private static final List<Syntax> AVAILABLE_SYNTAXES =
>>>> +
>>>> Collections.unmodifiableList(Arrays.asList(Syntax.XHTML_1_0,
>>>> Syntax.XWIKI_2_0, Syntax.EVENT_1_0,
>>>> + Â Â Â Â Â Â Syntax.TEX_1_0, Syntax.PLAIN_1_0));
>>>
>>> I don't like this, see above.
>>
>> Again it's a factory, it's the only place where we really now what are
>> the renderers. I don't like this either but since renderer are not
>> component there is no choice.
>>
>>>
>>>> +
>>>> Â Â /**
>>>> Â Â Â * Factory to easily create an XHTML Image and Link Renderers.
>>>> Â Â Â */
>>>> @@ -55,6 +63,16 @@
>>>> Â Â /**
>>>> Â Â Â * {@inheritDoc}
>>>> Â Â Â *
>>>> + Â Â * @see
>>>> org
>>>> .xwiki
>>>> .rendering.renderer.PrintRendererFactory#getAvailableSyntaxes()
>>>> + Â Â */
>>>> + Â Â public List<Syntax> getAvailableSyntaxes()
>>>> + Â Â {
>>>> + Â Â Â Â return AVAILABLE_SYNTAXES;
>>>> + Â Â }
>>>> +
>>>
>>> I don't like this, see above.
>>>
>>> [snip]
>>>
>>> Thanks
>>> -Vincent
>>>
>>> _______________________________________________
>>> devs mailing list
>>> devs(a)xwiki.org
>>> http://lists.xwiki.org/mailman/listinfo/devs
>>>
>>
>>
>>
>> --
>> Thomas Mortagne
>> _______________________________________________
>> devs mailing list
>> devs(a)xwiki.org
>> http://lists.xwiki.org/mailman/listinfo/devs
>
> _______________________________________________
> devs mailing list
> devs(a)xwiki.org
> http://lists.xwiki.org/mailman/listinfo/devs
>
--
Thomas Mortagne
1
0
[xwiki-devs] serialVersionUID (was Re: [xwiki-notifications] r21863 - platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/xwiki/plugin/wikimanager)
by Vincent Massol 11 Jul '09
by Vincent Massol 11 Jul '09
11 Jul '09
On Jul 9, 2009, at 12:15 PM, tmortagne (SVN) wrote:
> Author: tmortagne
> Date: 2009-07-09 12:15:53 +0200 (Thu, 09 Jul 2009)
> New Revision: 21863
>
> Modified:
> platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/
> xwiki/plugin/wikimanager/WikiManagerException.java
> Log:
> [misc] Add serialize id
>
> Modified: platform/xwiki-plugins/trunk/wiki-manager/src/main/java/
> com/xpn/xwiki/plugin/wikimanager/WikiManagerException.java
> ===================================================================
> --- platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/
> xwiki/plugin/wikimanager/WikiManagerException.java 2009-07-09
> 09:56:02 UTC (rev 21862)
> +++ platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/
> xwiki/plugin/wikimanager/WikiManagerException.java 2009-07-09
> 10:15:53 UTC (rev 21863)
> @@ -30,11 +30,6 @@
> public class WikiManagerException extends PluginException
> {
> /**
> - * Serialize id.
> - */
> - private static final long serialVersionUID =
> -6451750749104331619L;
> -
> - /**
> * Error when trying to use provided user that does not exists.
> * <p>
> * TODO : move in XWikiException
> @@ -98,6 +93,11 @@
> // //////
>
> /**
> + * Serialize id.
> + */
> + private static final long serialVersionUID =
> -6451750749104331619L;
> +
I've asked myself several times how to document this. I've used
different versions:
- "Unique ID for Class Serialization."
- "Class id for Serialization."
and the more descriptive:
/**
* Needed to identify the version of this code when serializing/
deserializing (since Exception is Serializable).
* Note that the value needs to be modified whenever a non
transient field is added or removed in this class.
*/
The last one is the one I prefer (I think) since not everyone knows
about this and it makes it clear that the id needs to be modified
whenever a new field is added/removed.
We could also add a link to some URL describing class serialization.
WDYT?
Thanks
-Vincent
2
1