protected void buildContexts(PojoComponent component, ImplementationManagerFactory factory) { PojoRequestContext requestContext = new PojoRequestContext(); SingletonObjectFactory<PojoRequestContext> requestFactory = new SingletonObjectFactory<PojoRequestContext>(requestContext); factory.setObjectFactory(Injectable.OASIS_REQUEST_CONTEXT, requestFactory); PojoComponentContext componentContext = new PojoComponentContext(component, requestContext, info); SingletonObjectFactory<PojoComponentContext> componentFactory = new SingletonObjectFactory<PojoComponentContext>(componentContext); factory.setObjectFactory(Injectable.OASIS_COMPONENT_CONTEXT, componentFactory); }
/** * Sets an object factory. * * @param injectable the injectable identifying the component reference, property or context artifact the object factory creates instances for * @param objectFactory the object factory * @param attributes the injection attributes */ public void setObjectFactory(Injectable injectable, ObjectFactory<?> objectFactory, InjectionAttributes attributes) { factory.setObjectFactory(injectable, objectFactory, attributes); List<Object> instances = scopeContainer.getActiveInstances(this); String name = injectable.getName(); for (Object instance : instances) { getImplementationManager().updated(instance, name); } // Clear the instance factory as it has changed and will need to be re-created. This can happen if reinjection occurs after the first // instance has been created. recreate.set(true); }
protected void createPropertyFactories(PCD definition, ImplementationManagerFactory factory) throws BuilderException { List<PhysicalPropertyDefinition> propertyDefinitions = definition.getPropertyDefinitions(); TypeMapping typeMapping = new TypeMapping(); helper.resolveTypeParameters(factory.getImplementationClass(), typeMapping); for (PhysicalPropertyDefinition propertyDefinition : propertyDefinitions) { String name = propertyDefinition.getName(); Document value = propertyDefinition.getValue(); Injectable source = new Injectable(InjectableType.PROPERTY, name); Type type = factory.getGenericType(source); DataType<?> dataType = getDataType(type, typeMapping); ClassLoader classLoader = classLoaderRegistry.getClassLoader(definition.getClassLoaderId()); boolean many = propertyDefinition.isMany(); ObjectFactory<?> objectFactory = propertyBuilder.createFactory(name, dataType, value, many, classLoader); factory.setObjectFactory(source, objectFactory); } }