Hi all,

I put a solution for anybody, and for challenge it.

I used bundle.getRegisteredServices(); to having all services registered by
my bundle, and I keep the service.factoryPid key to having the value. here
the code:

String returnValue = "";
ServiceReference<?>[] refs = bundle.getRegisteredServices();
if (refs != null) {
        boolean isFound = false;
        int size = refs.length;
        for (int i = 0; i < size && !isFound; i++) {
                String[] keys = refs[i].getPropertyKeys();
                for (String key : keys) {
                        if (!key.equalsIgnoreCase(Constants.OBJECTCLASS)) {
                                if ("service.factoryPid".equalsIgnoreCase(key)) 
{
                                        returnValue = 
refs[i].getProperty(key).toString();
                                        isFound = true;
                                        break;
                                }
                        }
                }
        }
}

regards




--
View this message in context: 
http://karaf.922171.n3.nabble.com/Set-dynamically-a-property-hosted-in-a-etc-config-file-tp4049866p4049949.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Reply via email to