temp

ContainerBuilder中的public Container create(boolean loadSingletons)
① final ContainerImpl container = new ContainerImpl(
new HashMap<Key<?>, InternalFactory<?>>(factories));
this.factories = factories;
ContainerImpl的构造方法中,用factories的Key部分构件一个新Map
for (Key<?> key : factories.keySet()) {
Set<String> names = map.get(key.getType());
if (names == null) {
names = new HashSet<String>();
map.put(key.getType(), names);
}
names.add(key.getName());
}

for (Entry<Class<?>,Set<String>> entry : map.entrySet()) {
entry.setValue(Collections.unmodifiableSet(entry.getValue()));
}
使Map的Value只读,即一些default、struts之类的值
Returns an unmodifiable view of the specified set. This method allows modules to provide users with "read-only" access to internal sets. Query operations on the returned set "read through" to the specified set, and attempts to modify the returned set, whether direct or via its iterator, result in an UnsupportedOperationException.

this.factoryNamesByType = Collections.unmodifiableMap(map) 不可修改

{type=class com.opensymphony.xwork2.ObjectFactory, name=default, implementation=class com.opensymphony.xwork2.ObjectFactory, scope=SINGLETON}

② container.callInContext(new ContainerImpl.ContextualCallable<Void>() {
public Void call(InternalContext context) {
for (InternalFactory<?> factory : singletonFactories) {
factory.create(context);
}
return null;
}
})

callInContext 创建了一个InternalContext

匿名ContextualCallable的实例调用call(创建的InternalContext)
对单例工厂中的每个工厂,factory.create(context)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在引用的代码中,temp是一个结构体中的字符串成员。在main函数中,一个结构体temp的指针q被分配了一块内存空间,并且temp的字符串成员s被赋值为p。然而,p的值没有在代码中给出,所以这段代码无法正确运行。 在引用的代码中,temp是一个字符串变量。在main函数中,temp的第一个、第二个和第三个字符分别被赋值为'a'、'b'和'c',并且第四个字符设置为'\0',表示字符串结束。然后,通过cout语句输出了temp的第一个、第二个和第三个字符,并且输出了整个字符串temp。 而在引用的问题中,提到了temp的输出为空的情况。根据代码的解释,如果temp的输出为空,那可能是因为temp字符串的前三个字符都没有被赋值为有效的字符,导致cout语句输出为空。要解决这个问题,可以确保在给temp赋值之前,先将其所有的字符都初始化为有效的值。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [C++结构体里面string类型赋值问题](https://download.csdn.net/download/weixin_38571992/14857036)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [C++string类的存储](https://blog.csdn.net/Dimensionoffive/article/details/70054356)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值