All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.aspectj.weaver.loadtime.ConfigurationHolder Maven / Gradle / Ivy

Go to download

Scripting extension for AspectJ agent. Allow java bytecode instrumentation at jvm startup by using MVEL expression and execute code from maven artifacts

The newest version!
package org.aspectj.weaver.loadtime;

import com.github.igorsuhorukov.google.common.cache.CacheBuilder;
import com.github.igorsuhorukov.google.common.cache.CacheLoader;
import com.github.igorsuhorukov.google.common.cache.LoadingCache;
import org.aspectj.configuration.AspectJDescriptor;
import org.aspectj.util.Utils;

import java.io.IOException;
import java.net.URL;

/**
 */
public class ConfigurationHolder {

    private static final String AOP_FROM_CONFIGURATION_PREFIX = "config:";

    public static LoadingCache configuration = CacheBuilder.newBuilder().maximumSize(Integer.MAX_VALUE)
            .build(
                    new CacheLoader() {
                        public URL load(String resource) throws IOException {
                            if(isAspectJScriptingManagedResource(resource)){
                                String configuration = resource.substring(AOP_FROM_CONFIGURATION_PREFIX.length());
                                String configurationLocation = Utils.checkMvelExpression(configuration).toString();
                                return AspectJDescriptor.renderConfigurationToTemporaryFile(configurationLocation);
                            }
                            return null;
                        }
                    });

    public static boolean isAspectJScriptingManagedResource(String resource) {
        return resource.startsWith(AOP_FROM_CONFIGURATION_PREFIX);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy