gae怎么打开谷歌学术?
In the first part of this series, we went through the basic environment GAE offers the developer. You must be excited to get yourself into coding your first application and seeing it live! Setting up the IDE for GAE development is a fairly simple task: simply install the GAE plugin in Eclipse version of your choice and you are good to start development on GAE.
在本系列的第一部分中 ,我们介绍了GAE为开发人员提供的基本环境。 您必须激动自己才能编写第一个应用程序并开始观看它! 设置IDE进行GAE开发是一项相当简单的任务:只需在您选择的Eclipse版本中安装GAE插件,便可以开始在GAE上进行开发了。
But before we actually get into APIs and services GAE can offer, let’s understand the application structure and configuration which affects how your application will work in runtime. This will also take us through some interesting aspects of the environment, and lead to better design and planning of the application.
但是在实际了解GAE可以提供的API和服务之前,让我们了解影响应用程序在运行时工作方式的应用程序结构和配置。 这还将带我们了解环境中的一些有趣方面,并导致更好地设计和规划应用程序。
The deployment descriptor of a web app on GAE as very much like any other web application, you configure Servlet and JSP URL mappings in the same fashion or URLs are secured and roles specified the same way as in a web application. Filters and error handlers can also be leveraged in the same fashion. A few minor differences to note: EJB/JNDI and the like aren’t supported, obvious since we don’t have an EJB container. The load-on-start-up does not load the servlet at application start-up but when web server receives the first request. Some of the usual configurations like configuring a ServletContextListener or load-on-startup parameters can be configured, but are placed in appengine-web.xml.
与任何其他Web应用程序一样,GAE上Web应用程序的部署描述符与您以相同的方式配置Servlet和JSP URL映射,或者以与Web应用程序中相同的方式来保护URL和指定角色。 过滤器和错误处理程序也可以以相同的方式利用。 需要注意的一些细微差异:不支持EJB / JNDI之类,这很明显,因为我们没有EJB容器。 启动时加载不会在应用程序启动时加载servlet,而是在Web服务器收到第一个请求时加载。 可以配置一些常规配置,例如配置ServletContextListener或启动时加载参数,但可以将它们放置在appengine-web.xml中。
appengine-web.xml file is a mandatory requirement for a GAE web app, and at bare minimum it houses the application id and version. While deploying the application, the version number is used to decide whether to deploy to existing version if a match is found, or to deploy to a new version if no match is found. This is particularly helpful to have multiple instances of the application for testing while not touching the live instance. Though note that the datastore is shared across versions of an application.
appengine-web.xml文件是GAE Web应用程序的强制性要求,并且至少包含应用程序ID和版本。 部署应用程序时,如果发现匹配项,则使用版本号来决定是部署到现有版本,还是如果找不到匹配项,则使用版本号来决定部署到新版本。 这对于在不接触实时实例的情况下具有多个应用程序实例进行测试特别有用。 不过请注意,数据存储区在应用程序的各个版本之间共享。
<?xml version="1.0" encoding="utf-8"?> <appengine-web-app xmlns="http://appengine.google.com/ns/1.0"> <application>my-app</application> <version>2</version> </appengine-web-app>In the above XML, the my-app application’s version 2 is being deployed.
在上述XML中,正在部署my-app应用程序的版本2。
Static content can be marked by <static-files> tag so that all static content is served by a separate web server which is a good practice in web applications as you might be aware. The static content does not change much in lifecycle of an application and serving by the static server leaves the container/app server to focus on dynamic content, which it is best at. This includes the expression first taken into account, and even if you don’t specify a default once are applied, followed by application of exclude expression.
可以用<static-files>标记标记静态内容,以便所有静态内容都由单独的Web服务器提供服务,这可能是您意识到的Web应用程序中的一个好习惯。 静态内容在应用程序的生命周期中变化不大,并且由静态服务器提供服务使容器/应用程序服务器专注于动态内容,这是最擅长的。 这包括首先考虑到的表达式,即使您未指定默认值也要应用一次,然后再应用排除表达式。
The following example marks all jpg files as static except for those in the classes directory. A similar expression can be defined for resource files with the </resource-files> tag. The expiration parameter inside the include tag sets the expiration of cache for browsers, for example in the below example set to 36 hours.
以下示例将所有jpg文件标记为静态,除了classes目录中的文件。 可以使用</ resource-files>标记为资源文件定义类似的表达式。 include标签内的expiration参数设置浏览器缓存的过期时间,例如在以下示例中设置为36小时。
<static-files> <include path="/**.jpg" expiration="1d 12h /> <exclude path="/classes/**.jpg" /> </static-files>System and environment level properties can be set using the following tags:
可以使用以下标记设置系统和环境级别的属性:
<system-properties> <property name="my-app.user.timeout" value="300" /> </system-properties> <env-variables> <env-var name="ENV_VAR_NAME" value="ENV_VAR_VALUE" /> </env-variables>There are certain inbound services like mail or XMPP which are by default disabled. If you need to enable them, you need to add them specifically to appengine-web.xml like in the example below.
某些入站服务(例如邮件或XMPP)默认情况下处于禁用状态。 如果需要启用它们,则需要将它们专门添加到appengine-web.xml中,如下例所示。
<inbound-services> <service>channel_presence</service> </inbound-services>Services
Description
Enables incoming emails
channel_presence
Enables clients to use channel and enables notification
warmup
Used to warmup of certain application components at startup
xmpp_presence
xmpp_message
xmpp_subscribe
XMPP related services
服务
描述
邮件
启用传入电子邮件
channel_presence
使客户端能够使用频道并启用通知
暖身
用于在启动时预热某些应用程序组件
xmpp_presence
xmpp_message
xmpp_subscribe
XMPP相关服务
GAE offers a session mechanism using the servlet session interface, but is disabled by default and to enable it you need to add the following to appengine-web.xml:
GAE使用Servlet会话接口提供了一种会话机制,但默认情况下处于禁用状态,要启用该机制,您需要在appengine-web.xml中添加以下内容:
<sessions-enabled>true</sessions-enabled>The data of a session is stored in datastore with entities of type _ah_SESSION and is also stored in MEMCACHE for faster access. You can reduce the latency by marking the session data written to datastore to be asynchronous. The session data writing to datastore is done by a queue, if unspecified is “default” queue, but can be configured to other names.
会话的数据存储在具有_ah_SESSION类型的实体的数据存储中,并且还存储在MEMCACHE中,以加快访问速度。 您可以通过将写入数据存储区的会话数据标记为异步来减少延迟。 如果未指定“默认”队列,则将会话数据写入数据存储是通过队列完成的,但是可以将其配置为其他名称。
<async-session-persistence enabled="true" queue-name="sessionQueue"/>Indexes are used to speed up retrieval of data. In GAE the indexes can be defined by the developer/user and are also auto generated by the development server.
索引用于加速数据检索。 在GAE中,索引可以由开发人员/用户定义,也可以由开发服务器自动生成。
File name
Details
WEB-INF/datastore-indexes.xml
Indexes defined by user/developer
WEB-INF/appengine-generated/datastore-indexes-auto.xml
Indexes auto generated by development server when queries are made to data
文档名称
细节
WEB-INF / datastore-indexes.xml
用户/开发人员定义的索引
WEB-INF / appengine-generated / datastore-indexes-auto.xml
对数据进行查询时,开发服务器自动生成的索引
Let’s look at structure of a typical datastore-indexes.xml and two key aspects it controls.
让我们看一下典型的datastore-indexes.xml的结构及其控制的两个关键方面。
<?xml version="1.0" encoding="utf-8"?> <datastore-indexes autoGenerate="true"> <datastore-index kind="Employee" ancestor="false"> <property name="employeeNumber" direction="asc" /> </datastore-index> </datastore-indexes>First look at the child element, <datastore-index>. This tag defines the Entity kind for which you will define index. The ancestor attribute shall be true if the index supports filtering of entity by parent entity group. Property tag defines name of the property wich is indexes and direction which can be “asc” or “dsc”.
首先查看子元素<datastore-index>。 此标记定义您将为其定义索引的实体类型。 如果索引支持按父实体组过滤实体,则祖先属性应为true。 属性标签定义了属性的名称,该属性的名称是索引和方向,可以是“ asc”或“ dsc”。
The second aspect which is defined in the parent tag of the file i.e. inside <datastore-indexes> controls how the auto-generated indexes are handled.
在文件的父标记(即<datastore-indexes>内部)中定义的第二个方面控制如何处理自动生成的索引。
autoGenerate=”true”
– By default true If user defined index file does not exist.
– Updated when a development server hits a query for which no index is defined in either index file, and adds index to datastore-indexes-auto.xml
– When you upload application to GAE, both index files are used to build indexes on GAE
autoGenerate=”false”
– Indexes in datastore-indexes-auto.xml are ignored
– When application hits a query for which there is no index defined in datastore-indexes.xml an exception is raised
autoGenerate =“ true”
–默认情况下为true如果用户定义的索引文件不存在。
–当开发服务器点击在两个索引文件中均未定义索引的查询并将其添加到datastore-indexes-auto.xml中时更新
–将应用程序上载到GAE时,两个索引文件都用于在GAE上建立索引
autoGenerate =“ false”
–忽略datastore-indexes-auto.xml中的索引
–当应用程序命中datastore-indexes.xml中未定义索引的查询时,将引发异常
Cron is a very familiar word for UNIX-like OS users and a powerful tool to get some tasks done at intervals, periodically or just one-off cases, but fires on its own by system at the time/interval specified. GAE crons are simple to use and plug very well in your web app. The job is defined in a servlet, and you configure URL for it in deployment descriptor. URL for job and schedule are only two mandatory requirements to configure the cron in cron.xml. If you don’t define target, it will use the default app instance, but you can choose to fire the cron against a specific version of instance to run against. Cron file can have upto 20 crons and the XML file resides in WEB-INF directory of your application.
对于像UNIX这样的OS用户,Cron是一个非常熟悉的词,它是一种功能强大的工具,可以按一定间隔,定期或仅一次完成某些任务,但可以在指定的时间/间隔由系统自行触发。 GAE crons易于使用,并且可以很好地插入您的Web应用程序。 作业是在Servlet中定义的,您可以在部署描述符中为其配置URL。 作业和计划的URL只是在cron.xml中配置cron的两个强制性要求。 如果您未定义目标,它将使用默认的应用程序实例,但是您可以选择针对特定版本的实例触发cron。 Cron文件最多可以包含20 Cron,XML文件位于应用程序的WEB-INF目录中。
Schedule format is almost English like “every 6 hours” or “1st Tuesday of jan,apr,jun,oct 05:00”
时间表格式几乎是英文的,例如“每6小时一次”或“ 1月,4月,6月,10月15:00的第一个星期二”
<?xml version="1.0" encoding="UTF-8"?> <cronentries> <cron> <url>/DailyReport</url> <description>Optional Desc goes here</description> <schedule>every day 11:30</schedule> <timezone>America/New_York</timezone> <target>version-2</target> </cron> </cronentries>As long as the entry in “url” of cron is accessible as a URL of web application, the cron job should run fine. The next thing you need to take care of is not to allow access to the cron by any user other than the system/admin, by adding the URL and corresponding admin roles who can access it in the deployment descriptor.
只要可以将cron的“ url”中的条目作为Web应用程序的URL进行访问,那么cron作业就可以正常运行。 接下来需要注意的是,通过在部署描述符中添加URL和可以访问它的相应管理员角色,不允许系统/管理员以外的任何用户访问cron。
We have understood pretty much all of GAE configurations and environment so far. We didn’t cover backend and task queue configurations as they would be more appropriately explained in context of those special topics. We are ready to dive now, after ground and sky demo! So keep a watch on on next part and setup your IDE and brains for some hands on!
到目前为止,我们几乎已经了解了所有GAE配置和环境。 我们没有介绍后端和任务队列配置,因为在这些特殊主题的上下文中会更恰当地解释它们。 在地面和天空演示之后,我们现在准备潜水! 因此,请继续关注下一部分,并设置您的IDE和大脑以进行实际操作!
翻译自: https://www.sitepoint.com/understanding-google-app-engine-gae-java-api-part-2-setup-and-introduction/
gae怎么打开谷歌学术?
相关资源:gae-boilerplate:Google App Engine样板-源码