AspectJ LoadTimeWeaving on OSGI - osgi

I'm trying to use aspectJ Load Time Weaving (no Spring) on OSGI with help of equinox jars (org.aspectj.runtime, org.aspectj.weaver, org.eclipse.equinox.weaving.aspectj on bundles folder and org.eclipse.equinox.weaving.hook located at the same folder as org.eclipse.osgi physical location) according to: https://wiki.eclipse.org/Equinox_Weaving_QuickStart
Here's the loading order of bundles:
[org.eclipse.equinox.weaving.hook::1 -> INSTALLED]
[org.aspectj.runtime::11 -> INSTALLED]
[org.aspectj.weaver::12 -> INSTALLED]
[org.eclipse.equinox.weaving.aspectj::13 -> INSTALLED]
[com.common-calculations_2.11::19 -> INSTALLED] //here I used aspects
[com.instrumentation_2.11::48 -> INSTALLED] //here I defined the aspects
Done installing bundles
Starting bundles...
[org.eclipse.equinox.weaving.aspectj::13 -> ACTIVE]
[org.aspectj.runtime::11 -> ACTIVE]
[org.eclipse.osgi::0 -> ACTIVE]
FRAGMENT Bundle - skip starting: org.eclipse.equinox.weaving.hook
FRAGMENT Bundle - skip starting: org.aspectj.runtime
[org.aspectj.weaver::12 -> ACTIVE]
FRAGMENT Bundle - skip starting: org.eclipse.equinox.weaving.aspectj
Bundle started: [com.common-calculations_2.11::19 -> ACTIVE]
Bundle started: [com.instrumentation_2.11::48 -> ACTIVE]
I want to know how should I start the hook jar?
I'll appreciate any help...
p.s. someone solved his issue by importing the bundle "org.eclipse.osgi" and the fragment "org.eclipse.equinox.weaving.hook" as "Binary Project with Linked Content" into his workspace, but I'm not really sure how to do that:
https://www.eclipse.org/forums/index.php?t=msg&th=440862
Thanks for your replies

Once I wrote a bigger article on this topic on my blog when I faced the issue at my job for a railroad traffic control application. It still runs with aspects at its core functionality - not just for call tracing, but for automatic resource and transaction handling for JPA and thread safety aspects and so on (so I know the solution still work in real life at my former project):
http://ballmerpeak.web.elte.hu/devblog/setting-up-aspect-oriented-programming-with-equinox-osgi-and-ajdt.html
Self-contained example code is provided at my github:
https://github.com/prenex/equinox_osgi_skeleton
I also add our email's content here if it might help others:
"
Hi!
It was a bit time ago when I worked on the topic but surely it was working well for us and still is part of a plugin-based railroad traffic control application.
For your problem:
1.) Did you put the equinox.weaving.hook bundle near the core org.eclipse.osgi bundle? There were some not-so-clear stuff like this requirement the last time I worked on it that is why I wrote it down in a blog post.
2.) Did you try my example code from the following link?
https://github.com/prenex/equinox_osgi_skeleton
I would first try to run this example project of mine which already contains AspectJ in it and then compare your solution line-by-line at relevant places until it start to work.
Look at the following commit to see what I changed in a generic equinox+osgi skeleton project to add simple AspectJ support:
https://github.com/prenex/equinox_osgi_skeleton/commit/882d7765f31a3fc8ee136e88b689fce116a73d1c
Best regards,
Richard Thier
PS.: How did you stumble upon my blog? I am happy someone actually read it and find it helpful even if it does not completely solve all their problems. :-)
"

Related

How to install Domains (port of CUIS Mathematics) in Pharo?

In a past question, Is there a CAS for Pharo?, I asked about a Computer Algebra System for Pharo, and people pointed to Domains, a port of Mathematics from CUIS smalltalk, that is part of PolyMath project. I suceeded installing PolyMath in Pharo 8, running the following code in the playground, as adviced in https://github.com/PolyMathOrg/PolyMath:
Metacello new
repository: 'github://PolyMathOrg/PolyMath:v1.0.2';
baseline: 'PolyMath';
load
The problem is, it appears Domains is not installed by default with PolyMath, as I didn't find the corresponding classes in the class browser, and the Domains subpage has no similar instructions on installation.
EDIT (March 2, 2021): I tried to follow the sugestion of EstebanLM, and load from iceberg, having PolyMath installed beforehand. But I only see the following packages in the iceberg screen:
It is in a separate github repo (PolyMathOrg/Domains), without a baseline. So you need to just clone the repo from github in Iceberg, and then load the packages in the right order from hand. Iceberg will complain if you try to load a package with unloaded dependencies (Mathematics-Kernel is a good starting point), and you can just reload after loading the missing dependency.
If you note down the needed loading order, you can provide a PR with a baseline
Once you load polymath, you will have all packages available to load.
The tool used to load/save packages in Pharo is called iceberg (is a git client). You can find it in the menu "tools" in Pharo 8 or in "browse" in Pharo 9.

