Java Code Examples for org.osgi.framework.FrameworkUtil

The following examples show how to use org.osgi.framework.FrameworkUtil. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: nebula   Source File: ToolbarButton.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Create a {@link ToolbarButton} with the given information.
 * 
 * @param buttonName
 *            The unique name of the dynamically created CKEditor button.
 * @param commandName
 *            The unique name of the dynamically created CKEditor command that is called by
 *            pressing this button.
 * @param buttonLabel
 *            The textual part of the button (if visible) and its tooltip.
 * @param toolbar
 *            The toolbar group into which the button will be added. An optional index value
 *            (separated by a comma) determines the button position within the group.
 * @param iconURL
 *            The {@link URL} of the image that should be show as button icon.
 */
public ToolbarButton(String buttonName, String commandName, String buttonLabel, String toolbar, URL iconURL) {
	this.buttonName = buttonName;
	this.commandName = commandName;
	this.buttonLabel = buttonLabel;
	this.toolbar = toolbar;

	// if we are in an OSGi context, we need to convert the bundle URL to a file URL
	Bundle bundle = FrameworkUtil.getBundle(RichTextEditor.class);
	if (bundle != null) {
		try {
			iconURL = FileLocator.toFileURL(iconURL);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	this.iconURL = iconURL;
}
 
Example 2
Source Project: aCute   Source File: DotnetExportWizardPage.java    License: Eclipse Public License 2.0 6 votes vote down vote up
protected DotnetExportWizardPage(IFile projectFile) {
	super(DotnetExportWizardPage.class.getName());
	setTitle(Messages.DotnetExportWizardPage_exportProject_title);
	setDescription(Messages.DotnetExportWizardPage_exportProject_message);

	Bundle bundle = FrameworkUtil.getBundle(this.getClass());
	URL url = bundle.getEntry("images/dotnet.png"); //$NON-NLS-1$
	ImageDescriptor imageDescriptor = ImageDescriptor.createFromURL(url);
	setImageDescriptor(imageDescriptor);

	if (projectFile != null) {
		projectPath = new Path(projectFile.getRawLocation().toString());
	}
	targetFrameworks = ProjectFileAccessor.getTargetFrameworks(projectPath);
	defaultRuntime = DotnetExportAccessor.getDefaultRuntime();
}
 
Example 3
Source Project: extended-objects   Source File: XOSGi.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Create a {@link com.buschmais.xo.api.XOManagerFactory} for the given XO unit.
 * <p>
 * Internally it performs a lookup in the OSGi service registry to retrieve the
 * XOBootstrapService service.
 * </p>
 *
 * @param xoUnit
 *            The XO unit.
 * @return The {@link com.buschmais.xo.api.XOManagerFactory}.
 */
public static XOManagerFactory createXOManagerFactory(XOUnit xoUnit) {
    if (OSGiUtil.isXOLoadedAsOSGiBundle()) {
        BundleContext bundleContext = FrameworkUtil.getBundle(XOSGi.class).getBundleContext();
        ServiceReference<XOBootstrapService> xoBootstrapServiceReference = bundleContext.getServiceReference(XOBootstrapService.class);
        if (xoBootstrapServiceReference == null) {
            throw new XOException("Cannot get XO bootstrap service reference.");
        }
        XOBootstrapService xoBootstrapService = bundleContext.getService(xoBootstrapServiceReference);
        if (xoBootstrapService == null) {
            throw new XOException("Cannot get XO bootstrap service.");
        }
        XOManagerFactory xoManagerFactory = xoBootstrapService.createXOManagerFactory(xoUnit);
        bundleContext.ungetService(xoBootstrapServiceReference);
        return xoManagerFactory;
    }
    throw new XOException("Cannot bootstrap XO implementation.");
}
 
Example 4
@Override
protected TransactionManager acquireTransactionManager() throws Exception {
    Bundle bundle = FrameworkUtil.getBundle(EclipseLinkOSGiTransactionController.class);
    BundleContext ctx = bundle.getBundleContext();

    if (ctx != null) {
        ServiceReference<?> ref = ctx.getServiceReference(TransactionManager.class.getName());

        if (ref != null) {
            TransactionManager manager = (TransactionManager) ctx.getService(ref);
            return manager;
        }
    }

    return super.acquireTransactionManager();
}
 
Example 5
/**
 * Appends the given section to a tab from the list.
 */
protected void appendToTabDescriptor(ISectionDescriptor section,
		List aTabDescriptors) {
	for (Iterator i = aTabDescriptors.iterator(); i.hasNext();) {
		TabDescriptor tab = (TabDescriptor) i.next();
		if (tab.append(section)) {
			return;
		}
	}
	// could not append the section to any of the existing tabs - log error
	String message = MessageFormat.format(NO_TAB_ERROR, section.getId(), section.getTargetTab());
	Bundle bundle = FrameworkUtil.getBundle(TabbedPropertyRegistry.class);
	IStatus status = new Status(IStatus.ERROR, bundle.getSymbolicName(),
			TabbedPropertyViewStatusCodes.NO_TAB_ERROR, message, null);
	Platform.getLog(bundle).log(status);
}
 
Example 6
Source Project: neoscada   Source File: MailEventHandler.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public MailEventHandler ( final String id, final MailSender sender, final PipeService pipeService, final int retries ) throws Exception
{
    this.bundle = FrameworkUtil.getBundle ( MailHandlerFactory.class );
    this.sender = sender;
    this.retries = retries;

    final String pipeName = "mail." + id;

    try
    {
        this.producer = pipeService.createProducer ( pipeName );
        this.workerHandle = pipeService.createWorker ( pipeName, this.mailWorker );
    }
    catch ( final Exception e )
    {
        if ( this.sender != null )
        {
            this.sender.dispose ();
            this.sender = null;
        }
    }
}
 
Example 7
@Override
protected TransactionManager acquireTransactionManager() throws Exception {
    Bundle bundle = FrameworkUtil.getBundle(EclipseLinkOSGiTransactionController.class);
    BundleContext ctx = bundle.getBundleContext();

    if (ctx != null) {
        ServiceReference<?> ref = ctx.getServiceReference(TransactionManager.class.getName());

        if (ref != null) {
            TransactionManager manager = (TransactionManager) ctx.getService(ref);
            return manager;
        }
    }

    return super.acquireTransactionManager();
}
 
Example 8
private void updateEventFilter()
{
  String filterString = (String) sr.getProperty(EventConstants.EVENT_FILTER);
  try {
    if (filterString == null) {
      filter = null;
    } else {
      filter = FrameworkUtil.createFilter(filterString);
    }
  } catch (InvalidSyntaxException e) {
    filter = null;
    setBlacklist(true);
    /*
     * if (Activator.log.doError()) {
     * Activator.log.error("Failure when matching filter '" +filterString
     * +"' in handler with service.id " +sid, handlerSR, err); }
     */
  }
}
 
Example 9
Source Project: peer-os   Source File: HealthRestServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
protected BundleStateService getBundleStateService()
{
    // get bundle instance via the OSGi Framework Util class
    BundleContext ctx = FrameworkUtil.getBundle( BundleStateService.class ).getBundleContext();
    if ( ctx != null )
    {
        ServiceReference serviceReference = ctx.getServiceReference( BundleStateService.class.getName() );
        if ( serviceReference != null )
        {
            Object service = ctx.getService( serviceReference );
            if ( BundleStateService.class.isInstance( service ) )
            {
                return BundleStateService.class.cast( service );
            }
        }
    }

    throw new IllegalStateException( "Can not obtain handle of BundleStateService" );
}
 
Example 10
Source Project: concierge   Source File: BundleLocationCondition.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Constructs a condition that tries to match the passed Bundle's location
 * to the location pattern.
 * 
 * @param bundle The Bundle being evaluated.
 * @param info The ConditionInfo from which to construct the condition. The
 *        ConditionInfo must specify one or two arguments. The first
 *        argument of the ConditionInfo specifies the location pattern
 *        against which to match the bundle location. Matching is done
 *        according to the filter string matching rules. Any '*' characters
 *        in the first argument are used as wildcards when matching bundle
 *        locations unless they are escaped with a '\' character. The
 *        Condition is satisfied if the bundle location matches the pattern.
 *        The second argument of the ConditionInfo is optional. If a second
 *        argument is present and equal to "!", then the satisfaction of the
 *        Condition is negated. That is, the Condition is satisfied if the
 *        bundle location does NOT match the pattern. If the second argument
 *        is present but does not equal "!", then the second argument is
 *        ignored.
 * @return Condition object for the requested condition.
 */
static public Condition getCondition(final Bundle bundle, final ConditionInfo info) {
	if (!CONDITION_TYPE.equals(info.getType()))
		throw new IllegalArgumentException("ConditionInfo must be of type \"" + CONDITION_TYPE + "\"");
	String[] args = info.getArgs();
	if (args.length != 1 && args.length != 2)
		throw new IllegalArgumentException("Illegal number of args: " + args.length);
	String bundleLocation = AccessController.doPrivileged(new PrivilegedAction<String>() {
		public String run() {
			return bundle.getLocation();
		}
	});
	Filter filter = null;
	try {
		filter = FrameworkUtil.createFilter("(location=" + escapeLocation(args[0]) + ")");
	} catch (InvalidSyntaxException e) {
		// this should never happen, but just in case
		throw new RuntimeException("Invalid filter: " + e.getFilter(), e);
	}
	Dictionary<String, String> matchProps = new Hashtable<String, String>(2);
	matchProps.put("location", bundleLocation);
	boolean negate = (args.length == 2) ? "!".equals(args[1]) : false;
	return (negate ^ filter.match(matchProps)) ? Condition.TRUE : Condition.FALSE;
}
 
Example 11
Source Project: tracecompass   Source File: ControlViewTest.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Open a trace in an editor
 *
 * @throws Exception
 *             if problem occurs
 */
@Before
public void beforeTest() throws Exception {
    SWTBotUtils.openView(ControlView.ID);
    WaitUtils.waitForJobs();
    URL location = FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path("testfiles" + File.separator + getTestStream()), null);
    File testfile = new File(FileLocator.toFileURL(location).toURI());
    fTestFile = testfile.getAbsolutePath();

    // Create root component
    SWTBotView viewBot = fBot.viewById(ControlView.ID);
    viewBot.setFocus();
    IViewPart part = viewBot.getViewReference().getView(true);
    ControlView view = (ControlView) part;
    fRoot = view.getTraceControlRoot();

    // Create node component
    fNode = new TargetNodeComponent(getNodeName(), fRoot, fProxy);
    fRoot.addChild(fNode);
    fTree = viewBot.bot().tree();
}
 
Example 12
/**
 * Constructs a Condition that tries to match the passed Bundle's location
 * to the location pattern.
 * 
 * @param bundle The Bundle being evaluated.
 * @param info The ConditionInfo from which to construct the condition. The
 *        ConditionInfo must specify one or two arguments. The first
 *        argument of the ConditionInfo specifies the chain of distinguished
 *        names pattern to match against the signer of the bundle. The
 *        Condition is satisfied if the signer of the bundle matches the
 *        pattern. The second argument of the ConditionInfo is optional. If
 *        a second argument is present and equal to "!", then the
 *        satisfaction of the Condition is negated. That is, the Condition
 *        is satisfied if the signer of the bundle does NOT match the
 *        pattern. If the second argument is present but does not equal "!",
 *        then the second argument is ignored.
 * @return A Condition which checks the signers of the specified bundle.
 */
public static Condition getCondition(final Bundle bundle, final ConditionInfo info) {
	if (!CONDITION_TYPE.equals(info.getType()))
		throw new IllegalArgumentException("ConditionInfo must be of type \"" + CONDITION_TYPE + "\"");
	String[] args = info.getArgs();
	if (args.length != 1 && args.length != 2)
		throw new IllegalArgumentException("Illegal number of args: " + args.length);

	Map<X509Certificate, List<X509Certificate>> signers = bundle.getSignerCertificates(Bundle.SIGNERS_TRUSTED);
	boolean match = false;
	for (List<X509Certificate> signerCerts : signers.values()) {
		List<String> dnChain = new ArrayList<String>(signerCerts.size());
		for (X509Certificate signer : signerCerts) {
			dnChain.add(signer.getSubjectDN().getName());
		}
		if (FrameworkUtil.matchDistinguishedNameChain(args[0], dnChain)) {
			match = true;
			break;
		}
	}

	boolean negate = (args.length == 2) ? "!".equals(args[1]) : false;
	return negate ^ match ? Condition.TRUE : Condition.FALSE;
}
 
Example 13
/**
 * Returns the configuration elements targeted for the given extension point
 * and the current contributor id. The elements are also sorted by plugin
 * prerequisite order.
 */
protected IConfigurationElement[] getConfigurationElements(
		String extensionPointId) {
	if (contributorId == null) {
		return new IConfigurationElement[0];
	}
	IExtensionPoint point = Platform.getExtensionRegistry()
			.getExtensionPoint(FrameworkUtil.getBundle(TabbedPropertyRegistry.class).getSymbolicName(),
					extensionPointId);
	IConfigurationElement[] extensions = point.getConfigurationElements();
	List<IConfigurationElement> unordered = new ArrayList<>(extensions.length);
	for (IConfigurationElement extension : extensions) {
		if (!extension.getName().equals(extensionPointId)) {
			continue;
		}
		String contributor = extension.getAttribute(ATT_CONTRIBUTOR_ID);
		if (!contributorId.equals(contributor)) {
			continue;
		}
		unordered.add(extension);
	}
	return unordered.toArray(new IConfigurationElement[unordered.size()]);
}
 
Example 14
@Override
protected TransactionManager acquireTransactionManager() throws Exception {
    Bundle bundle = FrameworkUtil.getBundle(EclipseLinkOSGiTransactionController.class);
    BundleContext ctx = bundle.getBundleContext();

    if (ctx != null) {
        ServiceReference<?> ref = ctx.getServiceReference(TransactionManager.class.getName());

        if (ref != null) {
            TransactionManager manager = (TransactionManager) ctx.getService(ref);
            return manager;
        }
    }

    return super.acquireTransactionManager();
}
 
Example 15
private static @Nullable String considerTransformation(String state, Item item, @Nullable Locale locale) {
    StateDescription stateDescription = item.getStateDescription(locale);
    if (stateDescription != null) {
        String pattern = stateDescription.getPattern();
        if (pattern != null) {
            try {
                return TransformationHelper.transform(
                        FrameworkUtil.getBundle(EnrichedItemDTOMapper.class).getBundleContext(), pattern, state);
            } catch (NoClassDefFoundError ex) {
                // TransformationHelper is optional dependency, so ignore if class not found
                // return state as it is without transformation
            } catch (TransformationException e) {
                LOGGER.warn("Failed transforming the state '{}' on item '{}' with pattern '{}': {}", state,
                        item.getName(), pattern, e.getMessage());
            }
        }
    }
    return state;
}
 
Example 16
Source Project: ghidra   Source File: AboutCommand.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	Version version = FrameworkUtil.getBundle(getClass()).getVersion();
	StringBuilder message = new StringBuilder();
	message.append("GhidraDev " + version.toString() + "\n\n");
	message.append("Ghidra Development support for Eclipse");
	EclipseMessageUtils.showInfoDialog("About", message.toString());
	return null;
}
 
