
public ESVocabulary getVocabulary(ESConnection session ) {
		if (theVocabulary == null ) 
			theVocabulary = new %%IFACE%%Vocabulary( session);
		return theVocabulary.getVocabulary();		
}

private %%IFACE%%Vocabulary theVocabulary=null;

class %%IFACE%%Vocabulary
{
    private ESVocabulary    vocab = null;

    public %%IFACE%%Vocabulary(ESConnection session)
    {
        
		ESAccessor accessor= null;
		
        
        try
        {

            ESVocabulary %%IFACE%%Vocab = null;

            ESVocabularyFinder vf = new ESVocabularyFinder(session);
            try
            {
               %%IFACE%%Vocab = vf.find( new ESQuery( 
					"Name == '%%IFACE%%Vocabulary'" ) );
            }
            catch (LookupFailedException e)
            {
               
               ESVocabularyDescription esvd = new ESVocabularyDescription();
               esvd.addAttribute(ESConstants.SERVICE_NAME,"%%IFACE%%Vocabulary"); 
               ESVocabularyElement esvc = 
					new ESVocabularyElement(session, esvd);
               vocab = esvc.register();
            
               accessor = ((ESVocabularyStub)vocab).getAccessor();


               ESContractDescription escd = new ESContractDescription();
 	       escd.setInterfaceName("%%QIFACE%%");
               escd.addAttribute(ESConstants.SERVICE_NAME, "%%IFACE%%Contract");

               ESContractElement escc = new ESContractElement(session, escd);
               ESContract cont = escc.register();
	        }

        }
        catch (Exception e) 
        {
            e.printStackTrace();
        }
    }

	
	/**
	 * Gets the vocabulary.
	 * @return ESVocabulary Vocabulary.
	 */
    public ESVocabulary getVocabulary()
    {
	return vocab;
    }

}


