Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Events
Videos
Audiobooks
Packt Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds

How-To Tutorials

7018 Articles
article-image-building-applications-spring-data-redis
Packt
03 Dec 2012
9 min read
Save for later

Building Applications with Spring Data Redis

Packt
03 Dec 2012
9 min read
(For more resources related on Spring, see here.) Designing a Redis data model The most important rules of designing a Redis data model are: Redis does not support ad hoc queries and it does not support relations in the same way than relational databases. Thus, designing a Redis data model is a total different ballgame than designing the data model of a relational database. The basic guidelines of a Redis data model design are given as follows: Instead of simply modeling the information stored in our data model, we have to also think how we want to search information from it. This often leads to a situation where we have to duplicate data in order to fulfill the requirements given to us. Don't be afraid to do this. We should not concentrate on normalizing our data model. Instead, we should combine the data that we need to handle as an unit into an aggregate. Since Redis does not support relations, we have to design and implement these relations by using the supported data structures. This means that we have to maintain these relations manually when they are changed. Because this might require a lot of effort and code, it could be wise to simply duplicate the information instead of using relations. It is always wise to spend a moment to verify that we are using the correct tool for the job. NoSQL Distilled, by Martin Fowler contains explanations of different NoSQL databases and their use cases, and can be found at http://martinfowler.com/books/nosql.html. Redis supports multiple data structures. However, one question remained unanswered: which data structure should we use for our data? This question is addressed in the following table: Data type Description String A string is good choice for storing information that is already converted to a textual form. For instance, if we want to store HTML, JSON, or XML, a string should be our weapon of choice. List A list is a good choice if we will access it only near the start or end. This means that we should use it for representing queues or stacks. Set We should use a set if we need to get the size of a collection or check if a certain item belongs to it. Also, if we want to represent relations, a set is a good choice (for example, "who are John's friends?"). Sorted set Sorted sets should be used in the same situations as sets when the ordering of items is important to us. Hash A hash is a perfect data structure for representing complex objects. Key components Spring Data Redis provides certain components that are the cornerstones of each application that uses it. This section provides a brief introduction to the components that we will later use to implement our example applications. Atomic counters Atomic counters are for Redis what sequences are for relational databases. Atomic counters guarantee that the value received by a client is unique. This makes these counters a perfect tool for creating unique IDs to our data that is stored in Redis. At the moment, Spring Data Redis offers two atomic counters: RedisAtomicInteger and RedisAtomicLong . These classes provide atomic counter operations for integers and longs. RedisTemplate The RedisTemplate<K,V> class is the central component of Spring Data Redis. It provides methods that we can use to communicate with a Redis instance. This class requires that two type parameters are given during its instantiation: the type of used Redis key and the type of the Redis value. Operations The RedisTemplate class provides two kinds of operations that we can use to store, fetch, and remove data from our Redis instance: Operations that require that the key and the value are given every time an operation is performed. These operations are handy when we have to execute a single operation by using a key and a value. Operations that are bound to a specific key that is given only once. We should use this approach when we have to perform multiple operations by using the same key. The methods that require that a key and value is given every time an operation is performed are described in following list: HashOperations<K,HK,HV> opsForHash(): This method returns the operations that are performed on hashes ListOperations<K,V> opsForList(): This method returns the operations performed on lists SetOperations<K,V> opsForSet(): This method returns the operations performed on sets ValueOperations<K,V> opsForValue(): This method returns the operations performed on simple values ZSetOperations<K,HK,HV> opsForZSet(): This method returns the operations performed on sorted sets The methods of the RedisTemplate class that allow us to execute multiple operations by using the same key are described in following list: BoundHashOperarations<K,HK,HV> boundHashOps(K key): This method returns hash operations that are bound to the key given as a parameter BoundListOperations<K,V> boundListOps(K key): This method returns list operations bound to the key given as a parameter BoundSetOperations<K,V> boundSetOps(K key):: This method returns set operations, which are bound to the given key BoundValueOperations<K,V> boundValueOps(K key): This method returns operations performed to simple values that are bound to the given key BoundZSetOperations<K,V> boundZSetOps(K key): This method returns operations performed on sorted sets that are bound to the key that is given as a parameter The differences between these operations become clear to us when we start building our example applications. Serializers Because the data is stored in Redis as bytes, we need a method for converting our data to bytes and vice versa. Spring Data Redis provides an interface called RedisSerializer<T>, which is used in the serialization process. This interface has one type parameter that describes the type of the serialized object. Spring Data Redis provides several implementations of this interface. These implementations are described in the following table: Serializer Description GenericToStringSerializer<T> Serializes strings to bytes and vice versa. Uses the Spring ConversionService to transform objects to strings and vice versa. JacksonJsonRedisSerializer<T> Converts objects to JSON and vice versa. JdkSerializationRedisSerializer Provides Java based serialization to objects. OxmSerializer Uses the Object/XML mapping support of Spring Framework 3. StringRedisSerializer  Converts strings to bytes and vice versa. We can customize the serialization process of the RedisTemplate class by using the described serializers. The RedisTemplate class provides flexible configuration options that can be used to set the serializers that are used to serialize value keys, values, hash keys, hash values, and string values. The default serializer of the RedisTemplate class is JdkSerializationRedisSerializer. However, the string serializer is an exception to this rule. StringRedisSerializer is the serializer that is by default used to serialize string values. Implementing a CRUD application This section describes two different ways for implementing a CRUD application that is used to manage contact information. First, we will learn how we can implement a CRUD application by using the default serializer of the RedisTemplate class. Second, we will learn how we can use value serializers and implement a CRUD application that stores our data in JSON format. Both of these applications will also share the same domain model. This domain model consists of two classes: Contact and Address. We removed the JPA specific annotations from them We use these classes in our web layer as form objects and they no longer have any other methods than getters and setters The domain model is not the only thing that is shared by these examples. They also share the interface that declares the service methods for the Contact class. The source code of the ContactService interface is given as follows: public interface ContactService {public Contact add(Contact added);public Contact deleteById(Long id) throws NotFoundException;public List&lt;Contact&gt; findAll();public Contact findById(Long id) throws NotFoundException;public Contact update(Contact updated) throws NotFoundException;} Both of these applications will communicate with the used Redis instance by using the Jedis connector. Regardless of the user's approach, we can implement a CRUD application with Spring Data Redis by following these steps: Configure the application context. Implement the CRUD functions. Let's get started and find out how we can implement the CRUD functions for contact information. Using default serializers This subsection describes how we can implement a CRUD application by using the default serializers of the RedisTemplate class. This means that StringRedisSerializer is used to serialize string values, and JdkSerializationRedisSerializer serializes other objects. Configuring the application context We can configure the application context of our application by making the following changes to the ApplicationContext class: Configuring the Redis template bean. Configuring the Redis atomic long bean. Configuring the Redis template bean We can configure the Redis template bean by adding a redisTemplate() method to the ApplicationContext class and annotating this method with the @Bean annotation. We can implement this method by following these steps: Create a new RedisTemplate object. Set the used connection factory to the created RedisTemplate object. Return the created object. The source code of the redisTemplate() method is given as follows: @Beanpublic RedisTemplate redisTemplate() {RedisTemplate&lt;String, String&gt; redis = new RedisTemplate&lt;String,String&gt;();redis.setConnectionFactory(redisConnectionFactory());return redis;} Configuring the Redis atomic long bean We start the configuration of the Redis atomic long bean by adding a method called redisAtomicLong() to the ApplicationContext class and annotating the method with the @Bean annotation. Our next task is to implement this method by following these steps: Create a new RedisAtomicLong object. Pass the name of the used Redis counter and the Redis connection factory as constructor parameters. Return the created object. The source code of the redisAtomicLong() method is given as follows: @Beanpublic RedisAtomicLong redisAtomicLong() {return new RedisAtomicLong("contact", redisConnectionFactory());} If we need to create IDs for instances of different classes, we can use the same Redis counter. Thus, we have to configure only one Redis atomic long bean.
Read more
  • 0
  • 0
  • 14558

article-image-batterymonitor-application
Packt
30 Nov 2012
9 min read
Save for later

BatteryMonitor Application

Packt
30 Nov 2012
9 min read
(For more resources related to this topic, see here.) Overview of the technologies The BatteryMonitor application makes reference to two very important frameworks to allow for drawing of graphics to the iOS device's view, as well as composing and sending of e-mail messages, directly within the application. In this article, we will be making use of the Core Graphics framework that will be responsible for handling the creation of our battery gauge to allow the contents to be filled based on the total amount of battery life remaining on the device. We will then use the MessageUI framework that will be responsible for composing and sending e-mails whenever the application has determined that the battery levels fall below the 20 percent threshold. This is all handled and done directly within our app. We will make use of the UIDevice class that will be used to gather the device information for our iOS device. This class enables you to recover device-specific values, including the model of the iOS device that is being used, the device name, and the OS name and version. We will then use the MFMailComposeViewController class object to directly open up the e-mail dialog box within the application. The information that you can retrieve from the UIDevice class is shown in the following table: Type Description System name This returns the name of the operating system that is currently in use. Since all current generation iOS devices run using the same OS, only one will be displayed; that is iOS 5.1. System version This lists the firmware version that is currently installed on the iOS device; that is, 4.3, 4.31, 5.01, and so on. Unique identifier The unique identifier of the iOS device generates a hexadecimal number to guarantee that it is unique for each iOS device, and does this by applying an internal hash to several of its hardware specifiers, including the device's serial number. This unique identifier is used to register the iOS devices at the iOS portal for provisioning of distribution of software apps. Apple is currently phasing out and rejecting apps that access the Unique Device Identifier on an iOS device to solve issues with piracy, and has suggested that you should create a unique identifier that is specific to your app. Model The iOS model returns a string that describes its platform; that is, iPhone, iPod Touch, and iPad. Name This represents the assigned name of the iOS device that has been assigned by the user within iTunes. This name is also used to create the localhost names for the device, particularly when networking is used. For more information on the UIDevice class, you can refer to the Apple Developer Documentation that can be found and located at the following URL: https://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIDevice_Class/Reference/UIDevice.html. Building the BatteryMonitor application Monitoring battery levels is a common thing that we do in our everyday lives. The battery indicator on the iPhone/iPad lets us know when it is time for us to recharge our iOS device. In this section, we will look at how to create an application that can run on an iOS device to enable us to monitor battery levels on an iOS device, and then send an e-mail alert when the battery levels fall below the threshold. We first need to create our BatteryMonitor project. It is very simple to create this in Xcode. Just follow the steps listed here. Launch Xcode from the /Xcode4/Applications folder. Choose Create a new Xcode project, or File | New Project. Select the Single View Application template from the list of available templates. Select iPad from under the Device Family drop-down list. Ensure that the Use Storyboard checkbox has not been selected. Select the Use Automatic Reference Counting checkbox. Ensure that the Include Unit Tests checkbox has not been selected. Click on the Next button to proceed with the next step in the wizard. Enter in BatteryMonitor as the name for your project. Then click on the Next button to proceed with the next step of the wizard. Specify the location where you would like to save your project. Then, click on the Save button to continue and display the Xcode workspace environment. Now that we have created our BatteryMonitor project, we need to add the MessageUI framework to our project. This will enable us to send e-mail alerts when the battery levels fall below the threshold. Adding the MessageUI framework to the project As we mentioned previously, we need to add the MessageUI framework to our project to allow us to compose and send an e-mail directly within our iOS application, whenever we determine that our device is running below the allowable percentage. To add the MessageUI framework, select Project Navigator Group, and follow the simple steps outlined here: Click and select your project from Project Navigator. Then, select your project target from under the TARGETS group. Select the Build Phases tab. Expand the Link Binary With Libraries disclosure triangle. Finally, use + to add the library you want. Select MessageUI.framework from the list of available frameworks. Now that we have added MessageUI.framework into our project, we need to start building our user interface that will be responsible for allowing us to monitor the battery levels of our iOS device, as well as handle sending out e-mails when the battery levels fall below the agreed threshold. Creating the main application screen The BatteryMonitor application doesn't do anything at this stage; all we have done is created the project and added the MessageUI framework to handle the sending of e-mails when our battery levels are falling below the threshold. We now need to start building the user interface for our BatteryMonitor application. This screen will consist of a View controller, and some controls to handle setting the number of bars to be displayed, as well as whether the monitoring of the battery should be enabled or disabled. Select the ViewController.xib file from Project Navigator. Set the value of Background of the View controller to read Black Color. Next, from Object Library, select-and-drag a (UILabel) Label control, and add this to our view. Modify the Text property of the control to Battery Status:. Modify the Font property of the control to System 42.0. Modify the Alignment property of the control to Center. Next, from Object Library, select-and-drag another (UILabel) Label control, and add this to our view directly underneath the Battery Status label. Modify the Text property of the control to Battery Level:. Modify the Font property of the control to System 74.0. Modify the Alignment property of the control to Center. Now that we have added our label controls to our view controller, our next step is to start adding the rest of our controls that will make up our user interface. So let's proceed to the next section. Adding the Enable Monitoring UISwitch control Our next step is to add a switch control to our view controller; this will be responsible for determining whether or not we are to monitor our battery levels and send out alert e-mails whenever our battery life is running low on our iOS device. This can be achieved by following these simple steps: From Object Library, select-and-drag a (UILabel) Label control, and add this to the bottom right-hand corner of our view controller. Modify the Text property of the control to Enable Monitoring:. Modify the Font property of the control to System 17.0. Modify the Alignment property of the control to Left. Next, from Object Library, select-and-drag a (UISwitch) Switch control to the right of the Enable Monitoring label. Next, from the Attributes Inspector section, change the value of State to On. Then, change the value of On Tint to Default. Now that we have added our Enable Monitoring switch control to our BatteryMonitor View controller, our next step is to add the Send E-mail Alert switch that will be responsible for sending out e-mail alerts if it has determined that the battery levels have fallen below our threshold. So, let's proceed with the next section. Adding the Send E-mail Alert UISwitch control Now, we need to add another switch control to our view that will be responsible for sending e-mail alerts. This can be achieved by following these simple steps: From Object Library, select-and-drag another (UILabel) Label control, and add this underneath our Enable Monitoring label. Modify the Text property of the control to Send E-mail Alert:. Modify the Font property of the control to System 17.0. Modify the Alignment property of the control to Left. Next, from Object Library, select-and-drag a (UISwitch) Switch control to the right of the Send Email Alert label. Next, from the Attributes Inspector section, change the value of State to On. Then, change the value of On Tint to Default. To duplicate a UILabel and/or UISwitch control and have them retain the same attributes, you can use the keyboard shortcut Command + D. You can then update the Text label for the newly added control. Now that we have added our Send E-mail Alert button to our BatteryMonitor view controller, our next step is to add the Fill Gauge Levels switch that will be responsible for filling our battery gauge when it has been set to ON. Adding the Fill Gauge Levels UISwitch control Now, we need to add another switch control to our view that will be responsible for determining whether our gauge should be filled to show the amount of battery remaining. This can be achieved by following these simple steps: From Object Library, select-and-drag another (UILabel) Label control, and add this underneath our Send E-mail Alert label. Modify the Text property of the control to Fill Gauge Levels:. Modify the Font property of the control to System 17.0. Modify the Alignment property of the control to Left. Next, from Object Library, select-and-drag a (UISwitch) Switch control to the right of the Fill Gauge Levels label. Next, from the Attributes Inspector section, change the value of State to On. Then, change the value of On Tint to Default. Now that we have added our Fill Gauge Levels switch control to our BatteryMonitor view controller, our next step is to add the Increment Bars stepper that will be responsible for increasing the number of bar cells within our battery gauge.
Read more
  • 0
  • 0
  • 9687

