OSGi jar restricted inside a CQ5/ AEM component - aem

Is it possible to install a OSGi jar to Felix by keeping the jar as a part of the cq5 component and install it on build?

You cannot restrict an OSGi bundle so that only one CQ component can use it. If an OSGi bundle exports a java package, that will be visible from all java and scripting code.

You can include it in a content package at build time, if you're targeting this with your question. The multimodule-content-package-archetype provided by Adobe does that as well.

Related

AEM 6.5 add Third party dependency And AEM OSGI shows 'com.twilio -- Cannot be resolved'

I want to add the dependency of twilio in AEM 6.5,there is an error such as the image
This is the dependency I added
so,How can AEM correctly introduce third-party dependencies?
You have to install the dependency as an OSGi bundle. Some libraries provide OSGi bundles as part of their releases, others you’ll have to bundle yourself. One of the ways to do this is with bnd from bndtools. They have a guide that should help you get started: https://bnd.bndtools.org/chapters/390-wrapping.html
Once you have that, you need to ensure it declares the packages you depend on as exported and then you need to install it into your AEM. From that point on, the dependencies will be marked as resolved.

Hot code deployment during development with embedded Apache Felix and Eclipse?

I am trying to embed Felix in an application of ours to handle plugins. Everything is working fine, however, development and debugging is very cumbersome.
Is there a solution where I can tell Felix to automatically reload a plugin bundle or its classes when I recompile a plugin in Eclipse?
I cannot use any OSGi specific launchers because Felix is embedded in our application
Felix' fileinstall supports directories, but expects a specific structure, which is incompatible with the layout of the Eclipse project.
Any help or pointers to a solution would be greatly appreciated.
You could take a look at Bndtools and the remote launcher. You only need to install a remote agent in your framework and then Bndtools can update any bundle that has changed in the workspace.
This is explained in remote launching. In OSGi enRoute you find an IoT tutorial that uses this model as well as a Karaf App Note.

Use external equinox jar for equinox container in Eclipse Project

I've created a project in eclipse and I want to use the equinox jars which are available in local repository i.e. I don't want to use equinox from eclipse. How can I achieve this?
For Example: If I create any project in eclipse and want to use OSGI framework then eclipse automatically uses the equinox jars which are available for that particular version of eclipse. But I don't want to use the eclipse's equinox jar. I want to specify some location for my project from where it can load the equinox jars.
Add a dependency for a concrete version in your pom file. That will add the jar file to your class path and your application will use that concrete version

Implementing simple modules or extensions for axis2 as an eclipse project

I wish to setup an eclipse project for implementing a simple module but not a service for axis. I wonder if there're any templates I could use?
Secondly, I would like to ask if there are any information sources such as links around on how to build complex Axis2 applications in eclipse mainly focusing on module building as well
I appreciate your hints.
Best regards,
Alex
I could come along with this issue with my own solution:
Using an customized build.xml based on axis2 module builds I am able to build a module project in Eclipse using ant. I trigger this via key shortcut.
The build.xml has an deploy.module target that puts the module back to the axis2 $HOME/repository folder. Running there ant build.xml will deploy axis2 at whole as an war-file (EAR) the module containing there within to be ready to deploy in a container such as jboss.
The eclipse project is based on common java project (no dynamic web project) containing the $AXIS2/lib in CLASSPATH.
Since Jboss supports hot deployment on update, you can run jboss in a terminal or withing eclipse. I customized the latter build.xml to support easy jboss deployment.
This is a good solution for me.

debuggging eclipse plugin dependancy

I am creating an eclipse plugin that calls some classes from a Java project. I have added this Java project as a required project on my build path.
When I create an eclipse plugin jar using an ant script, everything works fine.
However when I try to debug the code at run time or open the eclipse as a run time application, the classes from the Java project are not accessible. I get a NoClassDefFoundException.
Is there something I am missing while adding the dependancy?
Eclipse is based on OSGi, and as a rule of thumb, bundles can only see other bundles. Usually for including 3rd party jars in an eclipse plugin, you have 2 choices:
1) Include the jar in your eclipse project. Add it to the build.properties. Edit the MANIFEST.MF and add it to the Classpath section on the Runtime tab.
2) turn the 3rd party jar into a bundle so that your eclipse plugin can require it. You can use File>New>Other...>Plug-in Development>Plug-in from Existing JAR. The simplest form of an OSGi bundle is just the original jar with OSGi headers added to its MANIFEST.MF.
EDIT:
Remember also you have to honour the 3rd party jar license with whichever option you choose.