### Eclipse Workspace Patch 1.0 #P jackrabbit-jca Index: src/main/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java =================================================================== --- src/main/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java (revision 1467898) +++ src/main/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java (working copy) @@ -63,6 +63,13 @@ private Boolean bindSessionToTransaction = Boolean.TRUE; /** + * Flag indicating whether the Repository should start + * immediately or lazy on first access. Per default true so the Repository will + * start immediately if this JCAManagedConnectionFactory will be initialized. + */ + private Boolean startRepositoryImmediately = Boolean.TRUE; + + /** * Repository. */ private transient Repository repository; @@ -143,8 +150,10 @@ public Object createConnectionFactory(ConnectionManager cm) throws ResourceException { // JCR-3491 Start the Repository immediatly in JCA Environment. - // If this Instance is in a Cluster it would not get any changes till someone performs a first login - createRepository(); + // If this Instance is in a Cluster it would not get any changes till someone performs a first login + if (startRepositoryImmediately) { + createRepository(); + } JCARepositoryHandle handle = new JCARepositoryHandle(this, cm); log("Created repository handle (" + handle + ")"); return handle; @@ -221,7 +230,17 @@ /** * Return the repository, automatically creating it if needed. */ - public Repository getRepository() throws RepositoryException { + @SuppressWarnings("deprecation") + public Repository getRepository() throws RepositoryException { + if (repository == null) { + synchronized (this) { + try { + createRepository(); + } catch (ResourceException e) { + throw (RepositoryException) e.getLinkedException(); + } + } + } return repository; } @@ -288,4 +307,12 @@ this.bindSessionToTransaction = bindSessionToTransaction; } + public Boolean getStartRepositoryImmediately() { + return startRepositoryImmediately; + } + + public void setStartRepositoryImmediately(Boolean startRepositoryImmediately) { + this.startRepositoryImmediately = startRepositoryImmediately; + } + }