Apex code can be created with any tool that edits
text files, but the standard methods of creating and editing Apex code
are the Setup menu and the Force Platform IDE.
You can interact with Apex Classes through the setup
Develop
Apex Classes choices to get to the page shown below.
Accessing Apex Classes through Setup
This page lists the classes currently available
and gives you the opportunity to create new ones. You can edit, delete
and assign security, described below, through this interface.
When you edit a class, you are placed into a code
editing window, as shown below. This edit window uses color to
highlight different attributes in the code, such as variables and
keywords. This window is similar to the window used to edit Visualforce
pages in Developer Mode.
If you are developing a
trigger with Apex, you start from the detail page for the object that
triggers the code. The Triggers section of the page lists existing
triggers, along with a New button to create new triggers. Both creating a
new trigger and editing an existing trigger or creating a new trigger
puts you into the edit window shown above.
The Force Platform IDE is a plug-in to the
industry standard Eclipse framework. Many developers are already
familiar with the Eclipse, and the Force Platform IDE The Force Platform IDE,
is a highly productive environment for developing and testing Apex
code. You can create and edit both Apex classes and triggers in the
Force Platform IDE. The examples in the remainder of this chapter and
the next use the Force Platform IDE as the development environment for
hands-on examples.
Apex Code and Security
Apex code exists on the Force Platform. As such,
no one can run your Apex code, whether implicitly, with triggers, or
explicitly without first being authenticated users for your
organization.
the Force Platform has a rich security framework, consisting of
component-based security, implemented through profiles, and record-based
security, implemented through record ownership and sharing. All Apex
code executes as system user, with all access to all data and other
components, with one exception, which you will learn about later. A
system user is not limited by any profiles, so component-based security
limitations expressed through profiles are, by default, ignored.
Because of this, a user must have the powerful
Modify All Data permission before they can be granted the Author Apex
permission, required to develop Apex code.
However, you can limit the ability to use a class
to one or more security profiles, so you can prevent groups of users
from using the functionality of those classes in this manner. Although
triggers use Apex code implicitly, a user cannot cause a trigger to fire
if they do not have access to the operations that would cause the
trigger to fire.
You can also add the keywords with sharing in
your definition of an Apex class. These keywords indicate that the
sharing rules for the user who has called the Apex class should be
respected.
Apex Code and Web Services
Apex communicates with the outside world through
the mechanism of web services. You can expose any method in an Apex
class as a web service through the addition of the keyword webservice at the beginning of the method declaration. You can also expose variables within the class with the same keyword.
Once you have created methods designated as web
services, you can generate Web Service Definition Language (WSDL) for
them. The WSDL can be consumed by applications to access the Force
Platform methods.
No comments:
Post a Comment