<废弃> openHAB 体系结构与编程模型 (1) --- 术语

本文介绍 openHAB 中用于构建用户界面的核心组件,包括 Item、Widget 和 Sitemap 的概念及其作用。Item 作为硬件设备属性的抽象,Widget 为用户界面的基本元素,而 Sitemap 则定义了用户界面的结构。

openHAB 术语


Item : 对硬件设备属性的抽象 (

  • Items are objects that can be read from or written to in order to interact with them.
  • Items can be bound to bindings i.e. for reading the status from e.g. KNX or for updating them.)

Item UI Provider :

Item UI providers offer a dynamic way to configure the UI, so that not everything must be stored statically in the Sitemap. An item UI provider can for example define, what widget should be used for an item, if none is specified and can dynamically define icons and labels (which might depend on the current state of the item) for the widgets.

An important use case for this feature is the dynamic display of item groups - all that there is stored in the Sitemap is the information that a certain group should be displayed; the page is then dynamically assembled at runtime with whatever items are available at that time.

This interface describes the methods that need to be implemented by a provider that wants to define the appearance of an item in the UI.


Item UI Registry :

This interface is used by a service which combines the core item registry with an aggregation of item ui providers; it can be therefore widely used for all UI related information requests regarding items.


Item Provider :

An item provider provides instances of GenericItem. These items can be constructed from some static configuration files or they can be derived from some dynamic logic.


Item Registry :

The ItemRegistry is the central place, where items are kept in memory and their state is permanently tracked. So any code that requires the current state of items should use this service (instead of trying to keep their own local copy of the items). Items are registered by ItemProviders, which can provision them from any source they like and also dynamically remove or add items.


Widget :用户界面的基本元素 (描述的是内容而非展现 [Sitemaps can be composed by grouping various user interface elements into areas, which will be rendered by openHAB.]), org.openhab.model.sitemap 工程的 src-gen 目录的 org.openhab.model.sitemap.Widget.java 中仅保存 Item 的全局唯一的名称(或者说ID)


/**
 */
package org.openhab.model.sitemap;

import org.eclipse.emf.ecore.EObject;

/**
 * <!-- begin-user-doc -->
 * A representation of the model object '<em><b>Widget</b></em>'.
 * <!-- end-user-doc -->
 *
 * <p>
 * The following features are supported:
 * <ul>
 *   <li>{@link org.openhab.model.sitemap.Widget#getItem <em>Item</em>}</li>
 *   <li>{@link org.openhab.model.sitemap.Widget#getLabel <em>Label</em>}</li>
 *   <li>{@link org.openhab.model.sitemap.Widget#getIcon <em>Icon</em>}</li>
 * </ul>
 * </p>
 *
 * @see org.openhab.model.sitemap.SitemapPackage#getWidget()
 * @model
 * @generated
 */
public interface Widget extends EObject
{
  /**
   * Returns the value of the '<em><b>Item</b></em>' attribute.
   * <!-- begin-user-doc -->
   * <p>
   * If the meaning of the '<em>Item</em>' attribute isn't clear,
   * there really should be more of a description here...
   * </p>
   * <!-- end-user-doc -->
   * @return the value of the '<em>Item</em>' attribute.
   * @see #setItem(String)
   * @see org.openhab.model.sitemap.SitemapPackage#getWidget_Item()
   * @model
   * @generated
   */
  String getItem();

  /**
   * Sets the value of the '{@link org.openhab.model.sitemap.Widget#getItem <em>Item</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @param value the new value of the '<em>Item</em>' attribute.
   * @see #getItem()
   * @generated
   */
  void setItem(String value);

  /**
   * Returns the value of the '<em><b>Label</b></em>' attribute.
   * <!-- begin-user-doc -->
   * <p>
   * If the meaning of the '<em>Label</em>' attribute isn't clear,
   * there really should be more of a description here...
   * </p>
   * <!-- end-user-doc -->
   * @return the value of the '<em>Label</em>' attribute.
   * @see #setLabel(String)
   * @see org.openhab.model.sitemap.SitemapPackage#getWidget_Label()
   * @model
   * @generated
   */
  String getLabel();

  /**
   * Sets the value of the '{@link org.openhab.model.sitemap.Widget#getLabel <em>Label</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @param value the new value of the '<em>Label</em>' attribute.
   * @see #getLabel()
   * @generated
   */
  void setLabel(String value);

  /**
   * Returns the value of the '<em><b>Icon</b></em>' attribute.
   * <!-- begin-user-doc -->
   * <p>
   * If the meaning of the '<em>Icon</em>' attribute isn't clear,
   * there really should be more of a description here...
   * </p>
   * <!-- end-user-doc -->
   * @return the value of the '<em>Icon</em>' attribute.
   * @see #setIcon(String)
   * @see org.openhab.model.sitemap.SitemapPackage#getWidget_Icon()
   * @model
   * @generated
   */
  String getIcon();

  /**
   * Sets the value of the '{@link org.openhab.model.sitemap.Widget#getIcon <em>Icon</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @param value the new value of the '<em>Icon</em>' attribute.
   * @see #getIcon()
   * @generated
   */
  void setIcon(String value);

} // Widget

Sitemap :用户界面定义(树形结构,同样也是描述内容而非展现),由该 Sitemap 对应的全部 Widget 组成 (The sitemap is a tree structure of widgets, which define the different pages of a UI and their content. Widgets can be associated to items, for which they should show the status and/or control elements.),  (demo.items    demo.sitemap)


