diff options
Diffstat (limited to 'branches/sca-java-1.x/samples/calculator-rcp/src/main/java/calculator/rcp/Activator.java')
-rw-r--r-- | branches/sca-java-1.x/samples/calculator-rcp/src/main/java/calculator/rcp/Activator.java | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/branches/sca-java-1.x/samples/calculator-rcp/src/main/java/calculator/rcp/Activator.java b/branches/sca-java-1.x/samples/calculator-rcp/src/main/java/calculator/rcp/Activator.java new file mode 100644 index 0000000000..50f68dcb01 --- /dev/null +++ b/branches/sca-java-1.x/samples/calculator-rcp/src/main/java/calculator/rcp/Activator.java @@ -0,0 +1,94 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator.rcp; + +import java.io.File; + +import org.apache.tuscany.sca.extensibility.equinox.EquinoxServiceDiscoverer; +import org.apache.tuscany.sca.node.SCAContribution; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.apache.tuscany.sca.sample.calculator.rcp"; + + // The shared instance + private static Activator plugin; + + private SCANode node; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + Class<?> cls = EquinoxServiceDiscoverer.class; + SCANodeFactory factory = SCANodeFactory.newInstance(); + node = factory.createSCANode("Calculator.composite", new SCAContribution("c1", new File("target/classes").toURI().toString())); + node.start(); + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + if (node != null) { + node.stop(); + } + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + + /** + * Returns an image descriptor for the image file at the given + * plug-in relative path + * + * @param path the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return imageDescriptorFromPlugin(PLUGIN_ID, path); + } +} |