Added binders
This commit is contained in:
parent
07cc61f096
commit
35bbfde328
|
@ -4,10 +4,30 @@ import java.net.URL;
|
|||
|
||||
import javax.ws.rs.ApplicationPath;
|
||||
|
||||
import org.aopalliance.reflect.Metadata;
|
||||
import org.gcube.smartgears.ContextProvider;
|
||||
import org.gcube.smartgears.configuration.container.ContainerConfiguration;
|
||||
import org.gcube.smartgears.context.application.ApplicationContext;
|
||||
import org.gcube.spatial.data.sdi.engine.GISManager;
|
||||
import org.gcube.spatial.data.sdi.engine.GeoNetworkManager;
|
||||
import org.gcube.spatial.data.sdi.engine.RoleManager;
|
||||
import org.gcube.spatial.data.sdi.engine.SDIManager;
|
||||
import org.gcube.spatial.data.sdi.engine.TemplateManager;
|
||||
import org.gcube.spatial.data.sdi.engine.TemporaryPersistence;
|
||||
import org.gcube.spatial.data.sdi.engine.ThreddsManager;
|
||||
import org.gcube.spatial.data.sdi.engine.impl.factories.GeoNetworkManagerFactory;
|
||||
import org.gcube.spatial.data.sdi.engine.impl.factories.GeoServerManagerFactory;
|
||||
import org.gcube.spatial.data.sdi.engine.impl.factories.MetadataTemplateManagerFactory;
|
||||
import org.gcube.spatial.data.sdi.engine.impl.factories.RoleManagerFactory;
|
||||
import org.gcube.spatial.data.sdi.engine.impl.factories.SDIManagerFactory;
|
||||
import org.gcube.spatial.data.sdi.engine.impl.factories.TemporaryPersistenceFactory;
|
||||
import org.gcube.spatial.data.sdi.engine.impl.factories.ThreddsManagerFactory;
|
||||
import org.gcube.spatial.data.sdi.model.ServiceConstants;
|
||||
import org.gcube.spatial.data.sdi.rest.GeoNetwork;
|
||||
import org.gcube.spatial.data.sdi.rest.GeoServer;
|
||||
import org.gcube.spatial.data.sdi.rest.SDI;
|
||||
import org.gcube.spatial.data.sdi.rest.Thredds;
|
||||
import org.glassfish.hk2.utilities.binding.AbstractBinder;
|
||||
import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
||||
import org.glassfish.jersey.server.ResourceConfig;
|
||||
|
||||
|
@ -44,24 +64,32 @@ public class SDIService extends ResourceConfig{
|
|||
packages("org.gcube.spatial.data");
|
||||
|
||||
|
||||
// log.warn("Initializing App : Binders");
|
||||
//
|
||||
// AbstractBinder binder = new AbstractBinder() {
|
||||
// @Override
|
||||
// protected void configure() {
|
||||
// bindFactory(SDIManagerImpl.class).to(SDIManager.class);
|
||||
// bindFactory(CapabilitiesProviderFactory.class).to(CapabilitiesProvider.class);
|
||||
// bindFactory(PersistenceProviderFactory.class).to(PersistenceProvider.class);
|
||||
// bindFactory(PluginManagerFactory.class).to(PluginManager.class);
|
||||
// bindFactory(RequestManagerFactory.class).to(RequestManager.class);
|
||||
// bindFactory(TicketManagerFactory.class).to(TicketManager.class);
|
||||
// }
|
||||
// };
|
||||
// register(binder);
|
||||
log.warn("Initializing App : Binders");
|
||||
|
||||
AbstractBinder binder = new AbstractBinder() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bindFactory(SDIManagerFactory.class).to(SDIManager.class);
|
||||
bindFactory(GeoNetworkManagerFactory.class).to(GeoNetworkManager.class);
|
||||
bindFactory(ThreddsManagerFactory.class).to(ThreddsManager.class);
|
||||
bindFactory(GeoServerManagerFactory.class).to(GISManager.class);
|
||||
bindFactory(MetadataTemplateManagerFactory.class).to(TemplateManager.class);
|
||||
bindFactory(RoleManagerFactory.class).to(RoleManager.class);
|
||||
bindFactory(TemporaryPersistenceFactory.class).to(TemporaryPersistence.class);
|
||||
|
||||
}
|
||||
};
|
||||
register(binder);
|
||||
|
||||
|
||||
|
||||
register(MultiPartFeature.class);
|
||||
registerClasses(SDI.class);
|
||||
registerClasses(GeoNetwork.class);
|
||||
registerClasses(GeoServer.class);
|
||||
registerClasses(Thredds.class);
|
||||
registerClasses(Metadata.class);
|
||||
|
||||
// register(MoxyXmlFeature.class);
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package org.gcube.spatial.data.sdi.engine.impl.factories;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.gcube.spatial.data.sdi.engine.GeoNetworkManager;
|
||||
import org.gcube.spatial.data.sdi.engine.RoleManager;
|
||||
import org.gcube.spatial.data.sdi.engine.impl.GeoNetworkManagerImpl;
|
||||
import org.glassfish.hk2.api.Factory;
|
||||
|
||||
public class GeoNetworkManagerFactory implements Factory<GeoNetworkManager>{
|
||||
|
||||
@Inject
|
||||
private RoleManager manager;
|
||||
|
||||
@Override
|
||||
public void dispose(GeoNetworkManager instance) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeoNetworkManager provide() {
|
||||
|
||||
return new GeoNetworkManagerImpl(manager);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
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;
|
||||
|
||||
public class GeoServerManagerFactory implements Factory<GISManager>{
|
||||
|
||||
@Override
|
||||
public void dispose(GISManager instance) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public GISManager provide() {
|
||||
return new GISManagerImpl();
|
||||
}
|
||||
|
||||
|
||||
private GISManager instance=null;
|
||||
|
||||
@Singleton
|
||||
private GISManager getInstance() {
|
||||
if(instance==null)
|
||||
instance=new GISManagerImpl();
|
||||
return instance;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package org.gcube.spatial.data.sdi.engine.impl.factories;
|
||||
|
||||
import org.gcube.spatial.data.sdi.engine.TemplateManager;
|
||||
import org.gcube.spatial.data.sdi.engine.impl.metadata.MetadataTemplateManagerImpl;
|
||||
import org.glassfish.hk2.api.Factory;
|
||||
|
||||
public class MetadataTemplateManagerFactory implements Factory<TemplateManager>{
|
||||
@Override
|
||||
public TemplateManager provide() {
|
||||
return new MetadataTemplateManagerImpl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose(TemplateManager instance) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package org.gcube.spatial.data.sdi.engine.impl.factories;
|
||||
|
||||
import org.gcube.spatial.data.sdi.engine.RoleManager;
|
||||
import org.gcube.spatial.data.sdi.engine.impl.RoleManagerImpl;
|
||||
import org.glassfish.hk2.api.Factory;
|
||||
|
||||
import lombok.Synchronized;
|
||||
|
||||
public class RoleManagerFactory implements Factory<RoleManager>{
|
||||
|
||||
@Override
|
||||
public void dispose(RoleManager instance) {
|
||||
}
|
||||
|
||||
|
||||
private RoleManager instance;
|
||||
|
||||
@Override
|
||||
public RoleManager provide() {
|
||||
return getInstance();
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
private RoleManager getInstance() {
|
||||
if(instance==null)
|
||||
instance=new RoleManagerImpl();
|
||||
return instance;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package org.gcube.spatial.data.sdi.engine.impl.factories;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.gcube.spatial.data.sdi.engine.GISManager;
|
||||
import org.gcube.spatial.data.sdi.engine.GeoNetworkManager;
|
||||
import org.gcube.spatial.data.sdi.engine.SDIManager;
|
||||
import org.gcube.spatial.data.sdi.engine.ThreddsManager;
|
||||
import org.gcube.spatial.data.sdi.engine.impl.SDIManagerImpl;
|
||||
import org.glassfish.hk2.api.Factory;
|
||||
|
||||
import lombok.Synchronized;
|
||||
|
||||
public class SDIManagerFactory implements Factory<SDIManager>{
|
||||
|
||||
@Override
|
||||
public void dispose(SDIManager instance) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
@Override
|
||||
public SDIManager provide() {
|
||||
return getInstance();
|
||||
}
|
||||
|
||||
|
||||
private SDIManager sdiManager=null;
|
||||
|
||||
@Inject
|
||||
private GeoNetworkManager gnManager;
|
||||
@Inject
|
||||
private GISManager gisManager;
|
||||
@Inject
|
||||
private ThreddsManager thManager;
|
||||
|
||||
|
||||
|
||||
@Synchronized
|
||||
private SDIManager getInstance() {
|
||||
if(sdiManager==null)
|
||||
sdiManager=new SDIManagerImpl(gnManager,thManager,gisManager);
|
||||
return sdiManager;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package org.gcube.spatial.data.sdi.engine.impl.factories;
|
||||
|
||||
import org.gcube.spatial.data.sdi.engine.TemporaryPersistence;
|
||||
import org.gcube.spatial.data.sdi.engine.impl.TemporaryPersistenceImpl;
|
||||
import org.glassfish.hk2.api.Factory;
|
||||
|
||||
public class TemporaryPersistenceFactory implements Factory<TemporaryPersistence>{
|
||||
|
||||
|
||||
@Override
|
||||
public void dispose(TemporaryPersistence arg0) {
|
||||
arg0.shutdown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TemporaryPersistence provide() {
|
||||
TemporaryPersistenceImpl temp=new TemporaryPersistenceImpl();
|
||||
|
||||
temp.init();
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package org.gcube.spatial.data.sdi.engine.impl.factories;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.gcube.spatial.data.sdi.engine.TemplateManager;
|
||||
import org.gcube.spatial.data.sdi.engine.ThreddsManager;
|
||||
import org.gcube.spatial.data.sdi.engine.impl.ThreddsManagerImpl;
|
||||
import org.glassfish.hk2.api.Factory;
|
||||
|
||||
public class ThreddsManagerFactory implements Factory<ThreddsManager>{
|
||||
|
||||
@Inject
|
||||
private TemplateManager manager;
|
||||
|
||||
|
||||
@Override
|
||||
public ThreddsManager provide() {
|
||||
return new ThreddsManagerImpl(manager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose(ThreddsManager instance) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue