Re: How To Build Apache Felix Dependency Manager

2015-09-17 Thread Hubert Felber

-Changed to java 7
-the sources are from
http://svn.apache.org/repos/asf/felix/trunk/dependencymanager 
-did not know gradlew (first contact) after making gradlew available
and setting the proxies I could compile  -- even on windows ;-)


Thank you!!

It seams that the latest release is DM 4.1.1
But this is not available in
http://mvnrepository.com/artifact/org.apache.felix/org.apache.felix.dependencymanager


The latest release there is 4.1.0


If 4.1.1 is released, could somebody please make 4.1.1  available on
mavenrepository?

Hubert


>>> Pierre De Rop  16.09.2015 23:29 >>>
It looks like you are building DM with java 8, but java 7 is required.

Now, using java7, can you try  gradlew instead of gradle:

./gradlew org.apache.felix.dependencymanager.annotation:jar

Can you also confirm me that you are building the felix-trunk  version
? or
are you building the latest released sources from
http://apache.websitebeheerjd.nl//felix/org.apache.felix.dependencymanager-r5-src.zip

?

it seems that you are building under windows. I'm working under linux,
but
will try to build under windows in order to see if I'm able to
reproduce
the same issue, and I will let you know.

Also, are you using an http proxy ? if yes, then can you verify that
you
are using the GRADLE_OPTS environment variable and that this variable
is
set to the proper http proxy (it is used by gradle in order to
download
dependencies).

For example, under linux:

export GRADLE_OPTS="-Dhttps.proxyHost=
-Dhttps.proxyPort="

let me know !


cheers;
/Pierre

On Wed, Sep 16, 2015 at 10:47 PM, Hubert Felber

wrote:

> Pierre,
> Thank you
>
> gradle org.apache.felix.dependencymanager.annotation:jar
>
> gives me a lot of errors, it seams I miss some dependencies
>
> do you have me a hint?
>
> p.s.
> I try to compile this, because the code in current
> ComponentImpl#calculateNewState is hard to read, and I noticed that
it
> was rewritten on trunk.
>
> Hubert
>
> E:\dependencymanager>gradle
> org.apache.felix.dependencymanager.annotation:jar
> :org.apache.felix.dependencymanager.annotation:compileJava
> warning: [options] bootstrap class path not set in conjunction with
> -source 1.7
>
>
E:\dependencymanager\org.apache.felix.dependencymanager.annotation\src\org\apache\felix\dm\annotation\plugin\bnd\AnnotationCollector.java:52:
> error: package aQute.bnd.osgi does not exist
> import aQute.bnd.osgi.Annotation;
>  ^
>
>
E:\dependencymanager\org.apache.felix.dependencymanager.annotation\src\org\apache\felix\dm\annotation\plugin\bnd\AnnotationCollector.java:53:
> error: package aQute.bnd.osgi does not exist
> import aQute.bnd.osgi.ClassDataCollector;
>  ^
>
>
E:\dependencymanager\org.apache.felix.dependencymanager.annotation\src\org\apache\felix\dm\annotation\plugin\bnd\AnnotationCollector.java:54:
> error: package aQute.bnd.osgi does not exist
> import aQute.bnd.osgi.Clazz;
>  ^
>
>
E:\dependencymanager\org.apache.felix.dependencymanager.annotation\src\org\apache\felix\dm\annotation\plugin\bnd\AnnotationCollector.java:55:
> error: package aQute.bnd.osgi.Descriptors does not exist
> import aQute.bnd.osgi.Descriptors.TypeRef;
>
>
>
> >>> Pierre De Rop  16.09.2015 21:10 >>>
> Hello Hubert,
>
> This is an old documentation. We are now using BndTools and Gradle
and
> the
> latest documentation is located at [1]. More specifically, how to
build
> DM
> is described at [2]
>
> Don't hesitate to ping here if you need more helps.
>
> cheers;
> /Pierre
>
> [1]
>
>
http://felix.apache.org/documentation/subprojects/apache-felix-dependency-manager.html

>
> [2]
>
>
http://felix.apache.org/documentation/subprojects/apache-felix-dependency-manager/guides/development.html

>
>
>
>
> On Wed, Sep 16, 2015 at 8:54 PM, Hubert Felber
> 
> wrote:
>
> > Hi,
> >
> > How can I build  "Felix Dependency Manager" ?
> >
> > I followed these instructions, checked out trunk and tried to
build
> >
> >
> >
>
>
https://cwiki.apache.org/confluence/display/FELIX/Apache+Felix+Dependency+Manager+-+How+To+Build

