Without more context the best I can do is suggest that you read the source. Specifically, take a look at
Depending on what you want to do you might also pick up a few tips by looking at org/alfresco/repo/processor/ScriptServiceImpl.java.
Thank you Mr. for your reply. But how to get this code works inside my Java class ? there is classes not defined, how do I import them all to my code and execute them. If you can please Mr. Jeff describe to me the steps. Thanks a lot.