示例ContextHub存储候选项

ContextHub提供了几个可在解决方案中使用的样本存储候选。 为每个示例提供以下信息:

  • 在何处可以找到源代码,以便您打开它进行学习。
  • 如何配置从应用商店创建的商店。
  • 存储数据的结构,以便您能够访问它。
警告

示例存储候选项作为参考配置提供,以帮助您为项目构建自己的专用配置,因此不应直接使用。

aem.segmentation Store Candidate示例

存储已解析和未解析的ContextHub区段。 自动从ContextHub SegmentManager检索区段。

源位置

/libs/settings/cloudsettings/legacy/contexthub/segmentation

基本实现

aem.segmentation存储候选扩展ContextHub.Store.PersistedJSONPStore

配置

创建aem.segmentation存储时,无需提供详细配置。 默认配置指定ContextHub段定义的位置。

{
   "service":{
      "jsonp":false,
      "timeout":1000,
      "path":"/etc/segmentation/contexthub.segment.js"
   }
}

contexthub.geolocation示例存储候选项

contexthub.geolocation范例存储候选项使用Google Maps获取和存储有关客户端位置的信息。

源位置

/libs/settings/cloudsettings/legacy/contexthub/geolocation

基本实现

contexthub.geolocation存储候选扩展ContextHub.Store.PersistedJSONPStore

配置

默认配置指定有关Google服务的信息以及初始经纬度坐标。

{
        "service": {
            "jsonp": false,
            "timeout": 1000,
            "ttl": 1800000,
            "secure": false,
            "host": "maps.googleapis.com",
            "port": 80,
            "path": "/maps/api/geocode/json"
        },

        "eventDeferring": 16,

        "html5coordinatesDiscoveryAPI": {
            "timeout": 30000,
            "ttl": 900000,
            "highAccuracy": false
        },

        "initialValues": {
            "latitude": 37.331375,
            "longitude": -121.893992
        }
    }

数据项

存储使用与以下示例类似的数据树:

{
   "latitude":"37.331375",
   "longitude":"-121.893992"
}
注意

Chrome 50.x中引入的安全策略要求所有地理位置相关调用都通过安全连接进行。 因此,如果AEM也通过https运行,AEM会强制使用https进行geolocation API调用。 否则,使用http以符合同一来源的策略。 有关Chrome中更改的详细信息,请参阅此Google博客文章

contexthub.surferinfo示例存储候选项

存储有关当前客户端环境的信息,如设备、窗口、浏览器、日期和时间。

源位置

/libs/settings/cloudsettings/legacy/contexthub/surferinfo

基本实现

contexthub.datetime存储候选项扩展ContextHub.Store.PersistedStore

配置

默认配置从ContextHub.Store.PersistedStore继承。

数据项

使用此存储候选项的存储具有与以下示例类似的数据树:

{
   "display":{
      "resolution":{
         "width":1440,
         "height":900
      },
      "devicePixelRatio":1,
      "colorDepth":24,
      "nrOfColors":16777216,
      "pixelsPerInch":96,
      "orientation":{
         "mode":"landscape",
         "direction":"normal"
      }
   },
   "window":{
      "dimension":{
         "width":1395,
         "height":652
      },
      "percentageUsage":0.7
   },
   "browser":{
      "version":"39.0",
      "family":"Firefox",
      "userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:39.0) Gecko/20100101 Firefox/39.0"
   },
   "device":{
      "category":"Desktop",
      "type":"Desktop",
      "model":"PC",
      "version":""
   },
   "isMobile":true,
   "os":{
      "name":"Mac OS X",
      "version":"10"
   },
   "year":2015,
   "month":7,
   "day":22,
   "hour":14,
   "minutes":1
}

granite.emulators示例存储候选项

granite.emulators示例存储候选存储有关客户端设备的信息。

源位置

/libs/settings/cloudsettings/legacy/contexthub/emulators

基本实现

contexthub.geolocation存储候选扩展ContextHub.Store.PersistedStore

配置

默认配置包含一个名为defaultEmulators的阵列,它包含有关不同设备的信息。 创建商店时,请根据需要在“详细配置”属性中提供不同的设备用户档案,格式如下例所示:

