- /**
- * Method: implementsStorableObject
- * Description: internall helper method to find out if a class implements
- * interface StorableObject.
- *
- * @return true if yes, otherwise no.
- */
- private final static boolean implementsStorableObject(Class aClass) {
- if (aClass!=null) {
- Class[] interfaces = aClass.getInterfaces();
- if (interfaces.length>0) {
- for (int i=0;i<interfaces.length;i++) {
- if (interfaces[i]==storableObjectInterface) return true;
- }
- }
- }
- return false;
- }
-
-
- private boolean has(StoreIdentifier sid) {
- StoreContainer stoc = getStoreContainerForSid( sid );
- return ( stoc != null && stoc.has(sid) ) ? true:false;
- }
-
-
- /**
- * Method: version()
- * Description: returns ObjectStore version as String
- *
- * @return String
- */
- private String version() { return "00.d5";}
+ private StoreContainer getStoreContainerForStocType(StoreContainerType
+ stoc_type) {
+ if (stoc_type != null && containerMap.containsKey(stoc_type))
+ return (StoreContainer) containerMap.get(stoc_type);
+ return null;
+ }
+
+ private boolean has(StoreIdentifier sid) {
+ StoreContainer stoc = getStoreContainerForSid(sid);
+ return (stoc != null && stoc.has(sid)) ? true : false;
+ }
+
+ public String getConfProperty(String name) {
+ if (name != null) {
+ try {
+ return configuration.getString(name);
+ }
+ catch (MissingResourceException e) {
+ logger.error("getConfProperty: " + e.toString());
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Method: toString()
+ * Description: Displays statistical information about the ObjectStore.
+ * Further information is gathered from all @see StoreContainer
+ *
+ * @return String
+ */
+ public String toString() {
+ return toHtml(null);
+ }
+
+ public String toHtml(HttpServletRequest req) {
+ float hitRatio = 0;
+ long divisor = storeHit + storeMiss;
+ if (divisor > 0)
+ hitRatio = (float) storeHit / (float) divisor;
+ hitRatio *= 100;
+
+ StringBuffer sb = new StringBuffer("Mir-ObjectStore ");
+ sb.append( ( (req != null) ? html_version() : version())).append("\n");
+ sb.append("ObjectStore overall hits/misses/ratio: ").append(storeHit);
+ sb.append("/").append(storeMiss).append("/").append(hitRatio);
+ sb.append("%\nCurrently ").append(containerMap.size());
+ sb.append(" StoreContainer in use - listing information:\n");
+
+ // ask container for information
+ StoreContainer currentStoc;
+ for (Iterator it = containerMap.keySet().iterator(); it.hasNext(); ) {
+ currentStoc = (StoreContainer) containerMap.get(it.next());
+ sb.append(currentStoc.toHtml(req));
+ }
+
+ return sb.toString();
+ }
+
+ /**
+ * Method: html_version()
+ * Description: returns ObjectStore version as String for HTML representation
+ *
+ * @return String
+ */
+ private String html_version() {
+ return "<i>" + version() + "</i>";
+ }
+
+ /**
+ * Method: version()
+ * Description: returns ObjectStore version as String
+ *
+ * @return String
+ */
+ private String version() {
+ return "v_sstart3__1.0";
+ }
+