>
> >
> > but there is no pom.xml.
> >
> > I then installed gradle and did a "gradle build" which gives me 98
> > errors
> >
> > 98 errors
> > 4 warnings
> > :org.apache.felix.dependencymanager:compileJava FAILED
> >
> > So how can I build DM ?
> >
> > Thank you
> > Hubert
> >
> >
>
-
> > To unsubscribe, e-mail: users-unsubscr...@felix.apache.org 
> > For additional commands, e-mail: users-h...@felix.apache.org 
> >
> >
>
>
-
> To unsubscribe, e-mail: users-unsubscr...@felix.apache.org 
> For additional commands, e-mail: users-h...@felix.apache.org 
>
>

-
To unsubscribe, e-mail: users-unsubscr...@felix.apache.org
For additional 

Re: Dependency Manager does not behave as expected

2015-09-17 Thread Hubert Felber
Hi Pierre,

Thank you for all your efforts!

unfortunately I could not check it out using svn.
I get a "Redirect cycle detected for URL 
'http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.test'" 
on both linux and windows


And I don´t have Eclipse installed since we work with IntelliJ Idea

nevertheless I was able to load the relevant files via http and try them.

I made the same observation: as soon as a add a ServiceDependency
then ComponentImpl#startDependencies() is called -- before I added the component
to DM.
Of course the service cannot be started then, the state remains inactive, but 
DM tries to do so and 
maybe can do this, before I finished the component configuration.

I reduced the snippet:

Component comp = createComponent()
//.setInterface(toString(LoggingConfService.class,
//ManagedService.class), null)
//.setImplementation(LoggingConfigServiceImpl.class)

// after this, DM tries to start the service -> state remains INACTIVE


.add(createServiceDependency().setService(LoggingService.class).setRequired(true));

// before I add the component to DM

System.out.println("Adding component to dependency manager");
dependencyManager.add(comp);


after this, DM tries to start the service agein -> state now is 
WAITING_FOR_REQUIRED
which is what I expected. The service will start as soon as the dependency is 
resolved.


You should be able to see this with a breakpoint on 
ComponentImpl#calculateNewState 
after adding the service dependency.
In my opinion DM should not try to start the service before I finally add the 
component
to DM, but now it tries to start the service, as soon as add a 
ServiceDependency. 

Tested with DM 4.1.0

Thank you again
Hubert


>>> Pierre De Rop  17.09.2015 01:03 >>>
Hi Hubert;

I don't understand how this is possible, because a DM component initial
state is Inactive, and remains in this state until you add it to a
DependencyManager object.

So, your service implementation can not be called in start() before you add
the component to the dm object.

Ok, in order to go ahead, I have made a (temporary) commit of a
dependencymanager.test project in my sandbox (see [1]).

So, can you please take a look at it ? I tried to follow your samples by
creating two bundles:

dependencymanager.test.log.jar -> contains the LoggingService + its
Activator
dependencymanager.test.logconfig.jar -> contains the LoggingConfigService
that depends on the LoggingService.

Here is the Activator for the dependencymanager.test.logconfig.jar bundle
(I made it a bit more compact, by reusing the methods available from the
DependencyActivatorBase)

public class Activator extends DependencyActivatorBase {

@Override
public void init(BundleContext ctx, DependencyManager dm) throws
Exception {
Component comp = createComponent()
.setInterface(toString(LoggingConfigService.class,
ManagedService.class), null)
.setImplementation(LoggingConfigServiceImpl.class)

.add(createServiceDependency().setService(LoggingService.class).setRequired(true));

System.out.println("Adding component to dependency manager");
dm.add(comp);
}

// Helper used to convert an array of classes to an array of class
strings
String[] toString(Class ... services) {
return Stream.of(services).map(c ->
c.getName()).toArray(String[]::new);
}

}


So, can you install an Eclipse mars + java8 + latest bndtool (Use the
dependencymanager.test directory as the eclipse workspace directory).

Then open the bndtools perspective.

Then click on File -> Import -> General -> Existing Projects into workspace
-> Browse -> Ok -> Finish

Then click on the dependencymanager.test/bnd.bnd file -> Run tab -> Run
OSGi.

You will then see in the console:

   Adding component to dependency manager
   LoggingConfigServiceImpl is starting.

So, the "Adding component to dependency manager" message is displayed, then
after, when the component is added to the DependencyManager "dm" object,
then when the component is injected with the LoggingService, it is then
started and you see the log "LoggingConfigServiceImpl is starting" message.

You can also type "dm" shell command in the console:

dm

[8] dependencymanager.test.logconfig
 [0] dependencymanager.test.logconf.LoggingConfigService,
org.osgi.service.cm.ManagedService registered
dependencymanager.test.log.LoggingService service required available
[9] dependencymanager.test.log
 [1] dependencymanager.test.log.LoggingService registered


So, maybe if you try to play with this sample, you will then be able to
figure out what is going wrong in your own project ?

hope this helps;
/Pierre

[1]
http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.test/ 






On Wed, Sep 16, 2015 at 10:43 PM, Hubert Felber 
wrote:

> Hi,
>
> as soon as I add a ServiceDependency to my component, 

Re: Dependency Manager does not behave as expected

2015-09-17 Thread Benson Margulies
On Thu, Sep 17, 2015 at 6:29 AM, Hubert Felber  wrote:
> Hi Pierre,
>
> Thank you for all your efforts!
>
> unfortunately I could not check it out using svn.
> I get a "Redirect cycle detected for URL 
> 'http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.test'"
> on both linux and windows

you don't checkout through a viewvc link. That's just for browsing.

https://svn.apache.org/repos/asf/felix/sandbox/...

>
>
> And I don´t have Eclipse installed since we work with IntelliJ Idea
>
> nevertheless I was able to load the relevant files via http and try them.
>
> I made the same observation: as soon as a add a ServiceDependency
> then ComponentImpl#startDependencies() is called -- before I added the 
> component
> to DM.
> Of course the service cannot be started then, the state remains inactive, but 
> DM tries to do so and
> maybe can do this, before I finished the component configuration.
>
> I reduced the snippet:
>
> Component comp = createComponent()
> //.setInterface(toString(LoggingConfService.class,
> //ManagedService.class), null)
> //.setImplementation(LoggingConfigServiceImpl.class)
>
> // after this, DM tries to start the service -> state remains INACTIVE
>
> 
> .add(createServiceDependency().setService(LoggingService.class).setRequired(true));
>
> // before I add the component to DM
>
> System.out.println("Adding component to dependency manager");
> dependencyManager.add(comp);
>
>
> after this, DM tries to start the service agein -> state now is 
> WAITING_FOR_REQUIRED
> which is what I expected. The service will start as soon as the dependency is 
> resolved.
>
>
> You should be able to see this with a breakpoint on 
> ComponentImpl#calculateNewState
> after adding the service dependency.
> In my opinion DM should not try to start the service before I finally add the 
> component
> to DM, but now it tries to start the service, as soon as add a 
> ServiceDependency.
>
> Tested with DM 4.1.0
>
> Thank you again
> Hubert
>
>
 Pierre De Rop  17.09.2015 01:03 >>>
> Hi Hubert;
>
> I don't understand how this is possible, because a DM component initial
> state is Inactive, and remains in this state until you add it to a
> DependencyManager object.
>
> So, your service implementation can not be called in start() before you add
> the component to the dm object.
>
> Ok, in order to go ahead, I have made a (temporary) commit of a
> dependencymanager.test project in my sandbox (see [1]).
>
> So, can you please take a look at it ? I tried to follow your samples by
> creating two bundles:
>
> dependencymanager.test.log.jar -> contains the LoggingService + its
> Activator
> dependencymanager.test.logconfig.jar -> contains the LoggingConfigService
> that depends on the LoggingService.
>
> Here is the Activator for the dependencymanager.test.logconfig.jar bundle
> (I made it a bit more compact, by reusing the methods available from the
> DependencyActivatorBase)
>
> public class Activator extends DependencyActivatorBase {
>
> @Override
> public void init(BundleContext ctx, DependencyManager dm) throws
> Exception {
> Component comp = createComponent()
> .setInterface(toString(LoggingConfigService.class,
> ManagedService.class), null)
> .setImplementation(LoggingConfigServiceImpl.class)
>
> .add(createServiceDependency().setService(LoggingService.class).setRequired(true));
>
> System.out.println("Adding component to dependency manager");
> dm.add(comp);
> }
>
> // Helper used to convert an array of classes to an array of class
> strings
> String[] toString(Class ... services) {
> return Stream.of(services).map(c ->
> c.getName()).toArray(String[]::new);
> }
>
> }
>
>
> So, can you install an Eclipse mars + java8 + latest bndtool (Use the
> dependencymanager.test directory as the eclipse workspace directory).
>
> Then open the bndtools perspective.
>
> Then click on File -> Import -> General -> Existing Projects into workspace
> -> Browse -> Ok -> Finish
>
> Then click on the dependencymanager.test/bnd.bnd file -> Run tab -> Run
> OSGi.
>
> You will then see in the console:
>
>Adding component to dependency manager
>LoggingConfigServiceImpl is starting.
>
> So, the "Adding component to dependency manager" message is displayed, then
> after, when the component is added to the DependencyManager "dm" object,
> then when the component is injected with the LoggingService, it is then
> started and you see the log "LoggingConfigServiceImpl is starting" message.
>
> You can also type "dm" shell command in the console:
>
> dm
>
> [8] dependencymanager.test.logconfig
>  [0] dependencymanager.test.logconf.LoggingConfigService,
> org.osgi.service.cm.ManagedService registered
> dependencymanager.test.log.LoggingService service required available
> [9] dependencymanager.test.log
>  [1] 

