本文整理汇总了Java中org.apache.felix.main.AutoProcessor类的典型用法代码示例。如果您正苦于以下问题:Java AutoProcessor类的具体用法?Java AutoProcessor怎么用?Java AutoProcessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AutoProcessor类属于org.apache.felix.main包,在下文中一共展示了AutoProcessor类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.apache.felix.main.AutoProcessor; //导入依赖的package包/类
public BundleContext start() throws Exception {
Map<String, String> configMap = getConfiguration();
Felix fx = new Felix(configMap);
fwkTemplate = new DefaultFrameworkTemplate(fx, log);
fwkTemplate.init();
BundleContext context = fx.getBundleContext();
AutoProcessor.process(configMap, context);
fwkTemplate.start();
return context;
}
示例2: prepareFramework
import org.apache.felix.main.AutoProcessor; //导入依赖的package包/类
private void prepareFramework() {
fileInstall = new FileInstall();
propertiesDictionary = new Hashtable<String, String>();
StartupProperties startupProperties = CommunoteRuntime.getInstance()
.getConfigurationManager().getStartupProperties();
propertiesDictionary.put(DirectoryWatcher.DIR, startupProperties.getPluginDir()
.getAbsolutePath());
propertiesDictionary.put(DirectoryWatcher.NO_INITIAL_DELAY, Boolean.TRUE.toString());
propertiesDictionary.put(DirectoryWatcher.START_NEW_BUNDLES, Boolean.TRUE.toString());
propertiesDictionary.put(DirectoryWatcher.LOG_LEVEL, Integer.toString(4));
Properties frameworkProperties = loadFrameworkProperties();
List<BundleActivator> activatorList = new ArrayList<BundleActivator>();
activatorList.add(fileInstall);
frameworkProperties.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, activatorList);
// TODO better add a setSystemBundlesLocation method
String pathToWebInf = CommunoteRuntime.getInstance().getApplicationInformation()
.getApplicationRealPath()
+ "WEB-INF" + File.separator;
initSystemBundles(frameworkProperties, pathToWebInf + "plugins");
frameworkProperties.put(Constants.FRAMEWORK_STORAGE, OSGiHelper.getBundleBasePath()
.getAbsolutePath() + File.separator + "bundle-cache");
try {
framework = new Felix(frameworkProperties);
framework.init();
AutoProcessor.process(frameworkProperties, framework.getBundleContext());
framework.getBundleContext().addBundleListener(this);
} catch (BundleException e) {
throw new BeanCreationException(
"Starting OSGi framework failed because of a BundleException.", e);
}
LOG.info("OSGi Framework initialized.");
}
示例3: initialize
import org.apache.felix.main.AutoProcessor; //导入依赖的package包/类
private void initialize() throws BundleException, URISyntaxException {
Map<String, String> configMap = loadProperties();
System.setProperty(LOG_CONFIG_FILE_PROPERTY, configMap.get(LOG_CONFIG_FILE_PROPERTY));
System.out.println("Building OSGi Framework");
FrameworkFactory frameworkFactory = ServiceLoader.load(FrameworkFactory.class).iterator().next();
Framework framework = frameworkFactory.newFramework(configMap);
framework.init();
// (9) Use the system bundle context to process the auto-deploy
// and auto-install/auto-start properties.
AutoProcessor.process(configMap, framework.getBundleContext());
// (10) Start the framework.
System.out.println("Starting OSGi Framework");
framework.start();
BundleContext context = framework.getBundleContext();
// declarative services dependency is necessary, otherwise they won't be picked up!
loadScrBundle(context);
try {
framework.waitForStop(0);
} catch (InterruptedException e) {
appendToFile(e);
showErrorMessage();
}
System.exit(0);
}
示例4: FelixConfig
import org.apache.felix.main.AutoProcessor; //导入依赖的package包/类
public FelixConfig(String felixDeploymentDir){
config = new HashMap<String, String>();
config.put(org.osgi.framework.Constants.FRAMEWORK_STORAGE,
felixDeploymentDir.concat(File.separator).concat("felix-cache"));
config.put(AutoProcessor.AUTO_DEPLOY_DIR_PROPERY,
felixDeploymentDir.concat(File.separator).concat("bundle"));
config.put(BundleCache.CACHE_ROOTDIR_PROP, felixDeploymentDir);
config.put("felix.embedded.execution", "true");
config.put("org.osgi.framework.bootdelegation", "*");
config.put("felix.bootdelegation.implicit", "false");
//config.put("felix.log.level", "3");
config.put("felix.service.urlhandlers", "false");
config.put("felix.auto.deploy.action", "install,start");
config.put("org.osgi.framework.system.packages.extra", ANDROID_PACKAGES_FOR_EXPORT);
}
示例5: startPluginContainer
import org.apache.felix.main.AutoProcessor; //导入依赖的package包/类
private void startPluginContainer() throws BundleException, Exception {
Map<String, String> config = new HashMap<>();
config.put(FelixConstants.ACTIVATION_LAZY, "false");
config.put("felix.cache.locking", "false");
config.put("felix.auto.deploy.dir", "install");
config.put("felix.auto.deploy.action", "install,start");
config.put("org.osgi.framework.system.packages.extra",
"javafx.event,"
+ "org.badvision.outlaweditor.api,"
+ "org.badvision.outlaweditor.data,"
+ "org.badvision.outlaweditor.data.xml,"
+ "org.badvision.outlaweditor.ui,"
+ "org.osgi.framework");
// MH: Had to add these to allow plugin to access basic Java XML classes,
// and other stuff you'd think would just be default.
config.put("org.osgi.framework.bootdelegation",
"sun.*,"
+ "com.sun.*,"
+ "org.w3c.*,"
+ "org.xml.*,"
+ "javax.xml.*");
felix = new Felix(config);
felix.start();
felix.getBundleContext().registerService(ApplicationState.class, this, null);
tracker = new ServiceTracker(felix.getBundleContext(), MenuAction.class, null);
tracker.open();
Activator scrActivator = new Activator();
scrActivator.start(felix.getBundleContext());
AutoProcessor.process(config, felix.getBundleContext());
}
示例6: doLaunch
import org.apache.felix.main.AutoProcessor; //导入依赖的package包/类
public void doLaunch() {
// Create a case-insensitive configuration property map.
StringMap configMap = new StringMap(false);
// Configure the Felix instance to be embedded.
// configMap.put(FelixConstants.EMBEDDED_EXECUTION_PROP, "true");
// Add core OSGi packages to be exported from the class path
// via the system bundle.
configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES, "org.osgi.framework; version=1.3.0," + "org.osgi.service.packageadmin; version=1.2.0,"
+ "org.osgi.service.startlevel; version=1.0.0," + "org.osgi.service.url; version=1.0.0");
configMap.put(Constants.FRAMEWORK_STORAGE_CLEAN, Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT);
// Explicitly specify the directory to use for caching bundles.
// configMap.put(BundleCache.CACHE_PROFILE_DIR_PROP, "cache");
try {
// Create host activator;
List<Object> list = new ArrayList<Object>();
// list.add(new HostActivator());
configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, "org.xml.sax, org.xml.sax.helpers, javax.xml.parsers, javax.naming");
configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, list);
configMap.put("felix.log.level", "4");
// Now create an instance of the framework with
// our configuration properties and activator.
felix = new Felix(configMap);
felix.init();
// otherProps.put(Constants.FRAMEWORK_STORAGE, "bundles");
otherProps.put(AutoProcessor.AUTO_DEPLOY_DIR_PROPERY, AutoProcessor.AUTO_DEPLOY_DIR_VALUE);
otherProps.put(AutoProcessor.AUTO_DEPLOY_ACTION_PROPERY, AutoProcessor.AUTO_DEPLOY_START_VALUE + "," + AutoProcessor.AUTO_DEPLOY_INSTALL_VALUE);
BundleContext felixBudleContext = felix.getBundleContext();
AutoProcessor.process(otherProps, felixBudleContext);
// listen to errors
felixBudleContext.addFrameworkListener(frameworkErrorListener);
felixBudleContext.addBundleListener(myBundleListener);
// Now start Felix instance.
felix.start();
System.out.println("felix started");
} catch (Exception ex) {
ex.printStackTrace();
}
}
示例7: doLaunch
import org.apache.felix.main.AutoProcessor; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void doLaunch() {
// Create a case-insensitive configuration property map.
Map configMap = new StringMap(false);
// Configure the Felix instance to be embedded.
// configMap.put(FelixConstants.EMBEDDED_EXECUTION_PROP, "true");
// Add core OSGi packages to be exported from the class path
// via the system bundle.
configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES,
"org.osgi.framework; version=1.3.0,"
+ "org.osgi.service.packageadmin; version=1.2.0,"
+ "org.osgi.service.startlevel; version=1.0.0,"
+ "org.osgi.service.url; version=1.0.0");
configMap.put(Constants.FRAMEWORK_STORAGE_CLEAN,
Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT);
// Explicitly specify the directory to use for caching bundles.
// configMap.put(BundleCache.CACHE_PROFILE_DIR_PROP, "cache");
try {
// Create host activator;
List list = new ArrayList();
// list.add(new HostActivator());
configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
"org.xml.sax, org.xml.sax.helpers, javax.xml.parsers, javax.naming");
configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, list);
configMap.put("felix.log.level", "4");
// Now create an instance of the framework with
// our configuration properties and activator.
felix = new Felix(configMap);
felix.init();
// otherProps.put(Constants.FRAMEWORK_STORAGE, "bundles");
otherProps.put(AutoProcessor.AUTO_DEPLOY_DIR_PROPERY,
AutoProcessor.AUTO_DEPLOY_DIR_VALUE);
otherProps.put(AutoProcessor.AUTO_DEPLOY_ACTION_PROPERY,
AutoProcessor.AUTO_DEPLOY_START_VALUE + ","
+ AutoProcessor.AUTO_DEPLOY_INSTALL_VALUE);
BundleContext felixBudleContext = felix.getBundleContext();
AutoProcessor.process(otherProps, felixBudleContext);
// listen to errors
felixBudleContext.addFrameworkListener(frameworkErrorListener);
felixBudleContext.addBundleListener(myBundleListener);
// Now start Felix instance.
felix.start();
System.out.println("felix started");
} catch (Exception ex) {
ex.printStackTrace();
}
}
示例8: installBundle
import org.apache.felix.main.AutoProcessor; //导入依赖的package包/类
public void installBundle(){
AutoProcessor.process(configProps, bundleContext);
}
示例9: onCreate
import org.apache.felix.main.AutoProcessor; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
if(D) Log.d(TAG, "Setting up a thread for felix.");
Thread felixThread = new Thread() {
@Override
public void run() {
File dexOutputDir = getApplicationContext().getDir("transformationmanager", 0);
// if default bundles were not installed already, install them
File f = new File(dexOutputDir.getAbsolutePath()+"/bundle");
if(!f.isDirectory()) {
if(D) Log.i(TAG, "Installing default bundles...");
unzipBundles(FelixService.this.getResources().openRawResource(R.raw.bundles),
dexOutputDir.getAbsolutePath()+"/");
}
FelixConfig felixConfig = new FelixConfig(dexOutputDir.getAbsolutePath());
Map<String, String> configProperties = felixConfig.getProperties2();
try {
FrameworkFactory frameworkFactory = new org.apache.felix.framework.FrameworkFactory();
felixFramework = frameworkFactory.newFramework(configProperties);
felixFramework.init();
AutoProcessor.process(configProperties,felixFramework.getBundleContext());
felixFramework.start();
// Registering the android context as an osgi service
Hashtable<String, String> properties = new Hashtable<String, String>();
properties.put("platform", "android");
felixFramework.getBundleContext().registerService(
Context.class.getName(), getApplicationContext(),
properties);
} catch (Exception ex) {
Log.e(TAG, "Felix could not be started", ex);
ex.printStackTrace();
}
}
};
felixThread.setDaemon(true);
felixThread.start();
LocalBroadcastManager.getInstance(this).registerReceiver(downloadReceiver,
new IntentFilter(FELIX_SUCCESSFUL_WEB_REQUEST));
}
示例10: initFelixFramework
import org.apache.felix.main.AutoProcessor; //导入依赖的package包/类
private static void initFelixFramework() throws IOException, BundleException {
Properties configProps = _loadOsgiConfigProperties();
// configure Felix auto-deploy directory
String sAutoDeployDir = configProps.getProperty(AutoProcessor.AUTO_DEPLOY_DIR_PROPERY);
if (sAutoDeployDir == null) {
throw new RuntimeException("Can not find configuration ["
+ AutoProcessor.AUTO_DEPLOY_DIR_PROPERY + "] in file "
+ OSGiSERVER_OSGI_PROPERTIES.getAbsolutePath());
}
File fAutoDeployDir = new File(OSGiSERVER_HOME, sAutoDeployDir);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(AutoProcessor.AUTO_DEPLOY_DIR_PROPERY + ": "
+ fAutoDeployDir.getAbsolutePath());
}
configProps.setProperty(AutoProcessor.AUTO_DEPLOY_DIR_PROPERY,
fAutoDeployDir.getAbsolutePath());
// configure Felix temp (storage) directory
String sCacheDir = configProps.getProperty(Constants.FRAMEWORK_STORAGE);
if (sCacheDir == null) {
throw new RuntimeException("Can not find configuration [" + Constants.FRAMEWORK_STORAGE
+ "] in file " + OSGiSERVER_OSGI_PROPERTIES.getAbsolutePath());
} else if (LOGGER.isDebugEnabled()) {
LOGGER.debug(Constants.FRAMEWORK_STORAGE + ": " + sCacheDir);
}
File fCacheDir = new File(OSGiSERVER_HOME, sCacheDir);
configProps.setProperty(Constants.FRAMEWORK_STORAGE, fCacheDir.getAbsolutePath());
// configure Felix's File Install watch directory
final String PROP_FELIX_FILE_INSTALL_DIR = "felix.fileinstall.dir";
String sMonitorDir = configProps.getProperty(PROP_FELIX_FILE_INSTALL_DIR);
if (sMonitorDir != null) {
File fMonitorDir = new File(OSGiSERVER_HOME, sMonitorDir);
configProps.setProperty(PROP_FELIX_FILE_INSTALL_DIR, fMonitorDir.getAbsolutePath());
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(PROP_FELIX_FILE_INSTALL_DIR + ": " + fMonitorDir.getAbsolutePath());
}
}
// check for Felix's Remote Shell listen IP & Port
if (LOGGER.isDebugEnabled()) {
String remoteShellListenIp = configProps.getProperty("osgi.shell.telnet.ip");
String remoteShellListenPort = configProps.getProperty("osgi.shell.telnet.port");
LOGGER.debug("Remote Shell: " + remoteShellListenIp + ":" + remoteShellListenPort);
}
Map<String, String> config = new HashMap<String, String>();
for (Entry<Object, Object> entry : configProps.entrySet()) {
config.put(entry.getKey().toString(), entry.getValue().toString());
}
FrameworkFactory factory = new org.apache.felix.framework.FrameworkFactory();
framework = factory.newFramework(config);
framework.init();
AutoProcessor.process(configProps, framework.getBundleContext());
_autoDeployBundles(fAutoDeployDir, framework);
framework.start();
}