article-image-sharing-mind-map-using-best-mobile-and-web-featuressil
Packt
29 Nov 2012
14 min read
Save for later

Sharing a Mind Map: Using the Best of Mobile and Web Featuressil

Packt
29 Nov 2012
14 min read
(For more resources related to this topic, see here.) Mind Mapping Sharing the mind map, using the exporting features of FreeMind, is to be explored in this Article. Besides, we can export and upload the mind map on the Web. We are going to deal with the options offered, and we are also adding another condiment to the recipes to spice them up. There are plenty of features that can make our mind map more attractive to the reader, but we have to dig into the different alternatives to make it happen. Moreover, taking into account the pros and cons of each exporting feature, we are going to consider them before exporting our mind map. When designing the activity considering how useful the reader can find the mind map, we are also bearing in mind, at the same time, which exporting features to work with afterwards. Therefore, it is very important to learn the options and their possibilities. Besides, we can improve the exporting possibilities by using a multimedia asset, which can enhance our mind map as well. Exporting the mind map in different formats is going to be the main concern when designing and creating mind maps. We are working with FreeMind, and we see the maps as we design them. However, when exporting the maps, we can see them in different ways; thus the importance of the exporting feature. Exporting a branch as a new map or HTML In this recipe we are going to split the mind map in order to create a new one, using one part of the original one. It is very important to do it when the mind map is getting overwritten, that is to say when we add too much information and we want to represent the subject matter and write the exact information. Getting ready It is time to design a new mind map out of a node that already exists in the one that we are designing; therefore, we will export a branch in order to create a new one. Another option for exporting a branch is to export it as HTML. How to do it... When writing the mind map, if we feel that we do need to split it or if we want to keep on writing but the space that we have is not enough, it means that we have to export a branch as a new mind map. We must bear in mind that this branch appears as the root node of the new one. The sibling nodes that it has are to be exported as well. In the first part of the recipe we are going to focus on the two ways to export the branch; in the second part of the recipe we will compare the results when exporting them in one way or another. The following are the steps that you have to perform: Open the file that you are going to work with. In case you are working with a new file, you do need to save it before exporting the branch. Click on the node that you want to make the root node, as shown in the following screenshot: Click on File | Export | Branch As New Mind, as shown in the following screenshot: A pop-up window appears. Write a name for your file and click on Save. A red arrow appears on the branch, indicating that the branch was exported as a new mind map, as shown in the following screenshot: The branch exported as a mind map looks like the following screenshot: It is important to point out that when exporting the branch of the mind map, the nodes—whether folded or not—no longer appear in the original one, as they are going to be exported to the new mind map. To export another branch of the mind map as HTML, click on the node to export, as shown in the following screenshot: Click on File | Export | Branch as HTML, as shown in the following screenshot: How it works... The main difference between exporting the branch as HTML instead of exporting the branch itself, is that the sibling nodes remain in the original mind map. So, we only export the branch and it appears in our default web browser. Another relevant feature is that when exporting the branch of the mind map as HTML, we see the map in a different format, not as a mind map itself. It is shown in the following screenshot: We can also save this HTML file. Click on the down arrow next to Firefox. Click on Save Page As, write a name for the file, and click on Save. The file is saved as shown in the preceding screenshot, on your computer. Exporting the mind map to bitmaps or vector graphics We can export a mind map as an image, using any of the following three graphic file formats—JPEG, PNG, and SVG. We are going to analyze the options, although they are very simple. If the mind map has bitmaps, we can export the mind map as PNG (short for Portable Network Graphics). It is a file format that provides advanced graphic features and lossless compression. It is advisable to use this type of file format while working with bitmaps when we don't want to lose image quality while rendering the mind map to the final bitmap. In case we want to export the mind map in the file form with the smallest possible size, we can use the JPEG (short for Joint Photographic Experts Group) file format, which uses lossy compression. Pixels with different colors add noise to the image, and delete color information and replace it with pixels of approximated values. If the mind map has many photographs, the best choice for the smallest file size that will lose some image quality is JPEG. JPEG is a compressed graphic file that is used for images that have many colors, that is to say, pictures taken with any type of photographic camera. The third option is to export the mind map as SVG (short for Scalable Vector Graphics). It is advisable to export the mind map in this format if we want to edit the geometric forms that make up the mind map. We can use software that deals with vector graphics and can edit this format. An example of such software is Inkscape. Getting ready It is time to think which mind map we want to export! The steps are the same for any of the exports, what differs is that we are going to choose a different type of file extension. How to do it... We have designed several types of mind maps, using different elements. We are now going to choose a mind map to export and a file extension that suits it. The following are the steps to be performed: Open the file that you want to export. Remember to unfold all the nodes, otherwise they are going to be exported as folded. Click on File | Export | As SVG…, as shown in the following screenshot: Write a name for the file and click on Save. How it works... We must take into consideration that the software that deals with SVG should be Inkscape or any other similar commercial one, such as Paint. When we look for the file on our computer and click on it, any of the said software will open and show the file. It is shown in the following screenshot: Uploading the mind map on Flickr and sharing it In this recipe we are going to upload our mind map on Flickr in order to share it. We must bear in mind that we have to unfold all its branches at the time of exporting, because we won't be able to unfold a branch if it is exported in a folded form. So, the first step is to prepare a mind map in order to be exported. Another important aspect to consider when uploading a file on Flickr is that it does not accept SVG files; therefore, we have to export our mind map either as PNG or JPEG, taking into account how they are designed. So, let's get ready! Getting ready It is time to sign up on Flickr; to do it, we must go to http://www.flickr.com/. In this recipe, we are going to upload that mind map on Flickr. Why? So that we can have access to the HTML code and embed it, and have the URL and create a link with it. There are plenty of options to have our mind map uploaded on this photo-sharing site. Furthermore, there are several activities that teachers can create using this mind map. How to do it... The first step that we have to perform in order to upload the mind map is to export it. We have to choose a mind map with pictures or photographs. After that, we have to export it as PNG or JPEG. In this recipe we are going to export it as PNG, because the mind map has bitmaps. The following are the steps that you have to perform: Open the file that you are going to work with. Click on File | Export | As PNG.... Write a name for the file and click on Save, as shown in the following screenshot: The file is saved in order to upload it on Flickr Sign in to your Flickr account and personalize your profile. Go to http://www.flickr.com/, and sign in for your account. You can also sign in with your Facebook account if you happen to have one. Click on Upload, as shown in the following screenshot: Click on Choose photos and videos. Search for the mind map that you have just exported as PNG. Click on the name of the file and click on Open. Choose the type of privacy for this file, within the Set Privacy block, as shown in the following screenshot: Click on Upload Photos and Videos. Wait for the file to upload. Click on add a description, as shown in the following screenshot: Complete the blocks, as shown in the following screenshot: Click on SAVE. How it works... After uploading the mind map to Flickr, we can now click on it. We can share it through different ways—by grabbing the link or copying and pasting the HTML/BBCode, as shown in the following screenshot: Exporting the mind map as HTML In this recipe we are going to export the mind map as HTML. In order to export the mind map as HTML, it is important to consider the fact that it has to be designed using words rather than images. Furthermore, it is also convenient to create the mind map using different types of sizes, fonts, as well as colors, in order to show the importance and differences after being exported. Getting ready The mind map has only text, and it is appropriate for exporting as HTML. How to do it... First, we have to choose the mind map to export; in this case, the one of British onarchs. After exporting the mind map, we can also save it in this new format on our computer. When exporting as HTML, we have two options. We can export the mind map folded or unfolded. If we export it as folded, we also have the possibility to unfold it when exported; but if we export it as unfolded, we do not have the possibility to fold it afterwards. These possibilities are explored in this recipe. So, the following are the steps that we have to perform: Open the file to export. Fold all the nodes. Click on File | Export | As HTML…, as shown in the following screenshot: The mind map is exported. There appear + signs next to the nodes that have subnodes, as shown in the following screenshot: Click on the + sign to unfold the nodes, as shown in the following screenshot: How it works... When exporting the mind map with its nodes folded, the result is different. The mind map looks the same as the previous screenshot, but the + or - signs do not appear next to the nodes that contain subnodes. The exported mind map, with its nodes unfolded, appears as shown in the following screenshot: Exporting the mind map as XHTML There are three options when exporting our mind maps as XHTML. Two of them are available in the menu, but the third one depends on whether the mind map is folded or not. Therefore, before exporting it, we have to analyze the options. When the mind map is exported, it looks similar to HTML, but it is more colorful and the information in the note window appears below the node in which we have added it. Getting ready We are going to export the same mind map using the three different alternatives, so that we can notice the different results. The mind map to be exported is the one of British monarchs. In the previous recipe we exported the mind map as HTML, so we can also compare the difference with that exportation. How to do it... We are going to export the mind map as XHTML (clickable map image version). But, we are going to export it with its nodes folded. So, the following are the steps that you have to perform: Open the file that you are going to work with. Fold all the nodes containing subnodes. Click on File | Export | As XHTML (Clickable map image version) …, as shown in the following screenshot: Enter a name for the file and click on Save. The exported map appears in the default web browser, as shown in the following screenshot: Minimize your default web browser and go back to FreeMind. Unfold all the nodes in the same mind map. Repeat steps 3 and 4. The exported map appears in your default web browser, as shown in the following screenshot: How it works... It is time to explore the third option when exporting the mind map as XHTML. The option that we are exploring here does not export the image of the map, so it does not matter whether the nodes are folded or not. The information about the different nodes is exported, and we can expand or collapse the nodes, by clicking on the upper part. Perform the following steps: Open the mind map you want to export. Click on File | Export | As XHTML (JavaScript version)…, as shown in the following screenshot: Enter a name for the file. Click on Save. The mind map is exported to your default web browser, as shown in the following screenshot: Save the files on your computer in any of these cases, when the mind map is exported. Exporting the mind map as Flash Exporting the mind map as Flash is very interesting, because it maintains the characteristics that we have added to the mind map. Besides, whether exported with the nodes folded or not, we can open them by clicking on the nodes. In the case that the nodes contain information in the note window, we can read them if we hover the mouse over those nodes. Getting ready It is time to see how to export the mind map in a different way. We have to bear in mind that Flash is not available in some operating systems. How to do it... We are going to keep on exporting the same mind map, so that the difference in the exportations is noticeable. The following are the steps to perform: Open the file that you are going to work with. Click on File | Export | As Flash…, as shown in the following screenshot: Write a name for the file. Click on Save. How it works... The exported mind map appears in the default web browser. The mind map looks the same as in FreeMind. When clicking on the nodes, they fold or unfold. If there is a node that contains information in the note window, it appears while hovering the mouse over it. It is shown in the following screenshot:
Read more
  • 0
  • 0
  • 2613

article-image-article
Packt
28 Nov 2012
14 min read
Save for later

Sharing a Mind Map: Using the Best of Mobile and Web Features

Packt
28 Nov 2012
14 min read
Mind Mapping Sharing the mind map, using the exporting features of FreeMind, is to be explored in this Article. Besides, we can export and upload the mind map on the Web. We are going to deal with the options offered, and we are also adding another condiment to the recipes to spice them up. There are plenty of features that can make our mind map more attractive to the reader, but we have to dig into the different alternatives to make it happen. Moreover, taking into account the pros and cons of each exporting feature, we are going to consider them before exporting our mind map. When designing the activity considering how useful the reader can find the mind map, we are also bearing in mind, at the same time, which exporting features to work with afterwards. Therefore, it is very important to learn the options and their possibilities. Besides, we can improve the exporting possibilities by using a multimedia asset, which can enhance our mind map as well. Exporting the mind map in different formats is going to be the main concern when designing and creating mind maps. We are working with FreeMind, and we see the maps as we design them. However, when exporting the maps, we can see them in different ways; thus the importance of the exporting feature. Exporting a branch as a new map or HTML In this recipe we are going to split the mind map in order to create a new one, using one part of the original one. It is very important to do it when the mind map is getting overwritten, that is to say when we add too much information and we want to represent the subject matter and write the exact information. Getting ready It is time to design a new mind map out of a node that already exists in the one that we are designing; therefore, we will export a branch in order to create a new one. Another option for exporting a branch is to export it as HTML. How to do it... When writing the mind map, if we feel that we do need to split it or if we want to keep on writing but the space that we have is not enough, it means that we have to export a branch as a new mind map. We must bear in mind that this branch appears as the root node of the new one. The sibling nodes that it has are to be exported as well. In the first part of the recipe we are going to focus on the two ways to export the branch; in the second part of the recipe we will compare the results when exporting them in one way or another. The following are the steps that you have to perform: Open the file that you are going to work with. In case you are working with a new file, you do need to save it before exporting the branch. Click on the node that you want to make the root node, as shown in the following screenshot: Click on File | Export | Branch As New Mind, as shown in the following screenshot: A pop-up window appears. Write a name for your file and click on Save. A red arrow appears on the branch, indicating that the branch was exported as a new mind map, as shown in the following screenshot: The branch exported as a mind map looks like the following screenshot: It is important to point out that when exporting the branch of the mind map, the nodes—whether folded or not—no longer appear in the original one, as they are going to be exported to the new mind map. To export another branch of the mind map as HTML, click on the node to export, as shown in the following screenshot: Click on File | Export | Branch as HTML, as shown in the following screenshot: How it works... The main difference between exporting the branch as HTML instead of exporting the branch itself, is that the sibling nodes remain in the original mind map. So, we only export the branch and it appears in our default web browser. Another relevant feature is that when exporting the branch of the mind map as HTML, we see the map in a different format, not as a mind map itself. It is shown in the following screenshot: We can also save this HTML file. Click on the down arrow next to Firefox. Click on Save Page As, write a name for the file, and click on Save. The file is saved as shown in the preceding screenshot, on your computer. Exporting the mind map to bitmaps or vector graphics We can export a mind map as an image, using any of the following three graphic file formats—JPEG, PNG, and SVG. We are going to analyze the options, although they are very simple. If the mind map has bitmaps, we can export the mind map as PNG (short for Portable Network Graphics). It is a file format that provides advanced graphic features and lossless compression. It is advisable to use this type of file format while working with bitmaps when we don't want to lose image quality while rendering the mind map to the final bitmap. In case we want to export the mind map in the file form with the smallest possible size, we can use the JPEG (short for Joint Photographic Experts Group) file format, which uses lossy compression. Pixels with different colors add noise to the image, and delete color information and replace it with pixels of approximated values. If the mind map has many photographs, the best choice for the smallest file size that will lose some image quality is JPEG. JPEG is a compressed graphic file that is used for images that have many colors, that is to say, pictures taken with any type of photographic camera. The third option is to export the mind map as SVG (short for Scalable Vector Graphics). It is advisable to export the mind map in this format if we want to edit the geometric forms that make up the mind map. We can use software that deals with vector graphics and can edit this format. An example of such software is Inkscape. Getting ready It is time to think which mind map we want to export! The steps are the same for any of the exports, what differs is that we are going to choose a different type of file extension. How to do it... We have designed several types of mind maps, using different elements. We are now going to choose a mind map to export and a file extension that suits it. The following are the steps to be performed: Open the file that you want to export. Remember to unfold all the nodes, otherwise they are going to be exported as folded. Click on File | Export | As SVG…, as shown in the following screenshot: Write a name for the file and click on Save. How it works... We must take into consideration that the software that deals with SVG should be Inkscape or any other similar commercial one, such as Paint. When we look for the file on our computer and click on it, any of the said software will open and show the file. It is shown in the following screenshot: Uploading the mind map on Flickr and sharing it In this recipe we are going to upload our mind map on Flickr in order to share it. We must bear in mind that we have to unfold all its branches at the time of exporting, because we won't be able to unfold a branch if it is exported in a folded form. So, the first step is to prepare a mind map in order to be exported. Another important aspect to consider when uploading a file on Flickr is that it does not accept SVG files; therefore, we have to export our mind map either as PNG or JPEG, taking into account how they are designed. So, let's get ready! Getting ready It is time to sign up on Flickr; to do it, we must go to http://www.flickr.com/. In this recipe, we are going to upload that mind map on Flickr. Why? So that we can have access to the HTML code and embed it, and have the URL and create a link with it. There are plenty of options to have our mind map uploaded on this photo-sharing site. Furthermore, there are several activities that teachers can create using this mind map. How to do it... The first step that we have to perform in order to upload the mind map is to export it. We have to choose a mind map with pictures or photographs. After that, we have to export it as PNG or JPEG. In this recipe we are going to export it as PNG, because the mind map has bitmaps. The following are the steps that you have to perform: Open the file that you are going to work with. Click on File | Export | As PNG.... Write a name for the file and click on Save, as shown in the following screenshot: The file is saved in order to upload it on Flickr Sign in to your Flickr account and personalize your profile. Go to http://www.flickr.com/, and sign in for your account. You can also sign in with your Facebook account if you happen to have one. Click on Upload, as shown in the following screenshot: Click on Choose photos and videos. Search for the mind map that you have just exported as PNG. Click on the name of the file and click on Open. Choose the type of privacy for this file, within the Set Privacy block, as shown in the following screenshot: Click on Upload Photos and Videos. Wait for the file to upload. Click on add a description, as shown in the following screenshot: Complete the blocks, as shown in the following screenshot: Click on SAVE. How it works... After uploading the mind map to Flickr, we can now click on it. We can share it through different ways—by grabbing the link or copying and pasting the HTML/BBCode, as shown in the following screenshot: Exporting the mind map as HTML In this recipe we are going to export the mind map as HTML. In order to export the mind map as HTML, it is important to consider the fact that it has to be designed using words rather than images. Furthermore, it is also convenient to create the mind map using different types of sizes, fonts, as well as colors, in order to show the importance and differences after being exported. Getting ready The mind map has only text, and it is appropriate for exporting as HTML. How to do it... When exporting as HTML, we have two options. We can export the mind map folded or unfolded. If we export it as folded, we also have the possibility to unfold it when exported; but if we export it as unfolded, we do not have the possibility to fold it afterwards. These possibilities are explored in this recipe. So, the following are the steps that we have to perform: Open the file to export. Fold all the nodes. Click on File | Export | As HTML…, as shown in the following screenshot: The mind map is exported. There appear + signs next to the nodes that have subnodes, as shown in the following screenshot: Click on the + sign to unfold the nodes, as shown in the following screenshot: How it works... When exporting the mind map with its nodes folded, the result is different. The mind map looks the same as the previous screenshot, but the + or - signs do not appear next to the nodes that contain subnodes. The exported mind map, with its nodes unfolded, appears as shown in the following screenshot: Exporting the mind map as XHTML There are three options when exporting our mind maps as XHTML. Two of them are available in the menu, but the third one depends on whether the mind map is folded or not. Therefore, before exporting it, we have to analyze the options. When the mind map is exported, it looks similar to HTML, but it is more colorful and the information in the note window appears below the node in which we have added it. Getting ready We are going to export the same mind map using the three different alternatives, so that we can notice the different results. The mind map to be exported is the one of British monarchs. In the previous recipe we exported the mind map as HTML, so we can also compare the difference with that exportation. How to do it... We are going to export the mind map as XHTML (clickable map image version). But, we are going to export it with its nodes folded. So, the following are the steps that you have to perform: Open the file that you are going to work with. Fold all the nodes containing subnodes. Click on File | Export | As XHTML (Clickable map image version) …, as shown in the following screenshot: Enter a name for the file and click on Save. The exported map appears in the default web browser, as shown in the following screenshot: Minimize your default web browser and go back to FreeMind. Unfold all the nodes in the same mind map. Repeat steps 3 and 4. The exported map appears in your default web browser, as shown in the following screenshot: How it works... It is time to explore the third option when exporting the mind map as XHTML. The option that we are exploring here does not export the image of the map, so it does not matter whether the nodes are folded or not. The information about the different nodes is exported, and we can expand or collapse the nodes, by clicking on the upper part. Perform the following steps: Open the mind map you want to export. Click on File | Export | As XHTML (JavaScript version)…, as shown in the following screenshot: Enter a name for the file. Click on Save. The mind map is exported to your default web browser, as shown in the following screenshot: Save the files on your computer in any of these cases, when the mind map is exported. Exporting the mind map as Flash Exporting the mind map as Flash is very interesting, because it maintains the characteristics that we have added to the mind map. Besides, whether exported with the nodes folded or not, we can open them by clicking on the nodes. In the case that the nodes contain information in the note window, we can read them if we hover the mouse over those nodes. Getting ready It is time to see how to export the mind map in a different way. We have to bear in mind that Flash is not available in some operating systems. How to do it... We are going to keep on exporting the same mind map, so that the difference in the exportations is noticeable. The following are the steps to perform: Open the file that you are going to work with. Click on File | Export | As Flash…, as shown in the following screenshot: Write a name for the file. Click on Save. How it works... The exported mind map appears in the default web browser. The mind map looks the same as in FreeMind. When clicking on the nodes, they fold or unfold. If there is a node that contains information in the note window, it appears while hovering the mouse over it. It is shown in the following screenshot:
Read more
  • 0
  • 0
  • 7592

article-image-basic-coding-hornetq-creating-and-consuming-messages
Packt
28 Nov 2012
4 min read
Save for later

Basic Coding with HornetQ: Creating and Consuming Messages

Packt
28 Nov 2012
4 min read
(For more resources related to this topic, see here.) Installing Eclipse on Windows You can download the Eclipse IDE for Java EE developers (in our case the ZIP file eclipse-jee-indigo-SR1-win32.zip) from http://www.eclipse.org/downloads/. Once downloaded, you have to unzip the eclipse folder inside the archive to the destination folder so that you have a folder structure like the one illustrated in the following screenshot: Now a double-click on the eclipse.exe file will fire the first run of Eclipse. Installing NetBeans on Windows NetBeans is one of the most frequently used IDE for Java development purposes. It mimics the Eclipse plugin module's installation, so you could download the J2EE version from the URL http://netbeans.org/downloads/.But remember that this version also comes with an integrated GlassFish application server and a Tomcat server. Even in this case you only need to download the .exe file (java_ee_sdk-6u3-jdk7-windows.exe, in our case) and launch the installer. Once finished, you should be able to run the IDE by clicking on the NetBeans icon in your Windows Start menu. Installing NetBeans on Linux If you are using a Debian-based version of Linux like Ubuntu, installing both NetBeans and Eclipse is nothing more than typing a command from the bash shell and waiting for the installation process to finish. As we are using Ubuntu Version 11, we will type the following command from a non-root user account to install Eclipse: sudo apt-get install eclipse The NetBeans installation procedure is slightly different due to the fact that the Ubuntu repositories do not have a package for a NetBeans installation. So, for installing NetBeans you have to download a script and then run it. If you are using a non-root user account, you need to type the following commands on a terminal: sudo wget http://download.netbeans.org/netbeans/7.1.1/final/bundles/ netbeans-7.1.1-ml-javaee-linux.sh sudo chmod +x netbeans-7.1.1-ml-javaee-linux.sh ./netbeans-7.1.1-ml-javaee-linux.sh During the first run of the IDE, Eclipse will ask which default workspace the new projects should be stored in. Choose the one suggested, and in case you are not planning to change it, check the Use this as the default and do not ask again checkbox for not re-proposing the question, as shown in the following screenshot: The same happens with NetBeans, but during the installation procedure. Post installation Both Eclipse and NetBeans have an integrated system for upgrading them to the latest version, so when you have correctly launched the first-time run, keep your IDE updated. For Eclipse, you can access the Update window by using the menu Help | Check for updates. This will pop up the window, as shown in this screenshot: NetBeans has the same functionality, which can be launched from the menu. A 10,000 foot view of HornetQ Before moving on with the coding phase, it is time to recover some concepts to allow the user and the coder to better understand how HornetQ manages messages. HornetQ is only a set of Plain Old Java Objects (POJOs) compiled and grouped into JAR files. The software developer could easily grasp that this characteristic leads to HornetQ having no dependency on third-party libraries. It is possible to use and even start HornetQ from any Java class; this is a great advantage over other frameworks. HornetQ deals internally only with its own set of classes, called the HornetQ core, avoiding any dependency on JMS dialect and specifications. Nevertheless, the client that connects with the HornetQ server can speak the JMS language. So the HornetQ server also uses a JMS to core HornetQ API translator. This means that when you send a JMS message to a HornetQ server, it is received as JMS and then translated into the core API dialect to be managed internally by HornetQ. The following figure illustrates this concept: The core messaging concepts of HornetQ are somewhat simpler than those of JMS: Message: This is a unit of data that can be sent/delivered from a consumer to a producer. Messages have various possibilities. But only to cite them, a message can have: durability, priority, expiry time, time, and dimension. Address: HornetQ maintains an association between an address (IP address of the server) and the queues available at that address. So the message is bound to the address. Queue: This is nothing more than a set of messages. Like messages, queues have attributes such as durability, temporary, and filtering expressions.
Read more
  • 0
  • 0
  • 3216

article-image-getting-started-couchdb-and-futon
Packt
27 Nov 2012
11 min read
Save for later

Getting Started with CouchDB and Futon