Example 17
Source Project: dartboard   Source File: BaseLaunchConfigTab.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Image getImage() {
	Bundle bundle = FrameworkUtil.getBundle(this.getClass());
	URL fileURL = bundle.getEntry(imagePath);
	ImageDescriptor createFromURL = ImageDescriptor.createFromURL(fileURL);
	image = createFromURL.createImage();
	return image;
}
 
Example 18
ReferenceDescription(String name,
                     String interfaceName,
                     boolean optional,
                     boolean multiple,
                     boolean dynamic,
                     boolean greedy,
                     String target,
                     String bind,
                     String unbind,
                     String updated,
                     String scope,
                     String field,
                     Boolean fieldUpdate,
                     int fieldCollectionType)
  throws InvalidSyntaxException
{
  targetFilter = (target != null) ? FrameworkUtil.createFilter(target) : null;
  this.name = name;
  this.interfaceName = interfaceName;
  this.optional = optional;
  this.multiple = multiple;
  this.dynamic = dynamic;
  this.greedy = greedy;
  this.bind = bind;
  this.unbind = unbind;
  this.updated = updated;
  this.scope = scope;
  this.field = field;
  this.fieldUpdate = fieldUpdate;
  this.fieldCollectionType = fieldCollectionType;
}
 
Example 19
Source Project: org.openhab.ui.habot   Source File: CardBuilder.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private String formatState(Item item, State state) throws TransformationException {
    if (item.getStateDescription() != null) {
        try {
            StateDescription stateDescription = item.getStateDescription();
            if (stateDescription != null && stateDescription.getPattern() != null) {
                String transformedState = TransformationHelper.transform(
                        FrameworkUtil.getBundle(CardBuilder.class).getBundleContext(),
                        stateDescription.getPattern(), state.toString());
                if (transformedState == null) {
                    return state.toString();
                }
                if (transformedState.equals(state.toString())) {
                    return state.format(stateDescription.getPattern());
                } else {
                    return transformedState;
                }

            } else {
                return state.toString();
            }
        } catch (IllegalFormatConversionException e) {
            return state.toString();
        }
    } else {
        return state.toString();
    }
}
 
Example 20
Source Project: elexis-3-core   Source File: ReChargeLabOpenCons.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private void deInitCodeElementService(){
	BundleContext context =
		FrameworkUtil.getBundle(ReChargeTarmedOpenCons.class).getBundleContext();
	if (codeServiceRef != null) {
		context.ungetService(codeServiceRef);
		codeElementService = null;
	}
}
 
Example 21
Source Project: neoscada   Source File: FilterUtil.java    License: Eclipse Public License 1.0 5 votes vote down vote up
protected static Filter createFilter ( final String operand, final Map<String, String> parameters ) throws InvalidSyntaxException
{
    final StringBuilder sb = new StringBuilder ();

    sb.append ( "(" );
    sb.append ( operand );

    for ( final Map.Entry<String, String> entry : parameters.entrySet () )
    {
        addPair ( sb, entry.getKey (), entry.getValue () );
    }
    sb.append ( ")" );

    return FrameworkUtil.createFilter ( sb.toString () );
}
 
Example 22
Source Project: neoscada   Source File: FilterUtil.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public static Filter createSimpleOr ( final String attribute, final Set<String> values ) throws InvalidSyntaxException
{
    final StringBuilder sb = new StringBuilder ();

    sb.append ( "(|" );

    for ( final String value : values )
    {
        addPair ( sb, attribute, value );
    }

    sb.append ( ")" );

    return FrameworkUtil.createFilter ( sb.toString () );
}
 
Example 23
/**
 * Perform pre-test initialization.
 *
 * @throws Exception
 *         if the initialization fails for some reason
 */
@Before
public void setUp() throws Exception {
    fFacility = TraceControlTestFacility.getInstance();
    fFacility.init();
    URL location = FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(TraceControlTestFacility.DIRECTORY + File.separator + TEST_STREAM), null);
    File testfile = new File(FileLocator.toFileURL(location).toURI());
    fTestFile = testfile.getAbsolutePath();
}
 
Example 24
Source Project: openhab1-addons   Source File: FreeboxBinding.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void activate() {
    Bundle bundle = FrameworkUtil.getBundle(getClass());
    appVersion = String.format("%d.%d", bundle.getVersion().getMajor(), bundle.getVersion().getMinor()); // something
                                                                                                         // like 1.5
    appID = bundle.getSymbolicName(); // org.openhab.binding.freebox
    appName = bundle.getHeaders().get("Bundle-Name"); // "openHAB Freebox Binding"
    lastPhoneCheck = Calendar.getInstance();
}
 
Example 25
public int cmdShow(Dictionary<String,?> opts, Reader in, PrintWriter out,
    Session session) {
  final String namespace = (String) opts.get("namespace");
  final String filterStr = (String) opts.get("filter");

  BasicRequirement requirement;
  requirement = new BasicRequirement(namespace);
  if (filterStr != null) {
    try {
      FrameworkUtil.createFilter(filterStr);
    } catch (InvalidSyntaxException e) {
      out.println("Invalid filter: " + e.getMessage());
      return 1;
    }
    requirement.addDirective("filter", filterStr); 
  }
  List<Capability> cs = getRepositoryManager().findProviders(requirement);
  if (cs.isEmpty()) {
    out.println("No matching resources found!");
    return 0;
  }
  List<Resource> resources = new ArrayList<Resource>();
  for (Capability c : cs) {
    resources.add(c.getResource());
  }
  printResources(out, resources, namespace, opts.get("-t") == null);
  return 0;
}
 
