ResourceManager manager = getResourceManager();
ManagementContributionProxy proxy = null;
if(contribution instanceof BundleContribution)
proxy = (ManagementContributionProxy)manager.createResource("/OSGiBundleResource");
else if(contribution instanceof ServiceContribution)
proxy = (ManagementContributionProxy)manager.createResource("/OSGiServiceResource");
proxy.setContribution(contribution);
proxy.initialize();
//fix up the EPR with the resource ID
EndpointReference epr = proxy.getEndpointReference();
epr.addParameter(WsaConstants.DEFAULT_RESOURCE_ID_QNAME ,contribution.getIdentifier());