public void testLookupOfInjectorAndCheckIfActive() { ServiceHandle inhabitant1 = habitat.getServiceHandle(ConfigInjector.class, "simple-connector"); ServiceHandle inhabitant2 = habitat.getServiceHandle(ConfigInjector.class, "ejb-container-availability"); assert(inhabitant1 != null && inhabitant2 != null && inhabitant1.isActive() == false && inhabitant2.isActive() == false); }
public void lookupConnectorServiceAndEnsureNotActive() { SimpleConnector sc = habitat.getService(SimpleConnector.class); System.out.println("[lookupConnectorService] Got sc : " + sc.getClass().getName()); ServiceHandle inhabitant1 = habitat.getServiceHandle(ConfigInjector.class, "simple-connector"); assert(sc != null && !inhabitant1.isActive()); }
public void onShutdown() { // Cleanup if TM was loaded if (tm == null) { ServiceHandle<JavaEETransactionManager> inhabitant = habitat.getServiceHandle(JavaEETransactionManager.class); if (inhabitant != null && inhabitant.isActive()) { tm = inhabitant.getService(); } } if (tm != null) { _logger.fine("ON TM SHUTDOWN STARTED"); tm.shutdown(); _logger.fine("ON TM SHUTDOWN FINISHED"); } }
private void cleanupTransactions() { try { /* Providers<TransactionManager> txProviders = habitat.forContract(TransactionManager.class); if (txProviders != null) { Provider<TransactionManager> provider = txProviders.getProvider(); if (provider != null && provider.isActive()) { TransactionManager txMgr = provider.get(); txMgr.rollback(); } } */ ServiceHandle<TransactionManager> inhabitant = habitat.getServiceHandle(TransactionManager.class); if (inhabitant != null && inhabitant.isActive()) { TransactionManager txmgr = inhabitant.getService(); if ( txmgr.getTransaction() != null ) { txmgr.rollback(); } } } catch (Throwable t) { _logger.log(Level.SEVERE, "Error in cleanupTransactions", t); } }
private void dumpInhabitantsImplementingContractPattern(String pattern, StringBuilder sb) { sb.append("\n*********** List of all services for contract named like " + contract + " **************\n"); List<ActiveDescriptor<?>> allDescriptors = serviceLocator.getDescriptors(BuilderHelper.allFilter()); HashSet<String> allContracts = new HashSet<String>(); for (ActiveDescriptor<?> aDescriptor : allDescriptors) { allContracts.addAll(aDescriptor.getAdvertisedContracts()); } Iterator<String> it = allContracts.iterator(); while (it.hasNext()) { String cn = it.next(); if (cn.toLowerCase(Locale.ENGLISH).indexOf(pattern.toLowerCase(Locale.ENGLISH)) < 0) continue; sb.append("\n-----------------------------\n"); for ( ActiveDescriptor<?> descriptor : serviceLocator.getDescriptors(BuilderHelper.createContractFilter(cn))) { sb.append("Inhabitant-Metadata: " + descriptor.getMetadata()); sb.append("\n"); boolean isStarted = Boolean.parseBoolean(started); if (isStarted) { ServiceHandle<?> handle = serviceLocator.getServiceHandle(descriptor); sb.append((handle.isActive() ? " started" : " not started")); } } } }
public void onShutdown() { // Cleanup if TM was loaded if (tm == null) { ServiceHandle<JavaEETransactionManager> inhabitant = habitat.getServiceHandle(JavaEETransactionManager.class); if (inhabitant != null && inhabitant.isActive()) { tm = inhabitant.getService(); } } if (tm != null) { _logger.fine("ON TM SHUTDOWN STARTED"); tm.shutdown(); _logger.fine("ON TM SHUTDOWN FINISHED"); } }
private void cleanupConnectorRuntime() { try { /* Providers<ConnectorRuntime> txProviders = habitat.forContract(ConnectorRuntime.class); if (txProviders != null) { Provider<ConnectorRuntime> provider = txProviders.getProvider(); if (provider != null && provider.isActive()) { ConnectorRuntime connectorRuntime = provider.get(); connectorRuntime.cleanUpResourcesAndShutdownAllActiveRAs(); } } */ ServiceHandle<ConnectorRuntime> inhabitant = habitat.getServiceHandle(ConnectorRuntime.class); if (inhabitant != null && inhabitant.isActive()) { ConnectorRuntime connectorRuntime = inhabitant.getService(); connectorRuntime.cleanUpResourcesAndShutdownAllActiveRAs(); } } catch (Throwable t) { _logger.log(Level.SEVERE, "Error in cleanupConnectorRuntime", t); } }
public void testLookupOfInjectorAndCheckIfActive() { ServiceHandle inhabitant1 = habitat.getServiceHandle(ConfigInjector.class, "simple-connector"); ServiceHandle inhabitant2 = habitat.getServiceHandle(ConfigInjector.class, "ejb-container-availability"); assert(inhabitant1 != null && inhabitant2 != null && inhabitant1.isActive() == false && inhabitant2.isActive() == false); }
public void lookupConnectorServiceAndEnsureNotActive() { SimpleConnector sc = habitat.getService(SimpleConnector.class); System.out.println("[lookupConnectorService] Got sc : " + sc.getClass().getName()); ServiceHandle inhabitant1 = habitat.getServiceHandle(ConfigInjector.class, "simple-connector"); assert(sc != null && !inhabitant1.isActive()); }
public void stop(Logger logger) { if (getDeployer()!=null) { ServiceHandle<?> i = registry.habitat.getServiceHandle(getDeployer().getClass()); if (i!=null) { i.destroy(); } } if (container != null && container.isActive()) { container.destroy(); } registry.removeContainer(this); if (logger.isLoggable(Level.FINE)) { logger.fine("Container " + getContainer().getName() + " stopped"); } } }
if (handle.isActive()) { Context<?> context = (Context<?>) handle.getService(); context.shutdown();
if (handle.isActive()) { Context<?> context = (Context<?>) handle.getService(); context.shutdown();
if (handle.isActive()) { Context<?> context = (Context<?>) handle.getService(); context.shutdown();
if (handle.isActive()) { Context<?> context = (Context<?>) handle.getService(); context.shutdown();