Problem when creating a Plugin

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem when creating a Plugin

Xavier MOGHRABI
Dear XWiki Dev,

I try to create a plugin which should reduce the image size to have a kind of
thumbnail feature.

To do that I've created a plugin a part of the code is hereunder.

To call the plugin I've added in xwiki.cfg the complete name of the class (and
also a parameter about the cache size). The plugin uses the cache service.

At runtime my plugin is set by this code :
Plugin imageplugin = (ImagePlugin) context.getWiki().getPlugin("image",
context);

But I don't have the cache service working, the attribute imageCache is null.
It seems that the init method is never called.

Any idea is welcome.

Regards

--
Xavier MOGHRABI - Consortium ObjectWeb


package com.xpn.xwiki.plugin.image;

public class ImagePlugin extends XWikiDefaultPlugin implements
                XWikiPluginInterface {

        private static String name = "image";

        private XWikiCache imageCache;

        private int capacity = 50;

        private static Log mLogger = LogFactory.getFactory().getInstance(
                        ImagePlugin.class);

        public ImagePlugin(String name, String className, XWikiContext context) {
                super(name, className, context);
        }

        /**
         * Allow to get the plugin name
         *
         * @return plugin name
         */
        public String getName() {
                return name;
        }

        public void init(XWikiContext context) {
                super.init(context);
                try {
                        String capacityParam = context.getWiki().Param(
                                        "xwiki.plugin.image.cache.capacity");
                        capacity = Integer.parseInt(capacityParam);
                } catch (NumberFormatException e) {
                }
                imageCache = new OSCacheCache(capacity, true, "temp/imageCache");
        }

        public void flushCache() {
                if (imageCache != null)
                        imageCache.flushAll();
        }
 ...
}




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Problem when creating a Plugin

Ludovic Dubost

Hi,

You need to call "init" in you constructor

Ludovic

Xavier MOGHRABI a écrit :

> Dear XWiki Dev,
>
> I try to create a plugin which should reduce the image size to have a kind of
> thumbnail feature.
>
> To do that I've created a plugin a part of the code is hereunder.
>
> To call the plugin I've added in xwiki.cfg the complete name of the class (and
> also a parameter about the cache size). The plugin uses the cache service.
>
> At runtime my plugin is set by this code :
> Plugin imageplugin = (ImagePlugin) context.getWiki().getPlugin("image",
> context);
>
> But I don't have the cache service working, the attribute imageCache is null.
> It seems that the init method is never called.
>
> Any idea is welcome.
>
> Regards
>
>  
> ------------------------------------------------------------------------
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
>  

--
Ludovic Dubost
XPertNet: http://www.xpertnet.fr/
Blog: http://www.ludovic.org/blog/
XWiki: http://www.xwiki.com
Skype: ldubost AIM: nvludo Yahoo: ludovic




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Problem when creating a Plugin

Xavier MOGHRABI
Thanks, It seems I was too tired to think well !
--
Xavier MOGHRABI - Consortium ObjectWeb

Le Lundi 13 Février 2006 22:23, Ludovic Dubost a écrit :

> Hi,
>
> You need to call "init" in you constructor
>
> Ludovic
>
> Xavier MOGHRABI a écrit :
> > Dear XWiki Dev,
> >
> > I try to create a plugin which should reduce the image size to have a
> > kind of thumbnail feature.
> >
> > To do that I've created a plugin a part of the code is hereunder.
> >
> > To call the plugin I've added in xwiki.cfg the complete name of the class
> > (and also a parameter about the cache size). The plugin uses the cache
> > service..
> >
> > At runtime my plugin is set by this code :
> > Plugin imageplugin = (ImagePlugin) context.getWiki().getPlugin("image",
> > context);
> >
> > But I don't have the cache service working, the attribute imageCache is
> > null. It seems that the init method is never called.
> >
> > Any idea is welcome.
> >
> > Regards
> >
> >
> > ------------------------------------------------------------------------
> >
> >
> > --
> > You receive this message as a subscriber of the [hidden email]
> > mailing list. To unsubscribe: mailto:[hidden email]
> > For general help: mailto:[hidden email]?subject=help
> > ObjectWeb mailing lists service home page: http://www.objectweb.org/wws



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws