{
if(m_resource == null)
{
try
{
UnitResource myresource = new UnitResource(); //this will create the resource IF it is has default constructor
myresource.setID("123");
m_resource = myresource;
myresource.init();
//the next line will create an EPR
EndpointReference epr = getEndpointReference(resourceContext.getBaseURL() + "/" + getServiceName().getLocalPart(), RESOURCE_KEY, m_namespaceSet.getAddressingNamespace());
myresource.setEndpointReference(epr); //make sure to set the EPR on your new instance
add(RESOURCE_KEY, myresource);
}
catch (Exception e)
{
throw new ResourceException(e);