Felix
  1. Felix
  2. FELIX-2296

iPojo : Unable to get a ServiceProperty change in an anonymous class

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Cannot Reproduce
    • Affects Version/s: iPOJO-1.4.0, iPOJO-1.6.0
    • Fix Version/s: iPOJO-1.6.0
    • Component/s: iPOJO
    • Labels:
      None

      Description

      @ServiceProperty(value = "false")
      private boolean ready;

      ...

      SwingUtilities.invokeLater(new Runnable() {
      public void run() {
      ready = true;
      }});

      is not equivalent to :

      SwingUtilities.invokeLater(new Runnable() {
      public void run() {
      connect();
      }});

      public void connect()

      { ready = true; }

      (I use a @Require(filter = "(ready=true)) to start an another service instance)

        Activity

        Brian Tribondeau created issue -
        Hide
        Brian Tribondeau added a comment -

        The original code is longer, but that's the spirit ...

        Show
        Brian Tribondeau added a comment - The original code is longer, but that's the spirit ...
        Clement Escoffier made changes -
        Field Original Value New Value
        Assignee Clement Escoffier [ clement.escoffier ]
        Clement Escoffier made changes -
        Fix Version/s iPOJO-1.8.0 [ 12314964 ]
        Affects Version/s iPOJO-1.6.0 [ 12314134 ]
        Hide
        Brian Tribondeau added a comment -

        D'ailleurs merci pour iPojo !

        Je n'aurais probablement jamais utilisé OSGi dans mon projet pro si j'avais du vendre l'usage brut d'OSGi. Et désormais on a plus qu'une seule application capable de charger toutes les briques fonctionnelles de notre domaine. Un gain de temps et de maintenance énorme.

        Bonne continuation.

        Show
        Brian Tribondeau added a comment - D'ailleurs merci pour iPojo ! Je n'aurais probablement jamais utilisé OSGi dans mon projet pro si j'avais du vendre l'usage brut d'OSGi. Et désormais on a plus qu'une seule application capable de charger toutes les briques fonctionnelles de notre domaine. Un gain de temps et de maintenance énorme. Bonne continuation.
        Hide
        Clement Escoffier added a comment -

        Hi,

        It seems to work...
        I did that:

               // Service properties
                private int intProp;
        	private String strProp;
        	private String[] strAProp;
        	private int[] intAProp;
        	private boolean boolProp;
        
        	public boolean foo() {
        		Runnable runnable = new Runnable() {
        			public void run() {
        				intProp = 3;
        				boolProp = true;
        				if(strProp.equals("foo")) { strProp = "bar"; }
        				else { strProp = "foo"; }
        				strAProp = new String[] {"foo", "bar", "baz"};
        				intAProp = new int[] {3, 2, 1};
        			}
        		};
        		new Thread(runnable).start();
        
        		try {
        			Thread.sleep(500);
        		} catch (InterruptedException e) {
        			e.printStackTrace();
        		}
        
        		return true;
        	}
        

        The service properties are correctly updated inside the method. Could you give me more details ? If you have a small bundle reproducing the issue, I would be happy to check that.

        Show
        Clement Escoffier added a comment - Hi, It seems to work... I did that: // Service properties private int intProp; private String strProp; private String [] strAProp; private int [] intAProp; private boolean boolProp; public boolean foo() { Runnable runnable = new Runnable () { public void run() { intProp = 3; boolProp = true ; if (strProp.equals( "foo" )) { strProp = "bar" ; } else { strProp = "foo" ; } strAProp = new String [] { "foo" , "bar" , "baz" }; intAProp = new int [] {3, 2, 1}; } }; new Thread (runnable).start(); try { Thread .sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } return true ; } The service properties are correctly updated inside the method. Could you give me more details ? If you have a small bundle reproducing the issue, I would be happy to check that.
        Hide
        Brian Tribondeau added a comment -

        Hello

        I am currently on vacation. I will post the code in two weeks.

        Fyi, I used ipojo 1.4, annotations only (@ServiceProperty & @Requires with filter) except for instance creation, and the OSGi runtime is Equinox.

        The problem is using the filter property of @Requires in two separate bundles. The instance using the filter is not created.

        Bundle A :

        @ServiceProperty(value = "false")
        private boolean ready;

        ...

        SwingUtilities.invokeLater(new Runnable() {
        public void run() {
        ready = true;
        }});

        Bundle B :

        @Require(filter = "(ready=true))

        BundleConstructor()

        { sysout("You will not see me") }

        By the way, there is no Runnable variable created, the anonymous function is invoked immediately.

        Show
        Brian Tribondeau added a comment - Hello I am currently on vacation. I will post the code in two weeks. Fyi, I used ipojo 1.4, annotations only (@ServiceProperty & @Requires with filter) except for instance creation, and the OSGi runtime is Equinox. The problem is using the filter property of @Requires in two separate bundles. The instance using the filter is not created. Bundle A : @ServiceProperty(value = "false") private boolean ready; ... SwingUtilities.invokeLater(new Runnable() { public void run() { ready = true; }}); Bundle B : @Require(filter = "(ready=true)) BundleConstructor() { sysout("You will not see me") } By the way, there is no Runnable variable created, the anonymous function is invoked immediately.
        Hide
        Clement Escoffier added a comment -

        I also tried with:
        SwingUtilities.invokeLater(new Runnable() {
        public void run() {
        intProp = 3;
        boolProp = true;
        if(strProp.equals("foo"))

        { strProp = "bar"; }

        else

        { strProp = "foo"; }

        strAProp = new String[]

        {"foo", "bar", "baz"}

        ;
        intAProp = new int[]

        {3, 2, 1}

        ;
        }
        });

        try

        { Thread.sleep(500); }

        catch (InterruptedException e)

        { e.printStackTrace(); }

        But, it also works.

        Show
        Clement Escoffier added a comment - I also tried with: SwingUtilities.invokeLater(new Runnable() { public void run() { intProp = 3; boolProp = true; if(strProp.equals("foo")) { strProp = "bar"; } else { strProp = "foo"; } strAProp = new String[] {"foo", "bar", "baz"} ; intAProp = new int[] {3, 2, 1} ; } }); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } But, it also works.
        Hide
        Brian Tribondeau added a comment -

        Hello

        I have sent you a few files on your gmail adress. I hope this will help you.

        Show
        Brian Tribondeau added a comment - Hello I have sent you a few files on your gmail adress. I hope this will help you.
        Hide
        Brian Tribondeau added a comment -

        The problem didn't occur with 1.6.2 release of iPojo... Solved but I am still puzzled
        This ticket it is not relevant anymore so I close it.

        Thanks Clement for your support !

        Show
        Brian Tribondeau added a comment - The problem didn't occur with 1.6.2 release of iPojo... Solved but I am still puzzled This ticket it is not relevant anymore so I close it. Thanks Clement for your support !
        Brian Tribondeau made changes -
        Fix Version/s iPOJO-1.8.0 [ 12314964 ]
        Resolution Cannot Reproduce [ 5 ]
        Status Open [ 1 ] Closed [ 6 ]
        Fix Version/s iPOJO-1.6.0 [ 12314134 ]

          People

          • Assignee:
            Clement Escoffier
            Reporter:
            Brian Tribondeau
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development