Package com.adaptrex.sandbox.services

Source Code of com.adaptrex.sandbox.services.AdaptrexService

package com.adaptrex.sandbox.services;

import org.apache.cayenne.configuration.server.ServerRuntime;
import org.apache.tapestry5.ioc.services.RegistryShutdownHub;
import org.apache.tapestry5.services.ApplicationGlobals;

import com.adaptrex.core.Adaptrex;
import com.adaptrex.core.persistence.api.AdaptrexPersistenceManager;
import com.adaptrex.core.persistence.cayenne.CayennePersistenceManager;
import com.adaptrex.core.rest.RestService;

public class AdaptrexService implements IAdaptrexService {

  private Adaptrex adaptrex;

  public AdaptrexService(ApplicationGlobals globals, RegistryShutdownHub registryShutdownHub) throws Exception {
    ServerRuntime rt = new ServerRuntime("cayenne-sandbox.xml");
    CayennePersistenceManager cpm = new CayennePersistenceManager(rt);
    this.adaptrex = new Adaptrex(cpm);
    this.adaptrex.initialize(globals.getServletContext());
   
    registryShutdownHub.addRegistryShutdownListener(new Runnable() {
      public void run() {
        adaptrex.shutdown();
      }
    });
 

  public Adaptrex adaptrex() {
    return this.adaptrex;
  }
 
  public RestService getRest() {
    return this.adaptrex.getRestService();
  }

  public AdaptrexPersistenceManager getPersistenceManager() {
    return this.adaptrex.getPersistenceManager();
  }

  public AdaptrexPersistenceManager getPersistenceManager(String factory) {
    return this.adaptrex.getPersistenceManager(factory);
  }
}
TOP

Related Classes of com.adaptrex.sandbox.services.AdaptrexService

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.