qianjava / ehcache-spring-annotations

Automatically exported from code.google.com/p/ehcache-spring-annotations
0 stars 0 forks source link

Add AspectJ Weaving Support #64

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Add support for AspectJ weaving, allowing for self-referential calls to still 
have interceptors applied.

Original issue reported on code.google.com by eric.dalquist on 25 Jan 2011 at 10:17

GoogleCodeExporter commented 8 years ago
I need this feature too, how the Issue #63

Original comment by castocol...@gmail.com on 28 Mar 2011 at 5:13

GoogleCodeExporter commented 8 years ago
If someone out there has AspectJ weaving experience and wants to provide a 
patch to implement it we'll be happy to include the changes and cut a release. 
Right now Nick and I don't have a direct need for the feature so its hard to 
allocate time for learning how to implement it.

Original comment by eric.dalquist on 28 Mar 2011 at 5:16

GoogleCodeExporter commented 8 years ago
I hope it release soon
Greate work
Thank you

Original comment by tk1c...@gmail.com on 19 Apr 2011 at 4:36

GoogleCodeExporter commented 8 years ago
As much as we would like to get AspectJ support included we need help from 
someone with AspectJ experience. If you can help or know of someone that can 
help please have them comment here.

Original comment by eric.dalquist on 20 Apr 2011 at 1:48

GoogleCodeExporter commented 8 years ago
http://thoughtforge.net/2010/12/06/creating-a-method-result-caching-aspect-with-
spring-aop-and-aspectj/

It maybe help.

:D

Original comment by tk1c...@gmail.com on 22 Apr 2011 at 8:04

GoogleCodeExporter commented 8 years ago
I have a patch for this please see:
http://groups.google.com/group/ehcache-spring-annotations/browse_thread/thread/1
bf3ab92d6e2fba2

and

https://github.com/agentgt/ehcache-spring-annotations

Original comment by adam.g...@evocatus.com on 17 May 2011 at 1:14

GoogleCodeExporter commented 8 years ago
EhCache Support Aspect Error
Please file attach

Original comment by tk1c...@gmail.com on 18 May 2011 at 8:19

Attachments:

GoogleCodeExporter commented 8 years ago
My pom.xml

<dependency>
            <groupId>com.googlecode.ehcache-spring-annotations</groupId>
            <artifactId>ehcache-spring-annotations</artifactId>
            <version>1.2.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode.ehcache-spring-annotations</groupId>
            <artifactId>ehcache-spring-annotations-aspects</artifactId>
            <version>1.2.0-SNAPSHOT</version>
        </dependency>

Original comment by tk1c...@gmail.com on 18 May 2011 at 8:20

GoogleCodeExporter commented 8 years ago
@tk1 I think you need spring-aspects.jar in your classpath to resolve aspectOf. 
I'll have to add that as a dependency.

also your pom should be (copied from mailing list):

   <repositories>
        <repository>
            <id>mvn-adamgent</id>
            <url>http://mvn-adamgent.googlecode.com/svn/maven/release</
url>
            <name>Adam Gent Maven Repository</name>
        </repository>
    </repositories>

Now add the dep (notice the special suffix).

            <dependency>
                <groupId>com.googlecode.ehcache-spring-annotations</groupId>
                <artifactId>ehcache-spring-annotations-aspects</artifactId>
                <version>1.2.0-ADAMGENT</version>
                <scope>compile</scope>
            </dependency> 

Original comment by adam.g...@evocatus.com on 18 May 2011 at 11:05

GoogleCodeExporter commented 8 years ago
@tk1 apparently lots of things can cause the error message you are seeing.
Make sure you are actually code weaving @Cacheable (in eclipse you will see 
some Red arrows on the left hand side if you have code weaving turned on).

Make sure you have the aspectj jars including the weaver and the rt. And 
finally I'm not sure if this is needed but the spring-aspects jar.

Original comment by adam.g...@evocatus.com on 18 May 2011 at 11:10

GoogleCodeExporter commented 8 years ago
For aspectj support please add:
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
            <version>${spring.version}</version>
        </dependency>

Original comment by adam.g...@evocatus.com on 18 May 2011 at 11:16

GoogleCodeExporter commented 8 years ago
I tested with spring roo project
Build okie but when run i think ehcache not working
Please see file attack

2011-05-19 16:20:55,359 DEBUG BeanHandler: 271 - Ignoring ehcache attribute 
xmlns:xsi
2011-05-19 16:20:55,359 DEBUG BeanHandler: 271 - Ignoring ehcache attribute 
xsi:noNamespaceSchemaLocation
2011-05-19 16:20:55,359 DEBUG DiskStoreConfiguration: 118 - Disk Store Path: 
C:\DOCUME~1\Home\LOCALS~1\Temp\
2011-05-19 16:20:55,375 DEBUG PropertyUtil:  88 - propertiesString is null.
2011-05-19 16:20:55,390 DEBUG ConfigurationHelper: 184 - No 
CacheManagerEventListenerFactory class specified. Skipping...
2011-05-19 16:20:55,406 DEBUG      Cache: 948 - No BootstrapCacheLoaderFactory 
class specified. Skipping...
2011-05-19 16:20:55,406 DEBUG      Cache: 922 - CacheWriter factory not 
configured. Skipping...
2011-05-19 16:20:55,406 DEBUG ConfigurationHelper:  96 - No 
CacheExceptionHandlerFactory class specified. Skipping...
2011-05-19 16:20:55,421 DEBUG      Cache: 948 - No BootstrapCacheLoaderFactory 
class specified. Skipping...
2011-05-19 16:20:55,421 DEBUG      Cache: 922 - CacheWriter factory not 
configured. Skipping...
2011-05-19 16:20:55,421 DEBUG ConfigurationHelper:  96 - No 
CacheExceptionHandlerFactory class specified. Skipping...
2011-05-19 16:20:55,421 DEBUG      Cache: 948 - No BootstrapCacheLoaderFactory 
class specified. Skipping...
2011-05-19 16:20:55,421 DEBUG      Cache: 922 - CacheWriter factory not 
configured. Skipping...
2011-05-19 16:20:55,421 DEBUG ConfigurationHelper:  96 - No 
CacheExceptionHandlerFactory class specified. Skipping...
2011-05-19 16:20:55,421 DEBUG      Cache: 948 - No BootstrapCacheLoaderFactory 
class specified. Skipping...
2011-05-19 16:20:55,421 DEBUG      Cache: 922 - CacheWriter factory not 
configured. Skipping...
2011-05-19 16:20:55,437 DEBUG ConfigurationHelper:  96 - No 
CacheExceptionHandlerFactory class specified. Skipping...
2011-05-19 16:20:55,437 DEBUG      Cache:1175 - Initialised cache: findChoice
2011-05-19 16:20:55,453 DEBUG ConfigurationHelper: 331 - CacheDecoratorFactory 
not configured. Skipping for 'findChoice'.
2011-05-19 16:20:55,453 DEBUG ConfigurationHelper: 360 - CacheDecoratorFactory 
not configured for defaultCache. Skipping for 'findChoice'.
2011-05-19 16:20:55,453 DEBUG      Cache:1175 - Initialised cache: 
findChoiceEntries
2011-05-19 16:20:55,453 DEBUG ConfigurationHelper: 331 - CacheDecoratorFactory 
not configured. Skipping for 'findChoiceEntries'.
2011-05-19 16:20:55,453 DEBUG ConfigurationHelper: 360 - CacheDecoratorFactory 
not configured for defaultCache. Skipping for 'findChoiceEntries'.
2011-05-19 16:20:55,453 DEBUG      Cache:1175 - Initialised cache: 
findAllChoices
2011-05-19 16:20:55,453 DEBUG ConfigurationHelper: 331 - CacheDecoratorFactory 
not configured. Skipping for 'findAllChoices'.
2011-05-19 16:20:55,453 DEBUG ConfigurationHelper: 360 - CacheDecoratorFactory 
not configured for defaultCache. Skipping for 'findAllChoices'.

Original comment by tk1c...@gmail.com on 19 May 2011 at 9:24

Attachments:

GoogleCodeExporter commented 8 years ago
I'll have to take a look at that. I know it works for Spring Roo 1.1.1 as that 
is what we are using for http://evocatus.com

Original comment by adam.g...@evocatus.com on 19 May 2011 at 2:10

GoogleCodeExporter commented 8 years ago
@tk1c I believe your ehcache.xml is in the wrong place. It needs to be in 
src/main/resources. Also make sure you try running it with the mvn command.

If you hit your cached methods and you have your code "weaved" and ehcache is 
not setup correctly you will see major errors in the log. If nothing happens 
then its either working or the methods are not being weaved.

Original comment by adam.g...@evocatus.com on 19 May 2011 at 2:21

GoogleCodeExporter commented 8 years ago
Issue 75 has been merged into this issue.

Original comment by eric.dalquist on 20 Jun 2011 at 7:35

GoogleCodeExporter commented 8 years ago
Hi,

Which version this fix will be added?

Thanks

Original comment by SHN...@gmail.com on 20 Jun 2011 at 11:02

GoogleCodeExporter commented 8 years ago
Hi Guys,

I have ehcache-spring-annotations-aspects-1.2.0-ADAMGENT.jar and  
spring-aspects-3.0.5.RELEASE.jar in my class path but its still going to 
database instead of lookign at caching. Its not recognizing the cached inner 
method?

Original comment by SHN...@gmail.com on 21 Jun 2011 at 12:05

GoogleCodeExporter commented 8 years ago
I'll be add the code some time this week to trunk. Sorry for the delay.

Original comment by adam.g...@evocatus.com on 20 Jul 2011 at 12:07

GoogleCodeExporter commented 8 years ago
I'm getting the below error. Could anybody please guide me where am I wrong 

4:35:41,405 DEBUG Cache:948 - No BootstrapCacheLoaderFactory class specified. 
Skipping...
14:35:41,405 DEBUG Cache:922 - CacheWriter factory not configured. Skipping...
14:35:41,405 DEBUG ConfigurationHelper:96 - No CacheExceptionHandlerFactory 
class specified. Skipping...
14:35:41,405 DEBUG Cache:948 - No BootstrapCacheLoaderFactory class specified. 
Skipping...
14:35:41,405 DEBUG Cache:922 - CacheWriter factory not configured. Skipping...
14:35:41,405 DEBUG ConfigurationHelper:96 - No CacheExceptionHandlerFactory 
class specified. Skipping...
14:35:41,405 DEBUG Cache:948 - No BootstrapCacheLoaderFactory class specified. 
Skipping...
14:35:41,405 DEBUG Cache:922 - CacheWriter factory not configured. Skipping...
14:35:41,405 DEBUG ConfigurationHelper:96 - No CacheExceptionHandlerFactory 
class specified. Skipping...
14:35:41,405 DEBUG Cache:948 - No BootstrapCacheLoaderFactory class specified. 
Skipping...
14:35:41,405 DEBUG Cache:922 - CacheWriter factory not configured. Skipping...
14:35:41,405 DEBUG ConfigurationHelper:96 - No CacheExceptionHandlerFactory 
class specified. Skipping...
14:35:41,405 DEBUG Cache:948 - No BootstrapCacheLoaderFactory class specified. 
Skipping...
14:35:41,405 DEBUG Cache:922 - CacheWriter factory not configured. Skipping...
14:35:41,421 DEBUG ConfigurationHelper:96 - No CacheExceptionHandlerFactory 
class specified. Skipping...
14:35:41,421 DEBUG Cache:948 - No BootstrapCacheLoaderFactory class specified. 
Skipping...
14:35:41,421 DEBUG Cache:922 - CacheWriter factory not configured. Skipping...
14:35:41,421 DEBUG ConfigurationHelper:96 - No CacheExceptionHandlerFactory 
class specified. Skipping...
14:35:41,421 DEBUG Cache:948 - No BootstrapCacheLoaderFactory class specified. 
Skipping...
14:35:41,421 DEBUG Cache:922 - CacheWriter factory not configured. Skipping...
14:35:41,421 DEBUG ConfigurationHelper:96 - No CacheExceptionHandlerFactory 
class specified. Skipping...
14:35:41,421 DEBUG Cache:948 - No BootstrapCacheLoaderFactory class specified. 
Skipping...
14:35:41,421 DEBUG Cache:922 - CacheWriter factory not configured. Skipping...
14:35:41,421 DEBUG ConfigurationHelper:96 - No CacheExceptionHandlerFactory 
class specified. Skipping...
14:35:41,593 DEBUG DiskPersistentStorageFactory:96 - Matching data file missing 
(or empty) for index file. Deleting index file 
C:\DOCUME~1\sahmad31\LOCALS~1\Temp\getAccPndCnclIndicatorsCache.index
14:35:41,671 DEBUG Cache:1175 - Initialised cache: getAccPndCnclIndicatorsCache
14:35:41,671 DEBUG ConfigurationHelper:331 - CacheDecoratorFactory not 
configured. Skipping for 'getAccPndCnclIndicatorsCache'.
14:35:41,671 DEBUG ConfigurationHelper:360 - CacheDecoratorFactory not 
configured for defaultCache. Skipping for 'getAccPndCnclIndicatorsCache'.
14:35:41,686 DEBUG DiskPersistentStorageFactory:96 - Matching data file missing 
(or empty) for index file. Deleting index file 
C:\DOCUME~1\sahmad31\LOCALS~1\Temp\getActivityTypePathCodeCache.index
14:35:41,686 DEBUG Cache:1175 - Initialised cache: getActivityTypePathCodeCache
14:35:41,686 DEBUG ConfigurationHelper:331 - CacheDecoratorFactory not 
configured. Skipping for 'getActivityTypePathCodeCache'.
14:35:41,686 DEBUG ConfigurationHelper:360 - CacheDecoratorFactory not 
configured for defaultCache. Skipping for 'getActivityTypePathCodeCache'.
14:35:41,702 DEBUG DiskPersistentStorageFactory:96 - Matching data file missing 
(or empty) for index file. Deleting index file 
C:\DOCUME~1\sahmad31\LOCALS~1\Temp\msgcenterdetailCache.index
14:35:41,702 DEBUG Cache:1175 - Initialised cache: msgcenterdetailCache
14:35:41,702 DEBUG ConfigurationHelper:331 - CacheDecoratorFactory not 
configured. Skipping for 'msgcenterdetailCache'.
14:35:41,718 DEBUG ConfigurationHelper:360 - CacheDecoratorFactory not 
configured for defaultCache. Skipping for 'msgcenterdetailCache'.
14:35:41,718 DEBUG DiskPersistentStorageFactory:96 - Matching data file missing 
(or empty) for index file. Deleting index file 
C:\DOCUME~1\sahmad31\LOCALS~1\Temp\getJobnameCache.index
14:35:41,718 DEBUG Cache:1175 - Initialised cache: getJobnameCache
---------------------------------------------------

My spring bean configuration and ehcache.xml is as below:

application-context.xml
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oxm="http://www.springframework.org/schema/oxm"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jee="http://www.springframework.org/schema/jee" xmlns:cache="http://www.springframework.org/schema/cache"
    xmlns:p="http://www.springframework.org/schema/p" xmlns:security="http://www.springframework.org/schema/security"
    xsi:schemaLocation="http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd
        http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-1.5.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
        http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.1.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<cache:annotation-driven />
    <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
        <property name="cacheManager" ref="ehcache" />
    </bean>

    <bean id="ehcache"
        class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
        <property name="configLocation" value="classpath:/config/ehcache.xml" />
    </bean>

------------------------------------------
ehcache.xml
    <diskStore path="java.io.tmpdir" />

    <defaultCache eternal="false" maxElementsInMemory="120"
        overflowToDisk="false" />

    <cache name="getNotesConfigData" maxElementsInMemory="120"
        eternal="false" overflowToDisk="false" timeToLiveSeconds="1200"
        diskPersistent="true" diskExpiryThreadIntervalSeconds="100" />  

    <cache name="getNotesSupportData" maxElementsInMemory="120"
        eternal="false" overflowToDisk="false" timeToLiveSeconds="1200"
        diskPersistent="true" diskExpiryThreadIntervalSeconds="100" />

we're using spring annotations on methods for cache.We're also using AspectJ 
for weaving logging. 

Original comment by faisal....@gmail.com on 24 Feb 2012 at 9:15

GoogleCodeExporter commented 8 years ago
What is the status of this? I see that several people have suggested solutions 
and patches as seen above and here:
https://github.com/agentgt/ehcache-spring-annotations

Asking since the self reference limitation is rather crippling for out use 
case. I know  aspect, but would really rather not have to build my own version. 
The home page says in the opening line that Ehcache-Spring-Annotations uses 
aspect, but the 1.2 xsd still insists there is no "mode" flag.

Thanks for anything you can provide.

Original comment by lifeofl...@gmail.com on 28 Mar 2012 at 9:23

GoogleCodeExporter commented 8 years ago
I made my own aspect class for LTW, based on ehcache-spring-annotations.
I couldn't wait for it to become available.
So, if people are interested, then just let me know and then I will just dig it 
up for you.

Original comment by cbon...@gmail.com on 29 Mar 2012 at 5:52

GoogleCodeExporter commented 8 years ago
cbon...,

I'd be interested if you could put it out there (patch or branch). Thx.

Joe

Original comment by lifeofl...@gmail.com on 29 Mar 2012 at 6:39