Example 26
Source Project: neoscada   Source File: ConfigurationFactoryImpl.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public ConfigurationFactoryImpl ()
{
    final ReadWriteLock lock = new ReentrantReadWriteLock ();
    this.readLock = lock.readLock ();
    this.writeLock = lock.writeLock ();

    final BundleContext context = FrameworkUtil.getBundle ( DataContext.class ).getBundleContext ();

    this.executor = new ScheduledExportedExecutorService ( "org.eclipse.scada.da.server.exporter.rest", 1 );
    this.hiveSource = new ServiceListenerHiveSource ( context, this.executor );
    this.hiveSource.open ();
}
 
Example 27
Source Project: bonita-studio   Source File: ProductVersion.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static String manifestVersion() {
    Bundle bundle = FrameworkUtil.getBundle(ProductVersion.class);
    if (bundle == null) {
        String implementationVersion = ProductVersion.class.getPackage().getImplementationVersion();
        if (implementationVersion == null) {
            return "7.6.0";//fake version used in unit test
        }
        return stripSnaphot(implementationVersion);
    }
    Version version = bundle.getVersion();
    return String.format("%s.%s.%s", version.getMajor(), version.getMinor(), version.getMicro());
}
 
Example 28
@Before
public void setUp() {
    registerVolatileStorageService();

    readyService = getService(ReadyService.class);
    assertThat(readyService, is(notNullValue()));
    thingRegistry = getService(ThingRegistry.class);
    assertThat(thingRegistry, is(notNullValue()));
    modelRepository = getService(ModelRepository.class);
    assertThat(modelRepository, is(notNullValue()));
    modelRepository.removeModel(TESTMODEL_NAME);

    ComponentContext componentContextMock = mock(ComponentContext.class);
    when(componentContextMock.getBundleContext()).thenReturn(bundleContext);

    hueThingHandlerFactory = new TestHueThingHandlerFactoryX(componentContextMock) {
        @Override
        protected ThingHandler createHandler(final Thing thing) {
            if (thing instanceof Bridge) {
                return new TestBridgeHandler((Bridge) thing);
            } else {
                return new BaseThingHandler(thing) {
                    @Override
                    public void handleCommand(ChannelUID arg0, Command arg1) {
                    };

                    @Override
                    public void initialize() {
                        updateStatus(ThingStatus.ONLINE);
                    }
                };
            }
        }
    };

    finished = false;
    bundle = FrameworkUtil.getBundle(TestHueThingHandlerFactoryX.class);

    removeReadyMarker();
}
 
Example 29
Source Project: openhab1-addons   Source File: BticinoDevice.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private ItemRegistry getItemRegistry() throws ServiceException {
    BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
    if (bundleContext != null) {
        ServiceReference<?> serviceReference = bundleContext.getServiceReference(ItemRegistry.class.getName());
        if (serviceReference != null) {
            ItemRegistry itemregistry = (ItemRegistry) bundleContext.getService(serviceReference);
            return itemregistry;
        }
    }
    throw new ServiceException("Cannot get ItemRegistry");
}
 
Example 30
Source Project: neoscada   Source File: EventInjectorManager.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public synchronized void start () throws Exception
{
    final BundleContext context = FrameworkUtil.getBundle ( EventInjectorManager.class ).getBundleContext ();

    this.impl = new EventInjectorImpl ( context, this.evaluator );

    final Dictionary<String, Object> properties = new Hashtable<> ();
    properties.put ( Constants.SERVICE_DESCRIPTION, "Event injector manager" );
    properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
    properties.put ( "osgi.command.scope", "ein" );
    properties.put ( "osgi.command.function", new String[] { "rules", "state" } );
    properties.put ( ConfigurationAdministrator.FACTORY_ID, "org.eclipse.scada.ae.server.injector" );
    context.registerService ( ConfigurationFactory.class, this.impl, properties );
}