1 package org.jahia.services.usermanager; 2 3 11 12 import java.lang.reflect.InvocationTargetException ; 13 import java.lang.reflect.Method ; 14 15 public class GroupManagerProviderBean { 16 17 private String key; 18 private String className; 19 private String description; 20 private String title; 21 private boolean isReadOnly = true; 22 private JahiaGroupManagerProvider instance; 23 private boolean isDefault = false; 24 private int priority; 25 26 public GroupManagerProviderBean (String key, 27 String className, 28 String title, 29 String description, 30 boolean isDefault, 31 boolean isReadOnly, 32 int priority) { 33 this.key = key; 34 this.className = className; 35 this.description = description; 36 this.title = title; 37 this.isDefault = isDefault; 38 this.isReadOnly = isReadOnly; 39 this.priority = priority; 40 } 41 42 public String getKey () { 43 return key; 44 } 45 46 public void setKey (String key) { 47 this.key = key; 48 } 49 50 public void setClassName (String className) { 51 this.className = className; 52 } 53 54 public String getClassName () { 55 return className; 56 } 57 58 public void setDescription (String description) { 59 this.description = description; 60 } 61 62 public String getDescription () { 63 return description; 64 } 65 66 public void setTitle (String title) { 67 this.title = title; 68 } 69 70 public String getTitle () { 71 return title; 72 } 73 74 public void setIsDefault (boolean isDefault) { 75 this.isDefault = isDefault; 76 } 77 78 public boolean getIsDefault () { 79 return isDefault; 80 } 81 82 public void setIsReadOnly (boolean isReadOnly) { 83 this.isReadOnly = isReadOnly; 84 } 85 86 public boolean getIsReadOnly () { 87 return isReadOnly; 88 } 89 90 public void setPriority (int priority) { 91 this.priority = priority; 92 } 93 94 public int getPriority () { 95 return priority; 96 } 97 98 public JahiaGroupManagerProvider getInstance () { 99 if (this.instance != null) { 100 return this.instance; 101 } 102 103 if (this.className == null) { 104 return null; 105 } 106 107 try { 108 Class destClass = Class.forName (this.className); 109 Class superClass = destClass.getSuperclass (); 110 if (superClass == null) { 111 return null; 112 } 113 if (!"org.jahia.services.usermanager.JahiaGroupManagerProvider".equals ( 114 superClass.getName ())) { 115 return null; 117 } 118 Method getInstanceMethod = destClass.getMethod ("getInstance", null); 119 if (getInstanceMethod == null) { 120 return null; 121 } 122 this.instance = (JahiaGroupManagerProvider) getInstanceMethod.invoke (null, null); 123 124 } catch (LinkageError le) { 125 le.printStackTrace (); 126 this.instance = null; 127 } catch (ClassNotFoundException cnfe) { 128 cnfe.printStackTrace (); 129 this.instance = null; 130 } catch (NoSuchMethodException nsme) { 131 nsme.printStackTrace (); 132 this.instance = null; 133 } catch (InvocationTargetException ite) { 134 ite.printStackTrace (); 135 this.instance = null; 136 } catch (IllegalAccessException iae) { 137 iae.printStackTrace (); 138 this.instance = null; 139 } 140 return this.instance; 141 } 142 143 public boolean equals (Object obj) { 144 if (!(obj instanceof GroupManagerProviderBean)) { 145 return false; 146 } 147 GroupManagerProviderBean right = (GroupManagerProviderBean) obj; 148 return objectEquals (getKey (), right.getKey ()); 149 } 150 151 private boolean objectEquals (String left, String right) { 152 if ((left == null) && (right == null)) { 153 return true; 154 } else if ((left == null) && (right != null)) { 155 return false; 156 } else if ((left != null) && (right == null)) { 157 return false; 158 } else { 159 return left.equals (right); 162 } 163 } 164 } 165 | Popular Tags |