Singleton Management
This commit is contained in:
parent
35bbfde328
commit
0e26e2c75d
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import javax.validation.metadata.ConstraintDescriptor;
|
||||
|
||||
import org.gcube.spatial.data.sdi.engine.RoleManager;
|
||||
import org.gcube.spatial.data.sdi.model.credentials.AccessType;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package org.gcube.spatial.data.sdi.engine.impl.factories;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.gcube.spatial.data.sdi.engine.GISManager;
|
||||
import org.gcube.spatial.data.sdi.engine.impl.GISManagerImpl;
|
||||
import org.glassfish.hk2.api.Factory;
|
||||
|
||||
import lombok.Synchronized;
|
||||
|
||||
public class GeoServerManagerFactory implements Factory<GISManager>{
|
||||
|
||||
@Override
|
||||
|
@ -16,14 +16,14 @@ public class GeoServerManagerFactory implements Factory<GISManager>{
|
|||
|
||||
@Override
|
||||
public GISManager provide() {
|
||||
return new GISManagerImpl();
|
||||
return getInstance();
|
||||
}
|
||||
|
||||
|
||||
private GISManager instance=null;
|
||||
private static GISManager instance=null;
|
||||
|
||||
@Singleton
|
||||
private GISManager getInstance() {
|
||||
@Synchronized
|
||||
private static GISManager getInstance() {
|
||||
if(instance==null)
|
||||
instance=new GISManagerImpl();
|
||||
return instance;
|
||||
|
|
|
@ -13,7 +13,7 @@ public class RoleManagerFactory implements Factory<RoleManager>{
|
|||
}
|
||||
|
||||
|
||||
private RoleManager instance;
|
||||
private static RoleManager instance;
|
||||
|
||||
@Override
|
||||
public RoleManager provide() {
|
||||
|
@ -21,7 +21,7 @@ public class RoleManagerFactory implements Factory<RoleManager>{
|
|||
}
|
||||
|
||||
@Synchronized
|
||||
private RoleManager getInstance() {
|
||||
private static RoleManager getInstance() {
|
||||
if(instance==null)
|
||||
instance=new RoleManagerImpl();
|
||||
return instance;
|
||||
|
|
|
@ -20,11 +20,11 @@ public class SDIManagerFactory implements Factory<SDIManager>{
|
|||
}
|
||||
@Override
|
||||
public SDIManager provide() {
|
||||
return getInstance();
|
||||
return getInstance(gnManager,gisManager,thManager);
|
||||
}
|
||||
|
||||
|
||||
private SDIManager sdiManager=null;
|
||||
private static SDIManager sdiManager=null;
|
||||
|
||||
@Inject
|
||||
private GeoNetworkManager gnManager;
|
||||
|
@ -36,7 +36,7 @@ public class SDIManagerFactory implements Factory<SDIManager>{
|
|||
|
||||
|
||||
@Synchronized
|
||||
private SDIManager getInstance() {
|
||||
private static SDIManager getInstance(GeoNetworkManager gnManager, GISManager gisManager,ThreddsManager thManager) {
|
||||
if(sdiManager==null)
|
||||
sdiManager=new SDIManagerImpl(gnManager,thManager,gisManager);
|
||||
return sdiManager;
|
||||
|
|
|
@ -4,6 +4,8 @@ import org.gcube.spatial.data.sdi.engine.TemporaryPersistence;
|
|||
import org.gcube.spatial.data.sdi.engine.impl.TemporaryPersistenceImpl;
|
||||
import org.glassfish.hk2.api.Factory;
|
||||
|
||||
import lombok.Synchronized;
|
||||
|
||||
public class TemporaryPersistenceFactory implements Factory<TemporaryPersistence>{
|
||||
|
||||
|
||||
|
@ -14,11 +16,22 @@ public class TemporaryPersistenceFactory implements Factory<TemporaryPersistence
|
|||
|
||||
@Override
|
||||
public TemporaryPersistence provide() {
|
||||
TemporaryPersistenceImpl temp=new TemporaryPersistenceImpl();
|
||||
|
||||
temp.init();
|
||||
|
||||
return temp;
|
||||
return getInstance();
|
||||
}
|
||||
|
||||
|
||||
private static TemporaryPersistence temp=null;
|
||||
|
||||
@Synchronized
|
||||
private static TemporaryPersistence getInstance(){
|
||||
if(temp==null) {
|
||||
temp=new TemporaryPersistenceImpl();
|
||||
try {
|
||||
temp.init();
|
||||
}catch(Exception e) {
|
||||
throw new RuntimeException("Unable to init temp ",e);
|
||||
}
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ import org.gcube.spatial.data.sdi.engine.ThreddsManager;
|
|||
import org.gcube.spatial.data.sdi.engine.impl.ThreddsManagerImpl;
|
||||
import org.glassfish.hk2.api.Factory;
|
||||
|
||||
import lombok.Synchronized;
|
||||
|
||||
public class ThreddsManagerFactory implements Factory<ThreddsManager>{
|
||||
|
||||
@Inject
|
||||
|
@ -15,7 +17,7 @@ public class ThreddsManagerFactory implements Factory<ThreddsManager>{
|
|||
|
||||
@Override
|
||||
public ThreddsManager provide() {
|
||||
return new ThreddsManagerImpl(manager);
|
||||
return getInstance(manager);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -23,4 +25,13 @@ public class ThreddsManagerFactory implements Factory<ThreddsManager>{
|
|||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
private static ThreddsManager instance=null;
|
||||
|
||||
@Synchronized
|
||||
private static ThreddsManager getInstance(TemplateManager manager) {
|
||||
if(instance==null)
|
||||
instance=new ThreddsManagerImpl(manager);
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue