Java Code Examples for javax.enterprise.inject.Disposes

The following are top voted examples for showing how to use javax.enterprise.inject.Disposes. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: tomee   File: CdiPlugin.java   View source code 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) {
                        if (ann.annotationType().equals(Disposes.class) && doResolveViewMethod(bean, m) == null) {
                            throw new WebBeansConfigurationException("@Disposes is forbidden on non business EJB methods");
                        }
                    }
                }
            }
        }
    }
}
 
Example 2
Project: deltaspike   File: InjectableResourceProducer.java   View source code 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 3
Project: cito   File: SchedulerProducer.java   View source code 5 votes vote down vote up
/**
 * 
 * @param scheduler
 */
public void dispose(@Disposes ScheduledExecutorService scheduler) {
	scheduler.shutdown();
	try {
		if (!scheduler.awaitTermination(1, TimeUnit.MINUTES)) {
			this.log.warn("Shutdown did not complete in time!");
		}
	} catch (InterruptedException e) {
		this.log.warn("Shutdown interrupted!", e);
		Thread.currentThread().interrupt();
	}
}
 
Example 4
Project: mqtt-camunda-bpm   File: MqttClientProducer.java   View source code 5 votes vote down vote up
/**
 * Shuts down the MQTT client.
 * 
 * @param client
 *            client to shut down.
 */
public void destroy(@Disposes MqttClient client) {
    try {
        if (client != null) {
            client.disconnect();
            logger.info("Disconnected from broker: " + broker);
        }
    } catch (MqttException e) {
        logger.error("Error disconnecting", e);
    }
}
 
Example 5
Project: Purifinity   File: FileSystemProducter.java   View source code 5 votes vote down vote up
public void closeAnalysisKeyspaceSession(@Disposes FileSystem session) {
try {
    session.close();
} catch (IOException e) {
    logger.warn("Could not close Hadoop file system.", e);
}
   }
 
Example 6
Project: Purifinity   File: DuctileGraphProducer.java   View source code 5 votes vote down vote up
public void closeDuctileGraph(@Disposes DuctileGraph ductileGraph) {
try {
    ductileGraph.close();
} catch (IOException e) {
    logger.warn("Could not close Ductile Graph.", e);
}
   }
 
Example 7
Project: Purifinity   File: EvaluatorStoreConnectionProducer.java   View source code 5 votes vote down vote up
public void closeAnalysisKeyspaceSession(@Disposes @EvaluatorStoreConnection Connection connection) {
try {
    connection.close();
} catch (SQLException e) {
    logger.warn("Could not close connection to Phoenix/HBase.", e);
}
   }
 
Example 8
Project: Purifinity   File: AnalysisServiceConnectionProducer.java   View source code 5 votes vote down vote up
public void closeAnalysisKeyspaceSession(@Disposes @AnalysisServiceConnection Connection connection) {
try {
    connection.close();
} catch (SQLException e) {
    logger.warn("Could not close connection to Phoenix/HBase.", e);
}
   }
 
Example 9
Project: Purifinity   File: PreferencesStoreConnectionProducer.java   View source code 5 votes vote down vote up
public void closePreferencesStoreSession(@Disposes @PreferencesStoreConnection Connection connection) {
try {
    connection.close();
} catch (SQLException e) {
    logger.warn("Could not close connection to Phoenix/HBase.", e);
}
   }
 
Example 10
Project: Purifinity   File: PluginsDatabaseConnectionProducer.java   View source code 5 votes vote down vote up
public void closeAnalysisKeyspaceSession(@Disposes @PluginsDatabaseConnection Connection connection) {
try {
    connection.close();
} catch (SQLException e) {
    logger.warn("Could not close connection to Phoenix/HBase.", e);
}
   }
 
Example 11
Project: Purifinity   File: AccountManagerConnectionProducer.java   View source code 5 votes vote down vote up
public void closeAnalysisKeyspaceSession(@Disposes @AccountManagerConnection Connection connection) {
try {
    connection.close();
} catch (SQLException e) {
    logger.warn("Could not close connection to Phoenix/HBase.", e);
}
   }
 
Example 12
Project: Purifinity   File: PasswordStoreConnectionProducer.java   View source code 5 votes vote down vote up
public void closeAnalysisKeyspaceSession(@Disposes @PasswordStoreConnection Connection connection) {
try {
    connection.close();
} catch (SQLException e) {
    logger.warn("Could not close connection to Phoenix/HBase.", e);
}
   }
 
Example 13
Project: Purifinity   File: SystemMonitorConnectionProducer.java   View source code 5 votes vote down vote up
public void closeAnalysisKeyspaceSession(@Disposes @SystemMonitorConnection Connection connection) {
try {
    connection.close();
} catch (SQLException e) {
    logger.warn("Could not close connection to Phoenix/HBase.", e);
}
   }
 
Example 14
Project: Purifinity   File: ConnectionProducer.java   View source code 5 votes vote down vote up
public void closeAnalysisKeyspaceSession(
    @Disposes @IntermediateCoCoMoEvaluatorStoreConnection Connection connection) {
try {
    connection.close();
} catch (SQLException e) {
    logger.warn("Could not close connection to Phoenix/HBase.", e);
}
   }
 
Example 15
Project: Purifinity   File: ConnectionProducer.java   View source code 5 votes vote down vote up
public void closeAnalysisKeyspaceSession(@Disposes @BasicCoCoMoEvaluatorStoreConnection Connection connection) {
try {
    connection.close();
} catch (SQLException e) {
    logger.warn("Could not close connection to Phoenix/HBase.", e);
}
   }
 
Example 16
Project: Purifinity   File: ConnectionProducer.java   View source code 5 votes vote down vote up
public void closeAnalysisKeyspaceSession(@Disposes @McCabeMetricEvaluatorStoreConnection Connection connection) {
try {
    connection.close();
} catch (SQLException e) {
    logger.warn("Could not close connection to Phoenix/HBase.", e);
}
   }
 
Example 17
Project: Purifinity   File: ConnectionProducer.java   View source code 5 votes vote down vote up
public void closeAnalysisKeyspaceSession(@Disposes @SLOCEvaluatorStoreConnection Connection connection) {
try {
    connection.close();
} catch (SQLException e) {
    logger.warn("Could not close connection to Phoenix/HBase.", e);
}
   }
 
Example 18
Project: Purifinity   File: ConnectionProducer.java   View source code 5 votes vote down vote up
public void closeAnalysisKeyspaceSession(@Disposes @HalsteadMetricEvaluatorStoreConnection Connection connection) {
try {
    connection.close();
} catch (SQLException e) {
    logger.warn("Could not close connection to Phoenix/HBase.", e);
}
   }
 
Example 19
Project: Purifinity   File: ConnectionProducer.java   View source code 5 votes vote down vote up
public void closeAnalysisKeyspaceSession(
    @Disposes @MaintainabilityIndexEvaluatorStoreConnection Connection connection) {
try {
    connection.close();
} catch (SQLException e) {
    logger.warn("Could not close connection to Phoenix/HBase.", e);
}
   }
 
Example 20
Project: parco   File: EntityManagerProducer.java   View source code 5 votes vote down vote up
public void dispose(@Disposes EntityManager entityManager) 
{
     if ( entityManager.isOpen() )
     {
          entityManager.close();
     }
}
 
Example 21
Project: eclipselink-example   File: ApplicationManagedEntityManagerProducer.java   View source code 5 votes vote down vote up
public void dispose(@Disposes EntityManager entityManager) {
    if (log.isTraceEnabled()) {
        log.trace(String.format("[Lifecycle][@Disposes] entityManager=%s", entityManager.toString()));
    }
    if (entityManager.isOpen()) {
        entityManager.close();
        if (log.isTraceEnabled()) {
            log.trace(String.format("[Lifecycle][@Disposes.closed] entityManager=%s", entityManager.toString()));
        }
    }
}
 
Example 22
Project: omakase   File: HttpClientProducer.java   View source code 5 votes vote down vote up
public void close(@Disposes @Omakase HttpClient httpClient) {
    httpClient.getConnectionManager().shutdown();

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Shutdown Pooled HTTP Client");
    }
}
 
Example 23
Project: omakase   File: HttpClientProducer.java   View source code 5 votes vote down vote up
public void close(@Disposes @Omakase HttpClient httpClient) {
    httpClient.getConnectionManager().shutdown();

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Shutdown Pooled HTTP Client");
    }
}
 
Example 24
Project: exemplos   File: EntityManagerProducer.java   View source code 5 votes vote down vote up
/**
 * Encerra um entityManager ja utilizado pelo sistema
 *
 * @param entityManager o entity manager a ser encerrado
 */
void dispose(@Disposes EntityManager entityManager) {
    if (entityManager.isOpen()) {
        entityManager.clear();
        entityManager.close();
    }
}
 
Example 25
Project: exemplos   File: EntityManagerProducer.java   View source code 5 votes vote down vote up
/**
 * Encerra um entityManager ja utilizado pelo sistema
 *
 * @param entityManager o entity manager a ser encerrado
 */
void dispose(@Disposes EntityManager entityManager) {
    if (entityManager.isOpen()) {
        entityManager.clear();
        entityManager.close();
    }
}
 
Example 26
Project: esb-message-admin   File: EntityManagerProvider.java   View source code 5 votes vote down vote up
public void closeEntityManager(@Disposes EntityManager em) {
    /* if running in a lightweight container (such as jetty), commit the
     * transaction and close the EntityManager */
    if (entityManagerFactory != null) {
        em.getTransaction().commit();
        em.close();
    }
}
 
