Search in sources :

Example 6 with DynamicClassLoaderManager

use of org.apache.sling.commons.classloader.DynamicClassLoaderManager in project sling by apache.

the class FSClassLoaderProvider method destroyClassLoader.

private void destroyClassLoader() {
    final ClassLoader rcl = this.loader;
    if (rcl != null) {
        this.loader = null;
        final ServiceReference<DynamicClassLoaderManager> localDynamicClassLoaderManager = this.dynamicClassLoaderManager;
        final Bundle localCallerBundle = this.callerBundle;
        if (localDynamicClassLoaderManager != null && localCallerBundle != null) {
            localCallerBundle.getBundleContext().ungetService(localDynamicClassLoaderManager);
        }
    }
}
Also used : Bundle(org.osgi.framework.Bundle) DynamicClassLoaderManager(org.apache.sling.commons.classloader.DynamicClassLoaderManager)

Example 7 with DynamicClassLoaderManager

use of org.apache.sling.commons.classloader.DynamicClassLoaderManager in project sling by apache.

the class ClassLoaderWriterImpl method getOrCreateClassLoader.

private synchronized RepositoryClassLoader getOrCreateClassLoader() {
    if (this.repositoryClassLoader == null || !this.repositoryClassLoader.isLive()) {
        // make sure to cleanup any existing class loader
        this.destroyRepositoryClassLoader();
        // get the dynamic class loader for the bundle using this
        // class loader writer
        final DynamicClassLoaderManager dclm = (DynamicClassLoaderManager) this.callerBundle.getBundleContext().getService(this.dynamicClassLoaderManager);
        this.repositoryClassLoader = new RepositoryClassLoader(this.classPath, this, dclm.getDynamicClassLoader());
    }
    return this.repositoryClassLoader;
}
Also used : DynamicClassLoaderManager(org.apache.sling.commons.classloader.DynamicClassLoaderManager)

Example 8 with DynamicClassLoaderManager

use of org.apache.sling.commons.classloader.DynamicClassLoaderManager in project sling by apache.

the class GetPropertyTag method getClassLoader.

/**
	 * Method for retrieving the classloader from the OSGi console.
	 * 
	 * @return the classloader
	 */
protected ClassLoader getClassLoader() {
    final SlingBindings bindings = (SlingBindings) pageContext.getRequest().getAttribute(SlingBindings.class.getName());
    final SlingScriptHelper scriptHelper = bindings.getSling();
    final DynamicClassLoaderManager dynamicClassLoaderManager = scriptHelper.getService(DynamicClassLoaderManager.class);
    final ClassLoader classLoader = dynamicClassLoaderManager.getDynamicClassLoader();
    return classLoader;
}
Also used : SlingBindings(org.apache.sling.api.scripting.SlingBindings) SlingScriptHelper(org.apache.sling.api.scripting.SlingScriptHelper) DynamicClassLoaderManager(org.apache.sling.commons.classloader.DynamicClassLoaderManager)

Aggregations

DynamicClassLoaderManager (org.apache.sling.commons.classloader.DynamicClassLoaderManager)8 SlingBindings (org.apache.sling.api.scripting.SlingBindings)2 SlingScriptHelper (org.apache.sling.api.scripting.SlingScriptHelper)2 URL (java.net.URL)1 Item (javax.jcr.Item)1 HelperData (org.apache.sling.jcr.resource.internal.HelperData)1 SlingContextFactory (org.apache.sling.scripting.javascript.helper.SlingContextFactory)1 SlingWrapFactory (org.apache.sling.scripting.javascript.helper.SlingWrapFactory)1 Context (org.mozilla.javascript.Context)1 ContextFactory (org.mozilla.javascript.ContextFactory)1 Bundle (org.osgi.framework.Bundle)1 BundleContext (org.osgi.framework.BundleContext)1 ComponentContext (org.osgi.service.component.ComponentContext)1 Activate (org.osgi.service.component.annotations.Activate)1