Re: Dependency Manager does not behave as expected

2015-09-17 Thread Hubert Felber

>>> Benson Margulies  17.09.2015 12:39 >>>



Re: How To Build Apache Felix Dependency Manager

2015-09-17 Thread Pierre De Rop
Hi Hubert,

Good to know it works.

Ok; I will upload the already released 4.1.1 version for the
org.apache.felix.dependencymanager.jar artifact asap, and will let you know.

cheers
/Pierre

On Thu, Sep 17, 2015 at 10:50 AM, Hubert Felber 
wrote:

>
> -Changed to java 7
> -the sources are from
> http://svn.apache.org/repos/asf/felix/trunk/dependencymanager
> -did not know gradlew (first contact) after making gradlew available
> and setting the proxies I could compile  -- even on windows ;-)
>
>
> Thank you!!
>
> It seams that the latest release is DM 4.1.1
> But this is not available in
>
> http://mvnrepository.com/artifact/org.apache.felix/org.apache.felix.dependencymanager
>
>
> The latest release there is 4.1.0
>
>
> If 4.1.1 is released, could somebody please make 4.1.1  available on
> mavenrepository?
>
> Hubert
>
>
> >>> Pierre De Rop  16.09.2015 23:29 >>>
> It looks like you are building DM with java 8, but java 7 is required.
>
> Now, using java7, can you try  gradlew instead of gradle:
>
> ./gradlew org.apache.felix.dependencymanager.annotation:jar
>
> Can you also confirm me that you are building the felix-trunk  version
> ? or
> are you building the latest released sources from
>
> http://apache.websitebeheerjd.nl//felix/org.apache.felix.dependencymanager-r5-src.zip
>
> ?
>
> it seems that you are building under windows. I'm working under linux,
> but
> will try to build under windows in order to see if I'm able to
> reproduce
> the same issue, and I will let you know.
>
> Also, are you using an http proxy ? if yes, then can you verify that
> you
> are using the GRADLE_OPTS environment variable and that this variable
> is
> set to the proper http proxy (it is used by gradle in order to
> download
> dependencies).
>
> For example, under linux:
>
> export GRADLE_OPTS="-Dhttps.proxyHost=
> -Dhttps.proxyPort="
>
> let me know !
>
>
> cheers;
> /Pierre
>
> On Wed, Sep 16, 2015 at 10:47 PM, Hubert Felber
> 
> wrote:
>
> > Pierre,
> > Thank you
> >
> > gradle org.apache.felix.dependencymanager.annotation:jar
> >
> > gives me a lot of errors, it seams I miss some dependencies
> >
> > do you have me a hint?
> >
> > p.s.
> > I try to compile this, because the code in current
> > ComponentImpl#calculateNewState is hard to read, and I noticed that
> it
> > was rewritten on trunk.
> >
> > Hubert
> >
> > E:\dependencymanager>gradle
> > org.apache.felix.dependencymanager.annotation:jar
> > :org.apache.felix.dependencymanager.annotation:compileJava
> > warning: [options] bootstrap class path not set in conjunction with
> > -source 1.7
> >
> >
>
> E:\dependencymanager\org.apache.felix.dependencymanager.annotation\src\org\apache\felix\dm\annotation\plugin\bnd\AnnotationCollector.java:52:
> > error: package aQute.bnd.osgi does not exist
> > import aQute.bnd.osgi.Annotation;
> >  ^
> >
> >
>
> E:\dependencymanager\org.apache.felix.dependencymanager.annotation\src\org\apache\felix\dm\annotation\plugin\bnd\AnnotationCollector.java:53:
> > error: package aQute.bnd.osgi does not exist
> > import aQute.bnd.osgi.ClassDataCollector;
> >  ^
> >
> >
>
> E:\dependencymanager\org.apache.felix.dependencymanager.annotation\src\org\apache\felix\dm\annotation\plugin\bnd\AnnotationCollector.java:54:
> > error: package aQute.bnd.osgi does not exist
> > import aQute.bnd.osgi.Clazz;
> >  ^
> >
> >
>
> E:\dependencymanager\org.apache.felix.dependencymanager.annotation\src\org\apache\felix\dm\annotation\plugin\bnd\AnnotationCollector.java:55:
> > error: package aQute.bnd.osgi.Descriptors does not exist
> > import aQute.bnd.osgi.Descriptors.TypeRef;
> >
> >
> >
> > >>> Pierre De Rop  16.09.2015 21:10 >>>
> > Hello Hubert,
> >
> > This is an old documentation. We are now using BndTools and Gradle
> and
> > the
> > latest documentation is located at [1]. More specifically, how to
> build
> > DM
> > is described at [2]
> >
> > Don't hesitate to ping here if you need more helps.
> >
> > cheers;
> > /Pierre
> >
> > [1]
> >
> >
>
> http://felix.apache.org/documentation/subprojects/apache-felix-dependency-manager.html
>
> >
> > [2]
> >
> >
>
> http://felix.apache.org/documentation/subprojects/apache-felix-dependency-manager/guides/development.html
>
> >
> >
> >
> >
> > On Wed, Sep 16, 2015 at 8:54 PM, Hubert Felber
> > 
> > wrote:
> >
> > > Hi,
> > >
> > > How can I build  "Felix Dependency Manager" ?
> > >
> > > I followed these instructions, checked out trunk and tried to
> build
> > >
> > >
> > >
> >
> >
>
> https://cwiki.apache.org/confluence/display/FELIX/Apache+Felix+Dependency+Manager+-+How+To+Build
>
> >
> > >
> > > but there is no pom.xml.
> > >
> > > I then installed gradle and did a "gradle build" which gives me 98
> > > errors
> > >
> > > 98 errors
> > > 4 warnings
> > > :org.apache.felix.dependencymanager:compileJava FAILED
> > >
> > > So how can I 

