Révision 2157
| tmp/org.txm.core/src/java/org/txm/StandaloneTest.java (revision 2157) | ||
|---|---|---|
| 1 |
package org.txm; |
|
| 2 |
|
|
| 3 |
import java.util.ServiceLoader; |
|
| 4 |
|
|
| 5 |
import org.eclipse.core.internal.runtime.Activator; |
|
| 6 |
import org.eclipse.core.internal.runtime.InternalPlatform; |
|
| 7 |
import org.osgi.framework.BundleContext; |
|
| 8 |
import org.osgi.framework.Filter; |
|
| 9 |
import org.osgi.framework.launch.Framework; |
|
| 10 |
import org.osgi.framework.launch.FrameworkFactory; |
|
| 11 |
import org.osgi.util.tracker.ServiceTracker; |
|
| 12 |
import org.txm.core.preferences.TBXPreferences; |
|
| 13 |
|
|
| 14 |
public class StandaloneTest {
|
|
| 15 |
|
|
| 16 |
public static void main(String[] args) {
|
|
| 17 |
|
|
| 18 |
try {
|
|
| 19 |
|
|
| 20 |
//Load the framwork factory |
|
| 21 |
ServiceLoader loader = ServiceLoader.load( FrameworkFactory.class ); |
|
| 22 |
System.out.println("ServiceLoader= "+loader);
|
|
| 23 |
|
|
| 24 |
FrameworkFactory factory = ( FrameworkFactory ) loader.iterator( ).next( ); |
|
| 25 |
System.out.println("FrameworkFactory= "+loader);
|
|
| 26 |
|
|
| 27 |
// Create a new instance of the framework |
|
| 28 |
Framework framework = factory.newFramework( null ); |
|
| 29 |
System.out.println("Framework="+framework);
|
|
| 30 |
framework.init( ); |
|
| 31 |
framework.start( ); |
|
| 32 |
|
|
| 33 |
BundleContext bc = framework.getBundleContext(); |
|
| 34 |
System.out.println("BundleContext: "+bc);
|
|
| 35 |
|
|
| 36 |
Filter filter = bc.createFilter("(objectClass=*ServiceTasks)");
|
|
| 37 |
System.out.println("Filter: "+filter);
|
|
| 38 |
|
|
| 39 |
ServiceTracker serviceTaskTracker = new ServiceTracker(bc, filter, null); |
|
| 40 |
System.out.println("ServiceTracker: "+serviceTaskTracker);
|
|
| 41 |
|
|
| 42 |
InternalPlatform.getDefault().start(bc); |
|
| 43 |
System.out.println("context started");
|
|
| 44 |
|
|
| 45 |
// Activator.getDefault().start(bc); |
|
| 46 |
|
|
| 47 |
Toolbox.initialize(TBXPreferences.class); |
|
| 48 |
} catch (Exception e) {
|
|
| 49 |
// TODO Auto-generated catch block |
|
| 50 |
e.printStackTrace(); |
|
| 51 |
} |
|
| 52 |
} |
|
| 53 |
} |
|
| tmp/org.txm.core/src/java/org/txm/ToolboxApplication.java (revision 2157) | ||
|---|---|---|
| 1 |
package org.txm; |
|
| 2 |
|
|
| 3 |
import org.eclipse.core.runtime.adaptor.EclipseStarter; |
|
| 4 |
import org.eclipse.equinox.app.IApplication; |
|
| 5 |
import org.eclipse.equinox.app.IApplicationContext; |
|
| 6 |
import org.txm.core.preferences.TBXPreferences; |
|
| 7 |
|
|
| 8 |
public class ToolboxApplication implements IApplication {
|
|
| 9 |
|
|
| 10 |
public static void main(String[] args) {
|
|
| 11 |
|
|
| 12 |
try {
|
|
| 13 |
|
|
| 14 |
// //Load the framwork factory |
|
| 15 |
// ServiceLoader loader = ServiceLoader.load( FrameworkFactory.class ); |
|
| 16 |
// System.out.println("ServiceLoader= "+loader);
|
|
| 17 |
// |
|
| 18 |
// FrameworkFactory factory = ( FrameworkFactory ) loader.iterator( ).next( ); |
|
| 19 |
// System.out.println("FrameworkFactory= "+loader);
|
|
| 20 |
// |
|
| 21 |
// // Create a new instance of the framework |
|
| 22 |
// Framework framework = factory.newFramework( null ); |
|
| 23 |
// System.out.println("Framework="+framework);
|
|
| 24 |
// framework.init( ); |
|
| 25 |
// framework.start( ); |
|
| 26 |
// |
|
| 27 |
// BundleContext bc = framework.getBundleContext(); |
|
| 28 |
// System.out.println("BundleContext: "+bc);
|
|
| 29 |
// |
|
| 30 |
// Filter filter = bc.createFilter("(objectClass=*ServiceTasks)");
|
|
| 31 |
// System.out.println("Filter: "+filter);
|
|
| 32 |
// |
|
| 33 |
// ServiceTracker serviceTaskTracker = new ServiceTracker(bc, filter, null); |
|
| 34 |
// System.out.println("ServiceTracker: "+serviceTaskTracker);
|
|
| 35 |
// |
|
| 36 |
// InternalPlatform.getDefault().start(bc); |
|
| 37 |
// System.out.println("context started");
|
|
| 38 |
// |
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
String[] pargs = {"-application", "org.txm.core.Toolbox", "-data", "/home/mdecorde/workspace047/../runtime-rcpapplication.product", "-configuration", "file:/home/mdecorde/workspace047/.metadata/.plugins/org.eclipse.pde.core/rcpapplication.product/", "-dev", "file:/home/mdecorde/workspace047/.metadata/.plugins/org.eclipse.pde.core/rcpapplication.product/dev.properties", "-os", "linux", "-ws", "gtk", "-arch", "x86_64", "-nl", "fr_FR", "-consoleLog", "-run"};
|
|
| 43 |
EclipseStarter.main(pargs); |
|
| 44 |
// System.out.println("plugins: "+Arrays.toString(Platform.getPluginRegistry().getPluginDescriptors()));
|
|
| 45 |
// System.out.println("ext pts: "+Arrays.toString(Platform.getPluginRegistry().getExtensionPoints()));
|
|
| 46 |
|
|
| 47 |
|
|
| 48 |
//Toolbox.initialize(TBXPreferences.class); |
|
| 49 |
} catch (Exception e) {
|
|
| 50 |
// TODO Auto-generated catch block |
|
| 51 |
e.printStackTrace(); |
|
| 52 |
} |
|
| 53 |
} |
|
| 54 |
|
|
| 55 |
public static boolean started = false; |
|
| 56 |
private boolean goOn = true; |
|
| 57 |
private int exitCode = IApplication.EXIT_OK; |
|
| 58 |
|
|
| 59 |
public void stopToolbox() {
|
|
| 60 |
goOn = false; |
|
| 61 |
} |
|
| 62 |
|
|
| 63 |
public void setExitCode(int exitCode) {
|
|
| 64 |
this.exitCode = exitCode; |
|
| 65 |
} |
|
| 66 |
|
|
| 67 |
@Override |
|
| 68 |
public Object start(IApplicationContext context) throws Exception {
|
|
| 69 |
//System.out.println("Starting Toolbox...");
|
|
| 70 |
//Toolbox.initialize(TBXPreferences.class); |
|
| 71 |
started = true; |
|
| 72 |
while (goOn) {
|
|
| 73 |
Thread.sleep(1000); |
|
| 74 |
System.out.println("T"+started);
|
|
| 75 |
} |
|
| 76 |
started = false; |
|
| 77 |
return IApplicationContext.EXIT_ASYNC_RESULT; |
|
| 78 |
} |
|
| 79 |
|
|
| 80 |
@Override |
|
| 81 |
public void stop() {
|
|
| 82 |
// TODO Auto-generated method stub |
|
| 83 |
} |
|
| 84 |
} |
|
| 0 | 85 | |
| tmp/org.txm.core/plugin.xml (revision 2157) | ||
|---|---|---|
| 36 | 36 |
name="ScriptEngines"> |
| 37 | 37 |
</EngineManager> |
| 38 | 38 |
</extension> |
| 39 |
<extension |
|
| 40 |
id="Toolbox" |
|
| 41 |
point="org.eclipse.core.runtime.applications"> |
|
| 42 |
<application |
|
| 43 |
cardinality="singleton-global" |
|
| 44 |
thread="main" |
|
| 45 |
visible="true"> |
|
| 46 |
<run |
|
| 47 |
class="org.txm.ToolboxApplication"> |
|
| 48 |
</run> |
|
| 49 |
</application> |
|
| 50 |
</extension> |
|
| 39 | 51 |
|
| 40 | 52 |
</plugin> |
Formats disponibles : Unified diff