Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/main/java/com/googlecode/objectify/ObjectifyFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -371,19 +371,30 @@ public Objectify ofy() {
* <p>This will be removed from the public API in the future.</p>
*/
private ObjectifyImpl open() {
final ObjectifyImpl objectify = new ObjectifyImpl(this);
final ObjectifyImpl objectify = createObjectify();
stacks.get().add(objectify);
return objectify;
}

/** This is for internal housekeeping and is not part of the public API */
public ObjectifyImpl open(final ObjectifyOptions opts, final Transactor transactor) {
final ObjectifyImpl objectify = new ObjectifyImpl(this, opts, transactor);
final ObjectifyImpl objectify = createObjectify(opts, transactor);
stacks.get().add(objectify);
return objectify;
}

/** This is for internal housekeeping and is not part of the public API */
/** Can be overridden if you want to subclass ObjectifyImpl */
protected ObjectifyImpl createObjectify() {
return new ObjectifyImpl(this);
}

/** This is only public because it is used from the impl package, and is not part of the
* public API. However, it can be overridden if you want to subclass ObjectifyImpl. */
public ObjectifyImpl createObjectify(final ObjectifyOptions opts, final Transactor transactor) {
return new ObjectifyImpl(this, opts, transactor);
}

/** This is for internal housekeeping and is not part of the public API */
public void close(final Objectify ofy) {
final Deque<Objectify> stack = stacks.get();
if (stack.isEmpty())
Expand Down Expand Up @@ -527,4 +538,4 @@ public <T> Ref<T> ref(final Key<T> key) {
public <T> Ref<T> ref(final T value) {
return ref(key(value));
}
}
}
11 changes: 3 additions & 8 deletions src/main/java/com/googlecode/objectify/impl/ObjectifyImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,12 @@ public Objectify mandatoryTransactions(boolean value) {

/** Same transactor, different options */
ObjectifyImpl options(final ObjectifyOptions opts) {
return makeNew(opts, transactor);
return factory().createObjectify(opts, transactor);
}

/** Same options, different transactor */
ObjectifyImpl transactor(final Transactor transactor) {
return makeNew(options, transactor);
}

/** Can be overriden if you want to subclass the ObjectifyImpl */
protected ObjectifyImpl makeNew(final ObjectifyOptions opts, final Transactor transactor) {
return new ObjectifyImpl(factory, opts, transactor);
return factory().createObjectify(options, transactor);
}

/* (non-Javadoc)
Expand Down Expand Up @@ -356,4 +351,4 @@ public void close() {

factory().close(this);
}
}
}