/** * when this {@link Context} is used in an {@link Environment}, it needs a name. */ public WireContext(final WireDefinition wireDefinition, final String name) { super(); this.wireDefinition = wireDefinition; this.name = name; classLoader = wireDefinition != null ? wireDefinition.getClassLoader() : null; create(); }
/** * allows for postponing the creation of this wire context. * * @param delayCreate * specifies if creation should be postponed till {@link #create()} is called explicitly. If delayCreate is * set to false, creation is done as part of the constructor. If delayCreate is set to true, the * {@link #create()} method needs to be called explicitly by the client after construction is complete. The * use case is creation of environment where the transactionName needs to be set and the scope needs to be * added to the environment before the creation of this wire scope is done. * @see PvmEnvironmentFactory#openEnvironment() */ public WireContext(final WireDefinition wireDefinition, final String name, final boolean delayCreate) { super(); this.wireDefinition = wireDefinition; this.name = name; classLoader = wireDefinition != null ? wireDefinition.getClassLoader() : null; if (!delayCreate) { create(); } }
@Override public Class<?> getType(final WireDefinition wireDefinition) { if (className != null) { try { return ReflectUtil.loadClass(wireDefinition.getClassLoader(), className); } catch (final BonitaRuntimeException e) { final String message = ExceptionManager.getInstance().getFullMessage("bp_HCD_1", className, e.getMessage()); throw new WireException(message, e.getCause()); } } return Configuration.class; }
public Class<?> getType(WireDefinition wireDefinition) { if (className != null) { try { return ReflectUtil .loadClass(wireDefinition.getClassLoader(), className); } catch (BonitaRuntimeException e) { String message = ExceptionManager.getInstance().getFullMessage( "bp_OD_10", (name != null ? name : className), e.getMessage()); throw new WireException(message, e .getCause()); } } Descriptor descriptor = null; if (factoryDescriptor != null) { descriptor = factoryDescriptor; } else if (factoryObjectName != null) { descriptor = wireDefinition.getDescriptor(factoryObjectName); } if (descriptor != null) { Class<?> factoryClass = descriptor.getType(wireDefinition); if (factoryClass != null) { Method method = ReflectUtilDescriptor.findMethod(factoryClass, methodName, argDescriptors, null); if (method != null) { return method.getReturnType(); } } } return null; }