<think>好的,我现在需要解决用户在Maven settings.xml中配置<blocked>元素时报错的问题。用户提到他们使用的是Apache Maven 3.8.8,并且在设置后遇到了错误,提示HTTP仓库被阻止。用户之前的问题和我的回答已经讨论过<blocked>元素在较新版本中被废弃的情况,但现在用户具体遇到了在配置<blocked>false</blocked>时报错的问题。 首先,我需要确认Maven 3.8.1及以上版本对HTTP仓库的限制。根据引用内容,Maven从3.8.1开始默认阻止HTTP仓库,除非显式允许。用户可能在settings.xml中尝试通过<blocked>false</blocked>来绕过这个限制,但可能由于该元素已被废弃或使用不当导致报错。 接下来,我需要回顾之前的回答,其中提到<blocked>元素在3.8.1+版本中已废弃,并建议替代方案,如使用仓库黑名单、镜像拦截或依赖排除。现在用户的问题是明确如何在配置<blocked>时解决报错,因此需要更具体的解决方案。 可能的解决步骤包括: 1. **检查Maven版本**:确认用户确实使用的是3.8.1或更高版本,因为旧版本可能不支持相关配置。 2. **正确的位置使用<blocked>**:在之前的回答中,提到<blocked>应在<repository>或<pluginRepository>下使用,而非<mirror>。用户可能在错误的位置配置了该元素,导致报错。 3. **替代方案**:如果<blocked>不再有效,建议用户改用其他方法,如使用HTTPS仓库、配置镜像或降级Maven版本。 4. **配置镜像允许HTTP**:在<mirror>中设置<blocked>false</blocked>可能无效,应改用<mirrorOf>并确保URL正确,同时可能需要其他配置。 5. **详细错误日志分析**:用户提供的错误信息提到需要检查settings.xml和pom中的HTTP仓库,并建议添加允许HTTP的镜像或降级Maven。因此,解决方案应围绕这些方面展开。 需要确保回答结构清晰,分步骤说明,并验证每个方案的可行性。同时,生成相关问题以帮助用户进一步排查问题。</think>针对在Maven 3.8.1+版本中配置`<blocked>`元素报错的问题,以下是分步解决方案: --- ### 一、问题定位 报错核心原因是**Maven 3.8.1+默认禁止HTTP仓库访问**,且`<blocked>`元素在`<mirror>`中的使用已被废弃。当你在`settings.xml`的镜像配置中尝试`<blocked>false</blocked>`时,会触发以下错误: ```xml <!-- 错误示例 --> <mirror> <id>invalid-mirror</id> <url>http://insecure-repo.com</url> <mirrorOf>*</mirrorOf> <blocked>false</blocked> <!-- 此处报错 --> </mirror> ``` 报错提示: ``` 元素 blocked 在此上下文中不允许 ``` --- ### 二、解决方案 #### 方案1:合法启用HTTP仓库(推荐) 在`<profile>`中显式声明允许HTTP仓库: ```xml <settings> <profiles> <profile> <id>allow-http</id> <repositories> <repository> <id>insecure-http-repo</id> <url>http://your-repo.com</url> <!-- 关键配置 --> <blocked>false</blocked> <!-- 必须在<repository>标签内 --> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>insecure-http-plugin-repo</id> <url>http://your-plugin-repo.com</url> <blocked>false</blocked> </pluginRepository> </pluginRepositories> </profile> </profiles> <activeProfiles> <activeProfile>allow-http</activeProfile> </activeProfiles> </settings> ``` **验证命令**: ```bash mvn help:effective-settings -DshowProfiles=true ``` #### 方案2:镜像覆盖策略 通过镜像强制替换HTTP为HTTPS(无需使用`<blocked>`): ```xml <mirrors> <mirror> <id>secure-mirror</id> <url>https://maven.aliyun.com/repository/public</url> <mirrorOf>external:*</mirrorOf> </mirror> </mirrors> ``` #### 方案3:版本降级(临时方案) 修改`MAVEN_HOME/conf/settings.xml`前备份,然后降级到3.8.1以下版本: ```bash # 使用SDKMAN快速切换版本 sdk install maven 3.8.0 sdk use maven 3.8.0 ``` --- ### 三、配置验证流程 1. **语法检查**: ```bash xmllint --noout --schema http://maven.apache.org/xsd/settings-1.1.0.xsd settings.xml ``` 2. **依赖解析测试**: ```bash mvn clean install -U -X | grep "Repository access" ``` 正常应输出: ``` [DEBUG] Using repository http://your-repo.com (blocked: false) ``` --- ### 四、企业级安全实践 1. **强制HTTPS全局策略**(Nexus管理端): ```xml <!-- Nexus的security.xml配置 --> <httpClientAttributes> <connection> <blocked>false</blocked> <autoBlock>true</autoBlock> <strictSSL>true</strictSSL> <!-- 关键配置 --> </connection> </httpClientAttributes> ``` 2. **数字证书绑定**: ```bash keytool -importcert -alias corp-ca -file CA.cer -keystore $JAVA_HOME/lib/security/cacerts ``` --- ### 五、错误模式对照表 | 错误现象 | 根本原因 | 修复方案 | |---------|---------|---------| | `Element 'blocked' is not allowed` | `<blocked>`出现在非法位置 | 仅在`<repository>`或`<pluginRepository>`内使用 | | `Blocked mirror for repositories` | 镜像配置未覆盖所有HTTP源 | 设置`<mirrorOf>*</mirrorOf>`并确保镜像URL有效 | | `Failed to validate SSL certificate` | 未配置企业证书 | 导入CA证书到JVM信任库 | ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值