javax.enterprise.inject.Disposes Java Examples

The following examples show how to use javax.enterprise.inject.Disposes. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InjectableResourceProducer.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
public void closeInputStream(@Disposes
                             @InjectableResource(resourceProvider = InjectableResourceProvider.class, location = "")
                             InputStream inputStream)
{
    if (inputStream != null)
    {
        try
        {
            inputStream.close();
        }
        catch (IOException e)
        {
            if (logger.isLoggable(Level.FINE))
            {
                logger.log(Level.FINE,"Unable to close input stream ",e);
            }
        }
    }
}
 
Example #2
Source File: CdiPlugin.java    From tomee with Apache License 2.0 6 votes vote down vote up
private static void validateDisposeMethods(final CdiEjbBean<?> bean) {
    if (!bean.getBeanContext().isLocalbean()) {
        for (final Method m : bean.getBeanContext().getBeanClass().getMethods()) {
            if (m.getDeclaringClass().equals(Object.class)) {
                continue;
            }

            if (m.getParameterTypes().length > 0) {
                for (final Annotation[] a : m.getParameterAnnotations()) {
                    for (final Annotation ann : a) {
                        final Method method = doResolveViewMethod(bean, m);
                        if (ann.annotationType().equals(Disposes.class) &&
                                (method == null || bean.getBeanContext().getBusinessRemoteInterfaces().contains(method.getDeclaringClass()))) {
                            throw new WebBeansConfigurationException("@Disposes is forbidden on non business or remote EJB methods");
                        }
                    }
                }
            }
        }
    }
}
 
Example #3
Source File: Resources.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
public void dispose(@Disposes @Default EntityManager entityManager)
{
    if (entityManager.isOpen())
    {
        entityManager.close();
    }
}
 
Example #4
Source File: TestEntityManagerProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
protected void closeFirstEntityManager(@Disposes @First EntityManager entityManager)
{
    if (entityManager.isOpen())
    {
        entityManager.close();
    }
    closeEntityManagerCountFirstEntityManager++;
}
 
Example #5
Source File: TestEntityManagerProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
protected void closeEntityManager(@Disposes @First EntityManager entityManager)
{
    if (entityManager.isOpen())
    {
        entityManager.close();
    }
    closeEntityManagerCount++;
}
 
Example #6
Source File: TestEntityManagerProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
protected void closeEntityManager(@Disposes EntityManager entityManager)
{
    if (entityManager.isOpen())
    {
        entityManager.close();
    }
    closeEntityManagerCount++;
}
 
Example #7
Source File: TestEntityManagerProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
protected void closeEntityManager(@Disposes EntityManager entityManager)
{
    if (entityManager.isOpen())
    {
        entityManager.close();
    }
    closeEntityManagerCount++;
}
 
Example #8
Source File: TestEntityManagerProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
protected void closeEntityManager(@Disposes EntityManager entityManager)
{
    if (entityManager.isOpen())
    {
        entityManager.close();
    }
    closeEntityManagerCount++;
}
 
Example #9
Source File: TestEntityManagerProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
protected void closeDefaultEntityManager(@Disposes @Default EntityManager entityManager)
{
    if (entityManager.isOpen())
    {
        entityManager.close();
    }
    closeEntityManagerCountDefaultEntityManager++;
}
 
Example #10
Source File: TestEntityManagerProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
protected void closeFirstEntityManager(@Disposes @First EntityManager entityManager)
{
    if (entityManager.isOpen())
    {
        entityManager.close();
    }
    closeEntityManagerCountFirstEntityManager++;
}
 
Example #11
Source File: TestEntityManagerProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
protected void closeSecondEntityManager(@Disposes @Second EntityManager entityManager)
{
    if (entityManager.isOpen())
    {
        entityManager.close();
    }
    closeEntityManagerCountSecondEntityManager++;
}
 
Example #12
Source File: DisposerTest.java    From quarkus with Apache License 2.0 5 votes vote down vote up
void dipose(@Disposes Long value, @MyQualifier String injectedString, Instance<Pong> pongs) {
    assertNotNull(injectedString);
    DISPOSED.set(value);
    pongs.forEach(p -> {
        assertEquals("OK", p.id);
    });
}
 
Example #13
Source File: JsonbProducer.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void close(@Disposes final Jsonb jsonb) {
    try {
        jsonb.close();

    } catch (final Exception e) {
        log.log(Level.WARNING, e.getMessage(), e);
    }
}
 
Example #14
Source File: TestEntityManagerProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
protected void closeDefaultEntityManager(@Disposes @Default EntityManager entityManager)
{
    if (entityManager.isOpen())
    {
        entityManager.close();
    }
    closeEntityManagerCountDefaultEntityManager++;
}
 
Example #15
Source File: TestEntityManagerProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
protected void closeSecondEntityManager(@Disposes @Second EntityManager entityManager)
{
    if (entityManager.isOpen())
    {
        entityManager.close();
    }
    closeEntityManagerCountSecondEntityManager++;
}
 
Example #16
Source File: JsonbProducer.java    From component-runtime with Apache License 2.0 5 votes vote down vote up
public void close(@Disposes final Jsonb jsonb) {
    try {
        jsonb.close();
    } catch (final Exception e) {
        log.warn(e.getMessage(), e);
    }
}
 
Example #17
Source File: JsonbFactory.java    From component-runtime with Apache License 2.0 5 votes vote down vote up
void destroyJsonb(@Disposes final Jsonb jsonb) {
    try {
        jsonb.close();
    } catch (final Exception e) {
        log.error(e.getMessage(), e);
    }
}
 
Example #18
Source File: TestEntityManagerProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
protected void closeSecondEntityManager(@Disposes @Second EntityManager entityManager)
{
    if (entityManager.isOpen())
    {
        entityManager.close();
    }
    closeEntityManagerCountSecondEntityManager++;
}
 
Example #19
Source File: Resources.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
public void dispose(@Disposes @Default EntityManager entityManager)
{
    if (entityManager.isOpen())
    {
        entityManager.close();
    }
}
 
Example #20
Source File: LogFactory.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void closeLogHandler(@Disposes LogHandler handler) {
    switch (type) {
        case 1:
            System.out.println("Closing File handler!");
            break;
        case 2:
            System.out.println("Closing DB handler!");
            break;
        case 3:
        default:
            System.out.println("Closing Console handler!");
    }
}
 
Example #21
Source File: TestEntityManagerProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
protected void closeFirstEntityManager(@Disposes @First EntityManager entityManager)
{
    if (entityManager.isOpen())
    {
        entityManager.close();
    }
    closeEntityManagerCountFirstEntityManager++;
}
 
Example #22
Source File: EntityManagerProducer.java    From HotswapAgentExamples with GNU General Public License v2.0 4 votes vote down vote up
public void close(@Disposes EntityManager em) {
    if (em.isOpen()) {
        em.close();
    }
}
 
Example #23
Source File: EntityManagerProducer.java    From jpa-unit with Apache License 2.0 4 votes vote down vote up
public void close(@Disposes final EntityManager em) {
    if (em.isOpen()) {
        em.close();
    }
}
 
Example #24
Source File: EntityManagerFactoryProducer.java    From HotswapAgentExamples with GNU General Public License v2.0 4 votes vote down vote up
public void destroy(@Disposes EntityManagerFactory factory) {
    factory.close();
}
 
Example #25
Source File: EntityManagerProducer.java    From web-budget with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Dispose method to close the instances of an open {@link EntityManager}
 *
 * @param entityManager the {@link EntityManager} to be closed
 */
void close(@Disposes EntityManager entityManager) {
    if (entityManager.isOpen()) {
        entityManager.close();
    }
}
 
Example #26
Source File: EntityManagerProducer.java    From jpa-unit with Apache License 2.0 4 votes vote down vote up
public void close(@Disposes final EntityManager em) {
    if (em.isOpen()) {
        em.close();
    }
}
 
Example #27
Source File: EventsHandlerConfiguration.java    From apicurio-studio with Apache License 2.0 4 votes vote down vote up
public void closeEventsHandler(@Disposes EventsHandler handler) throws Exception {
    handler.close();
}
 
Example #28
Source File: EntityManagerFactoryProducer.java    From HotswapAgentExamples with GNU General Public License v2.0 4 votes vote down vote up
public void destroy(@Disposes EntityManagerFactory factory) {
    factory.close();
}
 
Example #29
Source File: SessionProvider.java    From mamute with Apache License 2.0 4 votes vote down vote up
public void destroy(@Disposes Session session) {
    session.close();
}
 
Example #30
Source File: SessionFactoryCreator.java    From mamute with Apache License 2.0 4 votes vote down vote up
void destroy(@Disposes SessionFactory factory) {
	if (!factory.isClosed()) {
		factory.close();
	}
	factory = null;
}