1 14 package org.jahia.services; 15 16 import org.jahia.exceptions.JahiaException; 17 import org.jahia.exceptions.JahiaInitializationException; 18 import org.jahia.settings.SettingsBean; 19 20 21 35 public abstract class JahiaService 36 { 37 private String mServiceName = null; 38 39 44 protected boolean mIsServiceInitialized = false; 45 46 47 52 public boolean isInitialized () 53 { 54 return mIsServiceInitialized; 55 } 56 57 58 65 protected void checkService () 66 throws JahiaException 67 { 68 if (!mIsServiceInitialized) { 69 throw new JahiaException ("Service error.", 70 "Service ["+mServiceName+"] is not initialized!", 71 JahiaException.SERVICE_ERROR, JahiaException.CRITICAL_SEVERITY); 72 } 73 } 74 75 76 82 public synchronized void setServiceName (String name) 83 { 84 if (name != null) { 85 if (name.length() > 0) { 86 mServiceName = name; 87 } 88 } 89 } 90 91 92 99 public String getServiceName () 100 { 101 return mServiceName; 102 } 103 104 105 113 public synchronized void shutdown () 114 throws JahiaException 115 { 116 mIsServiceInitialized = false; 117 } 118 119 120 127 public synchronized void init (SettingsBean jSettings) 128 throws JahiaInitializationException 129 { 130 mIsServiceInitialized = true; 131 } 132 133 134 145 public synchronized void restart (SettingsBean jSettings) 146 throws JahiaInitializationException, 147 JahiaException 148 { 149 shutdown (); 150 init (jSettings); 151 } 152 153 } 154 155 | Popular Tags |