Skip to content

Instantly share code, notes, and snippets.

@marcosblandim
Last active September 6, 2023 14:41
Show Gist options
  • Save marcosblandim/cf9d4e8911fa7cddab38402c9b77cda4 to your computer and use it in GitHub Desktop.
Save marcosblandim/cf9d4e8911fa7cddab38402c9b77cda4 to your computer and use it in GitHub Desktop.
Liferay: Get OSGi Service in Groovy
import com.liferay.registry.Registry
import com.liferay.registry.RegistryUtil
import com.liferay.registry.ServiceReference
def getService(Class clazz) {
Registry registry = RegistryUtil.getRegistry();
ServiceReference serviceReference = registry.getServiceReference(clazz);
return registry.getService(serviceReference);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment