27.1. Main Data StructuresTo understand the code for the neighboring infrastructure, we first need to describe a few data structures used heavily in the neighboring subsystem, and see how they interact with each other. Most of the definitions for these structures can be found in the file include/net/neighbour.h. Note that the Linux kernel code uses the British spelling neighbour for data structures and functions related to this subsystem. When speaking generically of neighbors, this book sticks to the American spelling, which is the spelling found in RFCs and other official documents.
The neighboring code also uses some other small data structures. For instance, struct pneigh_entry is used by destination-based proxying, and struct neigh_statistics is used to collect statistics about neighboring protocols. The first structure is described in the section "Acting As a Proxy," and the second one is described in the section "Statistics" in Chapter 29. Figure 27-2 also includes the following data structure types, described in greater detail in Chapters 22 and 23: Figure 27-1. Relationship among dst_entry, neighbour, and hh_cache structures
Figure 27-2 shows the relationships between the most important data structures. Right now it might seem a big mess, but it will make much more sense by the end of this chapter. Here are the main points shown in Figure 27-2:
|
Tuesday, October 20, 2009
Section 27.1. Main Data Structures
10.2 Conditional Compilation
| I l@ve RuBoard |
10.2 Conditional Compilation
Through the use of conditional #ifdef DEBUG
If the beginning of the program contains the following directive, the #define DEBUG /* Turn debugging on */ If the program contains the following directive, the #undef DEBUG /* Turn debugging off */ Strictly speaking, the #undef DEBUG is The directive #ifndef causes the #ifndef STACK_SIZE /* Is stack size defined? */ #else reverses the sense of the #ifdef DEBUG A programmer may wish to temporarily remove a section of code. A /***** Comment out this section This generates a syntax error for the fifth line. Why? Because the */ **** End of commented out section */ is not a legal C++ statement. A better method is to use the #ifdef #ifdef UNDEF (Of course the code will be included if anyone defines the symbol The compiler switch CC -DDEBUG -g -o prog prog.cc compiles the program prog.c and includes all the bcc32 -DDEBUG -g -N -eprog.exe prog.c The general form of the option is -Dsymbol or CC -DMAX=10 -o prog prog.c Most C++ compilers automatically define some system-dependent
|
| I l@ve RuBoard |
Chapter 8. Process Control
Chapter 8. Process Control
Exercises |
Section 26.11. Data Areas
26.11. Data AreasApplications often need to read or store data. Depending on the use case, this data may be stored in one of many locations. Consider preferences as an example. Typical products use at least some preferences. The preferences themselves may or may not be defined in the product's plug-ins. For example, if you are reusing plug-ins from different products, it is more convenient to manage the preferences outside the plug-in. In addition, applications often allow users to change preference values or use preferences to store recently opened files, recent chat partners, and so on. These values might be stored uniquely for each user or shared among users. In scenarios where applications operate on distinct datasets, some of the preferences may even relate to the particular data and should be stored or associated with that data. Preferences are just one example, but they illustrate the various scopes and lifecycles that applications have for the data they read and write. Eclipse defines four data areas that capture these characteristics and allows application writers to properly control the scope of their data:
In addition to these Eclipse wide areas, the Runtime defines two locations specifically for each installed plug-in:
Each of these locations is controlled by setting the system properties described before Eclipse starts (e.g., in the config.ini). Locations are URLs. For simplicity, file paths are also accepted and automatically converted to file: URLs. For better control and convenience, there are also a number of predefined symbolic locations that can be used. Note that not all combinations of location type and symbolic value are valid. Table 26-1 details which combinations are possible.
Since the default case is for all locations to be set, valid, and writable, some plug-ins may fail in other setups, even if they are listed as possible. For example, it is unreasonable to expect a plug-in focused on instance data, such as the Resources plug-in, to do much if the instance area is not defined. It is up to plug-in developers to choose the setups they support and design their functions accordingly. Note that each of the locations can be statically marked as read-only by setting the corresponding property osgi.AAA.area.readonly=true, where "AAA" is one of the area names. |
Recipe 11.11. Configuring Actions to Require SSL
Recipe 11.11. Configuring Actions to Require SSLProblemYou want to control if HTTPS is required on a page-by-page basis. SolutionUse the SSLEXT Struts extension. DiscussionThe Struts SSL Extension (SSLEXT), an open source Struts plug-in, SSLEXT enables fine-grained secure protocol control by
The SSLEXT distribution consists of a plug-in class for
For JSP pages, SSLEXT provides custom extensions of Struts tags for SSLEXT works by intercepting the request in its You can download the SSLEXT distribution from the project web site.
Make the following changes to the
If you have accessible JSP pages you want to specify as secured (or <%@ taglib uri="http://www.ebuilt.com/taglib" prefix="sslext"%> Now rebuild and deploy the application. When you click on a link to a
You can use SSLEXT alongside container-managed <security-constraint> You can then use SSLEXT for fine-grained control of the protocol at See AlsoEnabling an application server to support https SSLEXT is hosted on SourceForge at http://sslext.sourceforge.net. Craig McClanahan presents a good argument against switching back to Recipe 11.9 shows how you can specify the |
Section 3.5. Prototype
3.5. Prototype
Every object is linked to a prototype object from which it can inherit properties. All objects created from object literals are linked to Object.prototype, an object that comes standard with JavaScript.
When you make a new object, you can select the object that should be its prototype. The mechanism that JavaScript provides to do this is messy and complex, but it can be significantly simplified. We will add a beget method to the Object function. The beget method creates a new object that uses an old object as its prototype. There will be much more about functions in the next chapter.
if (typeof Object.beget !== 'function') {
Object.beget = function (o) {
var F = function () {};
F.prototype = o;
return new F();
};
}
var another_stooge = Object.beget(stooge);The prototype link has no effect on updating. When we make changes to an object, the object's prototype is not touched:
another_stooge['first-name'] = 'Harry';
another_stooge['middle-name'] = 'Moses';
another_stooge.nickname = 'Moe';
The prototype link is used only in retrieval. If we try to retrieve a property value from an object, and if the object lacks the property name, then JavaScript attempts to retrieve the property value from the prototype object. And if that object is lacking the property, then it goes to its prototype, and so on until the process finally bottoms out with Object.prototype. If the desired property exists nowhere in the prototype chain, then the result is the undefined value. This is called delegation.
The prototype relationship is a dynamic relationship. If we add a new property to a prototype, that property will immediately be visible in all of the objects that are based on that prototype:
stooge.profession = 'actor';
another_stooge.profession // 'actor'
We will see more about the prototype chain in Chapter 6.
22.10 ''Virtual'' methods
| [ Team LiB ] |
22.10 Virtual methodsThe keyword virtual Except in the case of a destructor, corresponding virtual functions have the same name. You don't put the word virtual But, in order to make our code more readable, when we derive off child classes from a parent class with a virtual function, we usually do put virtual One slightly weird thing is that a parent class destructor like ~cProgrammer() The delete
One final point should be mentioned here. Ordinarily, when you have a method virtual void somemethod()
But in the case of a virtual
|
| [ Team LiB ] |