use of lucee.loader.engine.CFMLEngineFactory in project Lucee by lucee.
the class OSGiUtil method getBundleFile.
/**
* this should be used when you not want to load a Bundle to the system
* @param name
* @param version
* @param id only necessray if downloadIfNecessary is set to true
* @param downloadIfNecessary
* @return
* @throws BundleException
*/
public static BundleFile getBundleFile(String name, Version version, Identification id, boolean downloadIfNecessary) throws BundleException {
name = name.trim();
CFMLEngine engine = CFMLEngineFactory.getInstance();
CFMLEngineFactory factory = engine.getCFMLEngineFactory();
StringBuilder versionsFound = new StringBuilder();
// is it in jar directory but not loaded
BundleFile bf = _getBundleFile(factory, name, version, versionsFound);
if (bf != null)
return bf;
// if not found try to download
if (downloadIfNecessary && version != null) {
try {
bf = new BundleFile(factory.downloadBundle(name, version.toString(), id));
if (bf.isBundle())
return bf;
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
}
if (versionsFound.length() > 0)
throw new BundleException("The OSGi Bundle with name [" + name + "] is not available in version [" + version + "] locally or from the update provider, the following versions are available locally [" + versionsFound + "].");
if (version != null)
throw new BundleException("The OSGi Bundle with name [" + name + "] in version [" + version + "] is not available locally or from the update provider.");
throw new BundleException("The OSGi Bundle with name [" + name + "] is not available locally or from the update provider.");
}
use of lucee.loader.engine.CFMLEngineFactory in project Lucee by lucee.
the class OSGiUtil method loadBundleFromLocal.
public static Bundle loadBundleFromLocal(BundleContext bc, String name, Version version, boolean loadIfNecessary, Bundle defaultValue) {
name = name.trim();
Bundle[] bundles = bc.getBundles();
for (Bundle b : bundles) {
if (name.equalsIgnoreCase(b.getSymbolicName())) {
if (version == null || version.equals(b.getVersion())) {
return b;
}
}
}
if (!loadIfNecessary)
return defaultValue;
// is it in jar directory but not loaded
CFMLEngine engine = ConfigWebUtil.getEngine(ThreadLocalPageContext.getConfig());
CFMLEngineFactory factory = engine.getCFMLEngineFactory();
BundleFile bf = _getBundleFile(factory, name, version, null);
if (bf != null) {
try {
return _loadBundle(bc, bf.getFile());
} catch (Exception e) {
}
}
return defaultValue;
}
use of lucee.loader.engine.CFMLEngineFactory in project Lucee by lucee.
the class XMLConfigAdmin method restart.
/*private Resource getPatchDirectory(CFMLEngine engine) throws IOException {
//File f=engine.getCFMLEngineFactory().getResourceRoot();
Resource res = ResourcesImpl.getFileResourceProvider().getResource(engine.getCFMLEngineFactory().getResourceRoot().getAbsolutePath());
Resource pd = res.getRealResource("patches");
if(!pd.exists())pd.mkdirs();
return pd;
}*/
/**
* run update from cfml engine
* @throws PageException
*/
public void restart(Password password) throws PageException {
checkWriteAccess();
ConfigServerImpl cs = (ConfigServerImpl) ConfigImpl.getConfigServer(config, password);
CFMLEngineFactory factory = cs.getCFMLEngine().getCFMLEngineFactory();
synchronized (factory) {
try {
cleanUp(factory);
factory.restart(cs.getPassword());
} catch (Exception e) {
throw Caster.toPageException(e);
}
}
}
use of lucee.loader.engine.CFMLEngineFactory in project Lucee by lucee.
the class OSGiUtil method getBundleDefinitions.
public static List<BundleDefinition> getBundleDefinitions(BundleContext bc) {
Set<String> set = new HashSet<>();
List<BundleDefinition> list = new ArrayList<>();
Bundle[] bundles = bc.getBundles();
for (Bundle b : bundles) {
list.add(new BundleDefinition(b));
set.add(b.getSymbolicName() + ":" + b.getVersion());
}
// is it in jar directory but not loaded
CFMLEngine engine = ConfigWebUtil.getEngine(ThreadLocalPageContext.getConfig());
CFMLEngineFactory factory = engine.getCFMLEngineFactory();
try {
File[] children = factory.getBundleDirectory().listFiles(JAR_EXT_FILTER);
BundleFile bf;
for (int i = 0; i < children.length; i++) {
try {
bf = new BundleFile(children[i]);
if (bf.isBundle() && !set.contains(bf.getSymbolicName() + ":" + bf.getVersion()))
list.add(new BundleDefinition(bf.getSymbolicName(), bf.getVersion()));
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
}
} catch (IOException ioe) {
}
return list;
}
use of lucee.loader.engine.CFMLEngineFactory in project Lucee by lucee.
the class OSGiUtil method removeLocalBundle.
/**
* get local bundle, but does not download from update provider!
* @param name
* @param version
* @return
* @throws BundleException
*/
public static void removeLocalBundle(String name, Version version, boolean removePhysical, boolean doubleTap) throws BundleException {
name = name.trim();
CFMLEngine engine = CFMLEngineFactory.getInstance();
CFMLEngineFactory factory = engine.getCFMLEngineFactory();
BundleFile bf = _getBundleFile(factory, name, version, null);
if (bf != null) {
BundleDefinition bd = bf.toBundleDefinition();
if (bd != null) {
Bundle b = bd.getLocalBundle();
if (b != null) {
stopIfNecessary(b);
b.uninstall();
}
}
}
if (!removePhysical)
return;
// remove file
if (bf != null) {
if (!bf.getFile().delete() && doubleTap)
bf.getFile().deleteOnExit();
}
}
Aggregations