Prototype (prototype manager) and prototype Manager

Source: Internet
Author: User

Prototype (prototype manager) and prototype Manager

Prototype:Object Creation Mode

Prototype Manager:The role of the prototype manager maintains an aggregation. As a registration of all prototype objects, this role provides the necessary methods to add new prototype objects and obtain registered prototype objects.

 

Public class PrototypeManager {/*** is used to record the correspondence between Prototype numbers and Prototype instances */private static Map <String, Prototype> map = new HashMap <String, prototype> ();/*** private constructor to avoid external instance creation */private PrototypeManager () {}/*** add or modify a prototype to the prototype manager * @ param prototypeId protonumber * @ param prototype instance */public synchronized static void setPrototype (String prototypeId, prototype prototype) {map. put (prototypeId, prototype);}/*** delete a prototype from the prototype manager * @ param prototypeId prototype number */public synchronized static void removePrototype (String prototypeId) {map. remove (prototypeId );} /*** obtain the prototype instance corresponding to a prototype Number * @ param prototypeId Prototype number * @ return Prototype number corresponding to the prototype instance * @ throws Exception if the instance corresponding to the prototype number does not exist, throw an Exception */public synchronized static Prototype getPrototype (String prototypeId) throws Exception {Prototype prototype = map. get (prototypeId); if (prototype = null) {throw new Exception ("the prototype you want to obtain is not registered or destroyed");} return prototype ;}}

 

Public class PropertiesUtil {/** save all properties */private static ConcurrentHashMap <String, Properties> propertiesMap = new ConcurrentHashMap <String, Properties> (); /*** obtain the specified properties * @ param path properties path (for example, com/webvoice/properties/webvoice. properties) * @ return properties */public synchronized static Properties getProperties (String path) {Properties prop = new Properties (); try (InputStream propIS = PropertiesUtil. class. getClassLoader (). getResourceAsStream (path);) {prop. load (propIS); propertiesMap. put (path, prop);} catch (Exception e) {AbstractBaseAction. logger. systemError ("001", "failed to get properties: path = [" + path + "]. "," PropertiesUtil ", e);} return propertiesMap. get (path );}}

 

Full version of PropertiesUtil

 

1 public class PropertiesUtil {2 3/** save all properties */4 private static ConcurrentHashMap <String, Properties> propertiesMap = new ConcurrentHashMap <String, Properties> (); 5 6/** 7 * obtain the path of the specified properties 8*9 * @ param path properties (for example, com/webvoice/properties/webvoice. properties) 10 * @ return properties 11 */12 public synchronized static Properties getProperties (String path) {13 Properties pro P = new Properties (); 14 try (15 InputStream propIS = getClassLoader (). getResourceAsStream (path); 16) {17 18 prop. load (propIS); 19 propertiesMap. put (path, prop); 20} catch (Exception e) {21 define actbaseaction. logger. systemError ("001", "failed to get properties: path = [" + path + "]. "," PropertiesUtil ", e); 22} 23 return propertiesMap. get (path); 24} 25 26/** 27 * get the ClassLoader 28*29 * @ return C of the current running program LassLoader 30 */31 public static ClassLoader getClassLoader () {32 return PropertiesUtil. class. getClassLoader (); 33} 34 35/** 36 * Get the key defined in properties, return 37*38 * @ param key 39 * @ param prop properties 40 * @ return key for the split array 41 */42 public static String [] getArrayFromProperties (String key, properties prop) {43 String allValue = prop. getProperty (key); 44 String [] values = null; 45 I F (allValue! = Null) {46 values = allValue. split (","); 47} 48 return values; 49} 50 51/** 52 * Get the key defined value in properties, convert to an array and return the 53*54 * @ param key 55 * @ param path properties path (for example, com/webvoice/properties/webvoice. properties) 56 * @ return key corresponding to the split value of the array 57 */58 public static String [] getArrayFromProperties (String key, String path) {59 String [] values = null; 60 Properties prop = getProperties (path); 61 if (pr Op = null) {62 return values; 63} 64 String allValue = prop. getProperty (key); 65 if (allValue! = Null) {66 values = allValue. split (","); 67} 68 return values; 69} 70 71/** 72 * Get the key defined value in properties, convert to List and return 73*74 * @ param key 75 * @ param prop properties 76 * @ return key. The split value of List 77 */78 public synchronized static List <String> getListFromProperties (String key, properties prop) {79 List <String> retList = new ArrayList <String> (); 80 String allValue = prop. getProperty (key); 81 if (al LValue! = Null) {82 String [] values = allValue. split (","); 83 for (String singleValue: values) {84 retList. add (singleValue); 85} 86} 87 return retList; 88} 89 90/** 91 * Get the value defined by the key in properties, convert to List and return 92*93 * @ param key 94 * @ param path properties (for example, com/webvoice/properties/webvoice. properties) 95 * @ return key: List 96 */97 public synchronized static List <String> getListFromProperties (St Ring key, String path) {98 List <String> retList = new ArrayList <String> (); 99 Properties prop = getProperties (path); 100 if (prop = null) {101 return retList; 102} 103 String allValue = prop. getProperty (key); 104 if (allValue! = Null &&! "". Equals (allValue) {105 String [] values = allValue. split (","); 106 for (String singleValue: values) {107 retList. add (singleValue); 108} 109} 110 return retList; 111} 112 113}View Code

 

 

 

 

 

1 public class PropertiesUtil {2 3/** save all properties */4 private static ConcurrentHashMap <String, Properties> propertiesMap = new ConcurrentHashMap <String, Properties> (); 5 6/** 7 * obtain the path of the specified properties 8 * @ param path properties (for example, com/webvoice/properties/webvoice. properties) 9 * @ return properties10 */11 public synchronized static Properties getProperties (String path) {12 Properties prop = new Properties (); 13 try (14 InputStream propIS = PropertiesUtil. class. getClassLoader (). getResourceAsStream (path); 15) {16 17 prop. load (propIS); 18 propertiesMap. put (path, prop); 19} catch (Exception e) {20 encode actbaseaction. logger. systemError ("001", "failed to get properties: path = [" + path + "]. "," PropertiesUtil ", e); 21} 22 return propertiesMap. get (path); 23} 24}View Code

 


We often say that we should first create a prototype system. What is the prototype?

The prototype method is an interactive process between users and software developers. It is applicable to (46) systems. It starts with the development of the user interface, first forms (47), the user (48), and puts forward opinions on (49). It is a (50) design process. (46). high demand uncertainty B. c. manage Information D. decision support (47). user Interface user manual B. user Interface requirement analysis specification C. system Interface prototype D. complete User Interface (48). improve the design of the user interface B. reading documents C. simulate the running of the user interface D. run the user interface prototype C. program structure D. whether the execution speed meets the requirements (50). from external to inner B. top-down C. d. bottom-up analysis: Typically, prototype refers to simulating the original model of a product. In software development, prototype is an early runnable version of the software, which reflects some important features of the final system. The prototype method is particularly suitable for the development of software systems with high demand uncertainty. The basic idea is to quickly construct a small executable model based on the basic requirements given by the user to meet the basic requirements of the user. This is the system interface prototype. Let the user's computer actually run this user interface prototype, get hands-on experience and Inspiration during the trial process, make responses and comments, and propose to agree or disagree with anything. Then the developer improves the prototype based on the user's opinion. As new prototype versions are obtained through continuous testing, error correction, use, evaluation, and modification, this cycle gradually reduces misunderstandings in analysis and communication, makes up for deficiencies, and further determines the details of various requirements, adapt to changes in demand, thus improving the quality of the final product. It is an external and inner design process.

Javascript prototype

The property method in the prototype is the empirical method in other languages. The static property does not belong to the object, but belongs to the class.
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.