[opencms-dev] How to add a new resource type
M Butcher
mbutcher at grcomputing.net
Fri Feb 13 20:21:01 CET 2004
I should have been more specific.... Here's the code (with imports and
comments cut out):
class GenericXmlResourceType extends CmsResourceTypePlain {
public static final String C_TYPE_RESOURCE_NAME = "GenericXML";
public CmsResource createResource(CmsObject cms, String name, Map
props,
byte[] contents, Object param)
throws CmsException {
CmsResource res =
cms.doCreateFile(name, contents, C_TYPE_RESOURCE_NAME, props);
cms.lockResource(name);
cvs.writerProperty(name, C_PROPERTY_EXPORT, "true");
return res;
}
}
As you can see, it extends com.opencms.file.CmsResourceTypePlain. The
problem is, the cms.doCreateFile() method is also protected. Since
CmsObject is in the same package as CmsResourceTypePlain, it works.
However, my module is in a different package.
Interestingly enough, if I remove the createResource method, it
compiles. Then, of course, I get a runtime error (access violation) when
the dynamic classloader loads it at startup. Besudes that, it kinda
makes it difficult to do anything new when I can't override any of the
methods that get called. ;-)
I've since moved on to creating a ContentDefinition, but I'm really
unhappy with that route, as it makes life difficult for the editor (and
me). In the end, I'll probably hack something together using Plain
documents.
I'm not really interested in forking the core code, but I am interested
in finding another way around the problem. Thanks for your suggestion --
let me know if you see a way out of this problem.
Matt
reed.mccauley at us.abb.com wrote:
>
>
>
>
> Matt,
> Have you tried extending the class to get access to these protected
> methods and add new ones?
> Thanks,
> Reed
>
>
> Message from M Butcher <mbutcher at grcomputing.net>@opencms.org received
> on
> 02/13/2004 09:40 AM
>
> 02/13/2004 09:40 AM
>
>
>
> M Butcher <mbutcher at grcomputing.net>@opencms.org
>
> Please respond to opencms-dev at opencms.org
> Sent by opencms-dev-admin at opencms.org
>
>
>
> To: opencms-dev at opencms.org
> cc:
> Subject: Re: [opencms-dev] How to add a new resource type
>
>
>
> I worked on this for a long time -- I wanted to create a module that
> provided generic XML and XSLT types. Unfortunately, too many of the
> important methods are 'protected', and I never figured out a way to add
> one without getting either compile errors or access violations.
>
> If anyone else knows of a workaround, please tell me.
>
> Matt
>
> Olli Aro wrote:
>
>>Hi all,
>>
>>Does anyone know if there is a standard way to add a new resource type
>
> as
>
>>part of the explorer view? Maybe similar to the ContentDefinitions
>
> with
> the
>
>>back office modules. I would like to add a new resource type similar
>
> to
> the
>
>>standard text resource, but the edit option would go to my JSP
>
> template.
>
>>Olli
>>
>>---
>>Outgoing mail is certified Virus Free.
>>Checked by AVG anti-virus system (http://www.grisoft.com).
>>Version: 6.0.580 / Virus Database: 367 - Release Date: 06/02/2004
>>
>>
>>_______________________________________________
>>This mail is send to you from the opencms-dev mailing list
>>To change your list options, or to unsubscribe from the list, please
>
> visit
>
>>http://mail.opencms.org/mailman/listinfo/opencms-dev
>
>
> _______________________________________________
> This mail is send to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please
> visit
> http://mail.opencms.org/mailman/listinfo/opencms-dev
>
>
> (See attached file: C.htm)
>
>
> ------------------------------------------------------------------------
>
>
> Matt,
> Have you tried extending the class to get access to these protected
> methods and add new ones?
> Thanks,
> Reed
>
>
> Message from M Butcher <mbutcher at grcomputing.net>@opencms.org received
> on 02/13/2004 09:40 AM
> 02/13/2004 09:40 AM
>
> *M Butcher <mbutcher at grcomputing.net>@opencms.org*
>
> Please respond to opencms-dev at opencms.org
> Sent by opencms-dev-admin at opencms.org
>
>
>
> To: opencms-dev at opencms.org
> cc:
> Subject: Re: [opencms-dev] How to add a new resource type
>
>
>
>
>
> I worked on this for a long time -- I wanted to create a module that
> provided generic XML and XSLT types. Unfortunately, too many of the
> important methods are 'protected', and I never figured out a way to add
> one without getting either compile errors or access violations.
>
> If anyone else knows of a workaround, please tell me.
>
> Matt
>
> Olli Aro wrote:
> > Hi all,
> >
> > Does anyone know if there is a standard way to add a new resource type as
> > part of the explorer view? Maybe similar to the ContentDefinitions
> with the
> > back office modules. I would like to add a new resource type similar
> to the
> > standard text resource, but the edit option would go to my JSP template.
> >
> > Olli
> >
> > ---
> > Outgoing mail is certified Virus Free.
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.580 / Virus Database: 367 - Release Date: 06/02/2004
> >
> >
> > _______________________________________________
> > This mail is send to you from the opencms-dev mailing list
> > To change your list options, or to unsubscribe from the list, please
> visit
> > http://mail.opencms.org/mailman/listinfo/opencms-dev
>
> _______________________________________________
> This mail is send to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://mail.opencms.org/mailman/listinfo/opencms-dev
>
More information about the opencms-dev
mailing list