void doRebind(OperationContext context, ModelNode model, BinderService service) throws OperationFailedException { ManagedReferenceFactory ref = service.getManagedObjectInjector().getValue(); if(ref instanceof MutableManagedReferenceFactory) { MutableManagedReferenceFactory factory = (MutableManagedReferenceFactory) ref; final BindingType type = BindingType.forName(NamingBindingResourceDefinition.BINDING_TYPE.resolveModelAttribute(context, model).asString()); if (type == BindingType.SIMPLE) { Object bindValue = createSimpleBinding(context, model); factory.setFactory(new ValueManagedReferenceFactory(new ImmediateValue<Object>(bindValue))); service.setSource(bindValue); } else if (type == BindingType.OBJECT_FACTORY) { final ObjectFactory objectFactoryClassInstance = createObjectFactory(context, model); final Hashtable<String, String> environment = getObjectFactoryEnvironment(context, model); factory.setFactory(new ObjectFactoryManagedReference(objectFactoryClassInstance, service.getName(), environment)); service.setSource(objectFactoryClassInstance); } else if (type == BindingType.LOOKUP) { final String lookup = NamingBindingResourceDefinition.LOOKUP.resolveModelAttribute(context, model).asString(); factory.setFactory(new LookupManagedReferenceFactory(lookup)); service.setSource(null); } else if (type == BindingType.EXTERNAL_CONTEXT) { throw NamingLogger.ROOT_LOGGER.cannotRebindExternalContext(); } else { throw NamingLogger.ROOT_LOGGER.unknownBindingType(type.toString()); } } else { throw NamingLogger.ROOT_LOGGER.cannotRebindExternalContext(); } }
void doRebind(OperationContext context, ModelNode model, BinderService service) throws OperationFailedException { ManagedReferenceFactory ref = service.getManagedObjectInjector().getValue(); if(ref instanceof MutableManagedReferenceFactory) { MutableManagedReferenceFactory factory = (MutableManagedReferenceFactory) ref; final BindingType type = BindingType.forName(NamingBindingResourceDefinition.BINDING_TYPE.resolveModelAttribute(context, model).asString()); if (type == BindingType.SIMPLE) { Object bindValue = createSimpleBinding(context, model); factory.setFactory(new ValueManagedReferenceFactory(new ImmediateValue<Object>(bindValue))); service.setSource(bindValue); } else if (type == BindingType.OBJECT_FACTORY) { final ObjectFactory objectFactoryClassInstance = createObjectFactory(context, model); final Hashtable<String, String> environment = getObjectFactoryEnvironment(context, model); factory.setFactory(new ObjectFactoryManagedReference(objectFactoryClassInstance, service.getName(), environment)); service.setSource(objectFactoryClassInstance); } else if (type == BindingType.LOOKUP) { final String lookup = NamingBindingResourceDefinition.LOOKUP.resolveModelAttribute(context, model).asString(); factory.setFactory(new LookupManagedReferenceFactory(lookup)); service.setSource(null); } else if (type == BindingType.EXTERNAL_CONTEXT) { throw NamingLogger.ROOT_LOGGER.cannotRebindExternalContext(); } else { throw NamingLogger.ROOT_LOGGER.unknownBindingType(type.toString()); } } else { throw NamingLogger.ROOT_LOGGER.cannotRebindExternalContext(); } }
void doRebind(OperationContext context, ModelNode model, BinderService service) throws OperationFailedException { ManagedReferenceFactory ref = service.getManagedObjectInjector().getValue(); if(ref instanceof MutableManagedReferenceFactory) { MutableManagedReferenceFactory factory = (MutableManagedReferenceFactory) ref; final BindingType type = BindingType.forName(NamingBindingResourceDefinition.BINDING_TYPE.resolveModelAttribute(context, model).asString()); if (type == BindingType.SIMPLE) { Object bindValue = createSimpleBinding(context, model); factory.setFactory(new ValueManagedReferenceFactory(new ImmediateValue<Object>(bindValue))); service.setSource(bindValue); } else if (type == BindingType.OBJECT_FACTORY) { final ObjectFactory objectFactoryClassInstance = createObjectFactory(context, model); final Hashtable<String, String> environment = getObjectFactoryEnvironment(context, model); factory.setFactory(new ObjectFactoryManagedReference(objectFactoryClassInstance, service.getName(), environment)); service.setSource(objectFactoryClassInstance); } else if (type == BindingType.LOOKUP) { final String lookup = NamingBindingResourceDefinition.LOOKUP.resolveModelAttribute(context, model).asString(); factory.setFactory(new LookupManagedReferenceFactory(lookup)); service.setSource(null); } else if (type == BindingType.EXTERNAL_CONTEXT) { throw NamingLogger.ROOT_LOGGER.cannotRebindExternalContext(); } else { throw NamingLogger.ROOT_LOGGER.unknownBindingType(type.toString()); } } else { throw NamingLogger.ROOT_LOGGER.cannotRebindExternalContext(); } }