[SCR] Obtaining component configuration

2015-09-17 Thread David Leangen

Hi!

Using Felix SCR...

I am trying to obtain a component’s properties object by:

  ConfigurationAdmin cm = {obtain the cm}
  Configuration componentConfig = cm.getConfiguration( componentPid );
  componentConfig.getProperties();

I can confirm that I am getting the correct Configuration object (when I add a 
property and update, it updates the component), however, I am getting a null 
result when I try to obtain the properties before doing an update, and an 
“incomplete” properties object after the update (containing only the 
service.pid property).

Am I misunderstanding what should happen? Or is my understanding correct, but I 
am for some reason not getting the correct result?


Thanks!
=David


-
To unsubscribe, e-mail: users-unsubscr...@felix.apache.org
For additional commands, e-mail: users-h...@felix.apache.org



InterruptedException when stopping system-bundle

2015-09-17 Thread marc . schlegel
Hello everyone

I created a little executable-jar which launches Felix. After some 
computation has been done the framework is shutdown by using 
context.getBundle(0).stop()

This however always throws an InterruptedException

java.lang.InterruptedException
at java.lang.Object.wait(Native Method)
at 
org.apache.felix.framework.util.ThreadGate.await(ThreadGate.java:79)
at org.apache.felix.framework.Felix.waitForStop(Felix.java:1068)
at aQute.launcher.Launcher.deactivate(Launcher.java:738)
at aQute.launcher.Launcher.run(Launcher.java:287)
at aQute.launcher.Launcher.main(Launcher.java:87)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at 
aQute.launcher.pre.EmbeddedLauncher.main(EmbeddedLauncher.java:38)

