Here is my test. I'm probably missing something obvious but self.title does not get set on the component and it is None when I try to access it in @Validate. thanks for your help!
from pelix.ipopo.decorators import *
import pelix.ipopo.constants as constants
from pelix.ipopo.constants import IPOPO_SERVICE_SPECIFICATION
from pelix.ipopo.constants import use_ipopo
@ComponentFactory(name="CFRComponentFactory")
@Property("name", constants.IPOPO_INSTANCE_NAME)
@Property("thread_safe", "thread.safe", False)
@Property("usable", "usable", True)
@Provides(specifications="my.cfr")
class CFRComponent(object):
def __init__(self):
pass
@Validate
def validate(self, context):
print "TITLE:",self.title
if __name__ == '__main__':
import pelix.framework as pelix
from pelix.ipopo.constants import IPOPO_SERVICE_SPECIFICATION
print IPOPO_SERVICE_SPECIFICATION
# Start framework
framework = pelix.FrameworkFactory.get_framework()
framework.start()
context = framework.get_bundle_context()
bundle_id = context.install_bundle("pelix.ipopo.core")
bundle = context.get_bundle(bundle_id)
bundle.start()
ipopo_ref = context.get_service_reference(IPOPO_SERVICE_SPECIFICATION)
ipopo = context.get_service(ipopo_ref)
bundle_id = context.install_bundle("ipopotest")
bundle = context.get_bundle(bundle_id)
bundle.start()
try:
cfr = ipopo.instantiate("CFRComponentFactory", "cfrobj", {"title":"the title"})
except:
print traceback.format_exc()