{
   "defaultEmulators":[
        {
            "id": "iphone-6",
            "title": "iPhone 6",
            "type": "mobile",
            "platform": "iOS",
            "platformVersion": "8.1.3",
            "width": 750,
            "height": 1334,
            "canRotate": true,
            "orientation": "Portrait",
            "device-pixel-ratio": 2
        },
        {
            "id": "iphone-6-plus",
            "title": "iPhone 6 Plus",
            "type": "mobile",
            "platform": "iOS",
            "platformVersion": "8.1.3",
            "width": 1080,
            "height": 1920,
            "canRotate": true,
            "orientation": "Portrait",
            "device-pixel-ratio": 3
        },
        {
            "id": "galaxy-s4",
            "title": "Samsung Galaxy S4",
            "type": "mobile",
            "platform": "Android",
            "platformVersion": "4.4.2 KitKat",
            "width": 1080,
            "height": 1920,
            "canRotate": true,
            "orientation": "Portrait",
            "device-pixel-ratio": 3
        }
    ]
}

数据项

存储数据树类似于以下示例:

{
   "devices":[
      {"id":"native",
      "title":"Native",
      "type":"screen",
      "width":1395,
      "height":374,
      "orientation":"Landscape",
      "platform":"Mac OS X",
      "platformVersion":"10",
      "canRotate":false
      },
      {"id":"ipad-3",
      "title":"iPad 3 / 4 / Air",
      "type":"tablet",
      "platform":"iOS",
      "platformVersion":"8.1.3",
      "width":1536,
      "height":2048,
      "canRotate":true,
      "orientation":"Portrait",
      "device-pixel-ratio":2
      },
      {"id":"iphone-6",
      "title":"iPhone 6",
      "type":"mobile",
      "platform":"iOS",
      "platformVersion":"8.1.3",
      "width":750,
      "height":1334,
      "canRotate":true,
      "orientation":"Portrait",
      "device-pixel-ratio":2
      },
      {"id":"galaxy-s4",
      "title":"Samsung Galaxy S4",
      "type":"mobile",
      "platform":"Android",
      "platformVersion":"4.4.2 KitKat",
      "width":1080,
      "height":1920,
      "canRotate":true,
      "orientation":"Portrait",
      "device-pixel-ratio":3
      }
   ],
   "currentDeviceId":"native",
   "orientations":[
      {"id":"landscape",
      "title":"Landscape"
      },
      {"id":"portrait",
       "title":"Portrait"
      }
   ],
   "currentDevice":{
      "id":"native",
      "title":"Native",
      "type":"screen",
      "width":1395,
      "height":374,
      "orientation":"Landscape",
      "platform":"Mac OS X",
      "platformVersion":"10",
      "canRotate":false
   }
}

granite.用户档案样本存储候选项

存储有关当前用户的信息。

源位置

/libs/settings/cloudsettings/legacy/contexthub/profile

基本实现

contexthub.datetime存储候选项扩展ContextHub.Store.PersistedJSONPStore

配置

使用以下默认配置。 您不应更改此配置。

{
   "service":{
      "jsonp":false,
      "timeout":1000,
      "path":"${contexthub:/store/profile/path}.infinity.json"
   },
   "initialValues":{"path":"/home/users/a/anonymous"}
}

数据项

使用此存储候选项的存储具有与以下示例类似的数据树:

{
   "displayName":"anonymous",
   "path":"/home/users/6/6zavE_DGre6Ad9Y5E0Ba",
   "avatar":"/etc/designs/default/images/social/avatar.png",
   "authorizableId":"anonymous"
}

在此页面上

Adobe Summit Banner

A virtual event April 27-28.

Expand your skills and get inspired.

Register for free
Adobe Summit Banner

A virtual event April 27-28.

Expand your skills and get inspired.

Register for free
Adobe Maker Awards Banner

Time to shine!

Apply now for the 2021 Adobe Experience Maker Awards.

Apply now
Adobe Maker Awards Banner

Time to shine!

Apply now for the 2021 Adobe Experience Maker Awards.

Apply now