My only guess is, that this has something to do with the way I execute my 
code: I use an @Activate method which runs some code and shuts down the 
framework before it completes

@Activate
void activate(ComponentContext ctx){
this.context = ctx.getBundleContext();
try{
executeGroovy();
}catch(Throwable t){
t.printStackTrace();
}
 
String keepAlive = context.getProperty(
"de.sdv.geb.runner.keepAlive");
 
if(!Boolean.parseBoolean(keepAlive)){
try {
System.out.println("Shutting down");
context.getBundle(0).stop();
} catch (BundleException e) {
System.err.println("Error stopping 
OSGI-Container...killing VM now");
e.printStackTrace();
// hard way
System.exit(1);
}
}
}

Using Felix 5.2.0 and the executable jar is created with BndTool 3.0.0 
from a run-descriptor.

Any ideas how to get rid of this exceptions?

Thanks
Marc

Re: InterruptedException when stopping system-bundle

2015-09-17 Thread Raymond Auge
What you probably want is:

Framework fw = context.getBundle(0).adapt(Framework.class);

fw.waitForStop(timeout);

- Ray

On Thu, Sep 17, 2015 at 4:02 PM,  wrote:

> Hello everyone
>
> I created a little executable-jar which launches Felix. After some
> computation has been done the framework is shutdown by using
> context.getBundle(0).stop()
>
> This however always throws an InterruptedException
>
> java.lang.InterruptedException
> at java.lang.Object.wait(Native Method)
> at
> org.apache.felix.framework.util.ThreadGate.await(ThreadGate.java:79)
> at org.apache.felix.framework.Felix.waitForStop(Felix.java:1068)
> at aQute.launcher.Launcher.deactivate(Launcher.java:738)
> at aQute.launcher.Launcher.run(Launcher.java:287)
> at aQute.launcher.Launcher.main(Launcher.java:87)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at
> aQute.launcher.pre.EmbeddedLauncher.main(EmbeddedLauncher.java:38)
>
> My only guess is, that this has something to do with the way I execute my
> code: I use an @Activate method which runs some code and shuts down the
> framework before it completes
>
> @Activate
> void activate(ComponentContext ctx){
> this.context = ctx.getBundleContext();
> try{
> executeGroovy();
> }catch(Throwable t){
> t.printStackTrace();
> }
>
> String keepAlive = context.getProperty(
> "de.sdv.geb.runner.keepAlive");
>
> if(!Boolean.parseBoolean(keepAlive)){
> try {
> System.out.println("Shutting down");
> context.getBundle(0).stop();
> } catch (BundleException e) {
> System.err.println("Error stopping
> OSGI-Container...killing VM now");
> e.printStackTrace();
> // hard way
> System.exit(1);
> }
> }
> }
>
> Using Felix 5.2.0 and the executable jar is created with BndTool 3.0.0
> from a run-descriptor.
>
> Any ideas how to get rid of this exceptions?
>
> Thanks
> Marc




-- 
*Raymond Augé* 
 (@rotty3000)
Senior Software Architect *Liferay, Inc.* 
 (@Liferay)
Board Member & EEG Co-Chair, OSGi Alliance  (@OSGiAlliance)


Re: How To Build Apache Felix Dependency Manager

2015-09-17 Thread Pierre De Rop
Hi Hubert,

the org.apache.felix.dependencymanager-4.1.1.jar artifact has been uploaded
to maven central, see [1]

/Pierre

[1]
http://repo1.maven.org/maven2/org/apache/felix/org.apache.felix.dependencymanager/4.1.1/

On Thu, Sep 17, 2015 at 10:50 AM, Hubert Felber 
wrote:

>
> -Changed to java 7
> -the sources are from
> http://svn.apache.org/repos/asf/felix/trunk/dependencymanager
> -did not know gradlew (first contact) after making gradlew available
> and setting the proxies I could compile  -- even on windows ;-)
>
>
> Thank you!!
>
> It seams that the latest release is DM 4.1.1
> But this is not available in
>
> http://mvnrepository.com/artifact/org.apache.felix/org.apache.felix.dependencymanager
>
>
> The latest release there is 4.1.0
>
>
> If 4.1.1 is released, could somebody please make 4.1.1  available on
> mavenrepository?
>
> Hubert
>
>
> >>> Pierre De Rop  16.09.2015 23:29 >>>
> It looks like you are building DM with java 8, but java 7 is required.
>
> Now, using java7, can you try  gradlew instead of gradle:
>
> ./gradlew org.apache.felix.dependencymanager.annotation:jar
>
> Can you also confirm me that you are building the felix-trunk  version
> ? or
> are you building the latest released sources from
>
> http://apache.websitebeheerjd.nl//felix/org.apache.felix.dependencymanager-r5-src.zip
>
> ?
>
> it seems that you are building under windows. I'm working under linux,
> but
> will try to build under windows in order to see if I'm able to
> reproduce
> the same issue, and I will let you know.
>
> Also, are you using an http proxy ? if yes, then can you verify that
> you
> are using the GRADLE_OPTS environment variable and that this variable
> is
> set to the proper http proxy (it is used by gradle in order to
> download
> dependencies).
>
> For example, under linux:
>
> export GRADLE_OPTS="-Dhttps.proxyHost=
> -Dhttps.proxyPort="
>
> let me know !
>
>
> cheers;
> /Pierre
>
> On Wed, Sep 16, 2015 at 10:47 PM, Hubert Felber
> 
> wrote:
>
> > Pierre,
> > Thank you
> >
> > gradle org.apache.felix.dependencymanager.annotation:jar
> >
> > gives me a lot of errors, it seams I miss some dependencies
> >
> > do you have me a hint?
> >
> > p.s.
> > I try to compile this, because the code in current
> > ComponentImpl#calculateNewState is hard to read, and I noticed that
> it
> > was rewritten on trunk.
> >
> > Hubert
> >
> > E:\dependencymanager>gradle
> > org.apache.felix.dependencymanager.annotation:jar
> > :org.apache.felix.dependencymanager.annotation:compileJava
> > warning: [options] bootstrap class path not set in conjunction with
> > -source 1.7
> >
> >
>
> E:\dependencymanager\org.apache.felix.dependencymanager.annotation\src\org\apache\felix\dm\annotation\plugin\bnd\AnnotationCollector.java:52:
> > error: package aQute.bnd.osgi does not exist
> > import aQute.bnd.osgi.Annotation;
> >  ^
> >
> >
>
> E:\dependencymanager\org.apache.felix.dependencymanager.annotation\src\org\apache\felix\dm\annotation\plugin\bnd\AnnotationCollector.java:53:
> > error: package aQute.bnd.osgi does not exist
> > import aQute.bnd.osgi.ClassDataCollector;
> >  ^
> >
> >
>
> E:\dependencymanager\org.apache.felix.dependencymanager.annotation\src\org\apache\felix\dm\annotation\plugin\bnd\AnnotationCollector.java:54:
> > error: package aQute.bnd.osgi does not exist
> > import aQute.bnd.osgi.Clazz;
> >  ^
> >
> >
>
> E:\dependencymanager\org.apache.felix.dependencymanager.annotation\src\org\apache\felix\dm\annotation\plugin\bnd\AnnotationCollector.java:55:
> > error: package aQute.bnd.osgi.Descriptors does not exist
> > import aQute.bnd.osgi.Descriptors.TypeRef;
> >
> >
> >
> > >>> Pierre De Rop  16.09.2015 21:10 >>>
> > Hello Hubert,
> >
> > This is an old documentation. We are now using BndTools and Gradle
> and
> > the
> > latest documentation is located at [1]. More specifically, how to
> build
> > DM
> > is described at [2]
> >
> > Don't hesitate to ping here if you need more helps.
> >
> > cheers;
> > /Pierre
> >
> > [1]
> >
> >
>
> http://felix.apache.org/documentation/subprojects/apache-felix-dependency-manager.html
>
> >
> > [2]
> >
> >
>
> http://felix.apache.org/documentation/subprojects/apache-felix-dependency-manager/guides/development.html
>
> >
> >
> >
> >
> > On Wed, Sep 16, 2015 at 8:54 PM, Hubert Felber
> > 
> > wrote:
> >
> > > Hi,
> > >
> > > How can I build  "Felix Dependency Manager" ?
> > >
> > > I followed these instructions, checked out trunk and tried to
> build
> > >
> > >
> > >
> >
> >
>
> https://cwiki.apache.org/confluence/display/FELIX/Apache+Felix+Dependency+Manager+-+How+To+Build
>
> >
> > >
> > > but there is no pom.xml.
> > >
> > > I then installed gradle and did a "gradle build" which gives me 98
> > > errors
> > >
> > > 98 errors
> > > 4 warnings
> > > :org.apache.felix.dependencymanager:compileJava FAILED

Re: Dependency Manager does not behave as expected

2015-09-17 Thread Pierre De Rop
Hi Hubert,

I'm sorry but don't understand when you say:

" ... DM should not try to start the service before I finally add the
component
to DM, but now it tries to start the service, as soon as add a
ServiceDependency ..."

Indeed, DM never do that. The service component is started only after you
add it to the DependencyManager. If you really observe this, then please
open a JIRA issue and a mini project that reproduces this issue.

Now, let's talk about what you observed: when a Dependency is added before
the Component is added to the DependencyManager object, the task that is
scheduled in the Component.add(Dependency) method registers the dependency
(ies) and calls the handleChange method, which in turns calls
calculateNewState. I do agree with this, but all this is made by design.
And if the Component is not yet added, the component won't be started at
all since we remain in the Inactive state.

We systematically calls handleChange when a Dependency is added, because if
some dependencies are added dynamically after the component is added (and
probably started), then we have to recalculate the state changes (if you
add a missing dependency to a started component, then it has to be stopped).

And we do all this inside the runnable task that is scheduled in the
component executor because all  events (like dynamic dependencies that are
added after the Component is added, or service injections, or service
removal, or bundle start/stop events, etc ...) are handled in a lock-free
way, through the SerialExecutor. This reduces the complexity, avoid
potential dead locks, and we want to minimize the usage of tricky
synchronization logic. We just want to systematically react to events
through the Executor, like in an Actor based thread-model.

I hope that my response will help.

Again, if you have a working sample code that demonstrates that a component
is started before it is actually added to the DependencyManager, then
please open a jira issue and we'll investigate it.

kind regards;
/Pierre





On Thu, Sep 17, 2015 at 12:29 PM, Hubert Felber 
wrote:

> Hi Pierre,
>
> Thank you for all your efforts!
>
> unfortunately I could not check it out using svn.
> I get a "Redirect cycle detected for URL '
> http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.test'"
> on both linux and windows
>
>
> And I don´t have Eclipse installed since we work with IntelliJ Idea
>
> nevertheless I was able to load the relevant files via http and try them.
>
> I made the same observation: as soon as a add a ServiceDependency
> then ComponentImpl#startDependencies() is called -- before I added the
> component
> to DM.
> Of course the service cannot be started then, the state remains inactive,
> but DM tries to do so and
> maybe can do this, before I finished the component configuration.
>
> I reduced the snippet:
>
> Component comp = createComponent()
> //.setInterface(toString(LoggingConfService.class,
> //ManagedService.class), null)
> //.setImplementation(LoggingConfigServiceImpl.class)
>
> // after this, DM tries to start the service -> state remains INACTIVE
>
>
> .add(createServiceDependency().setService(LoggingService.class).setRequired(true));
>
> // before I add the component to DM
>
> System.out.println("Adding component to dependency manager");
> dependencyManager.add(comp);
>
>
> after this, DM tries to start the service agein -> state now is
> WAITING_FOR_REQUIRED
> which is what I expected. The service will start as soon as the dependency
> is resolved.
>
>
> You should be able to see this with a breakpoint on
> ComponentImpl#calculateNewState
> after adding the service dependency.
> In my opinion DM should not try to start the service before I finally add
> the component
> to DM, but now it tries to start the service, as soon as add a
> ServiceDependency.
>
> Tested with DM 4.1.0
>
> Thank you again
> Hubert
>
>
> >>> Pierre De Rop  17.09.2015 01:03 >>>
> Hi Hubert;
>
> I don't understand how this is possible, because a DM component initial
> state is Inactive, and remains in this state until you add it to a
> DependencyManager object.
>
> So, your service implementation can not be called in start() before you add
> the component to the dm object.
>
> Ok, in order to go ahead, I have made a (temporary) commit of a
> dependencymanager.test project in my sandbox (see [1]).
>
> So, can you please take a look at it ? I tried to follow your samples by
> creating two bundles:
>
> dependencymanager.test.log.jar -> contains the LoggingService + its
> Activator
> dependencymanager.test.logconfig.jar -> contains the LoggingConfigService
> that depends on the LoggingService.
>
> Here is the Activator for the dependencymanager.test.logconfig.jar bundle
> (I made it a bit more compact, by reusing the methods available from the
> DependencyActivatorBase)
>
> public class Activator extends