コード例 #1
0
ファイル: mp_pub_activator.c プロジェクト: apache/celix
celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
	celix_status_t status = CELIX_SUCCESS;

	struct publisherActivator * act = malloc(sizeof(*act));

	const char* fwUUID = NULL;

	bundleContext_getProperty(context,OSGI_FRAMEWORK_FRAMEWORK_UUID,&fwUUID);
	if(fwUUID == NULL){
		printf("MP_PUBLISHER: Cannot retrieve fwUUID.\n");
		status = CELIX_INVALID_BUNDLE_CONTEXT;
	}

	if (status == CELIX_SUCCESS){
		bundle_pt bundle = NULL;
		long bundleId = 0;
		bundleContext_getBundle(context,&bundle);
		bundle_getBundleId(bundle,&bundleId);

		arrayList_create(&(act->trackerList));
		act->client = publisher_create(act->trackerList,fwUUID,bundleId);
		*userData = act;
	} else {
		free(act);
	}

	return status;
}
コード例 #2
0
ファイル: dcps_part.c プロジェクト: GerardoPardo/tinq-core
DDS_Publisher DDS_DomainParticipant_create_publisher (DDS_DomainParticipant       dp,
						      const DDS_PublisherQos      *qos,
						      const DDS_PublisherListener *listener,
						      DDS_StatusMask              mask)
{
	Publisher_t	*up;
	int		enable;

	ctrc_begind (DCPS_ID, DCPS_DP_C_PUB, &dp, sizeof (dp));
	ctrc_contd (&qos, sizeof (qos));
	ctrc_contd (&listener, sizeof (listener));
	ctrc_contd (&mask, sizeof (mask));
	ctrc_endd ();

	prof_start (dcps_create_pub);

	if (!domain_ptr (dp, 1, NULL))
		return (NULL);

	if (qos == DDS_PUBLISHER_QOS_DEFAULT)
		qos = &dp->def_publisher_qos;
	else if (!qos_valid_publisher_qos (qos)) {
		up = NULL;
		goto done;
	}
	up = publisher_create (dp, 0);
	if (!up)
		goto done;

	qos_publisher_new (&up->qos, qos);
	if (listener)
		up->listener = *listener;
	up->mask = mask;
	up->def_writer_qos = qos_def_writer_qos;
	enable = dp->autoenable;
	lock_release (dp->lock);
	if (enable)
		DDS_Publisher_enable (up);
	return (up);

    done:
	lock_release (dp->lock);
	prof_stop (dcps_create_pub, 1);
	return (NULL);
}