@Override
 public void destroy() throws Exception {
   synchronized (lock) {
     if (engineFactory != null) {
       scriptService.removeEngine(engineFactory);
     }
     engineFactory = null;
   }
 }
 @Override
 public void afterPropertiesSet() throws Exception {
   ScriptEngineFactory factory;
   try {
     factory = getEngineFactory();
   } catch (ClassNotFoundException e) {
     reportInstantiateEngineError(e);
     return;
   } catch (IllegalAccessException e) {
     reportInstantiateEngineError(e);
     return;
   } catch (InstantiationException e) {
     reportInstantiateEngineError(e);
     return;
   }
   scriptService.defaultRegistration(factory);
 }