public Class<?> getInterfaceClass() throws RulesInstantiationException, ProjectResolvingException, ClassNotFoundException { if (interfaceClass != null) { return interfaceClass; } if (generatedInterfaceClass != null) { return generatedInterfaceClass; } log.info("Interface class is undefined for factory. Generated interface has been used."); generatedInterfaceClass = getRulesInstantiationStrategy().getInstanceClass(); return generatedInterfaceClass; }
public Class<?> getInterfaceClass() throws RulesInstantiationException, ProjectResolvingException, ClassNotFoundException { if (interfaceClass != null) { return interfaceClass; } if (generatedInterfaceClass != null) { return generatedInterfaceClass; } log.info("Interface class is undefined for factory. Generated interface has been used."); generatedInterfaceClass = getRulesInstantiationStrategy().getInstanceClass(); return generatedInterfaceClass; }
/** * Gets interface classes what used for proxy construction. * * @return proxy interfaces * @throws Exception */ protected Class<?>[] getProxyInterfaces(Object originalInstance) throws Exception { List<Class<?>> proxyInterfaces = new ArrayList<Class<?>>(); proxyInterfaces.add(getServiceClass()); Class<?> originalServiceClass = getOriginalInstantiationStrategy().getInstanceClass(); for (Class<?> interfaceClass : originalInstance.getClass().getInterfaces()) { if (!interfaceClass.equals(originalServiceClass)) { proxyInterfaces.add(interfaceClass); } } return proxyInterfaces.toArray(new Class<?>[] {}); }
/** * Gets interface classes what used for proxy construction. * * @return proxy interfaces * @throws Exception */ protected Class<?>[] getProxyInterfaces(Object originalInstance) throws Exception { List<Class<?>> proxyInterfaces = new ArrayList<Class<?>>(); proxyInterfaces.add(getServiceClass()); Class<?> originalServiceClass = getOriginalInstantiationStrategy().getInstanceClass(); for (Class<?> interfaceClass : originalInstance.getClass().getInterfaces()) { if (!interfaceClass.equals(originalServiceClass)) { proxyInterfaces.add(interfaceClass); } } return proxyInterfaces.toArray(new Class<?>[] {}); }
@Override public ClassLoader getClassLoader() throws RulesInstantiationException { try { return getOriginalInstantiationStrategy().getInstanceClass().getClassLoader(); } catch (ClassNotFoundException e) { throw new RulesInstantiationException(e); } }
@Override public ClassLoader getClassLoader() throws RulesInstantiationException { try { return getOriginalInstantiationStrategy().getInstanceClass().getClassLoader(); } catch (ClassNotFoundException e) { throw new RulesInstantiationException(e); } }
/** * Makes invocation handler. * * @return {@link InvocationHandler} instance * @throws Exception */ protected InvocationHandler makeInvocationHandler(Object instanceObject) throws Exception { Map<Method, Method> methodsMap = makeMethodMap(getServiceClass(), getOriginalInstantiationStrategy().getInstanceClass()); return new RuntimeContextInstantiationStrategyEnhancerInvocationHandler(methodsMap, instanceObject); }
/** * Makes invocation handler. * * @return {@link InvocationHandler} instance * @throws Exception */ protected InvocationHandler makeInvocationHandler(Object originalInstance) throws Exception { Map<Method, Method> methodsMap = makeMethodMap(getServiceClass(), getOriginalInstantiationStrategy().getInstanceClass()); return new VariationInstantiationStrategyEnhancerInvocationHandler(methodsMap, originalInstance); }
/** * Makes invocation handler. * * @return {@link InvocationHandler} instance * @throws Exception */ protected InvocationHandler makeInvocationHandler(Object instanceObject) throws Exception { Map<Method, Method> methodsMap = makeMethodMap(getServiceClass(), getOriginalInstantiationStrategy().getInstanceClass()); return new RuntimeContextInstantiationStrategyEnhancerInvocationHandler(methodsMap, instanceObject); }
/** * Makes invocation handler. * * @return {@link InvocationHandler} instance * @throws Exception */ protected InvocationHandler makeInvocationHandler(Object originalInstance) throws Exception { Map<Method, Method> methodsMap = makeMethodMap(getServiceClass(), getOriginalInstantiationStrategy().getInstanceClass()); return new VariationInstantiationStrategyEnhancerInvocationHandler(methodsMap, originalInstance); }
private void resolveInterfaceAndClassLoader(OpenLService service, RulesInstantiationStrategy instantiationStrategy) throws RulesInstantiationException, ClassNotFoundException { String serviceClassName = service.getServiceClassName(); Class<?> serviceClass = null; ClassLoader serviceClassLoader = instantiationStrategy.getClassLoader(); service.setClassLoader(serviceClassLoader); if (serviceClassName != null) { try { serviceClass = serviceClassLoader.loadClass(serviceClassName.trim()); Class<?> interfaceForInstantiationStrategy = RuleServiceInstantiationFactoryHelper.getInterfaceForInstantiationStrategy(instantiationStrategy, serviceClass); instantiationStrategy.setServiceClass(interfaceForInstantiationStrategy); } catch (ClassNotFoundException e) { log.error("Failed to load service class '{}'.", serviceClassName, e); } catch (NoClassDefFoundError e) { log.error("Failed to load service class '{}'.", serviceClassName, e); } } if (serviceClass == null) { log.info("Service class is undefined for service '{}'. Generated interface has been used.", service.getName()); Class<?> instanceClass = instantiationStrategy.getInstanceClass(); serviceClass = processGeneratedServiceClass(instantiationStrategy, service, instanceClass, serviceClassLoader); service.setServiceClassName(null); //Generated class is used. } service.setServiceClass(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; }
/** * 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; }
log.info("Service class is undefined for service '{}'. Generated interface has been used.", service.getName()); Class<?> instanceClass = instantiationStrategy.getInstanceClass(); serviceClass = processGeneratedServiceClass(instantiationStrategy, serviceDescription,