osgi

How to use org.apache.felix.scr annotations for a bundle from scratch?

耗尽温柔 提交于 2019-12-23 18:10:02
问题 I've started developing a bundle for apache felix and did so with the ops4j pax plugin. I've created the project structure with pax-create-project and in there did the normal pax-create-bundle . Then you get the initial project structure for building the whole thing with maven. The important part here is, that your bundle has it's own pom ( bundlename/pom.xml ) and bnd file ( bundlename/osgi.bnd ) but the configuration for maven-bundle-plugin is already provided under poms/compiled/pom.xml .

OSGi: What happens if not to unget service

时光怂恿深爱的人放手 提交于 2019-12-23 16:28:09
问题 This is the way how I get OSGi service: ServiceReference reference = bundleContext.getServiceReference(Foo.class.getName()); Foo foo=(Foo) bundleContext.getService(reference); What happens if I don't do bunldeContext.ungetSerivice(reference) when I finished with service: If I registered service manually, for example in activator If I use declarative service and it is Singleton 回答1: The OSGi framework maintains a use count of each service for your bundle. If your bundle does not unget the

Programmatically adding declarative services

删除回忆录丶 提交于 2019-12-23 15:26:17
问题 Is it possible to add declarative services using some kind of api? A little background: I have a server application based on dynamic scripts (they can be added, edited or removed at any time). Those scripts have dependencies to OSGi services and possibly each other. Whenever a script gets edited, the script gets compiled to javascript, and its dependencies are detected. At that point, I'd like to (re)register it as a declarative service, so it will be activated / deactivated when its

Is it appropriate to use OSGI framework on small java app?

风流意气都作罢 提交于 2019-12-23 14:34:50
问题 I have a plan to reimplement one of my small but usefull applications with OSGI framework. I never used it, so I ask is it appropriate to use OSGI on small app and is it a big difference in speed or/and memory footprint when using such framework. Also if it is a good option I would ask what implementation is best for small applications. thank you! 回答1: For modern computer systems, speed and memory footprint of OSGi are of no concern at all: remember that OSGi was developed for resource

strange interaction with Axis & OSGi

怎甘沉沦 提交于 2019-12-23 13:17:06
问题 Here is the scenario: I have 2 bundles with axis 1.4 and it's transitive dependencies embedded in them (they each call a different web service to do their work). It seems that when one loads before the other, the other bundle "loses" with this exception: java.lang.RuntimeException: java.lang.ClassCastException: org.apache.axis.transport.http.HTTPSender cannot be cast to org.apache.axis.Handler I've dug through the axis code a bit and it looks like it is in fact doing some classloading that

OSGi console after running tycho tests

这一生的挚爱 提交于 2019-12-23 13:05:08
问题 I wonder is there any way to tell the osgi console in eclipse not to exit after running tests with tycho-surefire-plugin? I have tried out <argLine>-Dosgi.noShutdown=true</argLine> and <appArgLine>-console -noExit</appArgLine> , but I do not get what I want. 回答1: I finally succeeded in getting to the OSGi console by starting the tycho test in the remote debug mode. However in contrast to the above mentioned solution I had to use the following configuration: <argLine>-ea -Dosgi.clean=true

How to follow test first approach with Equinox/OSGi - Tycho - Eclipse RCP environment

僤鯓⒐⒋嵵緔 提交于 2019-12-23 12:27:38
问题 I joined a project where the development is carried on Eclipse RCP platform with the use of Equinox/OSGi, Tycho. I am slowly getting familiar with classpath/classloading mechanism of OSGi, how tycho, equinox works etc. I am writing plain unit tests with the use of mocking by collecting them in test bundles (which are fragments of the target bundles) however I am encountering ClassNotFound errors, issues with attaching source code. I have seen recommendations such as running tests as rcp

how to detect if running in osgi container

感情迁移 提交于 2019-12-23 12:27:02
问题 I have an OSGi bundle that can also run in plain Java process. I need to be able to tell if the bundle was loaded in an OSGi system or not. How can I do that? If there is no OSGi-standard way of doing this, I will settle for Eclipse/Equinox-specific approach. 回答1: If you don't have an activator, you can also try asking for your bundle: Bundle b = org.osgi.framework.FrameworkUtil.getBundle(MyClass.this); If it returns null, your class wasn't loaded by OSGi. 回答2: Add Bundle-Activator to your

Best solution for using AOP with OSGI?

感情迁移 提交于 2019-12-23 12:24:14
问题 I am using Equinox, so the Equinox Aspect project seems like a no-brainer, but that project appears to be inactive and has only one page of documentation that leaves me hanging at the end. Other than that project, I do not see many options for using AOP in OSGI. Let me know what you all think and what the possibilities are, thanks :) 回答1: I don't know of any alternative, but I didn't think Equinox Aspects was inactive. It's even receiving new features in the upcoming Helios release. 回答2: The

Maven SCR Plugin - Not generating OSGI-INF folder

房东的猫 提交于 2019-12-23 10:26:19
问题 I have been having trouble getting my SCR plugin working. I have searched as much as I could bur only found examples that were not similar to the structure I am required to use. Snippets of POMs below. These are pretty much the default generated by the CQ project archetype. All dependencies are there, so it is probably not that. Here is the output of the build: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: