tables-urls-views-forms处理工作流程-openstack E版

2024-03-16 10:48

本文主要是介绍tables-urls-views-forms处理工作流程-openstack E版,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

感谢朋友支持本博客,欢迎共同探讨交流,由于能力和时间有限,错误之处在所难免,欢迎指正!

如有转载,请保留源作者博客信息。

Better Me的博客:blog.csdn.net/tantexian

如需交流,欢迎大家博客留言。


tables->urls->views->forms处理工作流程-openstack E版

1、/opt/horizon-2012.1/horizon/dashboards/syspanel/balancers/ views.py
class EditAttachmentsView(tables.DataTableView):
table_class = AttachmentsTable
template_name = 'nova/instances_and_volumes/volumes/attach.html'

def get_object(self): #点击Edit Attachments之后第5步执行 
if not hasattr(self, "_object"): #点击deachments提交按钮后第7步执行 , 接着执行tables里面。
volume_id = self.kwargs['volume_id']
try:
self._object = api.volume_get(self.request, volume_id)
except:
self._object = None
exceptions.handle(self.request,
_('Unable to retrieve volume information.'))
return self._object

def get_data(self): #点击Edit Attachments第4步执行 
try: #点击deachments提交按钮后第6步执行 
volumes = self.get_object()  #此处在调用froms.py中的表单处理之后为tables获取data
attachments = [att for att in volumes.attachments if att] # 跟进到4中的父类get_data实现
except:
attachments = []
exceptions.handle(self.request,
_('Unable to retrieve volume information.'))
return attachments

def get_context_data(self, **kwargs): #点击Edit Attachments第6步执行, 还要继续调用get_object 
context = super(EditAttachmentsView, self).get_context_data(**kwargs)
context['form'] = self.form
context['volume'] = self.get_object()
return context

def handle_form(self): #点击Edit Attachments第2步执行 ,接着第3步执行forms (此处跟踪跳转到2、froms.py中流程解析)
instances = api.nova.server_list(self.request) #点击Attachments提交按钮后第2步执行 ,接着接着第3步执行forms
initial = {'volume_id': self.kwargs["volume_id"], #点击deachments提交按钮后第2步执行 ,接着接着第3步执行forms
'instances': instances} #点击deachments提交按钮后第5步执行 
return AttachForm.maybe_handle(self.request, initial=initial) #在此函数中初始化了instances和volume_id的initial字典,
#以便于在forms中 instance_list = kwargs.get('initial', {}).get('instances', [])取用     

def get(self, request, *args, **kwargs): #点击Edit Attachments第1步执行
self.form, handled = self.handle_form() #点击deachments提交按钮后第4步执行 
if handled:                                                 #每次在点击编辑按钮时候,发来一个url被get捕获,
return handled                                      #然后根据是提交表单还是link进行相应的处理, 接着就调用
handled = self.construct_tables()            #handle_form(self)函数进行处理
if handled:
return handled
context = self.get_context_data(**kwargs)
context['form'] = self.form
if request.is_ajax():
context['hide'] = True
self.template_name = ('nova/instances_and_volumes/volumes'
'/_attach.html')
return self.render_to_response(context)

def post(self, request, *args, **kwargs):
form, handled = self.handle_form() #点击Attachments提交按钮后第1执行 
if handled: #点击deachments提交按钮后第1执行 
return handled
return super(EditAttachmentsView, self).post(request, *args, **kwargs


2、/opt/horizon-2012.1/horizon/dashboards/syspanel/balancers/forms.py
class AttachForm(forms.SelfHandlingForm):
instance = forms.ChoiceField(label="Attach to Instance",
help_text=_("Select an instance to "
"attach to."))
device = forms.CharField(label="Device Name", initial="/dev/vdc",
widget=forms.TextInput(
attrs={'readonly':'readonly'}))
os_type = forms.ChoiceField(label=_("Operating System"),
help_text=_("The OS type of instance"),
choices=[('linux', 'Linux'),
('windows', 'Windows')],
widget=forms.Select(attrs={'class':
'switchable'}))
mount_path =forms.CharField(label="Mount Path",
initial="/data")
def __init__(self, *args, **kwargs): #上一步中views.py的handle_form取得的initial数据,在此处可以pop出来使用
super(AttachForm, self).__init__(*args, **kwargs)
# populate volume_id
volume_id = kwargs.get('initial', {}).get('volume_id', [])#
self.fields['volume_id'] = forms.CharField(widget=forms.HiddenInput(),
initial=volume_id)

# Populate instance choices
instance_list = kwargs.get('initial', {}).get('instances', [])
instances = []
for instance in instance_list:
if instance.status in ACTIVE_STATES:
instances.append((instance.id, '%s (%s)' % (instance.name,
instance.id)))
if instances:
instances.insert(0, ("", _("Select an instance")))
else:
instances = (("", _("No instances available")),)
self.fields['instance'].choices = instances #选择instance的下拉框

def handle(self, request, data):
try:
api.volume_attach(request,   #点击提交按钮时候执行此处函数调用
data['volume_id'],
data['instance'],
data['device'],
data['mount_path'],
data['os_type'])
vol_name = api.volume_get(request, data['volume_id']).display_name

message = (_('Attaching volume %(vol)s to instance '
'%(inst)s at %(dev)s' 'and mount at %(path)s') %
{"vol": vol_name, "inst": data['instance'],
"dev": data['device'],
"path":data['mount_path']})
LOG.info(message)
messages.info(request, message)
except novaclient_exceptions.ClientException, e:
LOG.exception("ClientException in AttachVolume")
messages.error(request,
_('Error attaching volume: %s') % e.message)
return shortcuts.redirect(
"horizon:nova:instances_and_volumes:index") #执行成功返回





3、/opt/horizon-2012.1/horizon/dashboards/syspanel/balancers/tables.py
class AttachmentsTable(tables.DataTable):
instance = tables.Column("server_id", verbose_name=_("Instance"))
device = tables.Column("device")

def get_object_id(self, obj): #点击deachments提交按钮后tables第2步执行 
return obj['id'] #点击deachments提交按钮后tables第5步执行 

def get_object_display(self, obj): #点击deachments提交按钮后tables第3步执行 
vals = {"dev": obj['device'],
"instance": obj['server_id']}
return "Attachment %(dev)s on %(instance)s" % vals

def get_object_by_id(self, obj_id): #点击deachments提交按钮后tables第1步执行 
for obj in self.data: #点击deachments提交按钮后tables第4步执行 
if self.get_object_id(obj) == obj_id:
return obj
raise ValueError('No match found for the id "%s".' % obj_id)

class Meta:
name = "attachments"
table_actions = (DetachVolume,)
row_actions = (DetachVolume,)



4、/opt/horizon-2012.1/horizon/tables/views.py
class DataTableView(MultiTableView):
""" A class-based generic view to handle basic DataTable processing.

Three steps are required to use this view: set the ``table_class``
attribute with the desired :class:`~horizon.tables.DataTable` class;
define a ``get_data`` method which returns a set of data for the
table; and specify a template for the ``template_name`` attribute.

Optionally, you can override the ``has_more_data`` method to trigger
pagination handling for APIs that support it.
"""
    #使用DataTableView必须满足三个条件:1、设定table_class属性
                                                                     #2、定义get_data方法返回数据给tabels
                                                                     #3、指定template_name属性
#本例中        table_class = AttachmentsTable (在AttachmentsTables中定义)
                     template_name = 'nova/instances_and_volumes/volumes/attach.html'


table_class = None
context_object_name = 'table'

def _get_data_dict(self):#解析data
if not self._data:
self._data = {self.table_class._meta.name: self.get_data()} #此处跟踪到3中的AttachmentsTable
return self._data

def get_data(self):
raise NotImplementedError('You must define a "get_data" method on %s.'
% self.__class__.__name__)

def get_tables(self):
tableName = self.request.GET.get("table",None)
if tableName=="volumes":
self.template_name = 'horizon/common/_volumes.html'
self.table_class = instances_and_volumes.volumes.tables.VolumesTable
elif tableName=="instances":
self.template_name = 'horizon/common/_instances.html'
self.table_class = instances_and_volumes.instances.tables.InstancesTable
elif tableName =="images":
self.template_name = 'horizon/common/_images.html'
self.table_class = images_and_snapshots.images.tables.ImagesTable
elif tableName == "snapshots":
self.template_name = 'horizon/common/_snapshots.html'
self.table_class = images_and_snapshots.snapshots.tables.SnapshotsTable
elif tableName == "volume_snapshots":
self.template_name = 'horizon/common/_volume_snapshots.html'
self.table_class = images_and_snapshots.volume_snapshots.tables.VolumeSnapshotsTable
elif tableName == "keypairs":
self.template_name = 'horizon/common/_keypairs.html'
self.table_class = access_and_security.keypairs.tables.KeypairsTable
elif tableName == "security_groups":
self.template_name = 'horizon/common/_security_groups.html'
self.table_class = access_and_security.security_groups.tables.SecurityGroupsTable
elif tableName == "floating_ips":
self.template_name = 'horizon/common/_floating_ips.html'
self.table_class = access_and_security.floating_ips.tables.FloatingIPsTable
elif tableName == "devices":
self.table_class = elastic_load_balancing.devices.tables.DevicesTable
self.template_name = 'horizon/common/_devices.html'
elif tableName == "serverfarms":
self.table_class = elastic_load_balancing.serverfarms.tables.ServerfarmsTable
self.template_name = 'horizon/common/_serverfarms.html'

if not self._tables:
self._tables = {self.table_class._meta.name: self.get_table()}
return self._tables

def get_table(self):
if not self.table_class:
raise AttributeError('You must specify a DataTable class for the '
'"table_class" attribute on %s.'
% self.__class__.__name__)
if not hasattr(self, "table"):
self.table = self.table_class(self.request, **self.kwargs)
return self.table

def get_context_data(self, **kwargs):
context = super(DataTableView, self).get_context_data(**kwargs)
context[self.context_object_name] = self.table
return context


5、/opt/horizon-2012.1/horizon/base.py
class DataTable(object):
""" A class which defines a table with all data and associated actions.

.. attribute:: name

String. Read-only access to the name specified in the
table's Meta options.

.. attribute:: multi_select

Boolean. Read-only access to whether or not this table
should display a column for multi-select checkboxes.

.. attribute:: data

Read-only access to the data this table represents.

.. attribute:: filtered_data

Read-only access to the data this table represents, filtered by
the :meth:`~horizon.tables.FilterAction.filter` method of the table's
:class:`~horizon.tables.FilterAction` class (if one is provided)
using the current request's query parameters.
"""
__metaclass__ = DataTableMetaclass

def __init__(self, request, data=None, **kwargs):
self._meta.request = request
self._meta.data = data
self.kwargs = kwargs

# Create a new set
columns = []
for key, _column in self._columns.items():
column = copy.copy(_column)
column.table = self
columns.append((key, column))
self.columns = SortedDict(columns)
self._populate_data_cache()

# Associate these actions with this table
for action in self.base_actions.values():
action.table = self

def __unicode__(self):
return unicode(self._meta.verbose_name)

def __repr__(self):
return '<%s: %s>' % (self.__class__.__name__, self.name)

@property
def name(self):
return self._meta.name

@property
def data(self):
return self._meta.data

@data.setter
def data(self, data):
self._meta.data = data

@property
def multi_select(self):
return self._meta.multi_select

@property
def filtered_data(self):
if not hasattr(self, '_filtered_data'):
self._filtered_data = self.data
if self._meta.filter and self._meta._filter_action:
action = self._meta._filter_action
filter_string = self.get_filter_string()
request_method = self._meta.request.method
if filter_string and request_method == action.method:
self._filtered_data = action.filter(self,
self.data,
filter_string)
return self._filtered_data

def get_filter_string(self):
filter_action = self._meta._filter_action
param_name = filter_action.get_param_name()
filter_string = self._meta.request.POST.get(param_name, '')
return filter_string

def _populate_data_cache(self):
self._data_cache = {}
# Set up hash tables to store data points for each column
for column in self.get_columns():
self._data_cache[column] = {}

def _filter_action(self, action, request, datum=None):
try:
# Catch user errors in permission functions here
return action._allowed(request, datum)
except Exception:
LOG.exception("Error while checking action permissions.")
return None

def render(self):
""" Renders the table using the template from the table options. """
table_template = template.loader.get_template(self._meta.template)
param_dict=self._meta.request.GET
rowsinfo=self.get_rows();
after_range_num=4
befor_range_num=3
perpage= int(param_dict.get("perpage",10))
perpage_list=[10,20,30]
paginator = Paginator(rowsinfo,perpage)
try:
page=int(param_dict.get("page",1))
if page<1:
page=1
elif page>paginator.num_pages:
page=paginator.num_pages    
except ValueError:
page=1
try:
paginatorRows=paginator.page(page)
except(EmptyPage,InvalidPage,PageNotAnInteger):
paginatorRows=paginator.page(1)
if page >= after_range_num:
page_range = paginator.page_range[page-after_range_num:page+befor_range_num]
else:
page_range = paginator.page_range[0:int(page)+befor_range_num]
extra_context = {self._meta.context_var_name: self,"rows":paginatorRows,"page_range":page_range,"perpage":perpage,"paginator_num_list":perpage_list}
context = template.RequestContext(self._meta.request,extra_context)
return table_template.render(context)

def get_absolute_url(self):
""" Returns the canonical URL for this table.

This is used for the POST action attribute on the form element
wrapping the table. In many cases it is also useful for redirecting
after a successful action on the table.

For convenience it defaults to the value of
``request.get_full_path()`` with any query string stripped off,
e.g. the path at which the table was requested.
"""
full_path=self._meta.request.get_full_path()
if("paginator" in full_path):
return full_path.partition('paginator')[0]
return full_path.partition('?')[0]

def get_empty_message(self):
""" Returns the message to be displayed when there is no data. """
return _("No items to display.")

def get_object_by_id(self, lookup):
"""
Returns the data object from the table's dataset which matches
the ``lookup`` parameter specified. An error will be raised if
the match is not a single data object.

Uses :meth:`~horizon.tables.DataTable.get_object_id` internally.
"""
matches = [datum for datum in self.data if
self.get_object_id(datum) == lookup]
if len(matches) > 1:
raise ValueError("Multiple matches were returned for that id: %s."
% matches)
if not matches:
raise exceptions.Http302(self.get_absolute_url(),
_('No match returned for the id "%s".')
% lookup)
return matches[0]

def get_table_actions(self):
""" Returns a list of the action instances for this table. """
bound_actions = [self.base_actions[action.name] for
action in self._meta.table_actions]
return [action for action in bound_actions if
self._filter_action(action, self._meta.request)]

def get_row_actions(self, datum):
""" Returns a list of the action instances for a specific row. """
bound_actions = []
for action in self._meta.row_actions:
# Copy to allow modifying properties per row
bound_action = copy.copy(self.base_actions[action.name])
bound_action.attrs = copy.copy(bound_action.attrs)
bound_action.datum = datum
# Remove disallowed actions.
if not self._filter_action(bound_action,
self._meta.request,
datum):
continue
# Hook for modifying actions based on data. No-op by default.
bound_action.update(self._meta.request, datum)
# Pre-create the URL for this link with appropriate parameters
if issubclass(bound_action.__class__, LinkAction):
bound_action.bound_url = bound_action.get_link_url(datum)
bound_actions.append(bound_action)
return bound_actions

def render_table_actions(self):
""" Renders the actions specified in ``Meta.table_actions``. """
template_path = self._meta.table_actions_template
table_actions_template = template.loader.get_template(template_path)
bound_actions = self.get_table_actions()
extra_context = {"table_actions": bound_actions}
if self._meta.filter:
extra_context["filter"] = self._meta._filter_action
context = template.RequestContext(self._meta.request, extra_context)
return table_actions_template.render(context)

def render_row_actions(self, datum):
"""
Renders the actions specified in ``Meta.row_actions`` using the
current row data. """
template_path = self._meta.row_actions_template
row_actions_template = template.loader.get_template(template_path)
bound_actions = self.get_row_actions(datum)
extra_context = {"row_actions": bound_actions,
"row_id": self.get_object_id(datum)}
context = template.RequestContext(self._meta.request, extra_context)
return row_actions_template.render(context)

@staticmethod
def parse_action(action_string):
"""
Parses the ``action`` parameter (a string) sent back with the
POST data. By default this parses a string formatted as
``{{ table_name }}__{{ action_name }}__{{ row_id }}`` and returns
each of the pieces. The ``row_id`` is optional.
"""
if action_string:
bits = action_string.split(STRING_SEPARATOR)
bits.reverse()
table = bits.pop()
action = bits.pop()
try:
object_id = bits.pop()
except IndexError:
object_id = None
return table, action, object_id

def take_action(self, action_name, obj_id=None, obj_ids=None):
"""
Locates the appropriate action and routes the object
data to it. The action should return an HTTP redirect
if successful, or a value which evaluates to ``False``
if unsuccessful.
"""
# See if we have a list of ids
obj_ids = obj_ids or self._meta.request.POST.getlist('object_ids')
action = self.base_actions.get(action_name, None)
if not action or action.method != self._meta.request.method:
# We either didn't get an action or we're being hacked. Goodbye.
return None

# Meanhile, back in Gotham...
if not action.requires_input or obj_id or obj_ids:
if obj_id:
obj_id = self.sanitize_id(obj_id)
if obj_ids:
obj_ids = [self.sanitize_id(i) for i in obj_ids]
# Single handling is easy
if not action.handles_multiple:
response = action.single(self, self._meta.request, obj_id)
# Otherwise figure out what to pass along
else:
# Preference given to a specific id, since that implies
# the user selected an action for just one row.
if obj_id:
obj_ids = [obj_id]
response = action.multiple(self, self._meta.request, obj_ids)
return response
elif action and action.requires_input and not (obj_id or obj_ids):
messages.info(self._meta.request,
_("Please select a row before taking that action."))
return None

@classmethod
def check_handler(cls, request):
""" Determine whether the request should be handled by this table. """
if request.method == "POST" and "action" in request.POST:
table, action, obj_id = cls.parse_action(request.POST["action"])
elif "table" in request.GET and "action" in request.GET:
table = request.GET["table"]
action = request.GET["action"]
obj_id = request.GET.get("obj_id", None)
else:
table = action = obj_id = None
return table, action, obj_id

def maybe_preempt(self):
"""
Determine whether the request should be handled by a preemptive action
on this table or by an AJAX row update before loading any data.
"""
request = self._meta.request
table_name, action_name, obj_id = self.check_handler(request)

if table_name == self.name:
# Handle AJAX row updating.
new_row = self._meta.row_class(self)
if new_row.ajax and new_row.ajax_action_name == action_name:
try:
datum = new_row.get_data(request, obj_id)
new_row.load_cells(datum)
error = False
except:
datum = None
error = exceptions.handle(request, ignore=True)
if request.is_ajax():
if not error:
return HttpResponse(new_row.render())
else:
return HttpResponse(status=error.status_code)

preemptive_actions = [action for action in
self.base_actions.values() if action.preempt]
if action_name:
for action in preemptive_actions:
if action.name == action_name:
handled = self.take_action(action_name, obj_id)
if handled:
return handled
return None

def maybe_handle(self):
"""
Determine whether the request should be handled by any action on this
table after data has been loaded.
"""
request = self._meta.request
table_name, action_name, obj_id = self.check_handler(request)
if table_name == self.name and action_name:
return self.take_action(action_name, obj_id)
return None

def sanitize_id(self, obj_id):
""" Override to modify an incoming obj_id to match existing
API data types or modify the format.
"""
return obj_id

def get_object_id(self, datum):
""" Returns the identifier for the object this row will represent.

By default this returns an ``id`` attribute on the given object,
but this can be overridden to return other values.

.. warning::

Make sure that the value returned is a unique value for the id
otherwise rendering issues can occur.
"""
return datum.id

def get_object_display(self, datum):
""" Returns a display name that identifies this object.

By default, this returns a ``name`` attribute from the given object,
but this can be overriden to return other values.
"""
return datum.name

def has_more_data(self):
"""
Returns a boolean value indicating whether there is more data
available to this table from the source (generally an API).

The method is largely meant for internal use, but if you want to
override it to provide custom behavior you can do so at your own risk.
"""
return self._meta.has_more_data

def get_marker(self):
"""
Returns the identifier for the last object in the current data set
for APIs that use marker/limit-based paging.
"""
return http.urlquote_plus(self.get_object_id(self.data[-1]))

def calculate_row_status(self, statuses):
"""
Returns a boolean value determining the overall row status
based on the dictionary of column name to status mappings passed in.

By default, it uses the following logic:

#. If any statuses are ``False``, return ``False``.
#. If no statuses are ``False`` but any or ``None``, return ``None``.
#. If all statuses are ``True``, return ``True``.

This provides the greatest protection against false positives without
weighting any particular columns.

The ``statuses`` parameter is passed in as a dictionary mapping
column names to their statuses in order to allow this function to
be overridden in such a way as to weight one column's status over
another should that behavior be desired.
"""
values = statuses.values()
if any([status is False for status in values]):
return False
elif any([status is None for status in values]):
return None
else:
return True

def get_row_status_class(self, status):
"""
Returns a css class name determined by the status value. This class
name is used to indicate the status of the rows in the table if
any ``status_columns`` have been specified.
"""
if status is True:
return "status_up"
elif status is False:
return "status_down"
else:
return "status_unknown"

def get_columns(self):
""" Returns this table's columns including auto-generated ones."""
return self.columns.values()

def get_rows(self):
""" Return the row data for this table broken out by columns. """
rows = []
try:
for datum in self.filtered_data:
rows.append(self._meta.row_class(self, datum))
except:
# Exceptions can be swallowed at the template level here,
# re-raising as a TemplateSyntaxError makes them visible.
LOG.exception("Error while rendering table rows.")
exc_info = sys.exc_info()
raise template.TemplateSyntaxError, exc_info[1], exc_info[2]
return rows

这篇关于tables-urls-views-forms处理工作流程-openstack E版的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/815233

相关文章

Ubuntu 24.04启用root图形登录的操作流程

《Ubuntu24.04启用root图形登录的操作流程》Ubuntu默认禁用root账户的图形与SSH登录,这是为了安全,但在某些场景你可能需要直接用root登录GNOME桌面,本文以Ubuntu2... 目录一、前言二、准备工作三、设置 root 密码四、启用图形界面 root 登录1. 修改 GDM 配

MyBatis-Plus通用中等、大量数据分批查询和处理方法

《MyBatis-Plus通用中等、大量数据分批查询和处理方法》文章介绍MyBatis-Plus分页查询处理,通过函数式接口与Lambda表达式实现通用逻辑,方法抽象但功能强大,建议扩展分批处理及流式... 目录函数式接口获取分页数据接口数据处理接口通用逻辑工具类使用方法简单查询自定义查询方法总结函数式接口

SpringBoot结合Docker进行容器化处理指南

《SpringBoot结合Docker进行容器化处理指南》在当今快速发展的软件工程领域,SpringBoot和Docker已经成为现代Java开发者的必备工具,本文将深入讲解如何将一个SpringBo... 目录前言一、为什么选择 Spring Bootjavascript + docker1. 快速部署与

Python使用vllm处理多模态数据的预处理技巧

《Python使用vllm处理多模态数据的预处理技巧》本文深入探讨了在Python环境下使用vLLM处理多模态数据的预处理技巧,我们将从基础概念出发,详细讲解文本、图像、音频等多模态数据的预处理方法,... 目录1. 背景介绍1.1 目的和范围1.2 预期读者1.3 文档结构概述1.4 术语表1.4.1 核

Spring Boot @RestControllerAdvice全局异常处理最佳实践

《SpringBoot@RestControllerAdvice全局异常处理最佳实践》本文详解SpringBoot中通过@RestControllerAdvice实现全局异常处理,强调代码复用、统... 目录前言一、为什么要使用全局异常处理?二、核心注解解析1. @RestControllerAdvice2

Spring Security中用户名和密码的验证完整流程

《SpringSecurity中用户名和密码的验证完整流程》本文给大家介绍SpringSecurity中用户名和密码的验证完整流程,本文结合实例代码给大家介绍的非常详细,对大家的学习或工作具有一定... 首先创建了一个UsernamePasswordAuthenticationTChina编程oken对象,这是S

SpringBoot集成LiteFlow工作流引擎的完整指南

《SpringBoot集成LiteFlow工作流引擎的完整指南》LiteFlow作为一款国产轻量级规则引擎/流程引擎,以其零学习成本、高可扩展性和极致性能成为微服务架构下的理想选择,本文将详细讲解Sp... 目录一、LiteFlow核心优势二、SpringBoot集成实战三、高级特性应用1. 异步并行执行2

Android ViewBinding使用流程

《AndroidViewBinding使用流程》AndroidViewBinding是Jetpack组件,替代findViewById,提供类型安全、空安全和编译时检查,代码简洁且性能优化,相比Da... 目录一、核心概念二、ViewBinding优点三、使用流程1. 启用 ViewBinding (模块级

Spring @Scheduled注解及工作原理

《Spring@Scheduled注解及工作原理》Spring的@Scheduled注解用于标记定时任务,无需额外库,需配置@EnableScheduling,设置fixedRate、fixedDe... 目录1.@Scheduled注解定义2.配置 @Scheduled2.1 开启定时任务支持2.2 创建

SpringBoot整合Flowable实现工作流的详细流程

《SpringBoot整合Flowable实现工作流的详细流程》Flowable是一个使用Java编写的轻量级业务流程引擎,Flowable流程引擎可用于部署BPMN2.0流程定义,创建这些流程定义的... 目录1、流程引擎介绍2、创建项目3、画流程图4、开发接口4.1 Java 类梳理4.2 查看流程图4