Fragment bundle is not getting activated - eclipse

I have Two osgi bundles Bundle A and Bundle B. Bundle B is a fragment bundle of bundle A. When both components are in the osgi environment, Bundle A is in ACTIVE state but Bundle B is in RESOLVED state and it is not getting activated. Bundle B gets activated if I remove the <Fragment-Host> header.
Is there any specific way I have to define the fragment bundle? (other than adding the <Fragment-Host>? maybe add any annotations, etc)? . If there any sample resource I could use, please let me know
I'm using org.eclipse.osgi_3.11.0.v20160603-1336. Sample bundle can be found in https://github.com/chamilaadhi/sample-bundles
Thanks

Seems like the fragment bundles do not get to ACTIVE state[1][2]. Also found similar discussion related to this in Component inside a fragment never activated
[1] https://osgi.org/specification/osgi.core/7.0.0/framework.module.html#framework.module.fragmentbundles
[2]https://dzone.com/articles/osgi-fragment-bundles-dont

Related

ServiceLocator Current GetInstance?

I have assemblies discovered in a directory using MEF and they are loaded when needed during runtime when a user selects a menu.
After a assembly is loaded each has its own UI and views can be added to it as the user needs them, but when I use excelView = ServiceLocator.Current.GetInstance(); I get an exception.
Exception Details
How do I solved this problem, because I'm assuming directory discovered assembles are added to the AggregateCatalog so the ServiceLocator can find them right?
This is how the main IExcelView is setup:
I found the problem, I needed to add the Key I used to Export the class.

Bundle Identifier Changed Core Data Lost

I changed a project from Objective-C to Swift and created a whole new project when I did this. I have an app in the AppStore and wanted to send an update instead of releasing a new app.
I understand that my Bundle Identifier needs to be the same when updating an app. When preparing the app for release, I changed my Bundle Identifier to match my app in the AppStore - since I started with a new project - and in the process my Core Data file seems to be missing. If I change my Bundle Identifier how do I keep access to Core Data?
This took me a while to figure out but here is how I fixed the issue.
Change your product name under Build Settings -> Packaging -> Product Name to the desired product name. This will change you Bundle Identifier to the desired name.
Clean your project by selecting Product -> Clean.
Select your CoreData model in the project navigator and then select the "Data Model Inspector" in the Inspector tab. Change the project name under class to the new class name. I got stuck here since I did not know Spaces, dashes, . are all replaced by underscores. You can see that my Product Name is FLO-Cycling and the CoreData class is FLO_Cycling.
If you have imported the Swift bridging header file anywhere make sure to update it.
I hope this can help someone.
Take care,
Jon

ATG browser components is not available

I want to create new companent in ATG. And if I forward to Browser Companent page, then I have 404 error. How I can fix this?
I assume that you have created a new component by creating a .properties file. The things to look for are
Is the file in an appropriate config layer? i.e. is it in a location on the configpath, such as the config directory of a module, or the localconfig directory of a server, where the application expects to look for .properties files?
Is the file a valid .properties file and properly formatted?
Is the class mentioned in the $class property correct, valid and fully qualified (package name and class name)
Has the named class been compiled successfully?
Is the named class available on the classpath? i.e. is it in the classes.jar of a module or in the classes directory (if that is how the module's class path has been defined?
Is the class a valid JavaBean - particularly, does it have a no-argument constructor?
Have you compiled, built and assembled your ATG application since creating this new component?
Have you restarted your ATG application since creating this new component?
Assuming this is all correct and yet you still cannot see your component, the next step is to troubleshoot why it is not visible.
Is the path to your component you are using in the dyn/admin component browser correct?
If the path is correct, and you still see an error in the browser, then take a look at the server logs (for around the time you first tried to access the component) - you might see an error or a sequence of errors telling you why the server could not instantiate the component
Can you go to the containing folder and see if the component is listed there - though it is OK if you cannot because it may not have been started if nothing is referencing it
Can you see your component in the ACC. Start the ACC, and go to View Components by Path and navigate to were you think your component should be. Can you see it there? If so, it means that your properties file is OK.
In the ACC, When you click on the puzzle-piece icon that represents your component, does it show it as being an instance of your class or as an instance of Object. If Object, it means that it cannot determine the class of the component
In the ACC, double-click the component and try to start it. Keep looking at the server logs as you do so
This should help you get to the bottom of things.

Why does my Swift bundle get the wrong principal class?

I made a bundle target, and its Info.plist file specifies that a very specific class (let's call it PrincipalClass) should be its principal class. This class was written in Swift and has the #objc attribute. The Info.plist file is correctly copied over to the bundle, and I have cleaned and rebuilt the project multiple times already.
However, when I load the bundle from my Swift framework, its principal class is a different class (let's call it NotPrincipalClass). It was not marked #objc, and in fact, it should be internal to the bundle. I checked bundle.bundleURL in the debugger, and the Info.plist file in the bundle does say that it should be PrincipalClass; but when I check bundle.infoDictionary, the NSPrincipalClass attribute reads NotPrincipalClass as a string! (The info dictionary also contains several keys that were not specified by the Info.plist file, like DTCompiler and such.)
If I entirely remove NotPrincipalClass, I get another internal class instead, which is still totally not my principal class.
I checked the build logs thoroughly and I saw no mention of NotPrincipalClass, except when it got compiled.
What could cause this? What can I do to solve it?
Somehow, using its qualified name instead ("PlugInNamespace.PrincipalClass") solved the problem, but this has me very skeptical because I have another plugin that does not requires this.

How to create view via fragment that is linked to applicatio model eclipse plugin

Using application.e4xmi, I want to create view via fragments using this application model. Could you please tell me the step by step procedure.
what i have tried is, i have created one fragment in the one plugin application. in that i have given application id after that i have created part stack and after that created part. Here i have given class URI is my view class(path of view class in the viewplugin project). But without that view plugin in the runconfigurations, i am unable to see view part.
As far as I understand your question, you wish to have a plugin containing a model fragment which contributes to an application model located in another plugin, and the problem is that a (View-)Part you tried to contribute that way doesn't show in the application window. I hope I didn't get you wrong there and I will assume that the error is not just that the plugin with the model fragment is not included in the run configurations... (?)
You can find a useful tutorial in Lars Vogel's webpages. However, as the various requirements may be confusing, I will summarize the process for potential future readers.
TL;DR:
You might have set a wrong Element ID and/or Featurename for your Part.
Your question implies that you maybe tried to implement a Part model element as a ViewPart, when in E4, there is no longer any interface for a (View) Part to implement, so maybe try creating the Part controls in a #PostConstruct-annotated method instead.
Another possible reason for your contributed Part not showing up is the plugin providing the model fragment not having the correct settings for the bundle options SymbolicName and/or ActivationPolicy ('Plug-in is singleton' and 'Activate when class is loaded').
Application
In order to have an application model to contribute to, we first need an Eclipse4 application project. Create one by selecting File -> New -> Other from the Eclipse main menu. Choose the wizard Eclipse 4 Application Project in the Eclipse 4 category. Name your project as you wish, choose Equinox as OSGI framework, and check the Generate an Activator... option. The newly created project will contain a file Application.e4xmi (your application model) and a *.product file (product definition). Open the latter in and make sure org.eclipse.e4.ui.workbench.swt.E4Application is set as Application in the Overview tab.
Open Application.e4xmi and append a Part Stack somewhere in the model tree, as you probably have already done anyways.
Model fragment
Create a new plugin for the model fragment. Letting it have an Activator class won't harm. It is important, however, that the options Activate this plug-in when one of its classes is loaded and This plug-in is a singleton are both checked in the Overview tab of its plugin.xml editor. Next, create a model fragment with New -> Other... -> Eclipse 4 -> Model -> New Model Fragment in the plugin's Package Explorer context menu. The wizard will automatically create an extension of org.bbaw.bts.ui.pdr.fragment specifying your model fragment file. The plugin's dependencies should include:
org.eclipse.swt
org.eclipse.jface
org.eclipse.e4.core.di
org.eclipse.e4.ui.workbench
javax.inject
org.eclipse.e4.ui.di
Open the model fragment file (fragment.e4xmi by default) and attach a Model Fragment to the Model Fragments node. Your new Model Fragment element needs to specify both an Element ID and a Featurename in order to correctly address the Application Model's element that you want to contribute to. Thus, copy the ID of the Part Stack previously created in the Application Model into the Element ID field of the Model Fragment you've just created. In the Featurename field, type children, as this is the Part stack's attribute we want to contribute to. Then, append a Part to the Model Fragment element and specify the Class URI of the Part's implementation. This class is basically a POJO, no implementation of ViewPart is necessary! It creates its GUI in a method annotated with the #PostConstruct annotation, e.g.
#PostConstruct
public final void createComposite(final Composite parent)
That should be it. When running the application project's product, the Part should appear like expected (given the plugin containing that Part is included in the run configuration...).