Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ajdt-dev] Adding Pointcut to existing aspect

Hi

"Andy Clement" <andrew.clement@xxxxxxxxx> writes:
>> "Warning: AspectJ type declaration factory class not found on
>> classpath."
>>
>> Can anyone point me how to get this running?

> In order to avoid dependency problems there is some funky dynamic
> class loading in the AJ AST support.   You say the class that can't be
> found is in your org.eclipse.core.*.jar - but I don't know what that
> is - how is your configuration set up - or do you mean
> org.eclipse.ajdt.core.*.jar??

Yes, i mean org.eclipse.ajdt.core.*.jar and
AjASTRewriteAnalyzerFactory.class is definitely in there but it won't
get loaded. Sorry for the confusion.

I try to use this in a eclipse plugin starting out of eclipse with the
last dev-build of ajdt using the following manifest.mf

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name.0
Bundle-SymbolicName: PointcutGenerator; singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: pointcutgenerator.Activator
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime,
 org.eclipse.ui,
 org.eclipse.core.resources,
 org.eclipse.jdt.core,
 org.aspectj.ajde,
 org.eclipse.ajdt.core,
 org.eclipse.jface.text
Eclipse-LazyStart: false
Export-Package: pointcutgenerator,
 pointcutgenerator.actions,
 pointcutgenerator.popup.actions

> The dynamic load is simply through a Class.forName() so some funny
> classloader configuration could trip it up. 

So the problem is the classloader for my plugin?

> I have to say you are on
> the bleeding edge working with the rewriter, we know it isn't
> complete.

Yes, I know. The plugin is only a small part of my work and i sadly
don't have the time to go deeper into it. So I will simply show you
what I got. If there is something obvious wrong with it, please tell
me. Otherwise I will just describe the problems I ran into.

Here is the code i use to get a new pointcut declaration.

---------------
// generate a new pointcut declaration
PointcutDeclaration pd = ast.newPointcutDeclaration();
NotPointcut pcn = ast.newNotPointcut();
DefaultPointcut pcd = ast.newDefaultPointcut();

// set attributes
pd.setName(ast.newSimpleName("test"));
pcd.setDetail("within(*de..*)");

// link the parts together
pcn.setBody(pcd);
pd.setDesignator(pcn);
---------------

an the code to add it..

---------------
List bd = type.bodyDeclarations();

// clone an existing pointcut
PointcutDeclaration ps = (PointcutDeclaration) PointcutDeclaration.copySubtree(ast, (PointcutDeclaration) bd.get(1));

// add everything to the bodydeclaration
bd.add(pd); // doesn't show up
bd.add(ps); // copyed pcd shows up
bd.add(md); // add a self-created simple method for testing
---------------

The bodydeclaration already contains a method and a pointcut which
were part of the aspect before I created the ast from it.
The interesting part of this is, the cloned pointcut-declaration shows
up in the new sourcecode but not the self-defined.

So... tell me if i made a mistake in the pointcut creation or if i have
to add something to the manifest to get the ajastrewriter running.

If the problem is just the unfinished implementation of ajast i will
just write this into my documentation.

Thanks for any comment and help on this.

-- 
Simon


Back to the top