Example 27
Project: web-budget   File: EntityManagerProducer.java   View source code 5 votes vote down vote up
/**
 * Encerra um entityManager ja utilizado pelo sistema
 *
 * @param entityManager o entity manager a ser encerrado
 */
void dispose(@Disposes EntityManager entityManager) {
    if (entityManager.isOpen()) {
        entityManager.clear();
        entityManager.close();
    }
}
 
Example 28
Project: restful-and-beyond-tut2184   File: LongPersistence.java   View source code 5 votes vote down vote up
public void cleanEM(@Disposes EntityManager entityManager) {
    logger.info("Disposing an entity manager "+entityManager);
    EntityTransaction et = entityManager.getTransaction();
    if(et.getRollbackOnly()) {
        et.rollback();
    }
    else {
        et.commit();
    }
    entityManager.close();
}
 
Example 29
Project: restful-and-beyond-tut2184   File: ShortPersistence.java   View source code 5 votes vote down vote up
public void cleanEM(@Disposes EntityManager entityManager) {
    logger.info("Disposing an entity manager "+entityManager);
    EntityTransaction et = entityManager.getTransaction();
    if(et.getRollbackOnly()) {
        et.rollback();
    }
    else {
        et.commit();
    }
    entityManager.close();
}
 
Example 30
Project: ViTA   File: Model.java   View source code 5 votes vote down vote up
/**
 * Closes the given EntityManager when it is disposed.
 *
 * @param instance - the instance of EntityManager to be disposed
 */
@Override
public void dispose(@Disposes EntityManager instance) {
  if (!instance.isOpen()) {
    return;
  }

  instance.close();
}
 
Example 31
Project: web-budget   File: EntityManagerProducer.java   View source code 5 votes vote down vote up
/**
 * Encerra um entityManager ja utilizado pelo sistema
 *
 * @param entityManager o entity manager a ser encerrado
 */
void dispose(@Disposes EntityManager entityManager) {
    if (entityManager.isOpen()) {
        entityManager.clear();
        entityManager.close();
    }
}
 
Example 32
Project: jbromo   File: CdiEntityManagerProducer.java   View source code 5 votes vote down vote up
/**
 * Close the entity manager.
 *
 * @param entityManager
 *            the manager to close.
 */
protected void closeEntityManager(
        @Disposes final EntityManager entityManager) {
    log.info("Closing an entity manager.");
    if (entityManager != null && entityManager.isOpen()) {
        entityManager.close();
    }
    if (this.entityManager == entityManager) {
        this.entityManager = null;
    }
}
 
Example 33
Project: tomee   File: LogFactory.java   View source code 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 34
Project: dtgov   File: ApplicationScopedProducer.java   View source code 5 votes vote down vote up
@ApplicationScoped
public void commitAndClose(@Disposes EntityManager em) {
    try {
        em.close();
    } catch (Exception e) {

    }
}
 
Example 35
Project: deltaspike   File: TestEntityManagerProducer.java   View source code 5 votes vote down vote up
protected void closeEntityManager(@Disposes EntityManager entityManager)
{
    if (entityManager.isOpen())
    {
        entityManager.close();
    }
    closeEntityManagerCount++;
}
 
Example 36
Project: deltaspike   File: TestEntityManagerProducer.java   View source code 5 votes vote down vote up
protected void closeEntityManager(@Disposes @First EntityManager entityManager)
{
    if (entityManager.isOpen())
    {
        entityManager.close();
    }
    closeEntityManagerCount++;
}
 
Example 37
Project: deltaspike   File: TestEntityManagerProducer.java   View source code 5 votes vote down vote up
protected void closeEntityManager(@Disposes EntityManager entityManager)
{
    if (entityManager.isOpen())
    {
        entityManager.close();
    }
    closeEntityManagerCount++;
}
 
Example 38
Project: deltaspike   File: TestEntityManagerProducer.java   View source code 5 votes vote down vote up
protected void closeDefaultEntityManager(@Disposes @Default EntityManager entityManager)
{
    if (entityManager.isOpen())
    {
        entityManager.close();
    }
    closeEntityManagerCountDefaultEntityManager++;
}
 
Example 39
Project: deltaspike   File: TestEntityManagerProducer.java   View source code 5 votes vote down vote up
protected void closeFirstEntityManager(@Disposes @First EntityManager entityManager)
{
    if (entityManager.isOpen())
    {
        entityManager.close();
    }
    closeEntityManagerCountFirstEntityManager++;
}
 
Example 40
Project: deltaspike   File: TestEntityManagerProducer.java   View source code 5 votes vote down vote up
protected void closeSecondEntityManager(@Disposes @Second EntityManager entityManager)
{
    if (entityManager.isOpen())
    {
        entityManager.close();
    }
    closeEntityManagerCountSecondEntityManager++;
}