@Override public final Object instantiate() throws RulesInstantiationException, ClassNotFoundException { try { Object originalInstance = getOriginalInstantiationStrategy().instantiate(); InvocationHandler invocationHandler = makeInvocationHandler(originalInstance); return Proxy.newProxyInstance(getClassLoader(), getProxyInterfaces(originalInstance), invocationHandler); } catch (Exception e) { throw new RulesInstantiationException(e.getMessage(), e); } }
@Override public final Object instantiate() throws RulesInstantiationException, ClassNotFoundException { try { Object originalInstance = getOriginalInstantiationStrategy().instantiate(); InvocationHandler invocationHandler = makeInvocationHandler(originalInstance); return Proxy.newProxyInstance(getClassLoader(), getProxyInterfaces(originalInstance), invocationHandler); } catch (Exception e) { throw new RulesInstantiationException(e.getMessage(), e); } }
/** * Gets enhanced service class. * * @return service class * @throws ClassNotFoundException * @throws InstantiationException */ @Override public final Class<?> getServiceClass() throws ClassNotFoundException { if (serviceClass == null) { try { Class<?> originalServiceClass = getOriginalInstantiationStrategy().getInstanceClass(); serviceClass = decorateServiceClass(originalServiceClass, getClassLoader()); } catch (Exception e) { throw new OpenlNotCheckedException("Failed to enhance service class.", e); } } return serviceClass; }
/** * Gets enhanced service class. * * @return service class * @throws ClassNotFoundException * @throws InstantiationException */ @Override public final Class<?> getServiceClass() throws ClassNotFoundException { if (serviceClass == null) { try { Class<?> originalServiceClass = getOriginalInstantiationStrategy().getInstanceClass(); serviceClass = decorateServiceClass(originalServiceClass, getClassLoader()); } catch (Exception e) { throw new OpenlNotCheckedException("Failed to enhance service class.", e); } } return serviceClass; }
@Override public void setServiceClass(Class<?> serviceClass) { try { if (validateServiceClass(serviceClass)) { this.serviceClass = serviceClass; try { Class<?> clazz = undecorateServiceClass(serviceClass, getClassLoader()); getOriginalInstantiationStrategy().setServiceClass(clazz); } catch (Exception e) { throw new OpenlNotCheckedException( "Failed to set service class to instantiation strategy enhancer. Failed to get undecorated class.", e); } } else { throw new OpenlNotCheckedException( "Failed to set service class to instantiation strategy enhancer. Service class isn't supported by this strategy!"); } } catch (ValidationServiceClassException e) { throw new OpenlNotCheckedException( "Failed to set service class to instantiation strategy enhancer. Service class isn't supported by this strategy!", e); } }
@Override public void setServiceClass(Class<?> serviceClass) { try { if (validateServiceClass(serviceClass)) { this.serviceClass = serviceClass; try { Class<?> clazz = undecorateServiceClass(serviceClass, getClassLoader()); getOriginalInstantiationStrategy().setServiceClass(clazz); } catch (Exception e) { throw new OpenlNotCheckedException( "Failed to set service class to instantiation strategy enhancer. Failed to get undecorated class.", e); } } else { throw new OpenlNotCheckedException( "Failed to set service class to instantiation strategy enhancer. Service class isn't supported by this strategy!"); } } catch (ValidationServiceClassException e) { throw new OpenlNotCheckedException( "Failed to set service class to instantiation strategy enhancer. Service class isn't supported by this strategy!", e); } }