XPage Osgi plug in development

background
I have designed many tools in the past year or so that is designed to help me program for XPages. These tools include primarily helper java classes, extended logging (making use of OpenLogger and my own stuff), and a few other things that I personally feel I cannot work without. It has been discussed with my employer, and we feel that it might be a good idea to start publishing these items to openNTF. Since these tools are made up of about 3 .nsfs, all designed to use the same java code, key javascript classes, css, and even a custom control or two, I would like to consolidate key items into a plug-in that can be installed at the server and client level. I want to do this consolidation before I even think about publishing any of the work I've done so far. It would just be far too much work to maintain, not just for me, but for potential users. I have not really found any information on how to do such a thing in google searches. I also have to make sure that I am able to make use of the ExtLib libraries, openNTF Domino API, and the Notes API.
my questions
How does one best go about designing such plug-ins? Must a designer
use eclipse, or is this it possible to do this directly in the Notes
Designer?
How does a designer best go about keeping a server and client up to date while designing and updating the plug-in code? Is this why GitHub is often used?
Where is the best place to get material to get started in this direction? I sort of feel lost in the woods, knowing I need to head north, but not having a compass for that first step.
Thank you very much for your input.
In my experience, I found that diving into plug-in development is a huge PITA until you get used to it, but it's definitely worth it overall.
As for whether you can use Designer for plugin development: yes, but you will likely eventually want to not do so. I started out by using Designer for this sort of thing for a while, presumably with the same sentiment as you: why bother installing another instance of Eclipse when I'm already sitting in one all day? However, between Designer's age (it's roughly equivalent to, I think, Eclipse 3.4), oddities when it comes to working sets between the "Applications" and "Project Explorer" views, and, in my case, my desire to use a Mac app, I ended up switching.
There are two major starting points: the XSP Starter Kit (http://www.openntf.org/internal/home.nsf/project.xsp?name=XSP%20Starter%20Kit) and Niklas Heidloff's video on setting up Eclipse for XPages development (http://www.openntf.org/main.nsf/blog.xsp?permaLink=NHEF-8RVB5H). The latter mentions the XPages SDK (http://www.openntf.org/internal/home.nsf/project.xsp?name=XPages%20SDK%20for%20Eclipse%20RCP), which is also useful. In my setup, I found the video largely useful, but some aspects either difficult to find (IBM's downloads are shifting sands) or optional (debugging, which will depend on whether or not you're using Eclipse on Windows).
Those resources should generally get you set up. The main thing to worry about when setting up your Eclipse environment will be making sure your Plug-In Execution Environment is properly done. If you're following the SDK setup instructions, that SHOULD get you where you need to be.
The next thing to know about is the way plugins are structured. Each plugin you want to install in Designer or Domino will also be paired with a feature project (a feature can house several plugins), and potentially an update site - the last one is optional if you just want to import the features into an Update Site NSF. That's how I often do my normal plugin development: export the paired feature to a directory and then import the feature into the server's Update Site NSF and then install in Designer from there using Application -> Install. You can also set things up so that you deploy into the server's plugin/feature directories instead of taking the step of installing into an update site if you'd prefer. GitHub doesn't really come into play for this aspect - it's more about sharing/collaborating with your code and also having a remote storage location for your git repositories (which I highly advise).
And as for the "lost in the woods" feeling: yep, you'll have that for a good while. There are lots of moving parts and esoteric concepts to get a hold of all at once. If you mostly follow the above links and then start with some basics from the XSP Starter Kit (which is itself a plugin project that you can pair with a feature) - say, printing text in the Activator class and making an implicit global variable just to make sure it works - that should help get your feet wet.
It's best done in Eclipse. You can debug your code running on the server from there, as well as run it directly from there. The editors are also more up-to-date. You want:
Eclipse for RCP and RAP developers
XPages SDK for Eclipse RCP (from OpenNTF)
XPages Debug Plugin (from OpenNTF - basically allows you to load the plugins to the Domino server dynamically, rather than exporting to an Update Site all the time)
XSP Starter Kit on OpenNTF is a good starting point for a plugin. There are various references to the library id, which has to be unique for your plugin. Basically, references to org.openntf.xsp.starter need changing to whatever you want to call your plugin. You're also best advised to remove what you don't need. I tend to work in a copy of the Starter, remove stuff, build and if there are errors with required classes (Activator.java obviously will be required and some others), then paste them back in from the Starter.
XPages OpenLog Logger is a good cross-reference, that was built from XPages Starter Kit. It's pretty much stripped down and you'll be able to see what had to be changed. A lot of the elements of the XSP Starter Kit correspond to Java classes you'll probably be familiar with from your XPages Java development.
GitHub etc tend to be used as source control, which is useful for working out what's changed from time to time.

Domino OSGI Update Site Creation

This is a continuation of a question I asked a few days ago regarding a designer connection for Domino OSGI dev and testing.
In eclipse, I do have the "debugging plug-in" installed (as mentioned by stwissel), and I am fairy certain that it is configured properly.
In a second attempt, I tried to export my plug-in in an update site.
1. import plug-in to feature
2. import feature to update site
3. build update site
I first tried to install using My Widgets in the notes sidebar. I did not get the thing to run with that so, then went into designer and installed it there directly, also nothing.
current stand
I built the update site and deployed using an nsf Update Site as a widget. I use this for openNTF Domino API, the ExtLibs -- it is comfortable and I like it.
I can verify that the feature is available in the application Management window of designer.
3 I expect to see those libraries in the xsp.properties page generation tab, but do not.
questions
1. Am I missing something?
2. Must I add some sort of class/code/flag in order to choose this library/plug-in in designer?
3. How can I best verify that the plug in and not just the feature is installed?
if your XspLibrary is not a 'global' one you probably won't see the activator run until the first nsf that uses it activates it.
seeing as you can't select it in an nsf this is probably why no nsf is ever activating it
can I ask have you correctly defined the library as an extension of com.ibm.commons.Extensions
as type
com.ibm.xsp.Library
if you don't define the extension you will not see it in the list of libraries.
also you must make sure you set the plugin settings to export the XspLibrary class (or package of the class) otherwise designer can't use the class
see this article on the domino designer wiki for an overview of necessary steps to correctly set up the XspLibrary plugin. the manifest.mf / plugin.xml settings are important.
another thing to double check, is to inspect the actual built plugin jar, using something like 7zip. you can open it up like a zip and have a look to make sure the .class files are actually included in the jar. if your build settings are incorrect it may not include them in the jar properly. also make sure the manifest.mf and plugin.xml are in there properly
EDIT from Greg
This should be the link for a non-mobile user
When you setup the debug plugin, it should create an entry in the workspace directory of the Notes client and Domino server (I think down in the RCP directory). This entry points back to the Eclipse workspace. So you don't need to deploy the plug-in. You also should see a warning when loading Notes ( with rparams -console) or Domino on the console about the debug.
Also what I found: auto deployment via Widget works when the update site sits on a server via http or nrpc. It doesn't when it is specified as file:/// so I run a Apache http on local (I need it for other stuff too, so no big deal for me).
I'll check the exact settings when I get back to my Dev workstation
You can identify if a plugin is installed via Help > About IBM Domino Designer, then clicking on the Plug-in Details button in the dialog.
Help > Support > View Log and View Trace should give more details. Trace is more detailed and allows you to write content, as we do for the OpenNTF Domino API. It may allow you to see how far through the code it's going.
That first message is in the XspLibrary class, in the constructor, just using a sysout
/**
* Constructor
*/
public XspLibrary() {
System.out.println("Loading org.openntf.domino.xsp library");
}
Hopefully that should help you see where it's failing.

Starting an Existing Java project that has not been documented

I have only worked on projects that I started from scratch, but now I got to work on a pre-existing project(Web applicaation) with no documentation and no guidance. All the folks that worked on the project are gone, and my client wants me to start working on the project.
I need the best Steps to do this, and start running it in my IDE.
Is there any efficient and non-time consuming method to start out? Any tools that might help?
All I got so far-->
1)Project.EAR file --> (module) one War file. (backup exported from server)
2)Versions used--> Java1.4, Websphere app server v5.1, Sapjco Connectors.
3)jars in lib folder(Frameworks) list.
acegi-security-1.0.2.jar
activation.jar
antlr.jar
antlr-2.7.6.jar
asm.jar
aspectjweaver-1.5.2.jar
cglib-2.1.3.jar
chartengineapi.jar
clickstream-1.0.2.jar
com.ibm.icu_4.0.1.v20090415.jar
commons-beanutils.jar
commons-cli-1.0.jar
commons-codec-1.3.jar
commons-collections.jar
commons-dbcp.jar
commons-digester.jar
commons-fileupload.jar
commons-io.jar
commons-lang.jar
commons-logging.jar
commons-logging-1.1.jar
commons-pool.jar
commons-validator.jar
coreapi.jar
crosstabcoreapi.jar
dataadapterapi.jar
dataaggregationapi.jar
dataextraction.jar
displaytag-1.1.jar
dom4j-1.6.1.jar
dteapi.jar
dwr.jar
ehcache-1.2.3.jar
emitterconfig.jar
engineapi.jar
flute.jar
itext-1.3.3.jar
jakarta-oro.jar
jaxen-full.jar
js.jar
jstl.jar
jta.jar
log4j-1.2.11.jar
mail.jar
modelapi.jar
modelodaapi.jar
odadesignapi.jar
org.apache.commons.codec_1.3.0.v20080530-1600.jar
org.eclipse.emf.common_2.5.0.v200906080927.jar
org.eclipse.emf.ecore_2.5.0.v200906080927.jar
org.eclipse.emf.ecore.xmi_2.5.0.v200906080927.jar
org.w3c.css.sac_1.3.0.v200805290154.jar
oscache-2.3.2.jar
sapjco.jar
saxpath.jar
scriptapi.jar
servletapi-2.3.jar
sitemesh-2.2.1.jar
spring.jar
spring-batch-infrastructure-1.1.2.jar
spring-mock.jar
standard.jar
struts.jar
struts-el.jar
struts-menu-2.4.2.jar
taglibs-datetime.jar
taglibs-mailer.jar
taglibs-string.jar
urlrewrite-3.0-beta.jar
utility.jar
velocity-1.4.jar
velocity-tools-view-1.1.jar
I know starting out is always time consuming. But i need better way to start this project
NEED:--
1) What frameworks used in this project.
2) Whats the best way to start. (Clear steps please)
3) Which (open source)Server I can use as alternative to Websphere v5.
Regards.
Edited
Jars added (sorry i forgot to mention some jars in lib)
"Write once, run anywhere" unfortunately doesn't mean you can compile the source code or start the result without errors.
The first step is probably to identify which IDE was used to develop the project with. Look for some specific files:
.project and .classpath -> Eclipse
*.ipr -> IDEA
pom.xml -> Maven
Import the project using the original IDE (make sure you use the same version if you can) so you can start and compile the project without errors.
If there are no such files, curse the people who did it. If they still work at your place, get in touch with their manager and give them input for the next performance interview ("leaves project zombies behind").
If you run into big trouble doing this step: Ask colleagues for help. Web projects are all similar but there are many subtle problems to get them working, so it's much more effective to pair with someone than, say, asking here.
You can also try to locate the original team members; they probably haven't all left the planet. Google is your friend here and maybe someone at your company stayed in contact.
Now your questions:
What frameworks used in this project.
Lots. Apparently, they just took whatever they needed. That said, this list looks pretty common for most web projects that go beyond "hello world."
Whats the best way to start.
See above.
Which (open source)Server I can use as alternative to Websphere v5.
WebSphere has a lot of .... "features" which can't be found anywhere else.
I suggest to try to get the app working with WebSphere first and then try Tomcat or Jetty.
In order not to get insane with WebSphere's startup times, get a powerful machine with lots of RAM, install it locally and use scripting to configure/control WebSphere (at the bottom of the page are scripts for WebSphere 5).

Problem in plug-in development: Eclipse 3.4 can't find a bundle that is definitively there!

Today I had a problem with my old Eclipse 3.4 installation and I had to re-download the entire package. However, I don't think that I got the exact package as before, and I'm having some problems.
The problem can be summarized as follows: when developing a plug-in, I cannot resolve dependencies towards 'org.eclipse.jdt.ui'. When trying to add the missing plugin, in the dialog the closest match is 'org.eclipse.jdt.ui**.source**'. A similar thing happens with other core plugins.
In order to test, I created a new plug-in using the wizard and I obtained a non-compiling plugin: one of the classes uses the class org.eclipse.jdt.ui.JavaUI and it cannot be resolved. Similarly, the MANIFEST.MF includes a dependency towards 'org.eclipse.jdt.ui', but the 'Bundle 'org.eclipse.jdt.ui' cannot be resolved'.
Now a summary of my platform:
I'm running Mac OS X 10.4 Tiger and Java 1.5.0_19-138
I'm running Eclipse Version: 3.4.1 Build id: M20080911-1700
I downloaded the modeling package, which comes in a file called 'eclipse-modeling-ganymede-SR1-incubation-macosx-carbon.tar.gz'
I've performed a fresh installation, in a new folder and using a new workspace.
If I look at the Plug-in Registry view, I can find the 'org.eclipse.jdt.ui' plugin in there, and it appears to be running. By the way, if it is disabled, then the workbench breaks and stops working.
I cannot understand what is happening. Is my installation broken? I wonder if the Eclipse package that I downloaded has an error and they included the sources instead of the compiled files. But in that case, the plug-in shouldn't be working in the workbench, isn't it?
In any case, why I cannot find the plug-in when I'm adding the dependencies, even if I see it in the Plug-in Registry?
Thanks for your help!
Problem solved: just restart the computer.
I don't restart my computer very frequently, so it took me a lot of time to find out that this was the solution. After I restarted it, everything started to work perfectly again. It seems that either Eclipse leaves something in the memory after running, or that some of my initial failures had left something nasty behind. In any case, I had checked and there were no Eclipse related processes running .... weird, but at least now it's fixed!

Resources