1 22 package org.objectweb.petals.jbi.management.systemstate; 23 24 import java.util.List ; 25 26 import org.objectweb.fractal.fraclet.annotation.FractalComponent; 27 import org.objectweb.fractal.fraclet.annotation.Interface; 28 import org.objectweb.fractal.fraclet.annotation.LifeCycle; 29 import org.objectweb.fractal.fraclet.annotation.LifeCycleType; 30 import org.objectweb.fractal.fraclet.annotation.Monolog; 31 import org.objectweb.fractal.fraclet.annotation.Provides; 32 import org.objectweb.fractal.fraclet.annotation.Requires; 33 import org.objectweb.petals.jbi.management.deployment.DeploymentService; 34 import org.objectweb.petals.jbi.management.service.InstallationService; 35 import org.objectweb.petals.jbi.management.service.LifeCycleManagerService; 36 import org.objectweb.petals.jbi.management.service.ManagementException; 37 import org.objectweb.petals.repository.RepositoryService; 38 import org.objectweb.petals.util.LoggingUtil; 39 import org.objectweb.util.monolog.api.Logger; 40 41 47 @FractalComponent 48 @Provides(interfaces=@Interface(name="service",signature=org.objectweb.petals.jbi.management.systemstate.SystemState.class)) 49 public class SystemStateImpl implements SystemState { 50 51 54 @Requires(name="deployment",signature=org.objectweb.petals.jbi.management.deployment.DeploymentService.class) 55 protected DeploymentService deploymentService; 56 57 60 @Requires(name="installation",signature=org.objectweb.petals.jbi.management.service.InstallationService.class) 61 protected InstallationService installationService; 62 63 66 protected LoggingUtil log; 67 68 71 @Monolog(name="logger") 72 protected Logger logger; 73 74 77 @Requires(name="lifecyclemanager",signature=org.objectweb.petals.jbi.management.service.LifeCycleManagerService.class) 78 protected LifeCycleManagerService managerService; 79 80 83 @Requires(name="repository",signature=org.objectweb.petals.repository.RepositoryService.class) 84 protected RepositoryService repositorySrv; 85 86 protected StateStorage stateStorage; 87 88 protected SystemRecovery systemRecovery; 89 90 public ComponentState createComponentStateHolder(String componentName, 91 String installURL, String zipURL, String installState, 92 String lifecycleState) throws Exception { 93 return stateStorage.createComponentStateHolder(componentName, 94 installURL, zipURL, installState, lifecycleState); 95 } 96 97 public ServiceAssemblyState createServiceAssemblyStateHolder(String saName, 98 String installURL, String zipURL, String lifecycleState) 99 throws Exception { 100 return stateStorage.createServiceAssemblyStateHolder(saName, 101 installURL, zipURL, lifecycleState); 102 } 103 104 public SharedLibraryState createSharedLibraryStateHolder(String slName, 105 String installURL, String zipURL) throws Exception { 106 return stateStorage.createSharedLibraryStateHolder(slName, installURL, 107 zipURL); 108 } 109 110 public ComponentState deleteComponentStateHolder(String componentName) 111 throws Exception { 112 return stateStorage.deleteComponentStateHolder(componentName); 113 } 114 115 public ServiceAssemblyState deleteServiceAssemblyStateHolder(String saName) 116 throws Exception { 117 return stateStorage.deleteServiceAssemblyStateHolder(saName); 118 } 119 120 public SharedLibraryState deleteSharedLibraryStateHolder(String slName) 121 throws Exception { 122 return stateStorage.deleteSharedLibraryStateHolder(slName); 123 } 124 125 public boolean recoverAllComponent() throws ManagementException { 126 return systemRecovery.recoverAllComponent(); 127 } 128 129 public boolean recoverAllEntities() throws ManagementException { 130 log.start(); 131 boolean result = false; 132 133 recoverAllSharedLibrary(); 134 recoverAllComponent(); 135 recoverAllServiceAssembly(); 136 result = true; 137 138 log.end(); 139 return result; 140 } 141 142 public boolean recoverAllServiceAssembly() throws ManagementException { 143 return systemRecovery.recoverAllServiceAssembly(); 144 } 145 146 public boolean recoverAllSharedLibrary() throws ManagementException { 147 return systemRecovery.recoverAllSharedLibrary(); 148 } 149 150 public List <ComponentState> retrieveAllComponentStates() { 151 return stateStorage.retrieveAllComponentStates(); 152 } 153 154 public List <ServiceAssemblyState> retrieveAllServiceAssemblyStates() { 155 return stateStorage.retrieveAllServiceAssemblyStates(); 156 } 157 158 162 public List <SharedLibraryState> retrieveAllSharedLibraryStates() { 163 return stateStorage.retrieveAllSharedLibraryStates(); 164 } 165 166 170 public void updateComponentInstallationState(String componentName, 171 String installState) throws Exception { 172 stateStorage.updateComponentInstallationState(componentName, 173 installState); 174 175 } 176 177 public void updateComponentLifeCycleState(String componentName, 178 String lifecycleState) throws Exception { 179 stateStorage.updateComponentLifeCycleState(componentName, 180 lifecycleState); 181 182 } 183 184 public void updateServiceAssemblyState(String saName, String lifecycleState) 185 throws Exception { 186 stateStorage.updateServiceAssemblyState(saName, lifecycleState); 187 188 } 189 190 @LifeCycle(on=LifeCycleType.START) 191 protected void start() { 192 log = new LoggingUtil(logger); 193 log.start(); 194 195 stateStorage = new StateStorage(); 196 197 try { 198 stateStorage.init(); 199 } catch (Exception e) { 200 String msg = "SystemState component can't be correctly initiated : " 201 + "StateStorage init failed !"; 202 log.error(msg, e); 203 throw new RuntimeException (msg); 204 } 205 206 systemRecovery = new SystemRecovery(installationService, logger, 207 deploymentService, managerService, stateStorage, repositorySrv); 208 209 log.end(); 210 } 211 212 @LifeCycle(on=LifeCycleType.STOP) 213 protected void stop() { 214 log.start(); 215 216 logger = null; 217 218 log.end(); 219 } 220 } 221 | Popular Tags |