public void detachSupplier(SpringWireSource source, PhysicalWireTarget target) { detach(source, target); }
public void detach(SpringSourceDefinition source, PhysicalTargetDefinition target) throws WiringException { SpringComponent component = getComponent(source); String referenceName = source.getReferenceName(); component.detach(referenceName); }
/** * Creates a parent application context populated with system components configured to be aliased as Spring beans. * * @param classLoader the context classloader * @param properties any defined property values keyed by name * @return the parent application context */ private SCAApplicationContext createParentContext(ClassLoader classLoader, Map<String, Pair> properties) { ClassLoader old = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(classLoader); SCAApplicationContext parent = new SCAApplicationContext(); for (Map.Entry<String, Pair> entry : properties.entrySet()) { String name = entry.getKey(); Pair pair = entry.getValue(); parent.add(name, pair.getType(), pair.getSupplier()); } for (ApplicationContextListener listener : listeners) { listener.onCreate(parent); } return parent; } finally { Thread.currentThread().setContextClassLoader(old); } }
if (PhysicalSpringComponent.LocationType.JAR == physicalComponent.getLocationType()) { resolveJarSources(physicalComponent, classLoader, sources); } else if (PhysicalSpringComponent.LocationType.DIRECTORY == physicalComponent.getLocationType()) { resolveDirectorySources(physicalComponent, classLoader, sources); } else { Map<String, Pair> properties = createProperties(physicalComponent); SCAApplicationContext parent = createParentContext(classLoader, properties); Map<String, String> alias = physicalComponent.getDefaultReferenceMappings(); URI contributionUri = physicalComponent.getContributionUri();
/** * Creates a parent application context populated with system components configured to be aliased as Spring beans. * * @param classLoader the context classloader * @param properties any defined property values keyed by name * @return the parent application context */ private SCAApplicationContext createParentContext(ClassLoader classLoader, Map<String, Pair> properties) { ClassLoader old = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(classLoader); SCAApplicationContext parent = new SCAApplicationContext(); for (Map.Entry<String, Pair> entry : properties.entrySet()) { String name = entry.getKey(); Pair pair = entry.getValue(); parent.add(name, pair.getType(), pair.getFactory()); } for (ApplicationContextListener listener : listeners) { listener.onCreate(parent); } return parent; } finally { Thread.currentThread().setContextClassLoader(old); } }
public void attach(PhysicalWireSource source, SpringWireTarget target, Wire wire) throws Fabric3Exception { String beanName = target.getBeanName(); ClassLoader loader = target.getClassLoader(); Class<?> interfaze; try { interfaze = loader.loadClass(target.getBeanInterface()); } catch (ClassNotFoundException e) { throw new Fabric3Exception(e); } for (WireListener listener : listeners) { listener.onAttach(wire); } SpringComponent component = getComponent(target); for (InvocationChain chain : wire.getInvocationChains()) { PhysicalOperation operation = chain.getPhysicalOperation(); Method beanMethod = MethodUtils.findMethod(source, target, operation, interfaze, loader); SpringInvoker invoker = new SpringInvoker(beanName, beanMethod, component); chain.addInterceptor(invoker); } }
protected Map<String, Pair> createProperties(PhysicalSpringComponent springComponent) throws Fabric3Exception { List<PhysicalProperty> properties = springComponent.getProperties(); Map<String, Pair> values = new HashMap<>(); for (PhysicalProperty property : properties) { String name = property.getName(); if (property.getInstanceValue() != null) { Pair pair = new Pair(Object.class, property::getInstanceValue); values.put(name, pair); } else { Document document = property.getXmlValue(); String value = document.getElementsByTagName("value").item(0).getFirstChild().getNodeValue(); QName type = property.getType(); if (XSD_BOOLEAN.equals(type)) { Pair pair = new Pair(Boolean.class, () -> Boolean.valueOf(value)); values.put(name, pair); } else if (XSD_INT.equals(type)) { Pair pair = new Pair(Integer.class, () -> Boolean.valueOf(value)); values.put(name, pair); } else { Pair pair = new Pair(String.class, () -> value); values.put(name, pair); } } } return values; }
public void detach(SpringWireSource source, PhysicalWireTarget target) { SpringComponent component = getComponent(source); String referenceName = source.getReferenceName(); component.detach(referenceName); }
/** * Creates a parent application context populated with system components configured to be aliased as Spring beans. * * @param classLoader the context classloader * @param properties any defined property values keyed by name * @return the parent application context */ private SCAApplicationContext createParentContext(ClassLoader classLoader, Map<String, Pair> properties) { ClassLoader old = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(classLoader); SCAApplicationContext parent = new SCAApplicationContext(); for (Map.Entry<String, Pair> entry : properties.entrySet()) { String name = entry.getKey(); Pair pair = entry.getValue(); parent.add(name, pair.getType(), pair.getSupplier()); } for (ApplicationContextListener listener : listeners) { listener.onCreate(parent); } return parent; } finally { Thread.currentThread().setContextClassLoader(old); } }
public void detachSupplier(SpringWireSource source, PhysicalWireTarget target) { detach(source, target); }
public void attach(PhysicalWireSource source, SpringWireTarget target, Wire wire) throws Fabric3Exception { String beanName = target.getBeanName(); ClassLoader loader = target.getClassLoader(); Class<?> interfaze; try { interfaze = loader.loadClass(target.getBeanInterface()); } catch (ClassNotFoundException e) { throw new Fabric3Exception(e); } for (WireListener listener : listeners) { listener.onAttach(wire); } SpringComponent component = getComponent(target); for (InvocationChain chain : wire.getInvocationChains()) { PhysicalOperation operation = chain.getPhysicalOperation(); Method beanMethod = MethodUtils.findMethod(source, target, operation, interfaze, loader); SpringInvoker invoker = new SpringInvoker(beanName, beanMethod, component); chain.addInterceptor(invoker); } }
public void detach(SpringWireSource source, PhysicalWireTarget target) { SpringComponent component = getComponent(source); String referenceName = source.getReferenceName(); component.detach(referenceName); }
public void detachObjectFactory(SpringSourceDefinition source, PhysicalTargetDefinition target) throws WiringException { detach(source, target); }
public void attach(PhysicalSourceDefinition source, SpringTargetDefinition target, Wire wire) throws WiringException { String beanName = target.getBeanName(); ClassLoader loader = classLoaderRegistry.getClassLoader(target.getClassLoaderId()); Class<?> interfaze; try { interfaze = loader.loadClass(target.getBeanInterface()); } catch (ClassNotFoundException e) { throw new WiringException(e); } for (WireListener listener : listeners) { listener.onAttach(wire); } SpringComponent component = getComponent(target); for (InvocationChain chain : wire.getInvocationChains()) { PhysicalOperationDefinition operation = chain.getPhysicalOperation(); Method beanMethod = MethodUtils.findMethod(source, target, operation, interfaze, loader, classLoaderRegistry); SpringInvoker invoker = new SpringInvoker(beanName, beanMethod, component); chain.addInterceptor(invoker); } }
public void attachSupplier(SpringWireSource source, Supplier<?> supplier, PhysicalWireTarget target) { SpringComponent component = getComponent(source); String referenceName = source.getReferenceName(); ClassLoader loader = source.getClassLoader(); Class<?> interfaze; try { interfaze = loader.loadClass(source.getInterface()); component.attach(referenceName, interfaze, supplier); } catch (ClassNotFoundException e) { throw new Fabric3Exception(e); } }
public void attachSupplier(SpringWireSource source, Supplier<?> supplier, PhysicalWireTarget target) { SpringComponent component = getComponent(source); String referenceName = source.getReferenceName(); ClassLoader loader = source.getClassLoader(); Class<?> interfaze; try { interfaze = loader.loadClass(source.getInterface()); component.attach(referenceName, interfaze, supplier); } catch (ClassNotFoundException e) { throw new Fabric3Exception(e); } }
public void attachObjectFactory(SpringSourceDefinition source, ObjectFactory<?> objectFactory, PhysicalTargetDefinition target) throws WiringException { SpringComponent component = getComponent(source); String referenceName = source.getReferenceName(); ClassLoader loader = classLoaderRegistry.getClassLoader(source.getClassLoaderId()); Class<?> interfaze; try { interfaze = loader.loadClass(source.getInterface()); component.attach(referenceName, interfaze, objectFactory); } catch (ClassNotFoundException e) { throw new WiringException(e); } }
public void attach(SpringWireSource source, PhysicalWireTarget target, Wire wire) { SpringComponent component = getComponent(source); String referenceName = source.getReferenceName(); ClassLoader loader = source.getClassLoader(); Class<?> interfaze; try { interfaze = loader.loadClass(source.getInterface()); // note callbacks not supported for spring beans Supplier<?> supplier = proxyService.createSupplier(interfaze, wire, null); component.attach(referenceName, interfaze, supplier); for (WireListener listener : listeners) { listener.onAttach(wire); } } catch (ClassNotFoundException e) { throw new Fabric3Exception(e); } }
public void attach(SpringWireSource source, PhysicalWireTarget target, Wire wire) { SpringComponent component = getComponent(source); String referenceName = source.getReferenceName(); ClassLoader loader = source.getClassLoader(); Class<?> interfaze; try { interfaze = loader.loadClass(source.getInterface()); // note callbacks not supported for spring beans Supplier<?> supplier = proxyService.createSupplier(interfaze, wire, null); component.attach(referenceName, interfaze, supplier); for (WireListener listener : listeners) { listener.onAttach(wire); } } catch (ClassNotFoundException e) { throw new Fabric3Exception(e); } }
public void attach(SpringSourceDefinition source, PhysicalTargetDefinition target, Wire wire) throws WiringException { SpringComponent component = getComponent(source); String referenceName = source.getReferenceName(); ClassLoader loader = classLoaderRegistry.getClassLoader(source.getClassLoaderId()); Class<?> interfaze; try { interfaze = loader.loadClass(source.getInterface()); // note callbacks not supported for spring beans ObjectFactory<?> factory = proxyService.createObjectFactory(interfaze, wire, null); component.attach(referenceName, interfaze, factory); for (WireListener listener : listeners) { listener.onAttach(wire); } } catch (ClassNotFoundException e) { throw new WiringException(e); } catch (ProxyCreationException e) { throw new WiringException(e); } }