MentaContainer

Compare Revisions

Ignore whitespace Rev 109 → Rev 110

/trunk/src/test/java/org/mentacontainer/impl/MentaContainerTest.java
427,7 → 427,7
}
@Override
public void onDestroyed(SomeObject obj) {
public void onCleared(SomeObject obj) {
obj.destroyed();
}
/trunk/src/main/java/org/mentacontainer/impl/GenericFactory.java
47,9 → 47,9
}
@Override
public void onDestroyed(E destroyedObject) {
public void onCleared(E clearedObject) {
if (interceptor != null) {
interceptor.onDestroyed(destroyedObject);
interceptor.onCleared(clearedObject);
}
}
/trunk/src/main/java/org/mentacontainer/impl/MentaContainer.java
142,7 → 142,7
}
}
if (cp != null) cp.c.onDestroyed(cp.value);
if (cp != null) cp.c.onCleared(cp.value);
return (T) value;
178,7 → 178,7
}
}
if (cp != null) cp.c.onDestroyed(cp.value);
if (cp != null) cp.c.onCleared(cp.value);
return (T) retVal;
526,7 → 526,7
}
public void clear() {
c.onDestroyed(value);
c.onCleared(value);
}
}
/trunk/src/main/java/org/mentacontainer/Container.java
14,7 → 14,7
* <li>Instantiation through constructors so you can instantiate any external class with objects from the container</li>
* <li>Support for SINGLETON and THREAD scopes, plus you can easily create REQUEST and SESSION scopes for web projects</li>
* <li>Generic Factories so you can easily turn anything into a object factory</li>
* <li>Interceptors for factories: onCreated, onDestroyed, useful for object pooling</li>
* <li>Interceptors for factories: onCreated, onCleared, useful for object pooling</li>
* </ul>
*
* @author sergio.oliveira.jr@gmail.com
/trunk/src/main/java/org/mentacontainer/ConfigurableFactory.java
4,7 → 4,7
* An IoC factory that knows how to create instances and
* can be configured by accepting values for its constructor
* and properties (setters). It can also be intercepted right
* after it creates an instance and right before it destroys/releases an instance
* after it creates an instance and right before it releases an instance
* through the Interceptor interface.
*
* It also supports constructor and property values that are dependencies, in other words, they come from the container itself.
/trunk/src/main/java/org/mentacontainer/Scope.java
13,7 → 13,7
SINGLETON,
/**
* The container calls factory.getInstance and caches the value on a thread local, so the same thread will always get the same instance.
* The container calls factory.getInstance and caches the value on a thread local, so the same thread will always get the same instance, at least until the scope is cleared by the client.
*/
THREAD
}
/trunk/src/main/java/org/mentacontainer/Interceptor.java
7,8 → 7,7
* the pool.
*
* It makes more sense to use this interface for factories that will be placed
* in the THREAD scope, but you can also use it with factories in the SINGLETON
* scope. It does not make sense to use an interceptor for scope NONE.
* in the THREAD scope, but you can also use it with other scopes as well.
*
* This is particular useful for the THREAD scope for dealing with thread pools, so
* when the thread is returned to the thread pool you will want to clear the THREAD
31,7 → 30,7
/**
* This method will be called right before the object is cleared from the scope.
*
* @param destroyedObject The object being cleared.
* @param clearedObject The object being cleared.
*/
public void onDestroyed(E destroyedObject);
public void onCleared(E clearedObject);
}