Trut and MVC (1)
Struts and MVC (1)
Posted on 2007-01-25 6:58 Simon brick reading (483) Comments (0) edit collections cited
Eclipe plug-in collection (the collection)
Eclipse Plugin collection (the collection)
Posted on 2007-01-27 01:12 brick read Simon (85) Comments (0) edit collections cited
Java SE 6 new characteristics: Instrumentation new features
Level: Intermediate
Rui Hu (ruihu@cn.ibm.com), software engineers, IBM
Lu:jing (purefire@126.com), software engineers, IBM
May 16, 2007
By the end of 2006, Sun announced Java Standard Edition 6 (Java SE 6) of the final version, code-named Mustang (Mustang). With Tiger (Java SE 5), the Mustang in a good performance upgrade. Tiger and the API library compared to the substantial strengthening, although the Mustang in the new API is not doing too much of, but also provides many useful and convenient features: in the script, WebService, XML, the compiler API, database , JMX, networks and Instrumentation both good new features and capabilities to strengthen. This series of articles mainly on Java SE 6 in the library of API some of the new features and some of the examples and explain to help in the development of better programming practice of the use of Java SE 6, increase development efficiency.
This paper is the first of the series, introduced in Java SE 6 Instrumentation the new features.
References) of the presentation.
Instrumentation the biggest role, is the definition of dynamic change and operation. Java SE 5 and the follow-up version, developers can an ordinary Java programs (with the main function of Java) running through-javaagent parameters specify a specific jar files (including Instrumentation Agents) to start the agent Instrumentation .
In the Java SE 5, a developer can allow Instrumentation agents operating in the main function, former executive. Summary says is the following steps:
- Prepared premain function
Preparation of a Java class, which contains the following two methods of any one
Public static void premain (String agentArgs, Instrumentation inst), [1] public static void premain (String agentArgs), [2]
Among them, the priority [1] [2] level than high priority will be the implementation of ([1] and [2] At the same time, the court has been neglected [2]).
In this premain function, a developer can carry out the type of operation.
AgentArgs is premain function to the process parameters, accompanying
"-javaagent"came together. And the main function is different, this parameter is a string rather than a string array, if the parameters of a number of procedures, procedures that will be self-analytical string.Inst is a java.lang.instrument.Instrumentation examples from JVM automatically imported. Java.lang.instrument.Instrumentation instrument package is the definition of an interface, is the core part of this package, which concentrated almost all of the features, for example, the definition of type conversion and operation, and so on.
- Jar file packing
This Java class will be packaged into a jar file, and in which the properties are manifest by adding "Premain-Class" to a specified steps that are prepared with premain the Java class. (May also need to specify other properties to open more features)
- Operation
Running by the following Instrumentation with the Java programs:
Java-javaagent: jar document position [= imported premain parameters]
Java class files on the operation, can be understood as a byte array operations (such document will be binary-byte read a byte array). Developers can "ClassFileTransformer" transform methods which have, operation and eventually return to the definition of a class (a byte array). This regard, the BCEL Apache open source projects provide strong support, readers can reference in the article "Java SE 5 of Instrumentation practice," to see a BCEL and Instrumentation with examples. Specific bytecode operation is not the focus of this paper, therefore, in this paper, the example cited, but the type of a simple way to replace the use of Instrumentation demonstration.
Below, we have adopted a simple example to illustrate the basic use of Instrumentation.
First, we have a simple category, TransClass, via a static method returns an integer 1.
Public class TransClass (public int getNumber () (return 1;))
We run the following categories, the output can be "1."
Public class TestMainInJar (public static void main (String [] args) (System.out.println (new TransClass (). GetNumber ());))
Then, we will TransClass into the getNumber method as follows:
Public int getNumber () (return 2;)
The two then returned to the document compiled into Java class files, in order to distinguish between the return of an original class, we will return 2 of this type of document named TransClass2.class.2.
Next, we build a Transformer categories:
Import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.lang.instrument.ClassFileTransformer; import java.lang.instrument.IllegalClassFormatException; import java.security . ProtectionDomain; class Transformer implements ClassFileTransformer (public static final String classNumberReturns2 = "TransClass.class.2" public static byte [] getBytesFromFile (String fileName) (try (/ / precondition File file = new File (fileName); InputStream is = new FileInputStream (file); file.length long length = (); byte [] bytes = new byte [(int) length]; / / Read in the bytes int offset = 0; int numRead = 0; while (offset <bytes . length & & (numRead = is.read (bytes, offset, bytes.length - offset))> = 0) (offset + = numRead;) if (offset <bytes.length) (throw new IOException ( "Could not completely read file "+ file.getName ());) is.close (); return bytes;) catch (Exception e) (System.out.println (" error occurs in _ClassTransformer! "+ e.getClass (). getName () ); return null;)) public byte [] transform (ClassLoader l, String className, Class <?> c, ProtectionDomain pd, byte [] b) throws IllegalClassFormatException (if (! className.equals ( "TransClass")) (return null;) return getBytesFromFile (classNumberReturns2);))
This class has ClassFileTransformer interface. Among them, according to the file name getBytesFromFile method read binary character stream, which provides the ClassFileTransformer transform method is completed replacement of the definition of conversion.
Finally, we have established a Premain categories, the agent into the Instrumentation premain methods:
Public class Premain (public static void premain (String agentArgs, Instrumentation inst) throws ClassNotFoundException, UnmodifiableClassException (inst.addTransformer (new Transformer ());))
Can be seen, addTransformer methods and does not specify which type to convert. Premain function in the conversion occurred after the implementation, before the implementation of main function, when a load of each category, will transform the operational methods, and see whether they need to change it, transform (Transformer category) methods, and procedures used className.equals ( "TransClass") to determine the need for the current type conversion.
Upon completion of the code, we will pack them for TestInstrument1.jar. 1 TransClass return to the types of documents that remain in the jar package, and returned to the 2 that TransClass.class.2 jar is put outside. Add the following inside the manifest attribute to specify where the premain categories:
Manifest-Version: 1.0 Premain-Class: Premain
In the running of this process, if we use ordinary run this way jar in the main function, the output can be "1." If running with the following:
Java-javaagent: TestInstrument1.jar-cp TestInstrument1.jar TestMainInJar
Output will be "2."
Of course, the main function of operating procedures do not necessarily need to be here, on this jar premain documents inside, here for just examples of procedures and on the convenience of packaged together.
In addition to using addTransformer way Instrumentation There is also another method "redefineClasses" for the realization of the designated premain conversion. Usage of similar, as follows:
Public class Premain (public static void premain (String agentArgs, Instrumentation inst) throws ClassNotFoundException, UnmodifiableClassException ClassDefinition def = (new ClassDefinition (TransClass.class, Transformer. GetBytesFromFile (Transformer.classNumberReturns2)); inst.redefineClasses (new ClassDefinition [] (def )); System.out.println ( "success");))
RedefineClasses function comparatively strong, can batch convert many types.
![]()
![]()
![]()
Java SE 6 new reading of the complete list of series of articles, the understanding of Java SE 6 other important enhancements.
ruihu@cn.ibm.com.

Lu:jing of computer science, open source software, and new things all have a deep interest.
Java theory and practice: Understanding JTS - Introduction Services
Class: Junior
Brian Goetz (brian@quiotix.com), Principal Consultant, Quiotix
March 1, 2002
February 8, 2007 update
Java Transaction Service is a key element of J2EE framework. With the combination of Java Transaction API that will enable us to build the systems and network faults are very robust distributed applications. Service is a reliable application of the basic building blocks - If there are no support services, the preparation of reliable distributed applications will be very difficult. Fortunately, most of the work JTS implementation is transparent to the programmer; J2EE containers affairs division and the acquisition of resources for programmers is almost not visible. This three-part series of articles on the first phase of a number of basic knowledge, including what services, as well as services for the construction of reliable distributed applications is critical reasons.
If you read any J2EE introductory articles or books, then we will find that only a small part of the information is specific to Java Transaction Service (JTS) or Java Transaction API (JTA). This is not because of JTS is unimportant part of J2EE or optional part - quite the contrary. JTS will be the concern is less than EJB technology, because of its procedures for the use of the services provided very transparent - many developers do not even have noted that in their application where the affairs of the beginning and end. In a sense, the unknown is precisely JTS its success: because it is very effective in the management of affairs of the hidden many of the details, so we have not heard or talked a lot about its content. However, you may want to know it all for you behind the scenes and what function.
It is no exaggeration to say that no services will not be able to prepare reliable distributed applications. Service allows some control to modify the application's persistent state, in order to enable applications for a variety of system failures (including system crashes, network failure, power failure or natural disaster) more robust. Construction Services is fault-tolerant, high reliability, high-availability applications, as well as the basic building blocks needed one.
Participate in the discussion forum.
Brian Goetz as a professional software developer has been more than 18 years. Quiotix he is the chief consultant, which is a software development and consulting firm in Los Altos, California. He also more than JCP expert group effectiveness. Please refer to Brian in the popular trade publication has been published and forthcoming articles.
Globalization will be embedded applications
Class: Junior
Shu Fang Rui (shufangrui@gmail.com), software engineers
Hu Wei Hong (nobleoliver@hotmail.com), software engineers
March 13, 2006
This article will introduce the embedded device solutions globalization two aspects - internationalization and localization. For international, to learn how to design the structure of code to support multiple languages. For localization, to learn how to customize the number, date, time and currency formats.
Internet for the rapid growth of cross-border enterprises to explore the opportunities for unpredictable, multi-language and multi-platform software products in the beginning of the success of global enterprises play an important role. Although the initial development based primarily on the Web in English, but it is understandable that people who do not speak English still like to see the use of its national language software interface, their own culture and national habits very sensitive. The result is, the growing demands of globalization inevitably falls on the e-commerce application procedures.
In the embedded device globalization support, developers face the challenge of how to make use of runtime support and limited resources to meet the different demands of globalization. Here, we will be in Java ™ 2 Platform, Micro Edition (J2ME) platform to address these challenges.
Generally speaking, the development of globalization to the application, need to take several steps, we will be divided into two groups these steps: internationalization and localization. Mean that the international application of the design and development should be flexible enough to meet the multilingual needs and cultural differences. In order to make possible the demand should be separated text data and code, and with the culture and customs of the relevant code and the basic business logic processing applications separation. Based on the application of this procedure is called globalization a single executable program (single executable). It can be run in all language versions, can call the corresponding text data as well as cultural and related code generation to meet the needs of the current user in the user interface.
Representatives of localization through the conversion of text data, design and culture-related configuration (such as name and address format), the generation of code to support globalization process. Can be converted to different areas according to the preservation and configuration files in different directories or folders, such globalization application can call them at any time. If you use a unified format text data, such as the OASIS XML Localization Interchange File Format (XLIFF), then this will greatly increase the efficiency of globalization.
a list of detailed information. Messages in three categories: setBundle (), getString () and getLocale (). Use setBundle (String propertyFileName) can be ResourceBundle class with the new document and the corresponding attribute linking the region. Using getString (String key), these will be returned to the region with the corresponding text.
2 set list on the label text, display the string "user ID."
Figure 1 demonstrates the user interface, and 3 in the list of categories demonstrated framework. For details, please refer to this article at the end of the download.
Table 1 compares each of the localization support.
Table 2 shows the different regions of the different digital format.
4 shows the list of how different areas according to the figures format.
5 will not use the list to be the result must be deleted formatted output in the box.
Table 2, the different regions of the digital format looks different. In the need to deal with the importation of the figures, the first need to verify it. Locale.SIMPLIFIED_CHINESE Locale.US and in the region in 1000 separator is "," (comma), the decimal point is "." (Sentence). And the region Locale.FRANCE, 1000 separation would become the "" (space), and then a decimal point "," (comma). While basic Java API provided some categories (such as Java.text.NumberFormat and Java.text.DecimalFormat) to do this work, but they can not ensure that the input string of the digital format effective. (6 through the analysis of a list of strings Java.text.NumberFormat shows the basic usage.)
list shows how to deal with seven regional fr_FR. Because fr_FR allow spaces, we will provide two functions to verify input.
First, the need to remove the spaces in the input string.
list of eight.
list of 10 shows to find things.
Figure 2 shows the relevant Chinese and the user interface.
10 in the list to amend section 3% DateFormat df = DateFormat.getDateInstance (DateFormat.LONG, Locale.FRANCE); can Figure 3 shown.
Table 3 shows the different languages DateTime format.
the list 11.
Table 4 shows the results of the above code.
List shows how to support 12 different regions of the currency format.
Table 5 shows the different regions of the output results.
13 shows how to list the monetary analysis.
13 list of the output should be 12345.08, and the same price variables.
![]()
![]()
![]()
HTTP ![]()
Information on the download ![]()
original English text.
Access to products and technologies
- Please use IBM trial software build your next development projects, and can be downloaded directly from the software developerWorks.
- Please download WebSphere Studio Device Developer, for building, testing and deployment of wireless devices running on J2ME applications to provide an integrated development environment (IDE).
- To use J2ME, from the Sun Microsystems Web site, download it.
Discuss
- Through participation in the developerWorks blogs join developerWorks community.

Shu Fang Rui is the Shanghai Jiaotong University (China) graduate. She wireless technology and Web services interested. In addition to travel, she also likes other sports.

Hu Wei Hong Zhejiang University (China) graduate. His interests include Java technology and dance.
[Into] script code: J + XML examples of the analytical methods of operation
[Into] script code: Js + XML examples of the analytical methods of operation script code: Js + XML examples of the analytical methods of operation Source: http://blog.csdn.net/hqx2008/archive/2007/06/21/1661107 . aspx posted on 2007-06-21 19:27-reading (6) Comments (0) edit collections cited
Script code: J + XML examples of the analytical methods of operation
Script code: Js + XML analytical examples of the methods of operation of the xml I Login.xml as follows.
<? Xml version = "1.0" encoding = "utf-8?">
<Login>
<Character>
<C Text="çƒè¡€" Value="0"> </ C>
<C Text="弱气" Value="1"> </ C>
<C Text="激情" Value="2"> </ C>
<C Text="冷é™" Value="3"> </ C>
<C Text="冷酷" Value="4"> </ C>
</ Character>
<Weapon>
<W Text="å…‰æŸå‰‘" Value="0"> </ W>
<W Text="å…‰æŸé…刀" Value="1"> </ W>
</ Weapon>
<EconomyProperty>
<P Text="å¹³å‡åž‹" Value="0"> </ P>
<P Text="é‡è§†æ”»å‡»" Value="1"> </ P>
<P Text="é‡è§†æ•æ·" Value="2"> </ P>
<P Text="é‡è§†é˜²å¾¡" Value="3"> </ P>
<P Text="é‡è§†å‘½ä¸" Value="4"> </ P>
</ EconomyProperty>
</ Login>
Now, I need to document the contents of this xml to operate.
Firstly, we need to load this xml document js load xml document, and is conducted through the XMLDOM.
/ / Load the xml document
LoadXML = function (xmlFile)
(
Var xmlDoc;
If (window.ActiveXObject)
(
XmlDoc = new ActiveXObject ( 'Microsoft.XMLDOM');
XmlDoc.async = false;
XmlDoc.load (xmlFile);
)
Else if (document.implementation & document.implementation.createDocument)
(
XmlDoc = document.implementation.createDocument ('',''null);
XmlDoc.load (xmlFile);
)
Else
(
Return null;
)
Return xmlDoc;
)
Xml document object out, I will be next on the operation of the documents.
For example, we now need to be node Login / Weapon / W of a node's attributes, then we can then do the following.
/ / First xml object to judge
CheckXMLDocObj = function (xmlFile)
(
Var xmlDoc = loadXML (xmlFile);
If (xmlDoc == null)
(
Alert ( 'Your browser does not support xml document reader, therefore prevents you from the pages of the operation, recommend using IE5.0 and above can be solved this problem!');
Window.location.href = '/ Index.aspx';
)
Return xmlDoc;
)
/ / Then start acquiring necessary Login / Weapon / W the first node attribute value
Var xmlDoc = checkXMLDocObj ( '/ EBS / XML / Login.xml');
Var v = xmlDoc.getElementsByTagName ( 'Login / Weapon / W') [0]. ChildNodes.getAttribute ( 'Text')
And I in my writing is in the process of this, of course, I am in the process of writing is the practice has been applied to it. To be out for the Show
InitializeSelect = function (oid, xPath)
(
Var xmlDoc = checkXMLDocObj ( '/ EBS / XML / Login.xml');
Var n;
Var l;
Var e = $ (oid);
If (e! = Null)
(
N = xmlDoc.getElementsByTagName (xPath) [0]. ChildNodes;
L = n.length;
For (var i = 0; i <l; i + +)
(
Var option = document.createElement ( 'option');
Option.value = n [i]. GetAttribute ( 'Value');
Option.innerHTML = n [i]. GetAttribute ( 'Text');
E.appendChild (option);
)
)
)
Above the access code, we are through xmlDoc.getElementsByTagName (xPath) carried out.
Can also xmlDoc.documentElement.childNodes (1) .. childNodes (0). GetAttribute ( 'Text') for a visit.
Some common methods:
XmlDoc.documentElement.childNodes (0). NodeName, can be the name of the node.
XmlDoc.documentElement.childNodes (0). NodeValue can get this node values. This value is from the xml format like this: <a> b </ b>, so this can be b value.
XmlDoc.documentElement.childNodes (0). HasChild can determine whether there is any node of
According to my experience, it is best to use getElementsByTagName (xPath) method node for a visit, because this way can be directly through xPath to locate nodes, this way there will be better performance.
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1661107
[Collections to pick my network] leon_huang published in the June 21, 2007 18:58:00
Radrail developed using Ruby on Rail procedures Getting Started
Radrails use Ruby on Rails development process Getting Started
RoR environment of a still relatively simple structures, but there are several small local needs attention, you may be a lot of thought.
5. This article below is the most important one, is the use of RadRails I started my problems compared to a place, it is the configuration, and here I also use more ink explain. In fact, mainly Interpreter Name, Ruby, and Rails Rake, and several other parameters of the configuration. First, Interpreter, RadRails environment Window> Preferences> Ruby> Installed Interpreters, which then click "Add" button, and casually Interpreter Name, enter a name, such as Ruby, and Ruby path selection in the Path of "ruby.exe" document, for example, I now is the "C: \ ruby \ bin \ ruby.exe" Below are the Rails in the Window> Preferences> Rails> Configuration, Rails path choice under the rails directory paper, with particular attention to not rails.cmd, if you select This document invalid operation, which may be vulnerable is that many people committed a defect; on the Rake is in the same place, a point document selection box, select rake binary file, with particular attention to not rake.bat not rake . cmd, if you select the two documents is still ineffective, if not for a long time to find a document that you do not have, it can be downloaded gem update rake.
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1657197
[Collections to pick my network] leon_huang published in the June 19, 2007 01:10:00
How close win2000, winxp default sharing
How close win2000, winxp default how close win2000 sharing, the sharing of default winxp
How close win2000, winxp default sharing
Windows 2000/XP/2003 version of the operating system provides a default sharing, the sharing of all these default "$" sign, meaning implied, including all Luojipan (C $, D $, E $… …) and the Windows system directory or Winnt ($ admin).
The questions:
Microsoft is designed to facilitate network management for remote management, although this convenience for LAN users, but for us, that the individual user settings is unsafe. If computer networking, and anyone on the network can be shared through the hard drive, and they get into your computer. So we need to close the share. More terrifying is that hackers can connect your PC to these default sharing visit.
Close these default shared many ways, the authors compiled the five, I believe there is a general right for you.
Small knowledge:
Visit WindowsXP default sharing is very simple: First, through the "Start" → "Run" and type "computer name or IP address or $ D $ admin" (without the quotation marks on both sides of, the same below); Second, such as the use of IE browser , in the address bar the importation of the above format, or "file: / / 10.80.34.33 / d $"
Sharing visit default
One, right to "stop sharing" Law
"Computer Management" window of a shared items (such as H $) on the right-click and select "stop sharing" and will be confirmed after the closure of this sharing, the sharing of icons below it will disappear, all repeat several times to stop the project can be shared.
NOTE: This method treating the symptoms but not the root cause, restart the machine if so, will resume sharing. This method is more suitable to never shut down the server, simple and effective.
Second, since the launch of batch
Open Notepad, enter the following (remember that each trip to the final round):
Net share ipc $ / delete
Net share admin $ / delete
Net share c $ / delete
Net share d $ / delete
Net share e $ / delete
…… (Several disk partitions you have to write a few lines on this order)
Save As NotShare.bat (Note the word!), And then dragged the batch file "procedure" → "kick-off" items, so each boot will run it, that is, through the net ordered the closure of sharing.
If you need to open a certain date or certain sharing, as long as the re-edit the batch files (corresponding to the command line that deleted).
Third, the registry keys to law
"Start" → "run" type "regedit" determined to open the registry editor, found "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServices
Lanmanserverparameters "items, double-click on the right window" AutoShareServer "will be the keys from 1 to 0, so the district will be able to shut down the hard drive sharing if there is no AutoShareServer items can be diverted to a newly built their own keys. Then or in the window to find "AutoShareWks" items, but also the keys from 1 to 0, closed admin $ sharing. final "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlLsa" find the item "restrictanonymous" keys will be set to 1, closed IPC $ sharing.
Note: This is essential to relaunch the machines, but the changes will never stop sharing.
Fourth, stop Services Act
Or to the "Computer Management" window, click the left of the start "services and applications" and selected to the "services" and then on the right lists all services. Sharing the corresponding name is the "Server" (in the name of the process for services), after double-click on it to find in the pop-up "conventional" label in the "startup type" from "automatically" be changed to " Prohibited. " Then click below "service status" of the "stop" button, and then check on OK.
5, unloading "file and printer sharing" Law
Right-click the "Network Places" choose "Properties" in the pop-up "network and dial-up connections" in the right-click window, "local connection" choose "Properties" from "connecting the following selected components" selected "Microsoft Network File and Printer Sharing, "click below" uninstall "button and confirm this.
Note: This method of the biggest flaws is that when you right-click on a folder, the pop-up menu shortcuts in the "shared" one disappear, because the corresponding functional services has been unloaded swap
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1657199
[Collections to pick my network] leon_huang published in the June 19, 2007 01:15:00
[Into] Health Guide: Where mobile phone radiation hazards minimum release?
[Into] Health Guide: Where mobile phone radiation hazards minimum release? Health Guide: Where mobile phone radiation hazards minimum release?
Source: http://blog.csdn.net/hqx2008/archive/2007/06/17/1655628.aspx posted on 2007-06-14 01:53-reading (3) Comments (0) edit collections cited