dev@glassfish.java.net

Re: [_at_V] Getting the ClassFile reference in rule classes in Verifier - Continued

From: Sahoo <Sahoo_at_Sun.COM>
Date: Mon, 12 May 2008 08:30:04 +0530

Yes, that looks fine. Please pass the same classFileLoader to the
constructor of the *ClosureCompiler(), that way the same class is not
read multiple times.

Thanks,
Sahoo

Seema Richard wrote:
>
> Sahoo,
>
> That is what I was also asking you. In my last mail, I referred to the
> code in WebVerifier that creates the new ClassFileLoader and was
> asking if I can set this to the context, so that it can be accessed in
> the rule.
>
> I did the following and it is working.
>
> 1. Set the created classFileLoader to context - In WebVerifier
>
> ClassFileLoader classFileLoader = ClassFileLoaderFactory
> .newInstance(new Object[] { arg });
> context.setClassFileLoader(classFileLoader);
>
> 2. For each entry in the archive, attempt to get the corresponding
> ClassFile and then load the annotation classes used.
>
> String className = (String) entries.next();
> classFile = classFileLoader.load(className);
> Set<Annotation> annotations = classFile.getAnnotations();
> for (Annotation annotation : annotations) {
>
> try {
> ClassFile c = classFileLoader.load(annotation.getName());
> } catch (IOException e) {
> result.addErrorDetails("The annotation class could not
> be loaded " + annotation.getName());
> allPassed = false;
> }
>
> Please do let me know your comments about this implementation.
>
> Thanks,
> Seema
>
>
>
> -----Original Message-----
> From: Sanjeeb.Sahoo_at_Sun.COM on behalf of Sahoo
> Sent: Sun 5/11/2008 12:55 AM
> To: dev_at_glassfish.dev.java.net
> Subject: Re: [@V] Getting the ClassFile reference in rule classes in
> Verifier - Continued
>
> Can you just create a new ClassFileLoader using
> ClassFileLoaderFactory.newInstance(new Object[]{arg})
> and use it to load ClassFiles?
>
> Thanks,
> Sahoo
>
> Seema Richard wrote:
> >
> > Sahoo,
> >
> > I saw this code in the EJBVerifier class.
> > protected void createClosureCompiler() throws IOException {
> > String specVer = SpecVersionMapper.getEJBVersion(
> > frameworkContext.getJavaEEVersion());
> > Object arg =
> > (isASMode)?ejbd.getClassLoader():(Object)getClassPath();
> > EjbClosureCompiler cc = new EjbClosureCompiler(specVer,
> > ClassFileLoaderFactory.newInstance(new Object[]{arg}));
> > context.setClosureCompiler(cc);
> > }
> >
> > Just like we are setting the closure compiler to the context, can we
> > can set the ClassFileLoader also to the context? In that case, we can
> > call the load() method on it to get the ClassFile.
> >
> > Thanks,
> > Seema
> >
> > -----Original Message-----
> > From: Seema Richard
> > Sent: Sat 5/10/2008 9:05 PM
> > To: dev_at_glassfish.dev.java.net
> > Subject: [@V] Getting the ClassFile reference in rule classes in
> Verifier
> >
> > Sahoo,
> >
> > This is regarding writing rules in the verifier to detect the usage of
> > non-standard annotations. I have made annotations a part of the model
> > that represents the information contained in a Java .class file. The
> > getAnnotations() method in ClassFile can be used to get the annotation
> > information. However, this model is not available within a rule class.
> > The model reference is available only the Closure-related classes at
> > present. I think we can access these classes in the rules.
> >
> > ClosureCompiler
> closureCompiler=getVerifierContext().getClosureCompiler();
> >
> > But using these classes to get to the model doesn't seem to be the
> > right way.
> >
> > Could you please share your thoughts on this?
> >
> > Thanks,
> > Seema
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>
>
>