Re: [xwiki-devs] [xwiki-notifications] r33873 - in platform/xwiki-plugins/trunk/skinx: . src/main src/main/java src/main/java/org src/main/java/org/xwiki src/main/java/org/xwiki/skinx src/main/java/org/xwiki/skinx/internal src/main/resources src/main/resources/META-INF
Hi Anca, On 01/10/2011 12:56 PM, lucaa (SVN) wrote:
Author: lucaa Date: 2011-01-10 11:56:58 +0100 (Mon, 10 Jan 2011) New Revision: 33873
Added: platform/xwiki-plugins/trunk/skinx/src/main/java/org/ platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/ platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/ platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/AbstractWrapperSkinExtension.java platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/ platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/CssDocumentSkinExtension.java platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/CssFileSkinExtension.java platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/CssResourceSkinExtension.java platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/JsDocumentSkinExtension.java platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/JsFileSkinExtension.java platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/JsResourceSkinExtension.java platform/xwiki-plugins/trunk/skinx/src/main/resources/ platform/xwiki-plugins/trunk/skinx/src/main/resources/META-INF/ platform/xwiki-plugins/trunk/skinx/src/main/resources/META-INF/components.txt Modified: platform/xwiki-plugins/trunk/skinx/pom.xml Log: XSKINX-47: Implement a bridge to the skin extension API
Modified: platform/xwiki-plugins/trunk/skinx/pom.xml =================================================================== --- platform/xwiki-plugins/trunk/skinx/pom.xml 2011-01-10 10:53:23 UTC (rev 33872) +++ platform/xwiki-plugins/trunk/skinx/pom.xml 2011-01-10 10:56:58 UTC (rev 33873) @@ -34,7 +34,7 @@ <version>1.20-SNAPSHOT</version> <description>XWiki Platform - Plugins - Skin Extensions</description> <properties> -<platform.core.version>2.4</platform.core.version> +<platform.core.version>3.0-SNAPSHOT</platform.core.version> </properties> <dependencies> <dependency> @@ -44,6 +44,12 @@ <scope>provided</scope> </dependency> <dependency> +<groupId>org.xwiki.platform</groupId> +<artifactId>xwiki-core-skin</artifactId> +<version>${platform.core.version}</version> +<scope>provided</scope> +</dependency> +<dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> </dependency>
Added: platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/AbstractWrapperSkinExtension.java =================================================================== --- platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/AbstractWrapperSkinExtension.java (rev 0) +++ platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/AbstractWrapperSkinExtension.java 2011-01-10 10:56:58 UTC (rev 33873) @@ -0,0 +1,81 @@ +/* + * 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.skinx; + +import java.util.Map; + +import org.xwiki.component.annotation.Requirement; +import org.xwiki.context.Execution; + +import com.xpn.xwiki.XWiki; +import com.xpn.xwiki.XWikiContext; +import com.xpn.xwiki.plugin.skinx.SkinExtensionPluginApi; + +/** + * The abstract implementation of the wrapper around the skinx plugin. Provides the mechanism needed to grab the skin + * extensions plugins and call the use methods on them, subclasses only need to provide the name of the skin extension. + * + * @version $Id$ + * @since 3.0M1 + */ +public abstract class AbstractWrapperSkinExtension implements SkinExtension +{ + + /** + * Execution context, needed to grab the sx plugins to include js and css. + */ + @Requirement + private Execution execution; + + /** + * {@inheritDoc} + * + * @see org.xwiki.skinx.SkinExtension#use(java.lang.String) + */ + public void use(String resource) + { + getSkinExtensionPluginApi().use(resource); + } + + /** + * {@inheritDoc} + * + * @see org.xwiki.skinx.SkinExtension#use(java.lang.String, java.util.Map) + */ + public void use(String resource, Map<String, Object> parameters) + { + getSkinExtensionPluginApi().use(resource, parameters); + } + + /** + * @return the {@link SkinExtensionPluginApi} in the running wiki. + */ + private SkinExtensionPluginApi getSkinExtensionPluginApi() + { + XWikiContext xwikiContext = (XWikiContext) execution.getContext().getProperty("xwikicontext"); + XWiki wiki = xwikiContext.getWiki(); + return (SkinExtensionPluginApi) wiki.getPluginApi(getName(), xwikiContext); + } +
+ /** + * @return the name of the skin extension (e.g. ssx, jsfx, etc) to wrap. + */ + public abstract String getName(); +}
This method is not necessary because you should be able to get component hint through introspection: Component component = (Component) this.getClass().getAnnotation(Component.class); String name = component.value();
Property changes on: platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/AbstractWrapperSkinExtension.java ___________________________________________________________________ Added: svn:keywords + Author Id Revision HeadURL Added: svn:eol-style + native
Added: platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/CssDocumentSkinExtension.java =================================================================== --- platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/CssDocumentSkinExtension.java (rev 0) +++ platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/CssDocumentSkinExtension.java 2011-01-10 10:56:58 UTC (rev 33873) @@ -0,0 +1,49 @@ +/* + * 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.skinx.internal; + +import org.xwiki.component.annotation.Component; +import org.xwiki.skinx.AbstractWrapperSkinExtension; + +/** + * Skin extension that provides the wrapper on the object CSS extensions. + * + * @version $Id$ + * @since 3.0M1 + */ +@Component(CssDocumentSkinExtension.NAME) +public class CssDocumentSkinExtension extends AbstractWrapperSkinExtension +{
If we remove the getName() method then the only purpose of these classes if to specify the hint. WDYT about making the skin extension plugins also component implementations (i.e. make them implement SkinExtension interface)? Thanks, Marius
+ /** + * The name of this extension. + */ + static final String NAME = "ssx"; + + /** + * {@inheritDoc} + * + * @see org.xwiki.skinx.AbstractWrapperSkinExtension#getName() + */ + @Override + public String getName() + { + return NAME; + } +}
Property changes on: platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/CssDocumentSkinExtension.java ___________________________________________________________________ Added: svn:keywords + Author Id Revision HeadURL Added: svn:eol-style + native
Added: platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/CssFileSkinExtension.java =================================================================== --- platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/CssFileSkinExtension.java (rev 0) +++ platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/CssFileSkinExtension.java 2011-01-10 10:56:58 UTC (rev 33873) @@ -0,0 +1,49 @@ +/* + * 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.skinx.internal; + +import org.xwiki.component.annotation.Component; +import org.xwiki.skinx.AbstractWrapperSkinExtension; + +/** + * Skin extension that provides the wrapper on the file CSS extensions. + * + * @version $Id$ + * @since 3.0M1 + */ +@Component(CssFileSkinExtension.NAME) +public class CssFileSkinExtension extends AbstractWrapperSkinExtension +{ + /** + * The name of this extension. + */ + static final String NAME = "ssfx"; + + /** + * {@inheritDoc} + * + * @see org.xwiki.skinx.AbstractWrapperSkinExtension#getName() + */ + @Override + public String getName() + { + return NAME; + } +}
Property changes on: platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/CssFileSkinExtension.java ___________________________________________________________________ Added: svn:keywords + Author Id Revision HeadURL Added: svn:eol-style + native
Added: platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/CssResourceSkinExtension.java =================================================================== --- platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/CssResourceSkinExtension.java (rev 0) +++ platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/CssResourceSkinExtension.java 2011-01-10 10:56:58 UTC (rev 33873) @@ -0,0 +1,49 @@ +/* + * 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.skinx.internal; + +import org.xwiki.component.annotation.Component; +import org.xwiki.skinx.AbstractWrapperSkinExtension; + +/** + * Skin extension that provides the wrapper on the resource CSS extensions. + * + * @version $Id$ + * @since 3.0M1 + */ +@Component(CssResourceSkinExtension.NAME) +public class CssResourceSkinExtension extends AbstractWrapperSkinExtension +{ + /** + * The name of this extension. + */ + static final String NAME = "ssrx"; + + /** + * {@inheritDoc} + * + * @see org.xwiki.skinx.AbstractWrapperSkinExtension#getName() + */ + @Override + public String getName() + { + return NAME; + } +}
Property changes on: platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/CssResourceSkinExtension.java ___________________________________________________________________ Added: svn:keywords + Author Id Revision HeadURL Added: svn:eol-style + native
Added: platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/JsDocumentSkinExtension.java =================================================================== --- platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/JsDocumentSkinExtension.java (rev 0) +++ platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/JsDocumentSkinExtension.java 2011-01-10 10:56:58 UTC (rev 33873) @@ -0,0 +1,49 @@ +/* + * 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.skinx.internal; + +import org.xwiki.component.annotation.Component; +import org.xwiki.skinx.AbstractWrapperSkinExtension; + +/** + * Skin extension that provides the wrapper on the object Javascript extensions. + * + * @version $Id$ + * @since 3.0M1 + */ +@Component(JsDocumentSkinExtension.NAME) +public class JsDocumentSkinExtension extends AbstractWrapperSkinExtension +{ + /** + * The name of this extension. + */ + static final String NAME = "jsx"; + + /** + * {@inheritDoc} + * + * @see org.xwiki.skinx.AbstractWrapperSkinExtension#getName() + */ + @Override + public String getName() + { + return NAME; + } +}
Property changes on: platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/JsDocumentSkinExtension.java ___________________________________________________________________ Added: svn:keywords + Author Id Revision HeadURL Added: svn:eol-style + native
Added: platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/JsFileSkinExtension.java =================================================================== --- platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/JsFileSkinExtension.java (rev 0) +++ platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/JsFileSkinExtension.java 2011-01-10 10:56:58 UTC (rev 33873) @@ -0,0 +1,49 @@ +/* + * 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.skinx.internal; + +import org.xwiki.component.annotation.Component; +import org.xwiki.skinx.AbstractWrapperSkinExtension; + +/** + * Skin extension that provides the wrapper on the file Javascript extensions. + * + * @version $Id$ + * @since 3.0M1 + */ +@Component(JsFileSkinExtension.NAME) +public class JsFileSkinExtension extends AbstractWrapperSkinExtension +{ + /** + * The name of this extension. + */ + static final String NAME = "jsfx"; + + /** + * {@inheritDoc} + * + * @see org.xwiki.skinx.AbstractWrapperSkinExtension#getName() + */ + @Override + public String getName() + { + return NAME; + } +}
Property changes on: platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/JsFileSkinExtension.java ___________________________________________________________________ Added: svn:keywords + Author Id Revision HeadURL Added: svn:eol-style + native
Added: platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/JsResourceSkinExtension.java =================================================================== --- platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/JsResourceSkinExtension.java (rev 0) +++ platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/JsResourceSkinExtension.java 2011-01-10 10:56:58 UTC (rev 33873) @@ -0,0 +1,49 @@ +/* + * 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.skinx.internal; + +import org.xwiki.component.annotation.Component; +import org.xwiki.skinx.AbstractWrapperSkinExtension; + +/** + * Skin extension that provides the wrapper on the resource Javascript extensions. + * + * @version $Id$ + * @since 3.0M1 + */ +@Component(JsResourceSkinExtension.NAME) +public class JsResourceSkinExtension extends AbstractWrapperSkinExtension +{ + /** + * The name of this extension. + */ + static final String NAME = "jsrx"; + + /** + * {@inheritDoc} + * + * @see org.xwiki.skinx.AbstractWrapperSkinExtension#getName() + */ + @Override + public String getName() + { + return NAME; + } +}
Property changes on: platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/JsResourceSkinExtension.java ___________________________________________________________________ Added: svn:keywords + Author Id Revision HeadURL Added: svn:eol-style + native
Added: platform/xwiki-plugins/trunk/skinx/src/main/resources/META-INF/components.txt =================================================================== --- platform/xwiki-plugins/trunk/skinx/src/main/resources/META-INF/components.txt (rev 0) +++ platform/xwiki-plugins/trunk/skinx/src/main/resources/META-INF/components.txt 2011-01-10 10:56:58 UTC (rev 33873) @@ -0,0 +1,6 @@ +org.xwiki.skinx.internal.CssDocumentSkinExtension +org.xwiki.skinx.internal.JsDocumentSkinExtension +org.xwiki.skinx.internal.CssFileSkinExtension +org.xwiki.skinx.internal.JsFileSkinExtension +org.xwiki.skinx.internal.CssResourceSkinExtension +org.xwiki.skinx.internal.JsResourceSkinExtension \ No newline at end of file
Property changes on: platform/xwiki-plugins/trunk/skinx/src/main/resources/META-INF/components.txt ___________________________________________________________________ Added: svn:eol-style + native
_______________________________________________ notifications mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/notifications
Hi Marius, I will log here my opinions, to make this discussion public: On 01/11/2011 02:33 PM, Marius Dumitru Florea wrote:
Hi Anca,
On 01/10/2011 12:56 PM, lucaa (SVN) wrote:
Author: lucaa Date: 2011-01-10 11:56:58 +0100 (Mon, 10 Jan 2011) New Revision: 33873
Added: platform/xwiki-plugins/trunk/skinx/src/main/java/org/ platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/ platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/ platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/AbstractWrapperSkinExtension.java platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/ platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/CssDocumentSkinExtension.java platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/CssFileSkinExtension.java platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/CssResourceSkinExtension.java platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/JsDocumentSkinExtension.java platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/JsFileSkinExtension.java platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/JsResourceSkinExtension.java platform/xwiki-plugins/trunk/skinx/src/main/resources/ platform/xwiki-plugins/trunk/skinx/src/main/resources/META-INF/ platform/xwiki-plugins/trunk/skinx/src/main/resources/META-INF/components.txt Modified: platform/xwiki-plugins/trunk/skinx/pom.xml Log: XSKINX-47: Implement a bridge to the skin extension API
Modified: platform/xwiki-plugins/trunk/skinx/pom.xml =================================================================== --- platform/xwiki-plugins/trunk/skinx/pom.xml 2011-01-10 10:53:23 UTC (rev 33872) +++ platform/xwiki-plugins/trunk/skinx/pom.xml 2011-01-10 10:56:58 UTC (rev 33873) @@ -34,7 +34,7 @@ <version>1.20-SNAPSHOT</version> <description>XWiki Platform - Plugins - Skin Extensions</description> <properties> -<platform.core.version>2.4</platform.core.version> +<platform.core.version>3.0-SNAPSHOT</platform.core.version> </properties> <dependencies> <dependency> @@ -44,6 +44,12 @@ <scope>provided</scope> </dependency> <dependency> +<groupId>org.xwiki.platform</groupId> +<artifactId>xwiki-core-skin</artifactId> +<version>${platform.core.version}</version> +<scope>provided</scope> +</dependency> +<dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> </dependency>
Added: platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/AbstractWrapperSkinExtension.java =================================================================== --- platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/AbstractWrapperSkinExtension.java (rev 0) +++ platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/AbstractWrapperSkinExtension.java 2011-01-10 10:56:58 UTC (rev 33873) @@ -0,0 +1,81 @@ +/* + * 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.skinx; + +import java.util.Map; + +import org.xwiki.component.annotation.Requirement; +import org.xwiki.context.Execution; + +import com.xpn.xwiki.XWiki; +import com.xpn.xwiki.XWikiContext; +import com.xpn.xwiki.plugin.skinx.SkinExtensionPluginApi; + +/** + * The abstract implementation of the wrapper around the skinx plugin. Provides the mechanism needed to grab the skin + * extensions plugins and call the use methods on them, subclasses only need to provide the name of the skin extension. + * + * @version $Id$ + * @since 3.0M1 + */ +public abstract class AbstractWrapperSkinExtension implements SkinExtension +{ + + /** + * Execution context, needed to grab the sx plugins to include js and css. + */ + @Requirement + private Execution execution; + + /** + * {@inheritDoc} + * + * @see org.xwiki.skinx.SkinExtension#use(java.lang.String) + */ + public void use(String resource) + { + getSkinExtensionPluginApi().use(resource); + } + + /** + * {@inheritDoc} + * + * @see org.xwiki.skinx.SkinExtension#use(java.lang.String, java.util.Map) + */ + public void use(String resource, Map<String, Object> parameters) + { + getSkinExtensionPluginApi().use(resource, parameters); + } + + /** + * @return the {@link SkinExtensionPluginApi} in the running wiki. + */ + private SkinExtensionPluginApi getSkinExtensionPluginApi() + { + XWikiContext xwikiContext = (XWikiContext) execution.getContext().getProperty("xwikicontext"); + XWiki wiki = xwikiContext.getWiki(); + return (SkinExtensionPluginApi) wiki.getPluginApi(getName(), xwikiContext); + } +
+ /** + * @return the name of the skin extension (e.g. ssx, jsfx, etc) to wrap. + */ + public abstract String getName(); +}
This method is not necessary because you should be able to get component hint through introspection:
Component component = (Component) this.getClass().getAnnotation(Component.class); String name = component.value();
We could do this, but still in the getName() method. Or rather, getPluginName(), which we implement in the abstract wrapper. Thus, the classes will only extend the abstract class to provide the hint. I think I would prefer this separation, in a way, because it's not mandatory that the hint translates automatically in plugin name, semantically speaking. I.e. you could think of a wrapper that uses a different hint than the plugin name... but in any case this is not really that important, if you feel like no getName(), go for it.
Property changes on: platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/AbstractWrapperSkinExtension.java ___________________________________________________________________ Added: svn:keywords + Author Id Revision HeadURL Added: svn:eol-style + native
Added: platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/CssDocumentSkinExtension.java =================================================================== --- platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/CssDocumentSkinExtension.java (rev 0) +++ platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/CssDocumentSkinExtension.java 2011-01-10 10:56:58 UTC (rev 33873) @@ -0,0 +1,49 @@ +/* + * 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.skinx.internal; + +import org.xwiki.component.annotation.Component; +import org.xwiki.skinx.AbstractWrapperSkinExtension; + +/** + * Skin extension that provides the wrapper on the object CSS extensions. + * + * @version $Id$ + * @since 3.0M1 + */ +@Component(CssDocumentSkinExtension.NAME) +public class CssDocumentSkinExtension extends AbstractWrapperSkinExtension +{
If we remove the getName() method then the only purpose of these classes if to specify the hint. WDYT about making the skin extension plugins also component implementations (i.e. make them implement SkinExtension interface)?
I thought about this too, but I found it a little too complex: if we do this, then the plugins will have 2 sets of use methods, use() with context parameter and use() without context parameter. It can make it hard to know, for a plugin user, for example, which method should be used, why are there 2 sets (if we can do without context, why would we have a method with context as well?), etc. Also, it really mashes together the concepts of plugin and component, into something which is not really a component, but not really a plugin either. IMO is creating too much mess to understand and maintain that code and the performance gain is not that dramatic, in my view... If you want to do it I am not against, though, but I don't see too many good reasons: that code will be refactored to a proper component anyway. Thanks, Anca
Thanks, Marius
+ /** + * The name of this extension. + */ + static final String NAME = "ssx"; + + /** + * {@inheritDoc} + * + * @see org.xwiki.skinx.AbstractWrapperSkinExtension#getName() + */ + @Override + public String getName() + { + return NAME; + } +}
Property changes on: platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/CssDocumentSkinExtension.java ___________________________________________________________________ Added: svn:keywords + Author Id Revision HeadURL Added: svn:eol-style + native
Added: platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/CssFileSkinExtension.java =================================================================== --- platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/CssFileSkinExtension.java (rev 0) +++ platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/CssFileSkinExtension.java 2011-01-10 10:56:58 UTC (rev 33873) @@ -0,0 +1,49 @@ +/* + * 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.skinx.internal; + +import org.xwiki.component.annotation.Component; +import org.xwiki.skinx.AbstractWrapperSkinExtension; + +/** + * Skin extension that provides the wrapper on the file CSS extensions. + * + * @version $Id$ + * @since 3.0M1 + */ +@Component(CssFileSkinExtension.NAME) +public class CssFileSkinExtension extends AbstractWrapperSkinExtension +{ + /** + * The name of this extension. + */ + static final String NAME = "ssfx"; + + /** + * {@inheritDoc} + * + * @see org.xwiki.skinx.AbstractWrapperSkinExtension#getName() + */ + @Override + public String getName() + { + return NAME; + } +}
Property changes on: platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/CssFileSkinExtension.java ___________________________________________________________________ Added: svn:keywords + Author Id Revision HeadURL Added: svn:eol-style + native
Added: platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/CssResourceSkinExtension.java =================================================================== --- platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/CssResourceSkinExtension.java (rev 0) +++ platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/CssResourceSkinExtension.java 2011-01-10 10:56:58 UTC (rev 33873) @@ -0,0 +1,49 @@ +/* + * 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.skinx.internal; + +import org.xwiki.component.annotation.Component; +import org.xwiki.skinx.AbstractWrapperSkinExtension; + +/** + * Skin extension that provides the wrapper on the resource CSS extensions. + * + * @version $Id$ + * @since 3.0M1 + */ +@Component(CssResourceSkinExtension.NAME) +public class CssResourceSkinExtension extends AbstractWrapperSkinExtension +{ + /** + * The name of this extension. + */ + static final String NAME = "ssrx"; + + /** + * {@inheritDoc} + * + * @see org.xwiki.skinx.AbstractWrapperSkinExtension#getName() + */ + @Override + public String getName() + { + return NAME; + } +}
Property changes on: platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/CssResourceSkinExtension.java ___________________________________________________________________ Added: svn:keywords + Author Id Revision HeadURL Added: svn:eol-style + native
Added: platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/JsDocumentSkinExtension.java =================================================================== --- platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/JsDocumentSkinExtension.java (rev 0) +++ platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/JsDocumentSkinExtension.java 2011-01-10 10:56:58 UTC (rev 33873) @@ -0,0 +1,49 @@ +/* + * 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.skinx.internal; + +import org.xwiki.component.annotation.Component; +import org.xwiki.skinx.AbstractWrapperSkinExtension; + +/** + * Skin extension that provides the wrapper on the object Javascript extensions. + * + * @version $Id$ + * @since 3.0M1 + */ +@Component(JsDocumentSkinExtension.NAME) +public class JsDocumentSkinExtension extends AbstractWrapperSkinExtension +{ + /** + * The name of this extension. + */ + static final String NAME = "jsx"; + + /** + * {@inheritDoc} + * + * @see org.xwiki.skinx.AbstractWrapperSkinExtension#getName() + */ + @Override + public String getName() + { + return NAME; + } +}
Property changes on: platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/JsDocumentSkinExtension.java ___________________________________________________________________ Added: svn:keywords + Author Id Revision HeadURL Added: svn:eol-style + native
Added: platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/JsFileSkinExtension.java =================================================================== --- platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/JsFileSkinExtension.java (rev 0) +++ platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/JsFileSkinExtension.java 2011-01-10 10:56:58 UTC (rev 33873) @@ -0,0 +1,49 @@ +/* + * 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.skinx.internal; + +import org.xwiki.component.annotation.Component; +import org.xwiki.skinx.AbstractWrapperSkinExtension; + +/** + * Skin extension that provides the wrapper on the file Javascript extensions. + * + * @version $Id$ + * @since 3.0M1 + */ +@Component(JsFileSkinExtension.NAME) +public class JsFileSkinExtension extends AbstractWrapperSkinExtension +{ + /** + * The name of this extension. + */ + static final String NAME = "jsfx"; + + /** + * {@inheritDoc} + * + * @see org.xwiki.skinx.AbstractWrapperSkinExtension#getName() + */ + @Override + public String getName() + { + return NAME; + } +}
Property changes on: platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/JsFileSkinExtension.java ___________________________________________________________________ Added: svn:keywords + Author Id Revision HeadURL Added: svn:eol-style + native
Added: platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/JsResourceSkinExtension.java =================================================================== --- platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/JsResourceSkinExtension.java (rev 0) +++ platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/JsResourceSkinExtension.java 2011-01-10 10:56:58 UTC (rev 33873) @@ -0,0 +1,49 @@ +/* + * 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.skinx.internal; + +import org.xwiki.component.annotation.Component; +import org.xwiki.skinx.AbstractWrapperSkinExtension; + +/** + * Skin extension that provides the wrapper on the resource Javascript extensions. + * + * @version $Id$ + * @since 3.0M1 + */ +@Component(JsResourceSkinExtension.NAME) +public class JsResourceSkinExtension extends AbstractWrapperSkinExtension +{ + /** + * The name of this extension. + */ + static final String NAME = "jsrx"; + + /** + * {@inheritDoc} + * + * @see org.xwiki.skinx.AbstractWrapperSkinExtension#getName() + */ + @Override + public String getName() + { + return NAME; + } +}
Property changes on: platform/xwiki-plugins/trunk/skinx/src/main/java/org/xwiki/skinx/internal/JsResourceSkinExtension.java ___________________________________________________________________ Added: svn:keywords + Author Id Revision HeadURL Added: svn:eol-style + native
Added: platform/xwiki-plugins/trunk/skinx/src/main/resources/META-INF/components.txt =================================================================== --- platform/xwiki-plugins/trunk/skinx/src/main/resources/META-INF/components.txt (rev 0) +++ platform/xwiki-plugins/trunk/skinx/src/main/resources/META-INF/components.txt 2011-01-10 10:56:58 UTC (rev 33873) @@ -0,0 +1,6 @@ +org.xwiki.skinx.internal.CssDocumentSkinExtension +org.xwiki.skinx.internal.JsDocumentSkinExtension +org.xwiki.skinx.internal.CssFileSkinExtension +org.xwiki.skinx.internal.JsFileSkinExtension +org.xwiki.skinx.internal.CssResourceSkinExtension +org.xwiki.skinx.internal.JsResourceSkinExtension \ No newline at end of file
Property changes on: platform/xwiki-plugins/trunk/skinx/src/main/resources/META-INF/components.txt ___________________________________________________________________ Added: svn:eol-style + native
_______________________________________________ notifications mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/notifications
devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
participants (2)
-
Anca Luca -
Marius Dumitru Florea