bean可数吗(通用12篇)由网友“昵称无所谓” 投稿提供,下面就是小编给大家带来的bean可数吗,希望大家喜欢阅读!
篇1:bean可数吗 bean例句分享
Bean sprouts are healthy.
豆芽有利于健康。
The French bean in the garden grows fast.
园子里的菜豆长得很快。
There are five peas in a bean pod.
在一个豆荚里,长着五颗豌豆。
篇2:Bean sprouting英语作文 Bean sprouting英语作文
Bean sprouts is a favorite of many people, I am no exception. Can be appeared on the market in recent years, the poison bean sprouts, let a person. Poison bean sprouts refers to the production process to join illegal additives in bean sprouts, bean sprouts grow long, grow strong, has tremendous harm to the human body. So, Thursday heald research class, the teacher let us home bean sprouts.
Back home, I took out a bowl, put a Huang Doufang inside, then filled with water on the sun insolates, a few days later, soybean is broken. My first attempt, so failed. This have not been able to reassure my confidence, but I feel will be able to make out of bean sprouts.
A few days later, I again is going to make bean sprouts, this time, I have from the Internet to find the beans.
篇3:Spring bean的作用域 下面通过一个例子来演示怎么自定义作用域并且分析框架中的代码自定义作用域是怎么实现,这个自定义scope的功能是把bean缓存到一个LRU缓存中,当bean被踢出缓存时触发析构回调
实现Scope接口,LRU缓存中最多只能放两个bean,被踢掉的bean会触犯析构回调,在removeEldestEntry方法中,析构回调保存在destructionCallback哈希表中:
public class LRUCacheScope implements Scope { private class BeanCache extends LinkedHashMap{ private static final long serialVersionUID = -887300667768355251L; @Override protected boolean removeEldestEntry(Entryeldest) { boolean flag = size >maxBeanNumber; if (flag) { executeDesCallback(eldest.getKey()); } return flag; } } private static final int DEFAULT_MAX_BEAN_NUMBER = 2; private MapbeanCache = Collections .synchronizedMap(new BeanCache()); private int maxBeanNumber; private MapdestructionCallback = new HashMap(); public LRUCacheScope() { this(DEFAULT_MAX_BEAN_NUMBER); } public LRUCacheScope(int maxBeanNumber) { super(); this.maxBeanNumber = maxBeanNumber; } @Override public Object get(String name, ObjectFactory<?>objectFactory) { Object bean = beanCache.get(name); if (bean == null) { bean = objectFactory.getObject(); beanCache.put(name, bean); } return bean; } @Override public Object remove(String name) { destructionCallback.remove(name); return beanCache.remove(name); } @Override public void registerDestructionCallback(String name, Runnable callback) { destructionCallback.put(name, callback); } @Override public Object resolveContextualObject(String key) { return null; } @Override public String getConversationId() { return null; } private void executeDesCallback(String beanName) { Runnable callBack = destructionCallback.get(beanName); if (callBack != null) { callBack.run(); } destructionCallback.remove(beanName); }}定义CustomScopeConfigurer注册Scope,并且定义其它的测试bean
JUnit测试代码
@Testpublic void test() { BeanFactory context = new ClassPathXmlApplicationContext( “spring/beans/scope/scope.xml”); ScopedBean bean1 = (ScopedBean) context.getBean(“scopedBean1”); ScopedBean bean11 = (ScopedBean) context.getBean(“scopedBean1”); assertEquals(bean1, bean11); ScopedBean bean2 = (ScopedBean) context.getBean(“scopedBean2”); ScopedBean bean3 = (ScopedBean) context.getBean(“scopedBean3”); bean11 = (ScopedBean) context.getBean(“scopedBean1”); assertNotEquals(bean1, bean11);}
执行测试代码发现代码执行通过,可以发现最后一次取出的scopedBean1和前面的scopedBean1已经不是一个实例了,查看控制台日志发现有如下信息:
22:28:48,738 DEBUG DefaultListableBeanFactory:432 - Creating instance of bean 'scopedBean1'22:28:48,738 DEBUG DefaultListableBeanFactory:460 - Finished creating instance of bean 'scopedBean1'22:28:48,738 DEBUG DefaultListableBeanFactory:432 - Creating instance of bean 'scopedBean2'22:28:48,738 DEBUG DefaultListableBeanFactory:460 - Finished creating instance of bean 'scopedBean2'22:28:48,738 DEBUG DefaultListableBeanFactory:432 - Creating instance of bean 'scopedBean3'22:28:48,738 DEBUG DefaultListableBeanFactory:460 - Finished creating instance of bean 'scopedBean3'22:28:48,738 DEBUG DisposableBeanAdapter:227 - Invoking destroy() on bean with name 'scopedBean1'destroy:spring.beans.scope.ScopedBean@18235ed22:28:48,738 DEBUG DefaultListableBeanFactory:432 - Creating instance of bean 'scopedBean1'22:28:48,738 DEBUG DefaultListableBeanFactory:460 - Finished creating instance of bean 'scopedBean1'22:28:48,738 DEBUG DisposableBeanAdapter:227 - Invoking destroy() on bean with name 'scopedBean2'destroy:spring.beans.scope.ScopedBean@1a28362从日志可以看出在创建完scopedBean3并且添加到缓存中之后scopedBean1被踢掉了并且触发了析构回调,我们ScopedBean实现了DisposableBean接口,它的destroy方法被调用了:
public class ScopedBean implements DisposableBean { @Override public void destroy() throws Exception { System.out.println(“destroy:” + this); }}
篇4:Spring bean的作用域 现在大致分析一下自定义作用域时如何实现的
首先看下CustomScopeConfigurer类,看下它的postProcessBeanFactory方法:
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { if (this.scopes != null) { for (Map.Entryentry : this.scopes.entrySet()) { String scopeKey = entry.getKey(); Object value = entry.getValue(); if (value instanceof Scope) { beanFactory.registerScope(scopeKey, (Scope) value); } else if (value instanceof Class) { Class scopeClass = (Class) value; Assert.isAssignable(Scope.class, scopeClass); beanFactory.registerScope(scopeKey, (Scope) BeanUtils.instantiateClass(scopeClass)); } else if (value instanceof String) { Class scopeClass = ClassUtils.resolveClassName((String) value, this.beanClassLoader); Assert.isAssignable(Scope.class, scopeClass); beanFactory.registerScope(scopeKey, (Scope) BeanUtils.instantiateClass(scopeClass)); } else { throw new IllegalArgumentException(“Mapped value [” + value + “] for scope key [” +scopeKey + “] is not an instance of required type [” + Scope.class.getName() +“] or a corresponding Class or String value indicating a Scope implementation”); } } }}在这个方法中把所有scope都注册到beanFactory中,来看看bean工厂的registerScope方法,在AbstractBeanFactory类中,在这个方法中把所有的作用域对象都存储到了scopes哈希表属性中,作用域名称作为哈希表的key:public void registerScope(String scopeName, Scope scope) { Assert.notNull(scopeName, “Scope identifier must not be null”); Assert.notNull(scope, “Scope must not be null”); if (SCOPE_SINGLETON.equals(scopeName) || SCOPE_PROTOTYPE.equals(scopeName)) { throw new IllegalArgumentException(“Cannot replace existing scopes 'singleton' and 'prototype'”); } this.scopes.put(scopeName, scope);}接下来看看bean的获取方法,在AbstractBeanFactory的doGetBean方法中,看doGetBean方法的代码片段:
if (mbd.isSingleton()) { ... }else if (mbd.isPrototype()) { ... }else { String scopeName = mbd.getScope(); final Scope scope = this.scopes.get(scopeName); if (scope == null) { throw new IllegalStateException(“No Scope registered for scope '” + scopeName + “'”); } try { Object scopedInstance = scope.get(beanName, new ObjectFactory() { public Object getObject() throws BeansException { beforePrototypeCreation(beanName); try { return createBean(beanName, mbd, args); } finally { afterPrototypeCreation(beanName); } } }); bean = getObjectForBeanInstance(scopedInstance, name, beanName, mbd); } catch (IllegalStateException ex) { throw new BeanCreationException(beanName, “Scope '” + scopeName + “' is not active for the current thread; ” + “consider defining a scoped proxy for this bean if you intend to refer to it from a singleton”, ex); }}可以看到获取自定义scope的bean调用了Scope的get方法,如果作用域没有缓存要找bean,那么会调用createBean来创建一个实例,这块创建bean实例的逻辑和prototype bean的是一样的,下面来看看注册析构回调的代码,在AbstractBeanFactory类的registerDisposableBeanIfNecessary方法中,在bean创建(AbstractAutowireCapableBeanFactory的doCreateBean方法)完成之后:
protected void registerDisposableBeanIfNecessary(String beanName, Object bean, RootBeanDefinition mbd) { AccessControlContext acc = (System.getSecurityManager() != null ? getAccessControlContext() : null); if (!mbd.isPrototype() && requiresDestruction(bean, mbd)) { if (mbd.isSingleton()) { // Register a DisposableBean implementation that performs all destruction // work for the given bean: DestructionAwareBeanPostProcessors, // DisposableBean interface, custom destroy method. registerDisposableBean(beanName, new DisposableBeanAdapter(bean, beanName, mbd, getBeanPostProcessors(), acc)); } else { // A bean with a custom scope... Scope scope = this.scopes.get(mbd.getScope()); if (scope == null) { throw new IllegalStateException(“No Scope registered for scope '” + mbd.getScope() + “'”); } scope.registerDestructionCallback(beanName, new DisposableBeanAdapter(bean, beanName, mbd, getBeanPostProcessors(), acc)); } }}代码中可以看到自定义scope的bean创建完成之后会注册一个DisposableBeanAdapter析构回调到到Scope,看看DisposableBeanAdapter这个类的代码,在scope中执行回调时调用run方法,而run方法会直接调用destroy方法,主要代码在destroy方法中,从代码中可以看出在destroy方法中执行了所有的bean的析构回调包括DestructionAwareBeanPostProcessor析构处理器、DisposableBean的destroy、bean定义中的destroy-method。
public void destroy() { if (this.beanPostProcessors != null && !this.beanPostProcessors.isEmpty()) { for (DestructionAwareBeanPostProcessor processor : this.beanPostProcessors) { processor.postProcessBeforeDestruction(this.bean, this.beanName); } } if (this.invokeDisposableBean) { if (logger.isDebugEnabled()) { logger.debug(“Invoking destroy() on bean with name '” + this.beanName + “'”); } try { if (System.getSecurityManager() != null) { AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws Exception {((DisposableBean) bean).destroy();return null; } }, acc); } else { ((DisposableBean) bean).destroy(); } } catch (Throwable ex) { String msg = “Invocation of destroy method failed on bean with name '” + this.beanName + “'”; if (logger.isDebugEnabled()) { logger.warn(msg, ex); } else { logger.warn(msg + “: ” + ex); } } } if (this.destroyMethod != null) { invokeCustomDestroyMethod(this.destroyMethod); } else if (this.destroyMethodName != null) { Method methodToCall = determineDestroyMethod(); if (methodToCall != null) { invokeCustomDestroyMethod(methodToCall); } }}框架自定义作用域 在Spring框架中也定义了一些自定义作用域:
web框架的request:bean在request范围内共享,实现类org.springframework.web.context.request.RequestScopeweb框架的session:bean在session范围内共享,实现类org.springframework.web.context.request.SessionScopeweb框架的application:ServletContextScope,bean在web应用共享,实现类org.springframework.web.context.support.ServletContextScopeorg.springframework.context.support.SimpleThreadScope:bean在线程内共享 篇5:第186讲:bean counters; spill the beans 第186讲:bean counters; spill the beans
我们给大家介绍过两个由bean这个字组成的习惯用语,它们是:Full of beans and not worth a hill of beans. Full of beans是指一个人精力充沛,not worth a hill of beans是一钱不值的意思。今天我们还要给大家讲解两个和bean这个字有关的习惯用语。现在先来讲第一个:bean counter.
Counter这个字是来自动词count. Count就是中文里数钱的数。在count这个动词后面加上er就变成了名词counter,也就是数数的人。那么,bean counter就是:数豆子的人。作为一个俗语,bean counter的'意思就是一个政府官员,或者一个公司的总管老是把时间浪费在鸡毛蒜皮的小事上,尤其是为了一点点钱算计个没完。那些为政府或公司真正干些实际工作的人都很讨厌这些bean counters。你们听了下面这个例句就明白了。
例句-1: I'm looking for a new job. This company I'm with now has too many bean counters. All they care about is how much we spend on postage and phone calls. They don't care if you are the best salesman in the place.
这是一个人对工作不满,他说:“我得另外找个工作。我现在工作的这个公司里尽是那些小里小气的人。他们关心的就是我们在邮票和电话上花了多少钱,至于你是不是这个公司最好的推销员他们根本不管。”
为了一点点钱纠缠不休的人恐怕在政府和公司之外也同样存在。下面是一个丈夫在说他的太太。
例句-2: My wife is really a bean counter. No matter how much money I make, she never lets me buy more than new two shirts a year. And she insists on washing and ironing my clothes at home, instead of sending them out to the laundry.
这位丈夫说:“我的妻子老是算计一点点钱。不管我赚多少,她每年最多只让我买两件衬衫。她还坚持要在家里洗和烫我的衬衫,而不愿意送到干洗店里去。”
美国人花在干洗店里的钱是不少的。许多人尽管家里都有洗衣机,但是他们还是很习惯地把衬衫送到乾洗店里去洗。当然,干洗店洗的衬衫烫的很平整,领子浆得很硬。可是,洗一件衬衫大约得花一块多美元,如果每天换一件乾净衬衫,一个星期就得花六、七美元。这还不算洗西装、大衣等其它衣服的开支。妇女们也经常把连衣裙、衬衣、西装等送去干洗店。
下面我们要讲的一个和bean有关的习惯用语是大家经常会用到的:To spill the beans. To spill就是什么东西从容器里撒出或倒出来。To spill the beans就是豆子从容器里倒了出来。可是,to spill the beans是一个俗语。它的意思是:泄漏秘密,但是往往是不小心、或偶然地泄漏了秘密,而不是故意这样做的。我们来举个例子吧。美国人经常为了生日或其它值得庆祝的事给家人或朋友举行聚会,但是有的人喜欢在事先不让过生日的人知道。这样可以让他很突然,感到很惊喜。下面就是一个人在说他准备聚会的经历。
例句-3: That Sue Ellen just can't keep her mouth shut! I invited her to our surprise party for Mary, and she went and spilled the beans to Mary. She says she's sorry but she certainly spoiled the surprise!
这人说:“那个苏爱伦,她就是闭不上她那张嘴。我请她参加为玛丽举行的聚会,但是事先不要告诉玛丽。可是,她跑去告诉了玛丽。她说她很
篇6:survey可数吗 例句:A recent survey showed 75% of those questioned were in favour of the plan.最近的民意调查显示,有75%的调查对象支持这项计划。The next morning we surveyed the damage caused by the fire.次日清早我们查看了火灾的`.破坏情况。This chapter briefly surveys the current state of European politics.本章对欧洲政治的现状作了简略概述。
篇7:weight可数吗 例句
We'll need to reduce the weight by half.
我们得把重量减轻一半。
I don't think that branch will hold your weight.
我觉得那根树枝撑不住你的重量。
The many letters of support added weight to the campaign.
许多声援信增加了这场运动的影响力。
I just hoped the branch would take my weight.
我只是希望树枝经得住我的体重。
篇8:fiction可数吗 fiction相关例句
His new novel is a must for all lovers of crime fiction.
他的`新作是所有犯罪小说爱好者的必读书。
Fact and fiction merge together in his latest thriller.
在他最近的惊险小说中,真实和虚构交织在一起。
It's important to distinguish fact from fiction.
区别真实和虚构是重要的。
This biography sometimes crosses the borderline between fact and fiction.
这部传记有时混淆了事实和虚构。
The book intermingles fact with fiction.
这本书事实和虚构并存。
篇9:thing可数吗? 例句:
In each and every thing you do.
无论你做哪一件和每一件事情。
Do not you have other thing to do?
你没有别的事情可以做吗?
As you, or any thing.
像你们,或者任何事物。
篇10:introduction可数吗 双语例句
1.It's a useful introduction to an extremely complex subject.
这是对一门极为复杂的学科的有益入门教程。
2.Introduction of electronic point-of-sale systems is improving efficiency.
引进销售点电子系统提高了效率。
3.On balance, the book is a friendly, down-to-earth introduction to physics.
总而言之,这是一本通俗而务实的.物理入门书。
4.A prolonged drought had necessitated the introduction of water rationing
由于持续干旱,用水需要实行配给了。
5.He explains in the introduction how he gathered the data.
他在引言里解释了他是如何收集到数据的。
篇11:institution可数吗? How long will it take to finish digging the foundations?
挖地基大概需要多长时间完成呢?
He laid the foundation of his success by study and hard work.
他通过学习和努力工作为成功打下了基础。
篇12:product可数吗 The product was developed in response to customer demand.
这种产品是为了满足顾客的需要而开发的。
Each product has a number for easy identification.
每件产品都有号码以便于识别。
The product has filled a gap in the market.
这个产品填补了市场的空白。
We need new product to sell.
我们需要新产品供销售。
Their latest product is aimed at the mass market.
他们的最新产品瞄准了大众市场。
★ icecream是可数名词还是不可数名词
★ ice cream范文
★ 小学五年级英语教案
★ 各种蔬菜及英语怎么说单词
★ sale的用法总结
★ morning的意思用法总结
★ how的用法总结出来
★ 小学腊八粥由来的作文
★ 介绍信常用英语词汇
★ 高二英语教案(人教版)
《bean可数吗.doc》
将本文的Word文档下载到电脑,方便收藏和打印
【bean可数吗(通用12篇)】相关文章:
英汉营养与食品卫生学词汇 2023-12-12
六年级英语名词复习 2023-10-10
人教PEP版三年级英语下册Unit 4单元教案 2022-07-23
四下英语期中复习课件 2024-04-06
compare用法精析 (人教版英语高考复习) 2023-12-30
介绍腊八节的作文 2022-08-26
高考英语冲刺必考知识点复习 2023-07-31
小学四年级语文下册知识 2023-06-27
long的意思用法总结 2024-02-01
plate的用法总结 2022-12-21