Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ice-dev] Python ICore update code

I wanted to find some sort of documentation about this outside a short StackOverflow answer, and found something in the Eclipse series book, OSGi and Equinox.

In section 15.2.2 (p250 in my copy), it says "the activate method is called immediately upon the component's configuration being satisfied...."
In section 24.2.1 (p445 in my copy), a component's configuration is satisfied if ... "all of the component's referenced services have been acquired per their cardinality attribute".

So, start(...) will *always* be called after setHttpService(...) and the other service references are set. Doing cool things with the HttpService reference should be happening in the start(...) method, which is set as the component activation method in the component.xml (see the overview page).

Jordan
Jordan Deyton
Oak Ridge National Laboratory
Telephone: (865) 574-1091
Email: deytonjh@xxxxxxxx
On 4/22/2015 12:03 PM, Jay Jay Billings wrote:

Oh wow. I hadn't even read this when I came by your office just now.

Yes, that's it.

Jay

On Apr 22, 2015 11:49 AM, "McCaskey, Alex" <mccaskeyaj@xxxxxxxx> wrote:
Jordan and I just dug around a little bit and found that the setHttpService method, which is bound to the Core’s Referenced Services, should not be doing all that heavy lifting after the service is set. Basically, the service reference should just be set, and then the connection / register servlet stuff after it should be done in the start method (or some private method invoked at the end of start), which is the Core’s activate method on the component definition.

This seems to be an easy fix, we can move forward with it if you’re cool with it.

Alex


On Apr 22, 2015, at 11:44 AM, Jay Jay Billings <jayjaybillings@xxxxxxxxx<mailto:jayjaybillings@xxxxxxxxx>> wrote:

Alex,

Yeah, that is not the way to fix that problem. I'll look into this at some point. As of, I think, Christmas, the HTTP service worked fine, but I notice now that ICE isn't registering with it correctly. Hopefully I'll fix this later today or tomorrow.

Jay

On Wed, Apr 22, 2015 at 10:30 AM, McCaskey, Alex <mccaskeyaj@xxxxxxxx<mailto:mccaskeyaj@xxxxxxxx>> wrote:
I forgot to add that the Core as it is could not establish this connection.

Basically, the Core.setHttpService method was being called through the OSGi DS before the Core.start method was being called. The start method initializes the ComponentContext object which is used by the setHttpService method, so the method was throwing a NullPointerException when it went to use the ComponentContext because it hadn’t been set yet.

To fix this, I just added a call to setHttpService at the end of the start method and added a null check for the componentContext in setHttpService. I’m sure there’s a better way to fix this, so I’ll hold of on committing any changes. I didn’t take any time to dig into a better fix.

Alex


On Apr 22, 2015, at 9:53 AM, McCaskey, Alex <mccaskeyaj@xxxxxxxx<mailto:mccaskeyaj@xxxxxxxx><mailto:mccaskeyaj@xxxxxxxx<mailto:mccaskeyaj@xxxxxxxx>>> wrote:

Everyone,

Here’s the code I was able to put together to let python post updates to a running Core instance.


import json
import requests
import base64

if __name__ == '__main__':

   # Set the ICore url for updates
   url = ''



   # It requires the username:password be encoded
   s = base64.b64encode('ice:veryice')



   # Set up your json map
   payload = {'some': 'data'}



   # Set up the headers, These have to be here
   headers = {'Authorization' : 'Basic ' + s, 'Content-type': 'application/x-www-form-urlencoded', 'Accept': 'text/plain'}

   # Start a requests session
   session = requests.session()



   # Get the ICE update url
   session.get(url)



   # Post the json message with the given headers
   r = session.post(url, json=payload, headers=headers)
   print r

   # Close the session
   session.close()

Jordan, I imagine you should be able to start experimenting with the Peacock IO stuff using this code now.

Best,

Alex

_______________________________________________
ice-dev mailing list
ice-dev@xxxxxxxxxxx<mailto:ice-dev@xxxxxxxxxxx><mailto:ice-dev@xxxxxxxxxxx<mailto:ice-dev@xxxxxxxxxxx>>
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/ice-dev

Alex McCaskey
ORNL Computer Science Research
mccaskeyaj@xxxxxxxx<mailto:mccaskeyaj@xxxxxxxx><mailto:mccaskeyaj@xxxxxxxx<mailto:mccaskeyaj@xxxxxxxx>>
(865) 574-8715<tel:%28865%29%20574-8715>



_______________________________________________
ice-dev mailing list
ice-dev@xxxxxxxxxxx<mailto:ice-dev@xxxxxxxxxxx>
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/ice-dev



--
Jay Jay Billings
Oak Ridge National Laboratory
Twitter Handle: @jayjaybillings
_______________________________________________
ice-dev mailing list
ice-dev@xxxxxxxxxxx<mailto:ice-dev@xxxxxxxxxxx>
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/ice-dev

Alex McCaskey
ORNL Computer Science Research
mccaskeyaj@xxxxxxxx<mailto:mccaskeyaj@xxxxxxxx>
(865) 574-8715



_______________________________________________
ice-dev mailing list
ice-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/ice-dev


_______________________________________________
ice-dev mailing list
ice-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/ice-dev


Back to the top