Package javax.jdo

Examples of javax.jdo.PersistenceManagerFactory


      else if (method.getName().equals("hashCode")) {
        // Use hashCode of PersistenceManagerFactory proxy.
        return new Integer(System.identityHashCode(proxy));
      }
      else if (method.getName().equals("getPersistenceManager")) {
        PersistenceManagerFactory target = getTargetPersistenceManagerFactory();
        PersistenceManager pm =
            PersistenceManagerFactoryUtils.doGetPersistenceManager(target, isAllowCreate());
        Class[] ifcs = ClassUtils.getAllInterfacesForClass(pm.getClass(), getClass().getClassLoader());
        return (PersistenceManager) Proxy.newProxyInstance(
            pm.getClass().getClassLoader(), ifcs, new TransactionAwareInvocationHandler(pm, target));
View Full Code Here


   */
  private class TransactionAwareFactoryInvocationHandler implements InvocationHandler {

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
      // Invocation on PersistenceManagerFactory interface coming in...
      PersistenceManagerFactory target = getTargetPersistenceManagerFactory();

      if (method.getName().equals("getPersistenceManager")) {
        PersistenceManager pm =
            PersistenceManagerFactoryUtils.doGetPersistenceManager(target, isAllowCreate());
        Class[] ifcs = ClassUtils.getAllInterfaces(pm);
View Full Code Here

  protected void doFilterInternal(
      HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
      throws ServletException, IOException {

    PersistenceManagerFactory pmf = lookupPersistenceManagerFactory(request);
    boolean participate = false;

    if (TransactionSynchronizationManager.hasResource(pmf)) {
      // Do not modify the PersistenceManager: just set the participate flag.
      participate = true;
View Full Code Here

  public final void testCheckAuthorizationNoRequestToken() {
    // Setup.
    LoginFormHandler loginForm = mock(LoginFormHandler.class);
    OAuthClient client = mock(OAuthClient.class);
    PersistenceManager pm = mock(PersistenceManager.class);
    PersistenceManagerFactory pmf = mock(PersistenceManagerFactory.class);

    OAuthAccessor accessor = buildAccessor(CONSUMER_KEY, CONSUMER_SECRET,
        REQUEST_TOKEN_URL, AUTHORIZE_URL, CALLBACK_URL, ACCESS_TOKEN_URL);
    accessor.requestToken = REQUEST_TOKEN_STRING;
    oauthService = new OAuthServiceImpl(accessor, client, pmf,
        USER_RECORD_KEY);
    OAuthUser userWithRequestToken = new OAuthUser(USER_RECORD_KEY, REQUEST_TOKEN_STRING);

    // Expectations.
    when(pmf.getPersistenceManager()).thenReturn(pm);
    when(pm.getObjectById(OAuthUser.class, USER_RECORD_KEY)).thenReturn(null, userWithRequestToken,
        userWithRequestToken);

    assertFalse(oauthService.checkAuthorization(null, loginForm));
View Full Code Here

        assertTrue("Has thread pm", TransactionSynchronizationManager.hasResource(pmf));

        TransactionAwarePersistenceManagerFactoryProxy proxyFactory =
            new TransactionAwarePersistenceManagerFactoryProxy();
        proxyFactory.setTargetPersistenceManagerFactory(pmf);
        PersistenceManagerFactory proxy = (PersistenceManagerFactory) proxyFactory.getObject();
        assertEquals(pm.toString(), proxy.getPersistenceManager().toString());
        proxy.getPersistenceManager().flush();
        proxy.getPersistenceManager().close();

        JdoTemplate jt = new JdoTemplate(pmf);
        return jt.execute(new JdoCallback() {
          public Object doInJdo(PersistenceManager pm2) {
            pm2.flush();
View Full Code Here

*/
public class JdoInterceptorTests extends TestCase {

  public void testInterceptor() {
    MockControl pmfControl = MockControl.createControl(PersistenceManagerFactory.class);
    PersistenceManagerFactory pmf = (PersistenceManagerFactory) pmfControl.getMock();
    MockControl pmControl = MockControl.createControl(PersistenceManager.class);
    PersistenceManager pm = (PersistenceManager) pmControl.getMock();
    pmf.getPersistenceManager();
    pmfControl.setReturnValue(pm, 1);
    pm.close();
    pmControl.setVoidCallable(1);
    pmfControl.replay();
    pmControl.replay();
View Full Code Here

    pmControl.verify();
  }

  public void testInterceptorWithPrebound() {
    MockControl pmfControl = MockControl.createControl(PersistenceManagerFactory.class);
    PersistenceManagerFactory pmf = (PersistenceManagerFactory) pmfControl.getMock();
    MockControl pmControl = MockControl.createControl(PersistenceManager.class);
    PersistenceManager pm = (PersistenceManager) pmControl.getMock();
    pmfControl.replay();
    pmControl.replay();
View Full Code Here

*/
public class JdoDaoSupportTests extends TestCase {

  public void testJdoDaoSupportWithPersistenceManagerFactory() throws Exception {
    MockControl pmfControl = MockControl.createControl(PersistenceManagerFactory.class);
    PersistenceManagerFactory pmf = (PersistenceManagerFactory) pmfControl.getMock();
    pmf.getConnectionFactory();
    pmfControl.setReturnValue(null, 1);
    pmfControl.replay();
    final List test = new ArrayList();
    JdoDaoSupport dao = new JdoDaoSupport() {
      protected void initDao() {
View Full Code Here

*/
public class OpenPersistenceManagerInViewTests extends TestCase {

  public void testOpenPersistenceManagerInViewInterceptor() throws Exception {
    MockControl pmfControl = MockControl.createControl(PersistenceManagerFactory.class);
    PersistenceManagerFactory pmf = (PersistenceManagerFactory) pmfControl.getMock();
    MockControl pmControl = MockControl.createControl(PersistenceManager.class);
    PersistenceManager pm = (PersistenceManager) pmControl.getMock();

    OpenPersistenceManagerInViewInterceptor rawInterceptor = new OpenPersistenceManagerInViewInterceptor();
    rawInterceptor.setPersistenceManagerFactory(pmf);
    HandlerInterceptor interceptor = new WebRequestHandlerInterceptorAdapter(rawInterceptor);

    MockServletContext sc = new MockServletContext();
    MockHttpServletRequest request = new MockHttpServletRequest(sc);
    MockHttpServletResponse response = new MockHttpServletResponse();

    pmf.getPersistenceManager();
    pmfControl.setReturnValue(pm, 1);
    pmfControl.replay();
    pmControl.replay();
    interceptor.preHandle(request, response, "handler");
    assertTrue(TransactionSynchronizationManager.hasResource(pmf));
View Full Code Here

    pmControl.verify();
  }

  public void testOpenPersistenceManagerInViewFilter() throws Exception {
    MockControl pmfControl = MockControl.createControl(PersistenceManagerFactory.class);
    final PersistenceManagerFactory pmf = (PersistenceManagerFactory) pmfControl.getMock();
    MockControl pmControl = MockControl.createControl(PersistenceManager.class);
    PersistenceManager pm = (PersistenceManager) pmControl.getMock();

    pmf.getPersistenceManager();
    pmfControl.setReturnValue(pm, 1);
    pm.close();
    pmControl.setVoidCallable(1);
    pmfControl.replay();
    pmControl.replay();

    MockControl pmf2Control = MockControl.createControl(PersistenceManagerFactory.class);
    final PersistenceManagerFactory pmf2 = (PersistenceManagerFactory) pmf2Control.getMock();
    MockControl pm2Control = MockControl.createControl(PersistenceManager.class);
    PersistenceManager pm2 = (PersistenceManager) pm2Control.getMock();

    pmf2.getPersistenceManager();
    pmf2Control.setReturnValue(pm2, 1);
    pm2.close();
    pm2Control.setVoidCallable(1);
    pmf2Control.replay();
    pm2Control.replay();
View Full Code Here

TOP

Related Classes of javax.jdo.PersistenceManagerFactory

Copyright © 2018 www.massapicom. 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.