Packt
27 Nov 2012
11 min read
(For more resources related to this topic, see here.) What is CouchDB? The first sentence of CouchDB's definition (as defined by http://couchdb.apache.org/) is as follows: CouchDB is a document database server, accessible through the RESTful JSON API. Let's dissect this sentence to fully understand what it means. Let's start with the term database server. Database server CouchDB employs a document-oriented database management system that serves a flat collection of documents with no schema, grouping, or hierarchy. This is a concept that NoSQL has introduced, and is a big departure from relational databases (such as MySQL), where you would expect to see tables, relationships, and foreign keys. Every developer has experienced a project where they have had to force a relational database schema into a project that really didn't require the rigidity of tables and complex relationships. This is where CouchDB does things differently; it stores all of the data in a self-contained object with no set schema. The following diagram will help to illustrate this: In order to handle the ability for many users to belong to one-to-many groups in a relational database (such as MySQL), we would create a users table, a groups table, and a link table, called users_groups. This practice is common to most web applications. Now look at the CouchDB documents. There are no tables or link tables, just documents. These documents contain all of the data pertaining to a single object. This diagram is very simplified. If we wanted to create more logic around the groups in CouchDB, we would have had to create group documents, with a simple relationship between the user documents and group documents. Let's dig into what documents are and how CouchDB uses them. Documents To illustrate how you might use documents, first imagine that you are physically filling out the paper form of a job application. This form has information about you, your address, and past addresses. It also has information about many of your past jobs, education, certifications, and much more. A document would save all of this data exactly in the way you would see it in the physical form - all in one place, without any unnecessary complexity. In CouchDB, documents are stored as JSON objects that contain key and value pairs. Each document has reserved fields for metadata such as id, revision, and deleted. Besides the reserved fields, documents are 100 percent schema-less, meaning that each document can be formatted and treated independently with as many different variations as you might need. Example of a CouchDB document Let's take a look at an example of what a CouchDB document might look like for a blog post: { "_id": "431f956fa44b3629ba924eab05000553", "_rev": "1-c46916a8efe63fb8fec6d097007bd1c6", "title": "Why I like Chicken", "author": "Tim Juravich", "tags": [ "Chicken", "Grilled", "Tasty" ], "body": "I like chicken, especially when it's grilled." } Downloading the example code You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you. JSON format The first thing you might notice is the strange markup of the document, which is JavaScript Object Notation (JSON). JSON is a lightweight data-interchange format based on JavaScript syntax and is extremely portable. CouchDB uses JSON for all communication with it. Key-value storage The next thing that you might notice is that there is a lot of information in this document. There are key-value pairs that are simple to understand, such as "title", "author", and "body", but you'll also notice that "tags" is an array of strings. CouchDB lets you embed as much information as you want directly into a document. This is a concept that might be new to relational database users who are used to normalized and structured databases. Reserved fields Let's look at the two reserved fields: _id and _rev. _id is the unique identifier of the document. This means that _id is mandatory, and no two documents can have the same value. If you don't define an _id on creation of a document, CouchDB will choose a unique one for you. _rev is the revision version of the document and is the field that helps drive CouchDB's version control system. Each time you save a document, the revision number is required so that CouchDB knows which version of the document is the newest. This is required because CouchDB does not use a locking mechanism, meaning that if two people are updating a document at the same time, then the first one to save his/her changes first, wins. One of the unique things about CouchDB's revision system is that each time a document is saved, the original document is not overwritten, and a new document is created with the new data, while CouchDB stores a backup of the previous documents in its original form in an archive. Old revisions remain available until the database is compacted, or some cleanup action occurs. The last piece of the definition sentence is the RESTful JSON API. So, let's cover that next. RESTful JSON API In order to understand REST, let's first define HyperText Transfer Protocol (HTTP ). HTTP is the underlying protocol of the Internet that defines how messages are formatted and transmitted and how services should respond when using a variety of methods. These methods consist of four main verbs, such as GET, PUT, POST, and DELETE. In order to fully understand how HTTP methods function, let's first define REST. Representation State Transfer (REST ) is a stateless protocol that accesses addressable resources through HTTP methods. Stateless means that each request contains all of the information necessary to completely understand and use the data in the request, and addressable resources means that you can access the object via a URL. That might not mean a lot in itself, but, by putting all of these ideas together, it becomes a powerful concept. Let's illustrate the power of REST by looking at two examples: Resource GET PUT POST DELETE http://localhost/collection Read a list of all of the items inside of collection Update the Collection with another collection Create a new collection Delete the collection http://localhost/collection/abc123 Read the details of the abc123 item inside of collection Update the details of abc123 inside of collection Create a new object abc123 inside of a collection Delete abc123 from collection By looking at the table, you can see that each resource is in the form of a URL. The first resource is collection, and the second resource is abc123, which lives inside of collection. Each of these resources responds differently when you pass different methods to them. This is the beauty of REST and HTTP working together. Notice the bold words I used in the table: Read, Update, Create, and Delete. These words are actually, in themselves, another concept, and it, of course, has its own term; CRUD. The unflattering term CRUD stands for Create, Read, Update, and Delete and is a concept that REST uses to define what happens to a defined resource when an HTTP method is combined with a resource in the form of a URL. So, if you were to boil all of this down, you would come to the following diagram: This diagram means: In order to CREATE a resource, you can use either the POST or PUT method In order READ a resource, you need to use the GET method In order to UPDATE a resource, you need to use the PUT method In order to DELETE a resource, you need to use the DELETE method As you can see, this concept of CRUD makes it really clear to find out what method you need to use when you want to perform a specific action. Now that we've looked at what REST means, let's move onto the term API , which means Application Programming Interface. While there are a lot of different use cases and concepts of APIs, an API is what we'll use to programmatically interact with CouchDB. Now that we have defined all of the terms, the RESTful JSON API could be defined as follows: we have the ability to interact with CouchDB by issuing an HTTP request to the CouchDB API with a defined resource, HTTP method, and any additional data. Combining all of these things means that we are using REST. After CouchDB processes our REST request, it will return with a JSON-formatted response with the result of the request. All of this background knowledge will start to make sense as we play with CouchDB's RESTful JSON API, by going through each of the HTTP methods, one at a time. We will use curl to explore each of the HTTP methods by issuing raw HTTP requests. Time for action – getting a list of all databases in CouchDB Let's issue a GET request to access CouchDB and get a list of all of the databases on the server. Run the following command in Terminal curl -X GET http://localhost:5984/_all_dbs Terminal will respond with the following: ["_users"] What just happened? We used Terminal to trigger a GET request to CouchDB's RESTful JSON API. We used one of the options: -X, of curl, to define the HTTP method. In this instance, we used GET. GET is the default method, so technically you could omit -X if you wanted to. Once CouchDB processes the request, it sends back a list of the databases that are in the CouchDB server. Currently, there is only the _users database, which is a default database that CouchDB uses to authenticate users. Time for action – creating new databases in CouchDB In this exercise, we'll issue a PUT request , which will create a new database in CouchDB. Create a new database by running the following command in Terminal: curl -X PUT http://localhost:5984/test-db Terminal will respond with the following: {"ok":true} Try creating another database with the same name by running the following command in Terminal: curl -X PUT http://localhost:5984/test-db Terminal will respond with the following: {"error":"file_exists","reason":"The database could not becreated, the file already exists."} Okay, that didn't work. So let's to try to create a database with a different name by running the following command in Terminal: curl -X PUT http://localhost:5984/another-db Terminal will respond with the following: {"ok":true} Let's check the details of the test-db database quickly and see more detailed information about it. To do that, run the following command in Terminal: curl -X GET http://localhost:5984/test-db Terminal will respond with something similar to this (I re-formatted mine for readability): {"committed_update_seq": 1,"compact_running": false,"db_name": "test-db","disk_format_version": 5,"disk_size": 4182,"doc_count": 0,"doc_del_count": 0,"instance_start_time": "1308863484343052","purge_seq": 0,"update_seq": 1} What just happened? We just used Terminal to trigger a PUT method to the created databases through CouchDB's RESTful JSON API, by passing test-db as the name of the database that we wanted to create at the end of the CouchDB root URL. When the database was successfully created, we received a message that everything went okay. Next, we created a PUT request to create another database with the same name test-db. Because there can't be more than one database with the same name, we received an error message We then used a PUT request to create a new database again, named another-db. When the database was successfully created, we received a message that everything went okay. Finally, we issued a GET request to our test-db database to find out more information on the database. It's not important to know exactly what each of these statistics mean, but it's a useful way to get an overview of a database. It's worth noting that the URL that was called in the final GET request was the same URL we called when we first created the database. The only difference is that we changed the HTTP method from PUT to GET. This is REST in action!
Read more
  • 0
  • 0
  • 5136
Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at €18.99/month. Cancel anytime
article-image-nmap-fundamentals
Packt
26 Nov 2012
7 min read
Save for later

Nmap Fundamentals

Packt
26 Nov 2012
7 min read
(For more resources related to this topic, see here.) Nmap (Network Mapper) Nmap (Network Mapper) is an open-source tool specialized in network exploration and security auditing, originally published by Gordon "Fyodor" Lyon. The official website (http://nmap.org) describes it as follows: Nmap (Network Mapper) is a free and open source (license) utility for network discovery and security auditing. Many systems and network administrators also find it useful for tasks such as network inventory, managing service upgrade schedules, and monitoring host or service uptime. Nmap uses raw IP packets in novel ways to determine what hosts are available on the network, what services (application name and version) those hosts are offering, what operating systems (and OS versions) they are running, what type of packet filters/firewalls are in use, and dozens of other characteristics. It was designed to rapidly scan large networks, but works fine against single hosts. Nmap runs on all major computer operating systems, and official binary packages are available for Linux, Windows, and Mac OS X. There are many other port scanners out there, but none of them even comes close to offering the flexibility and advanced options of Nmap. The Nmap Scripting Engine (NSE) has revolutionized the possibilities of a port scanner by allowing users to write scripts that perform custom tasks using the host information collected by Nmap. Additionally, the Nmap Project includes other great tools: Zenmap: A graphical interface for Nmap Ndiff: A tool for scan result comparison Nping: An excellent tool for packet generation and traffic analysis Ncrack: An Nmap-compatible tool for brute forcing network logins Ncat: A debugging utility to read and write data across networks Needless to say, it is essential that every security professional and network administrator master this tool to conduct security assessments, monitor, and administer networks efficiently. Nmap's community is very active, and new features are added every week. I encourage you to always keep an updated copy in your arsenal, if you haven't done this already; and even better, to subscribe to the development mailing list at http://cgi.insecure.org/mailman/listinfo/nmap-dev. Downloading Nmap from the official source code repository This section describes how to download Nmap's source code from the official subversion repository. By doing so, users can compile the latest version of Nmap and keep up with the daily updates that are committed to the subversion repository. Getting ready Before continuing, you need to have a working Internet connection and access to a subversion client. Unix-based platforms come with a command-line client called subversion (svn). To check if its already installed in your system, just open a terminal and type: $ svn If it tells you that the command was not found, install svn using your favorite package manager or build it from source code. The instructions for building svn from source code are out of the scope of this book, but they are widely documented online. Use your favorite search engine to find specific instructions for your system. If you would rather work with a graphical user interface, RapidSVN is a very popular, crossplatform alternative. You can download and install RapidSVN from http://rapidsvn.tigris.org/. How to do it... Open your terminal and enter the following command: $ svn co --username guest https://svn.nmap.org/nmap/ Downloading the example code You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you. Wait until svn downloads all the files stored in the repository. You should see the list of the added files as it finishes, as shown in the following screenshot: When the program returns/exits, you will have Nmap's source code in your current directory. How it works... $ svn checkout https://svn.nmap.org/nmap/ This command downloads a copy of the remote repository located at https://svn.nmap.org/nmap/. This repository has world read access to the latest stable build, allowing svn to download your local working copy. There's more... If you are using RapidSVN then follow these steps: Right-click on Bookmarks. Click on Checkout New Working Copy. Type https://svn.nmap.org/nmap/ in the URL field. Select your local working directory. Click on OK to start downloading your new working copy. Experimenting with development branches If you want to try the latest creations of the development team, there is a folder named nmapexp that contains different experimental branches of the project. Code stored there is not guaranteed to work all the time, as the developers use it as a sandbox until it is ready to be merged into the stable branch. The full subversion URL of this folder is https://svn.nmap.org/nmap-exp/. Keeping your source code up-to-date To update a previously-downloaded copy of Nmap, use the following command inside your working directory: $ svn update You should see the list of files that have been updated, as well as some revision information. Compiling Nmap from source code Precompiled packages always take time to prepare and test, causing delays between releases. If you want to stay up-to-date with the latest additions, compiling Nmap's source code is highly recommended. This recipe describes how to compile Nmap's source code in the Unix environment. Getting ready Make sure the following packages are installed in your system: gcc openssl make Install the missing software using your favorite package manager or build it from source code. How to do it... Open your terminal and go into the directory where Nmap's source code is stored. Configure it according to your system: $ ./configure An ASCII dragon warning you about the power of Nmap will be displayed (as shown in the following screenshot) if successful, otherwise lines specifying an error will be displayed. Build Nmap using the following command: $ make If you don't see any errors, you have built the latest version of Nmap successfully. You can check this by looking for the compiled binary Nmap in your current directory. If you want to make Nmap available for all the users in the system, enter the following command: # make install How it works... We used the script configure to set up the different parameters and environmental variables affecting your system and desired configuration. Afterwards, GNUs make generated the binary files by compiling the source code. There's more... If you only need the Nmap binary, you can use the following configure directives to avoid installing Ndiff, Nping, and Zenmap: Skip the installation of Ndiff by using --without-ndiff Skip the installation of Zenmap by using --without-zenmap Skip the installation of Nping by using --without-nping OpenSSL development libraries OpenSSL is optional when building Nmap. Enabling it allows Nmap to access the functions of this library related to multiprecision integers, hashing, and encoding/decoding for service detection and Nmap NSE scripts. The name of the OpenSSL development package in Debian systems is libssl-dev. Configure directives There are several configure directives that can be used when building Nmap. For a complete list of directives, use the following command: The name of the OpenSSL development package in Debian systems is libssl-dev. $ ./configure --help Precompiled packages There are several precompiled packages available online (http://nmap.org/download. html) for those who don't have access to a compiler, but unfortunately, it's very likely you will be missing features unless its a very recent build. Nmap is continuously evolving. If you are serious about harnessing the power of Nmap, keep your local copy up-to-date with the official repository.
Read more
  • 0
  • 0
  • 23468

article-image-creating-motion-through-timeline
Packt
23 Nov 2012
13 min read
Save for later

Creating Motion Through the Timeline

Packt
23 Nov 2012
13 min read
(For more resources related to this topic, see here.) Animation within Edge Animate There are many applications that enable the user to compose animated sequences. Users of Adobe Edge Animate may have experience in other programs such as Director, Flash Professional, After Effects, or even Photoshop. All of these applications handle animation in slightly different ways, but they do all share some aspects of animation techniques and tooling as well. Like many digital animation programs, Edge Animate employs the concept of "tweening" between keyframes. In traditional cell-based animation, a master animator would draw out certain key frames for an animation sequence, and the frames in between these key frames would be created by apprentice or lower-ranked members of the animation team. The goal was always to create a smooth transition between each key frame created by the master animator, which would result in a completed animation sequence. This process is performed programmatically within Edge Animate. As keyframes are placed along the Timeline, Edge Animate will record changes in property values as transitions at the position of the Playhead (moment in time). We have the additional ability to provide the tweening engine with instruction sets based upon a variety of easing equations. This allows a more natural flow between keyframes, and can also be used to achieved certain effects such as an elastic or bounce motion. The Edge Animate Timeline The Timeline is where all of the motion in an Edge Animate composition is orchestrated. The Timeline itself shares concepts and constructs from other Adobe applications, most notably Flash Professional and After Effects. Unlike the frame-based timeline in Flash Professional, the Edge Animate Timeline is purely time-based. Playback controls The playback controls in Edge Animate are all grouped together in the upper-left corner or the Timeline panel. These controls allow quick access to many of the playback options available through the Timeline. Time The time in Edge Animate is measured in standard decimal time code format (mm:ss.ddd), and this is how it is displayed in the Time control. As the Playhead moves along the Timeline, the information in this display is updated accordingly. A user can scrub the control to the left or right to adjust the current time, or simply click on it—making it editable. Note that the time controls in Edge Animate are actually grouped along with the Stage and are accessible from directly beneath that panel. The controls are also broken up to allow separate modification of the Playhead time (yellow), and Pin time (blue), when enabled. Timeline options These options can be toggled on or off depending upon current needs, as they perform a variety of Timeline-related functions. These options include the following: Auto-Keyframe Mode (K): Selecting this option will enable Edge Animate to generate keyframes for various properties automatically as they are adjusted along the Timeline. When not selected, any keyframes must be inserted manually. Auto-Transition Mode (X): When enabled, this informs Edge Animate to use immediate transitions between element property adjustments as they are animated across time. Toggle Pin (P): Toggles the Pin on and off. There are also a number of options present on the bottom of the Timeline: Only Show Animated Elements: When this option is selected, only those elements whose properties are animated will display within the Timeline. Static elements (such as a background image, perhaps) will be hidden. Timeline Snapping: WToggles Timeline snapping on or off. Show Grid: Toggles Timeline grid on or off and allows us to set the grid spacing units More about the Show Grid control We are also able to set the grid spacing by clicking on the small arrow to the immediate right of this icon in order to access a small list of options. We can choose to display grid lines over a selection of measurements across the Timeline. Timeline controls There are basically only four controls within the Timeline that we need to be concerned with: the Playhead, the Pin, Zoom, and a set of Grid controls. The functionality between controls varies greatly here, as some are used for playback, some for animation, and others are simply there for the enhancement of our overall workflow. All, however, are very useful. The Playhead The Playhead is the larger of the two elements on the Timeline and is represented by a solid red line that indicates the current time. We can click on the Playhead and scrub back and forth to change the current time. When an animation is being played back through Edge Animate, the Playhead will move along with the current time. Normally, the Playhead and the Pin are both synced. If not, they can be resynced through the application menu: Timeline | Toggle Pin. The Pin The Pin is a unique control to Edge Animate. It is a way of pinning the current state of element properties to a certain time, while using the Playhead to determine at which time the animation should complete. The Pin can be positioned either before or after the time indicated by the Playhead—but it always indicates a starting point for the animation, with the Playhead indicating the end. Changing any element properties while the Pin is unsynced will create animation of those properties beginning at the Pin and ending at the Playhead position. In this way, we can quickly and freely create animation that is tightly controlled across the Timeline. To quickly sync or unsync the Pin from the Playhead, we can double-click on the Playhead to toggle between each state. We can also use the keyboard shortcut (P) to accomplish this same task—or even use the control in the Timeline which performs this action.. When the Pin has been activated, the direction of animation is indicated through a colored strip of chevrons on the Timeline. The color will be yellow or blue, depending upon the direction of motion; blue indicates motion to the left of the Pin, while yellow indicates motion to the right of the Pin. Zoom controls There are two zoom controls in Edge Animate, which allow us to expand and contract the Timeline. One is the Zoom Timeline to Fit button that appears as dual arrows in the lower-right corner of the Timeline. This will expand or contract the entire span of the visible Timeline to the current width of the Timeline panel. It can provide a good overview of the entire animation. The second control is a slider which appears directly to the right and allows the user to manually control the zoom level of the Timeline to accommodate whatever we are specifically trying to accomplish at any particular time. Keyframes Similar to their representation in After Effects, keyframes in Edge Animate appear along the Timeline as small diamonds. Unlike keyframes in Flash Professional, Edge Animate keyframes are tied directly to the property that is being changed and not to the element itself. This allows for fine-grained property adjustments across the Timeline for any particular element. It is very flexible and a powerful way to animate selected element properties! Keyframe navigation There are a number of keyboard shortcuts in Edge Animate that assist with Timeline navigation—specifically when jumping across keyframes. Command Shortcut Go to Previous Keyframe Ctrl + Left Arrow (Windows), Command + Left Arrow (Mac) Go to Next Keyframe Ctrl + Right Arrow (Windows), Command + Right Arrow (Mac) Creating motion Animating element properties within Edge Animate is fairly straightforward. We're going to step through a number of basic ways to animate elements along the Edge Animate Timeline. Once using only the Playhead, and again using the Playhead in conjunction with the Pin. By performing the same animation in each way, we will get a feel for the different workflow styles Edge Animate makes available to us when animating element properties across time. Note that most elements will not appear within the Timeline until their properties are actually modified across time. The reasoning for this is if nothing is actually animated, there is no reason to clutter the Timeline. Inserting keyframes There are a number of mechanisms through which we can insert keyframes into our composition: using the Properties panel, the application menu, the Timeline Keyframe buttons, or through the right-click menu. Before we move on, let's have a quick look at each of these methods. Adding keyframes through the Properties panel With any element selected, we can position the Playhead upon the Timeline and look to the application menu to insert our keyframes. Simply navigate to the menu and choose Timeline | Add Keyframe and then select the type of keyframe to add, based upon the property we wish to set a keyframe for: Adding keyframes through the application menu With any element selected, we can position the Playhead upon the Timeline and look to the application menu to insert our keyframes. Simply navigate to the menu and choose Timeline | Add Keyframe and then select the type of keyframe to add, based upon the property we wish to set a keyframe for: Not all properties have keyboard shortcuts assigned to them by default, though we can easily assign them for commonly used properties, if we wish. This is accomplished through the application menu: Edit | Keyboard Shortcuts.... Using the Timeline keyframe buttons With any element selected, we can position the Playhead upon the Timeline and look to the left area of the Timeline panel to insert our keyframes. Any property which currently has a keyframe assigned to it will appear grouped beneath an element in the Timeline. These existing properties will include a small icon positioned to the right of the property name through which we can add new keyframes for that specific property. To add new keyframes to properties which do not appear beneath an element, we can simply right-click on the element name and choose Add Keyframe to insert them: Using right-click for keyframe insertion With any element selected, we can position the Playhead upon the Timeline and look to the Stage itself to insert our keyframes. Simply right-click on any element which exists on the Stage at that place in the Timeline, and choose Add Keyframe to insert any of the available properties for that element. Animating with the Playhead We will now do a simple animation of an element moving from one side of the Stage to the other, while rotating and changing color using the Playhead along with the Properties panel. Create a new Edge Animate project and save it to your local disk. Adjust the Stage as follows by using the Properties panel: Stage W: 600 px Stage H: 350 px Background Color: #000000 Overflow: hidden Using the Rectangle tool, draw out an element upon the Stage. We will modify its properties in the next step, so do not worry about dimensions or shape. For each property listed, make the following adjustments within the Properties panel: Location X: 20 px Location Y: 230 px Size W: 100 px Size H: 100 px Background Color: #c0c0c0 Still using the Properties panel, click on the keyframe diamond next to the properties for Location, Background Color, and Rotation. This will set a keyframe for each property within the Timeline. Be sure that Auto-Keyframe properties is in its selected state in the Timeline. Since we have already marked each of these properties with initial keyframes, any adjustments we make across time will be auto-keyframed. Our project should now appear as shown in the following screenshot. We are ready to proceed with the remainder of this exercise. Drag the Playhead over to the ruler marker labeled 0:04 and release. Now, select the element with the Selection tool and in the Properties panel, modify the following properties: Location X: 480 px Background Color: #900000 Rotation: 480 deg Notice that we now have transition bars appear on the Timeline with another set of keyframes at the end of our animation sequence. We can now either scrub through the Timeline by dragging the Playhead back and forth, or hit the Play button to view the full sequence. When played back, the element should appear to roll along the Stage from left to right, changing from gray to red as it does so. The resulting end state is displayed in the following screenshot: Note that any of the properties of an element can be keyframed, thus modified over time in the way we have done here. Animating with the Pin Now we will perform the preceding exercise, but this time we will employ the Pin to demonstrate an alternative way of creating motion in Edge Animate. Create a new Edge Animate project and save it to your local disk. Adjust the Stage as follows by using the Properties panel: Stage W: 600 px Stage H: 350 px Background Color: #000000 Overflow: hidden Using the Rectangle tool, draw out an element upon the Stage. We will modify its properties in the next step, so do not worry about dimensions or shape. For each property listed, make the following adjustments within the Properties panel: Location X: 20 px Location Y: 230 px Size W: 100 px Size H: 100 px Background Color: #c0c0c0 Drag the Playhead to 0:04 in the Timeline. Now, go to the application menu and select Timeline | Toggle Pin. This will unsync the Pin from the Playhead. Again, the Pin is the small control directly beneath the Playhead when unsynced. Grab the Pin and drag it to 0:00 in the Timeline. This will pin the element's current properties to the 0:00 point without the need to manually insert keyframes. Keep the Playhead itself at 0:04. Now, select the element with the Selection tool and in the Properties panel, modify the following properties: Location X: 480 px Background Color: #900000 Rotation: 480 deg Notice that we now have transition bars appear on the Timeline without the need to set any keyframes whatsoever. Go to the application menu and select Timeline | Toggle Pin to sync the Pin. We can also toggle the Pin through a keyboard shortcut. We can now either scrub through the Timeline by dragging the Playhead back and forth, or hit the Play button to view the full sequence. When played back, the element should appear to roll along the Stage from left to right, changing from gray to red as it does so. Note that, while in this case the Pin was placed at an earlier time in relation to the Playhead within our Timeline—that need not be the case. We can also place the Pin at a later time than the Playhead and the same behavior will be exhibited: current properties are pinned to the Pin position while adjusted properties align to the position of the Playhead.
Read more
  • 0
  • 0
  • 1955

article-image-troubleshooting-your-bam-applications
Packt
21 Nov 2012
9 min read
Save for later

Troubleshooting your BAM Applications

Packt
21 Nov 2012
9 min read
(For more resources related to this topic, see here.) Understanding BAM logging and troubleshooting methodologies In many cases, enabling BAM logging is the prerequisite for troubleshooting BAM issues. It is critical to set up the correct loggers to appropriate levels (for example, SEVERE, WARNING, INFO, CONFIG, FINE, FINER, and FINEST), so that you can collect the information to identify the actual problem, and determine the root cause. Apart from logging, it is also important to have the proven methodologies in place, so that you can follow these methods/procedures to conduct your troubleshooting practice. Understanding BAM logging concepts BAM provides a set of loggers, which are associated with BAM Java packages/ classes. Like Java, these loggers are named by following the dot convention, and are organized hierarchically. Let's take a look at an example. oracle.bam.adc is the root logger for the Active Data Cache. All the loggers for the sub-modules within the Active Data Cache should be named after oracle.bam.adc, and therefore become descendants of the root logger. For instance, oracle.bam.adc.security, which is the logger that tracks Active Data Cache security logs, is the child logger of oracle.bam.adc. The logging level for the descendant/child (for example, oracle.bam.adc.security)inherits from the ancestor/parent (for example, oracle.bam.adc adc) by default, unless its logging level is explicitly specified. Thus, you should be careful when setting a root or parent logger to a low level (for example, TRACE:32 ), which may produce a large amount of log entries in the log file The following table lists the major root-level loggers for troubleshooting key BAM components: Logger name Description oracle.bam.adapter This is the logger for troubleshooting the BAM Adapter issues oracle.bam.adc This is the logger for troubleshooting the BAM Active Data Cache operations, such as data persistence, ADC APIs, Active Data processing with ADC, and so on orable.bam.common This is the logger for debugging BAM common components, for example, BAM Security or BAM Messaging Framework oracle.bam.ems This is the logger for debugging BAM Enterprise Message Sources (EMS) oracle.bam.eventengine This is the logger for debugging the Event Engine oracle.bam.reportcache This is the logger for debugging the Report Cache oracle.bam.web This is the logger for debugging the BAM web applications, which include the Report Server oracle.bam.webservices This is the logger for debugging the BAM web services interface Enabling logging for BAM To set up loggers for BAM, perform the following steps: Log in to Enterprise Manager 11g Fusion Middleware Control. Click on OracleBamServer(bam_server1) from the left pane, and select BAM Server | Logs | Log Configuration. Expand oracle.bam to set the BAM loggers. To ensure that the log-level changes are persistent, check the checkbox for Persist log level state across component restarts. Click on Apply. The logs are written to the <server_name>-diagnostic.log file in the <mserver_domain_dir>/servers/<server_name>/logs directory. By default, the log file follows the size-based rotation policy, and the rotational size is 10M. You can change the default behavior by editing the log file configuration as follows: Log in to Enterprise Manager 11g Fusion Middleware Control. Click on OracleBamServer(bam_server1) from the left pane, and select BAM Server | Logs | Log Configuration. In the Log Configurations screen, click on the Log Files tab. Select odl-handler, and then click on Edit Configuration Edit the log file configuration, and click on OK. Setting BAM loggers to appropriate values Similar to what most Fusion Middleware components do, Oracle BAM uses the lo g levels specified in the Oracle Diagnostic Logging (ODL) standard to control the log details in the diagnostic log file. Similar to the log levels in Java, ODL log levels and their descriptions are listed in the following table: Log level (Java) Log level (ODL) Description SEVERE+100 INCIDENT_ ERROR:1 This log level enables the BAM Server that reports critical issues or fatal errors. SEVERE ERROR:1 This log level enables the BAM Server components to report issues (system errors, exceptions, or malfunctions) that may prevent the system from working properly. WARNING WARNING:1 This log level enables the BAM Server components to report events or conditions that should be reviewed and may require actions. INFO NOTIFICATION:1 This is the default setting for all the BAM loggers. This log level is used to capture the lifecycle events of BAM Server components and the key messages for notification purposes. For example, if you need to verify the cache location or its running status for the BAM Report Cache, you can set the report cache logger to this log level. CONFIG NOTIFICATION:16 This log level enables the BAM Server components to write more detailed configuration information. FINE TRACE:1 This log level enables the BAM Server components to write the debug information to the log file. To  troubleshoot the BAM server components, you may start with this log level, and increase to FINER or FINEST, if needed. FINER TRACE:16 This log level enables the BAM Server components to write a fairly detailed debug information to the log file. FINEST TRACE:32 This log level enables the BAM Server components to write a highly detailed debug information. Inherited from parent   Specify this value if you want a specific logger to inherit the log level from its parent logger. The default setting for all BAM loggers is NOTIFICATION:1. For troubleshooting purposes, it is recommended to set the appropriate loggers to TRACE:1, TRACE:16, or TRACE:32. The logging configuration is persisted in the following location on your BAM host: <domain_dir>/config/fmwconfig/ servers/<server_name>/logging.xml. Theoretically, you can edit this file to modify BAM loggers. However, it is not recommended to do so unless you have a good understanding of the configuration file. If you have multiple BAM instances in your environment, you can easily duplicate the logging configuration by copying the logging.xml file to all BAM instances, rather than making changes through EM. Introducing the methodologies for troubleshooting BAM Oracle BAM utilizes different technologies such as EMS, BAM Adapter, Web services, and ODI to integrate different enterprise information systems. Business data received from various data sources are then pushed all the way from the Active Data Cache, through the Report Cache and the Report Server, to Web browsers for rendering reports in real-time. Due to the complexity of the system and various technologies involved, it is critical to use the right troubleshooting methodologies to analyze and resolve issues. The following are the basic rules of thumb for troubleshooting your BAM applications: Understand the BAM key terminologies and architecture Identify the problem Set up BAM loggers Collect the information and debugging Understanding the key terminologies and the BAM architecture Understanding the key terminologies and the BAM architecture is a prerequisite for troubleshooting the BAM applications. The key terminologies for BAM include Active Data, Active Data Cache, Report Cache, Report Server, ChangeList, Data Objects, Report, and so on. Identifying the problem Different issues may require different techniques to troubleshoot. For example, for a report design issue (for example, calculated fields do not show correct values), you should focus on the building blocks for the report design, instead of enabling loggings for the BAM server, which does not provide any help at all. A BAM issue typically falls into the following categories: Report design and report loading (static rendering) Report rendering with Active Data (Active Data processing) Issues with the key BAM Server components (Active Data Cache, securities, Report Cache, and Event Engine) BAM Web applications (Active Viewer, Active Studio, Architect, Administrator, and Report Server) Issues with BAM Integration Framework (EMS, Web services APIs, SOA Suite integration, and ODI integration) To fully identify a problem, you need to first understand the problem description and the category to which the issue belongs. Then, you can gather relevant information, such as the time frame of when the issue happened, the BAM Server release information and patch level, BAM deployment topologies (single node or HA), and so on. Setting up BAM loggers Setting up BAM loggers with appropriate logging levels is the key for troubleshooting BAM issues. BAM loggers can be set up to the following levels (Java logging): SEVERE, WARNING, INFO, CONFIG, FINE, FINER, and FINEST. In a normal situation, all the BAM loggers are set to INFO, by default. In the case of debugging, it is recommended to increase the level to FINER or FINEST. Loggers contain hierarchies. You need to be careful when setting up root level loggers to FINE, FINER, or FINEST. Suppose that you want to troubleshoot a login issue with the BAM start page using the root logger oracle.bam.adc, which is set to FINEST. In this case, all the descendants that inherit from it have the same logging level. As a result, a large amount of unused log entries are produced, which is not helpful for troubleshooting, and can also impact the overall performance. Therefore, you should set up the corresponding child logger (oracle.bam.adc.security) without enabling the root logger.Collecting information and debugging. Once the problem is identified and BAM loggers are set up appropriately, it is time to collect the logs to analyze the problem. The following table lists the files that can be used to troubleshoot BAM issues: Name Description <server_name>.out This is the standard output file redirected by the Node Manager. If the server is started using the  tartManagedWebLogic.sh script directly, you need to refer to the standard output (either the command prompt output or another redirected file specified). This file is located in the following directory: <mserver_domain_dir>/servers/<server_name>/logs. <mserver_domain_dir> refers to the domain home directory for the Managed Server for BAM; <server_name> refers to the name of the Managed Server for BAM, for example, WLS_BAM1. Use this file to collect the server starting information and standard output. <server_name>.log This log provides information for the WebLogic Server that hosts BAM. This file is located in the following directory: <mserver_domain_dir>/servers/<server_name>/logs. <server_name>-diagnostic.log Unlike the <server_name>.log file, this log file keeps a track of BAM-specific logs produced by BAM loggers. The location of this file is as follows: <mserver_domain_dir>/servers/<server_name>/logs. Debugging actually becomes easier once you have all this relevant information in place.
Read more
  • 0
  • 0
  • 3646

article-image-web-services-testing-and-soapui
Packt
16 Nov 2012
8 min read
Save for later

Web Services Testing and soapUI

Packt
16 Nov 2012
8 min read
(For more resources related to this topic, see here.) SOA and web services SOA is a distinct approach for separating concerns and building business solutions utilizing loosely coupled and reusable components. SOA is no longer a nice-to-have feature for most of the enterprises and it is widely used in organizations to achieve a lot of strategic advantages. By adopting SOA, organizations can enable their business applications to quickly and efficiently respond to business, process, and integration changes which usually occur in any enterprise environment. Service-oriented solutions If a software system is built by following the principles associated with SOA, it can be considered as a service-oriented solution. Organizations generally tend to build service-oriented solutions in order to leverage flexibility in their businesses, merge or acquire new businesses, and achieve competitive advantages. To understand the use and purpose of SOA and service-oriented solutions, let's have a look at a simplified case study. Case study Smith and Co. is a large motor insurance policy provider located in North America. The company uses a software system to perform all their operations which are associated with insurance claim processing. The system consists of various modules including the following: Customer enrollment and registration Insurance policy processing Insurance claim processing Customer management Accounting Service providers management With the enormous success and client satisfaction of the insurance claims processed by the company during the recent past, Smith and Co. has acquired InsurePlus Inc., one of its competing insurance providers, a few months back. InsurePlus has also provided some of the insurance motor claim policies which are similar to those that Smith and Co. provides to their clients. Therefore, the company management has decided to integrate the insurance claim processing systems used by both companies and deliver one solution to their clients. Smith and Co. uses a lot of Microsoft(TM) technologies and all of their software applications, including the overall insurance policy management system, are built on .NET framework. On the other hand, InsurePlus uses J2EE heavily, and their insurance processing applications are all based on Java technologies. To worsen the problem of integration, InsurePlus consists of a legacy customer management application component as well, which runs on an AS-400 system. The IT departments of both companies faced numerous difficulties when they tried to integrate the software applications in Smith and Co. and InsurePlus Inc. They had to write a lot of adapter modules so that both applications would communicate with each other and do the protocol conversions as needed. In order to overcome these and future integration issues, the IT management of Smith and Co. decided to adopt SOA into their business application development methodology and convert the insurance processing system into a service-oriented solution. As the first step, a lot of wrapper services (web services which encapsulate the logic of different insurance processing modules) were built, exposing them as web services. Therefore the individual modules were able to communicate with each other with minimum integration concerns. By adopting SOA, their applications used a common language, XML, in message transmission and hence a heterogeneous systems such as the .NET based insurance policy handling system in Smith and Co. was able to communicate with the Java based applications running on InsurePlus Inc. By implementing a service-oriented solution, the system at Smith and Co. was able to merge with a lot of other legacy systems with minimum integration overhead. Building blocks of SOA When studying typical service-oriented solutions, we can identify three major building blocks as follows: Web services Mediation Composition Web services Web services are the individual units of business logic in SOA. Web services communicate with each other and other programs or applications by sending messages. Web services consist of a public interface definition which is a central piece of information that assigns the service an identity and enables its invocation. The service container is the SOA middleware component where the web service is hosted for the consuming applications to interact with it. It allows developers to build, deploy, and manage web services and it also represents the server-side processor role in web service frameworks. A list of commonly used web service frameworks can be found at http://en.wikipedia.org/wiki/List_of_web_service_frameworks; here you can find some popular web service middleware such as Windows Communication Foundation (WCF) Apache CXF, Apache Axis2, and so on. Apache Axis2 can be found at http://axis.apache.org/ The service container contains the business logic, which interacts with the service consumer via a service interface. This is shown in the following diagram: Mediation Usually, the message transmission between nodes in a service-oriented solution does not just occur via the typical point-to-point channels. Instead, once a message is received, it can be flowed through multiple intermediaries and subjected to various transformation and conversions as necessary. This behavior is commonly referred to as message mediation and is another important building block in service-oriented solutions. Similar to how the service container is used as the hosting platform for web services, a broker is the corresponding SOA middleware component for message mediation. Usually, enterprise service bus (ESB) acts as a broker in service-oriented solutions Composition In service-oriented solutions, we cannot expect individual web services running alone to provide the desired business functionality. Instead, multiple web services work together and participate in various service compositions. Usually, the web services are pulled together dynamically at the runtime based on the rules specified in business process definitions. The management or coordination of these business processes are governed by the process coordinator, which is the SOA middleware component associated with web service compositions. Simple Object Access Protocol Simple Object Access Protocol (SOAP) can be considered as the foremost messaging standard for use with web services. It is defined by the World Wide Web Consortium (W3C) at http://www.w3.org/TR/2000/NOTE-SOAP-20000508/ as follows: SOAP is a lightweight protocol for exchange of information in a decentralized, distributed environment. It is an XML based protocol that consists of three parts: an envelope that defines a framework for describing what is in a message and how to process it, a set of encoding rules for expressing instances of application-defined datatypes, and a convention for representing remote procedure calls and responses. The SOAP specification has been universally accepted as the standard transport protocol for messages processed by web services. There are two different versions of SOAP specification and both of them are widely used in service-oriented solutions. These two versions are SOAP v1.1 and SOAP v1.2. Regardless of the SOAP specification version, the message format of a SOAP message still remains intact. A SOAP message is an XML document that consists of a mandatory SOAP envelope, an optional SOAP header, and a mandatory SOAP body. The structure of a SOAP message is shown in the following diagram: The SOAP Envelope is the wrapper element which holds all child nodes inside a SOAP message. The SOAP Header element is an optional block where the meta information is stored. Using the headers, SOAP messages are capable of containing different types of supplemental information related to the delivery and processing of messages. This indirectly provides the statelessness for web services as by maintaining SOAP headers, services do not necessarily need to store message-specific logic. Typically, SOAP headers can include the following: Message processing instructions Security policy metadata Addressing information Message correlation data Reliable messaging metadata The SOAP body is the element where the actual message contents are hosted. These contents of the body are usually referred to as the message payload. Let's have a look at a sample SOAP message and relate the preceding concepts through the following diagram: In this example SOAP message, we can clearly identify the three elements; envelope, body, and header. The header element includes a set of child elements such as <wsa:To>, <wsa:ReplyTo>, <wsa:Address>, <wsa:MessageID>, and <wsa:Action>. These header blocks are part of the WS-Addressing specification. Similarly, any header element associated with WS-* specifications can be included inside the SOAP header element. The <s:Body> element carries the actual message payload. In this example, it is the <p:echoString> element with a one child element. When working with SOAP messages, identification of the version of SOAP message is one of the important requirements. At first glance, you can determine the version of the specification used in the SOAP message through the namespace identifier of the <Envelope> element. If the message conforms to SOAP 1.1 specification, it would be http://schemas.xmlsoap.org/soap/envelope/, otherwise http://www.w3.org/2003/05/soap-envelope is the name space identifier of SOAP 1.2 messages. Alternatives to SOAP Though SOAP is considered as the standard protocol for web services communication, it is not the only possible transport protocol which is used. SOAP was designed to be extensible so that the other standards could be integrated into it. The WS-* extensions such as WS-Security, WS-Addressing, and WSReliableMessaging are associated with SOAP messaging due to this extensible nature. In addition to the platform and language agnosticism, SOAP messages can be transmitted over various transports such as HTTP, HTTPS, JMS, and SMTP among others. However, there are a few drawbacks associated with SOAP messaging. The performance degradations due to heavy XML processing and the complexities associated with the usage of various WS-* specifications are two of the most common disadvantages of the SOAP messaging model. Because of these concerns, we can identify some alternative approaches to SOAP.
Read more
  • 0
  • 0
  • 3015
article-image-dispatchers-and-routers
Packt
12 Nov 2012
5 min read
Save for later

Dispatchers and Routers

Packt
12 Nov 2012
5 min read
(For more resources related to this topic, see here.) Dispatchers In the real world, dispatchers are the communication coordinators that are responsible for receiving and passing messages. For the emergency services (for example, in U.S. – 911), the dispatchers are the people responsible for taking in the call, and passing on the message to the other departments (medical, police, fire station, or others). The dispatcher coordinates the route and activities of all these departments, to make sure that the right help reaches the destination as early as possible. Another example is how the airport manages airplanes taking off. The air traffic controllers (ATCs) coordinate the use of the runway between the various planes taking off and landing. On one side, air traffic controllers manage the runways (usually ranging from 1 to 3), and on the other, aircrafts of different sizes and capacity from different airlines ready to take off and land. An air traffic controller coordinates the various airplanes, gets the airplanes lined up, and allocates the runways to take off and land: As we can see, there are multiple runways available and multiple airlines, each having a different set of airplanes needing to take off. It is the responsibility of air traffic controller(s) to coordinate the take-off and landing of planes from each airline and do this activity as fast as possible. Dispatcher as a pattern Dispatcher is a well-recognized and used pattern in the Java world. Dispatchers are used to control the flow of execution. Based on the dispatching policy, dispatchers will route the incoming message or request to the business process. Dispatchers as a pattern provide the following advantages: Centralized control: Dispatchers provide a central place from where various messages/requests are dispatched. The word "centralized" means code is re-used, leading to improved maintainability and reduced duplication of code. Application partitioning: There is a clear separation between the business logic and display logic. There is no need to intermingle business logic with the display logic. Reduced inter-dependencies: Separation of the display logic from the business logic means there are reduced inter-dependencies between the two. Reduced inter-dependencies mean less contention on the same resources, leading to a scalable model. Dispatcher as a concept provides a centralized control mechanism that decouples different processing logic within the application, which in turn reduces inter-dependencies. Executor in Java In Akka, dispatchers are based on the Java Executor framework (part of java.util.concurrent).Executor provides the framework for the execution of asynchronous tasks. It is based on the producer–consumer model, meaning the act of task submission (producer) is decoupled from the act of task execution (consumer). The threads that submit tasks are different from the threads that execute the tasks. Two important implementations of the Executor framework are as follows: ThreadPoolExecutor: It executes each submitted task using thread from a predefined and configured thread pool. ForkJoinPool: It uses the same thread pool model but supplemented with work stealing. Threads in the pool will find and execute tasks (work stealing) created by other active tasks or tasks allocated to other threads in the pool that are pending execution. Fork/join is based a on fine-grained, parallel, divide-andconquer style, parallelism model. The idea is to break down large data chunks into smaller chunks and process them in parallel to take advantage of the underlying processor cores. Executor is backed by constructs that allow you to define and control how the tasks are executed. Using these Executor constructor constructs, one can specify the following: How many threads will be running? (thread pool size) How are the tasks queued until they come up for processing? How many tasks can be executed concurrently? What happens in case the system overloads, when tasks to be rejected are selected? What is the order of execution of tasks? (LIFO, FIFO, and so on) Which pre- and post-task execution actions can be run? In the book Java Concurrency in Practice, Addison-Wesley Publishing, the authors have described the Executor framework and its usage very nicely. It will be useful to read the book for more details on the concurrency constructs provided by Java language. Dispatchers in Akka In the Akka world, the dispatcher controls and coordinates the message dispatching to the actors mapped on the underlying threads. They make sure that the resources are optimized and messages are processed as fast as possible. Akka provides multiple dispatch policies that can be customized according to the underlying hardware resource (number of cores or memory available) and type of application workload. If we take our example of the airport and map it to the Akka world, we can see that the runways are mapped to the underlying resources—threads. The airlines with their planes are analogous to the mailbox with the messages. The ATC tower employs a dispatch policy to make sure the runways are optimally utilized and the planes are spending minimum time on waiting for clearance to take off or land: For Akka, the dispatchers, actors, mailbox, and threads look like the following diagram: The dispatchers run on their threads; they dispatch the actors and messages from the attached mailbox and allocate on heap to the executor threads. The executor threads are configured and tuned to the underlying processor cores that available for processing the messages.
Read more
  • 0
  • 0
  • 6425

article-image-graphic-design-working-clip-art-and-making-your-own
Packt
09 Nov 2012
9 min read
Save for later

Graphic Design - Working with Clip Art and Making Your Own

Packt
09 Nov 2012
9 min read
(For more resources related to this topic, see here.) Making symbols from Character Palette into clip art—where to find clip art for iWork Clip art is the collective name for predrawn images, pictures, and symbols that can be quickly added to documents. In standalone products, a separate Clip art folder is often added to the package. iWork doesn't have one — this has been the subject of numerous complaints on the Internet forums. However, even though there is no clip art folder as such in iWork, there are hundreds of clip-art images on Mac computers that come as part of our computers. Unlike MS Office or Open Office that are separate Universes on your machine, iWork (even though we buy it separately) is an integral part of the Mac. It complements and works with applications that are already there, such as iLife (iPhoto), Mail, Preview, Address Book, Dictionaries, and Spotlight. Getting ready So, where is the clip art for iWork? First, elements of the Pages templates can be used as clip art—just copy and paste them. Look at this wrought iron fence post from the Collector Newsletter template. It is used there as a column divider. Select and copy-paste it into your project, set the image placement to Floating, and move it in between the columns or text boxes. The Collector Newsletter template also has a paper clip, a price tag, and several images of slightly rumpled and yellowed sheets of paper that can be used as backgrounds. Images with little grey houses and house keys from the Real Estate Newsletter template are good to use with any project related to property. The index card image from the Back Page of the Green Grocery Newsletter template can be used for designing a cooking recipe, and the background image of a yellowing piece of paper from the Musical Concert poster would make a good background for an article on history. Clip art in many templates is editable and easy to resize or modify. Some of the images are locked or grouped. Under the Arrange menu, select the Unlock and Ungroup options, to use those images as separate graphic elements. Many of the clip-art images are easy to recreate with iWork tools. Bear in mind, however, that some of the images have low resolution and should only be used with small dimensions. You will find various clip-art images in the following locations: A dozen or so attractive clip-art images are in Image Bullets, under the Bullets drop-down menu: Open the Text Inspector, click on the List tab, and choose Image Bullets from the Bullets & Numbering drop-down menu. There, you will find checkboxes and other images. Silver and gold pearls look very attractive, but any of your own original images can also be made into bullets. In Bullets, choose Custom Image | Choose and import your own image. Note that images with shadows may distort the surrounding text. Use them with care or avoid applying shadows. Navigate to Macintosh HD | Library | Desktop Pictures: Double-click on the hard disk icon on your desktop and go to Library | Desktop Pictures. There are several dozen images including the dew drop and the lady bug. These are large files, good enough for using as background images. They are not, strictly speaking, clip art but are worth keeping in mind. Navigate to Home| Pictures | iChat Icons (or HD | Library | Application Support | Apple | iChat Icons): The Home folder icon (a little house) is available in the side panel of any folder on your Mac. This is where documents associated with your account are stored on your computer. It has a Pictures folder with a dozen very small images sitting in the folder called iChat Icons. National flags are stored here as button-like images. The apple image can be found in the Fruit folder. The gems icons, such as the ruby heart, from this folder look attractive as bullets. Navigate to HD | Library | User Pictures: You can find animals, flowers, nature, sports, and other clip-art images in this folder. These are small TIFF files that can be used as icons when a personal account is set up on a Mac. But of course, they can be used as clip art. The Sports folder has a selection of balls, but not a cricket ball, even though cricket may have the biggest following in the world (Britain, South Africa, Australia, India, Pakistan, Bangladesh, Sri Lanka, and many Caribbean countries). But, a free image of the cricket ball from Wikipedia/Wikimedia can easily be made into clip art. There may be several Libraries on your Mac. The main Library is on your hard drive; don't move or rename any folders here. Duplicate images from this folder and use copies. Your personal library (it is created for each account on your machine) is in the Home folder. This may sound a bit confusing, but you don't have to wade through endless folders to find what you want, just use Spotlight to find relevant images on your computer, in the same way that you would use Google to search on the Internet. Character Palette has hundreds of very useful clip-art-like characters and symbols. You can find the Character Palette via Edit | Special Characters. Alternatively, open System Preferences | International | Input Menu. Check the Character Palette and Show input menu in menu bar boxes: Now, you will be able to open the Character Palette from the screen-top menu. Character Palette can also be accessed through Font Panel. Open it with the Command + T keyboard shortcut. Click on the action wheel at the bottom of the panel and choose Characters... to open the Character Palette. Check the Character Palette box to find what you need. Images here range from the familiar Command symbol on the Mac keyboard to zodiac symbols, to chess pieces and cards icons, to mathematical and musical signs, various daily life shapes, including icons of telephones, pens and pencils, scissors, airplanes, and so on. And there are Greek letters that can be used in scientific papers (for instance, the letter ∏). To import the Character Palette symbols into an iWork document, just click-and-drag them into your project. The beauty of the Character Palette characters is that they behave like letters. You can change the color and font size in the Format bar and add shadows and other effects in the Graphics Inspector or via the Font Panel. To use the Character Palette characters as clip art, we need to turn them into images in PDF, JPEG, or some other format. How to do it... Let's see how a character can be turned into a piece of clip art. This applies to both letters and symbols from the Character Palette. Open Character Palette | Symbols | Miscellaneous Symbols. In this folder, we have a selection of scissors that can be used to show, with a dotted line, where to cut out coupons or forms from brochures, flyers, posters, and other marketing material. Click on the scissors symbol with a snapped off blade and drag it into an iWork document. Select the symbol in the same way as you would select a letter, and enlarge it substantially. To enlarge, click on the Font Size drop-down menu in the Format bar and select a bigger size, or use the shortcut key Command + plus sign (hit the plus key several times). Next, turn the scissors into an image. Make a screenshot (Command + Shift + 4) or use the Print dialog to make a PDF or a JPEG. You can crop the image in iPhoto or Preview before using it in iWork, or you can import it straight into your iWork project and remove the white background with the Alpha tool. If Alpha is not in your toolbar, you can find it under Format |Instant Alpha. Move the scissors onto the dotted line of your coupon. Now, the blade that is snapped in half appears to be cutting through the dotted line. Remember that you can rotate the clip art image to put scissors either on the horizontal or on the vertical sides of the coupon. Use other scissors symbols from the Character Palette, if they are more suitable for your project. Store the "scissors" clip art in iPhoto or another folder for future use if you are likely to need it again. There's more... There are other easily accessible sources of clip art. MS Office clip art is compatible If you have kept your old copy of MS Office, nothing is simpler than copy-pasting or draggingand- dropping clip art from the Office folder right into your iWork project. When using clip art, it's worth remembering that some predrawn images quickly become dated. For example, if you put a clip art image of an incandescent lamp in your marketing documents for electric works, it may give an impression that you are not familiar with more modern and economic lighting technologies. Likewise, a clip art image of an old-fashioned computer with a CRT display put on your promotional literature for computer services can send the wrong message, because modern machines use flat-screen displays. Wikipedia/Wikimedia Look on Wikipedia for free generic images. Search for articles about tools, domestic appliances, furniture, houses, and various other objects. Most articles have downloadable images with no copyright restrictions for re-use. They can easily be made into clip art. This image of a hammer from Wikipedia can be used for any articles about DIY (do-it-yourself) projects. Create your own clip art Above all, it is fun to create your own clip art in iWork. For example, take a few snapshots with your digital camera or cell phone, put them in one of iWork's shapes, and get an original piece of clip art. It could be a nice way to involve children in your project.
Read more
  • 0
  • 0
  • 2759

article-image-blender-engine-characters
Packt
09 Nov 2012
4 min read
Save for later

Blender Engine : Characters

Packt
09 Nov 2012
4 min read
(For more resources related to this topic, see here.) An example — save the whale! The game can augment its levels of difficulty as we develop our world using different environments. We can always increase the capability of your character with new keyboard functions. Obviously, this is an example. Feel free to change the game, remake it, create another completely different character, and provide a gameplay of another gaming genre. There are thousands of possibilities, and it's fine if you deviate from our idea. It is important that you clear your design before you start your game library. That's all. How to create a library If we start working with the Blender Game Engine (BGE), we must have a library of all of the objects we use in our game. For example, the basic character, or even the smallest details, such as the appearance of health levels of our enemies. On the Internet, we can find plenty of 3D objects, which can be useful for our game. Let's make sure we use free models and read the instructions to run the model. Do not forget to mention the authorship of each object that you download. Time for action — downloading models from the Internet Let's go to one of the repositories for Blender, which can be found at http://www.opengameart.org/ and let's try to search for what is closest to our character. Write sea in the Search box, and choose 3D Art for Art Type, as shown in the following screenshot: We have some interesting options. We see a shark, seaweed, and some icebergs to select from. Choose and click on the thumbnail with the name ICEBERGS IN 3D: At the bottom of the page, you will find the file.blend downloadable. Click on it to start the download. Remember to click on RMB before the download begins. Now, let's try web pages, which have libraries that offer 3D models in other formats. An example of a very extensive library is http://sketchup.google.com/3dwarehouse/. Write trawler in the Search box, and choose the one that you like. In our case, we decided to go for the Google 3D model with the title Trawler boat, 28': Click on the Download model button: Save the file on your hard disk, in a folder of your game. What just happened? We have searched the Internet for 3D models, which will allow us to start a library for our game objects in Blender. Whether they are .blend files (original blender format) or of a 3D-model format, you can import them and work with them. Don't download models that you will not use. The libraries on the Internet grow every day, and we don't need to save all of the models that we like. Remember that before downloading the model and using it, we need to check if it has a free license. If you are releasing your project under some other free and/or open source license, then there could be licensing conflicts depending on what license the art is released under. It is your responsibility to verify the compatibility of the art license with the license you are using. Importing other files into Blender Before the imported mesh can be used, some scene and mesh prepping in Blender is usually required. It basically cleans up the model imported in Blender. Google SketchUp is another free, 3D software option. You can build models from scratch, and you can upload or download what you need, as you have seen. People all over the world share what they've made on the Google 3D Warehouse. It's our time to do the same. Download the program from http://sketchup.comand install it. You can uninstall it later. Open the boat file in SketchUp, click on Save as, and export the 3D model using the COLLADA format. The *.dae Collada format is a common, cross-platf orm file, which can be imported directly into Blender.
Read more
  • 0
  • 0
  • 3497
article-image-starting-gradle
Packt
07 Nov 2012
6 min read
Save for later

Starting with Gradle

Packt
07 Nov 2012
6 min read
(For more resources related on Gradle, see here.) Let's take a look at some of Gradle's features. Declarative builds and convention over configuration Gradle uses a Domain Specific Language (DSL) based on Groovy to declare builds. The DSL provides a fl exible language that can be extended by us. Because the DSL is based on Groovy, we can write Groovy code to describe a build and use the power and expressiveness of the Groovy language. Groovy is a language for the Java Virtual Machine (JVM), such as Java and Scala. Groovy makes it easy to work with collections, has closures, and has a lot of useful features. The syntax is closely related to the Java syntax. In fact, we could write a Groovy class file with Java syntax and it would compile. But, using the Groovy syntax makes it easier to express the code intent, and we need less boilerplate code than with Java. To get the most out of Gradle, it is best to learn the basics of the Groovy language, but it is not necessary to start writing Gradle scripts. Gradle is designed to be a build language and not a rigid framework. The Gradle core itself is written in Java and Groovy. To extend Gradle we can use Java and Groovy to write our custom code. We can even write our custom code in Scala if we want to. Gradle provides support for Java, Groovy, Scala, Web, and OSGi projects, out of the box. These projects have sensible convention over configuration settings that we probably already use ourselves. But we have the fl exibility to change these configuration settings, if needed, in our projects. Support for Ant tasks and Maven repositories Gradle supports Ant tasks and projects. We can import an Ant build and re-use all the tasks. But we can also write Gradle tasks dependent on Ant tasks. The integration also applies to properties, paths, and so on. Maven and Ivy repositories are supported to publish or fetch dependencies. So, we can continue to use any repository infrastructure we already have. Incremental builds With Gradle we have incremental builds. This means tasks in a build are only executed if necessary. For example, a task to compile source code will first check whether the sources since the last execution of the task have changed. If the sources have changed, the task is executed, but if the sources haven't changed, the execution of the task is skipped and the task is marked as being up to date. Gradle supports this mechanism for a lot of the provided tasks. But we can also use this for tasks we write ourselves. Multi-project builds Gradle has great support for multi-project builds. A project can simply be dependent on other projects or be a dependency for other projects. We can define a graph of dependencies between projects, and Gradle can resolve those dependencies for us. We have the flexibility to define our project layout as we want. Gradle has support for partial builds. This means Gradle will figure out if a project that our project depends on needs to be rebuilt or not. And if the project needs rebuilding, Gradle will do this before building our own project. Gradle wrapper The Gradle wrapper allows us to execute Gradle builds, even though Gradle is not installed on a computer. This is a great way to distribute source code and provide the build system with it, so that the source code can be built. Also, in an enterprise environment, we can have a zero administration way for client computers to build the software. We can use the wrapper to enforce a certain Gradle version to be used, so the whole team is using the same version. Free and open source Gradle is an open source project and it is licensed under the Apache Software License (ASL). Getting started We will download and install Gradle before writing our first Gradle build script. Before we get and install Gradle, we must make sure we have a Java Development Kit (JDK) installed on our computer. Gradle requires JDK 5 or higher. Gradle will use the JDK found at the path set on our computer. We can check this by running the following command on the command line: java -version Although Gradle uses Groovy, we don't have to install Groovy ourselves. Gradle bundles the Groovy libraries with the distribution and will ignore a Groovy installation already available on our computer. Gradle is available on the Gradle website, at http://www.gradle.org/downloads. From this page we can download the latest release of Gradle. Or, we can download a previous version if we want to. We can choose among three different distributions to download. We can download either the complete Gradle distribution, with binaries, sources, and documentation, or only the binaries, or only the sources. To get started with Gradle, we download the standard distribution with the binaries, sources, and documentation. On computers with a Debian Linux operation sytem, we can install Gradle as a Debian package. On computers with Mac OS X, we can use MacPorts or Homebrow to install Gradle. Installing Gradle Gradle is packaged as a ZIP file for one of the three distributions. So, when we have downloaded the Gradle full distribution ZIP file, we must unzip the file. After unpacking the ZIP file we have the following: Binaries in the bin directory Documentation with the user guide, Groovy DSL, and the API documentation in the docs directory A lot of samples in the samples directory Source code for Gradle in the src directory Supporting libraries for Gradle in the lib directory A directory named init.d where we can store Gradle scripts that need to be executed each time we run Gradle Once we have unpacked the Gradle distribution to a directory, we can open a command prompt. We change the directory to bin, which we extracted from the ZIP file. To check our installation, we run gradle -v and we get output, listing the JDK used and the library versions of Gradle: $ gradle -v------------------------------------------------------------Gradle 1.1------------------------------------------------------------Gradle build time: Tuesday, July 31, 2012 1:24:32 PM UTCGroovy: 1.8.6Ant: Apache Ant(TM) version 1.8.4 compiled on May 22 2012Ivy: 2.2.0JVM: 1.6.0_33 (Apple Inc. 20.8-b03-424)OS: Mac OS X 10.7.4 x86_64 Here we can check whether the displayed version is the same as the distribution version we have downloaded from the Gradle website. To run Gradle on our computer we only have to add $GRADLE_HOME/bin to our PATH environment variable. Once we have done that, we can run the gradle command from every directory on our computer. If we want to add JVM options to Gradle, we can use the environment variables JAVA_OPTS and GRADLE_OPTS. The former is a commonly used environment variable name to pass extra parameters to a Java application. Similarly, Gradle uses the GRADLE_OPTS environment variable to pass extra arguments to Gradle. Both environment variables are used so we can set them both with different values. This is mostly used to set, for example, an HTTP proxy or extra memory options.
Read more
  • 0
  • 0
  • 2251

article-image-retopology-3ds-max
Packt
06 Nov 2012
6 min read
Save for later

Retopology in 3ds Max

Packt
06 Nov 2012
6 min read
(For more resources related to this topic, see here.) High poly model import Different applications are biased to different file formats and may therefore have different import procedures. The Send To functionality between 3ds Mudbox and 3ds Max(which is possible as both are Autodesk products).This is essentially a .fbx transfer. If you are using ZBrush, you will want to get used to the GoZequivalent transfer feature. Note that GoZ must be run from ZBrush to 3ds Max before it can go in the other direction. GoZ also works the free, mini-modeler tool from Pixologic(who make ZBrush too)called Sculptris, which is available at http://www.pixologic.com/sculptris/. In the following example, we'll directly export from Sculptris, a model made from a sphere(so it needs retopology to get a clean base mesh). We'll export it as a .obj and import it to 3ds Max in order to show a few of the idiosyncrasies of this situation. With a model that is sculpted from a primitive base, such as a sphere or box, there are no meaningful texture coordinates, so it would be impossible to paint the model. Although many sculpting programs, including Sculptris, do automapping, the results are seldom optimal. Importing a model into Sculptris The following steps detail the instructions on importing a model into Sculptris: Install Sculptris 6 Alpha and run it. Note that the default scene is a sphere made of triangle faces that dynamically subdivide where you paint. Use the brush tools to experiment with this a while. Click on Open and browse the provided content for this article, and open Packt3dsMaxChapter 9Creature.sc1. The file format .sc1 is native to Sculptris. To get this model to work in 3ds Max, you will need to choose Export and save it instead as Sculptris.obj. Importing the Sculptris.OBJ mesh in 3ds Max After we have imported a model into Sculptris, we'll move on to see how we can save this file into 3ds Max. The importing part is fairly easy. In 3ds Max, choose File | Import and browse to Sculptris.obj, the mesh you just exported from Sculptris. You could also try the example .obj called Packt3dsMaxChapter 9RetopoBullStart.obj. The import options you set matter a lot. You will need to make sure that the options Import as single mesh and Import as Editable Poly are on. This makes sure that the symmetrical object employed in the Sculptris scene (actually a separate mesh that conforms to the model) doesn't prevent the import. While importing, you should also swap the Normals radio button from the From SM group to Auto Smooth, to avoid the triangulated mesh looking faceted. A model begun in Sculptris won't contain any smoothing information when sent to 3ds Max and will come in faceted if you don't choose Auto Smooth. After importing, another way to do the same thing is to apply a Smooth modifier. The Auto Smooth value should be 90 or so, to reduce the likelihood of any sharp creases. Finally, once the model is imported into the 3ds Max scene, move it in the Z plane so it is standing on the ground plane, and make sure its pivot is at 0,0,0. This can be done by choosing Edit | Transform Toolbox and clicking on Origin in the Pivot section. Note that the model's edges are all tiny triangles. This is a result of the way Sculptris adds detail to a model. Retopology will help us get a quad-based model to continue working from. The idea of retopology is to build up a new, nicely constructed model on top of the high-resolution model. The high-resolution model serves as a guide surface. If you are curious, apply an Unwrap UVW modifier to the model and see how its UV mapping looks. Probably a bit scary. A high-resolution model such as this one (250K polys) is virtually impossible to manually UV map,at least not quickly. So we need to simplify the model. If you can't see the Ribbon, go to Customize | Show UI | Show Ribbon, or press the icon in the main toolbar. Then click on the Freeform tab. With the creature mesh selected, click on Grid in the Freeform tab. This specifies the source to which we'll conform the new mesh that we're going to generate next. We don't want to conform to the grid, so change this to Draw On: Surface and then assign the source mesh using the Pick button below the Surface button, shown in the following screenshot: Each time you relaunch 3ds Max to keep working on the retopology, you'll have to reassign the high-resolution mesh as the source surface in the same way. You could also use Draw On: Selection, which would be handy if the source was, in fact, a bunch of different meshes. There is an Offset value you can adjust so that the mesh you'll generate next will sit slightly above the source mesh that can help reduce frustration from the lower-resolution mesh, which is likely to sink in places within the more curvy, high-resolution mesh. If you're just starting out, try leaving the setting alone and see how it turns out. An additional way to help see what you are doing is to apply a semitransparent material or low Visibility value to the high-resolution model (or press Alt + X while it is selected). Next, in a nested part of the Ribbon, we have to set a new object or model to work on (that doesn't exist yet). Click on the PolyDraw rollout at the bottom of the Freeform tab. Having expanded PolyDraw, click on the New Object button and we're ready to start retopologizing. I would strongly suggest raising the Min Distance value in the PolyDraw section, so when you create the first polygons they aren't too small. When using the Strips brush, usually I set the Min Distance to around 25-35, but it depends on the model scale and the level of detail you want. Just like with modeling, when you retopologize, it is best to move from large forms to small details. The object will be called something like Box001, an Editable Poly beginning in the Vertex mode. You can rename it to Retopo or something more memorable. Turn on the Strips mode and make sure Edged Faces is toggled on (F4) so you can see the high-resolution model's center line. Starting at the head, draw a strip of polygons along the symmetry line so that there's an edge on either side. As this model is symmetrical, we only have to work on half of it. If you hold the mouse over the Strips mode icon , you'll get a tool tip that explains how Strips are made, and if you press Y, you can watch a video demo albeit drawing on the Grid. Note that the size of the polygons, as you draw, is determined by the Min Distance value under PolyDraw. Bear in mind that apart from the Min Distance value, the size of the polygons drawn also depends on the current viewport zoom. This is handy because when working on tighter detail, you'll tend to zoom in closer to the source mesh.
Read more
  • 0
  • 0
  • 6363
Modal Close icon
Modal Close icon