Refine search
@Test public void testReplaceNode() throws TransactionFailure { SimpleConnector sc = habitat.getService(SimpleConnector.class); assertEquals("Eextensions", 1, sc.getExtensions().size()); GenericContainer extension = sc.getExtensions().get(0); assertEquals("Child extensions", 2, extension.getExtensions().size()); GenericConfig nestedChild = extension.getExtensions().get(0); ConfigSupport.apply(new SingleConfigCode<GenericConfig>() { @Override public Object run(GenericConfig nestedChild) throws PropertyVetoException, TransactionFailure { nestedChild.setGenericConfig(null); GenericConfig newChild = nestedChild.createChild(GenericConfig.class); newChild.setName("test3"); nestedChild.setGenericConfig(newChild); return nestedChild; } }, nestedChild); assertNotNull("Nested named child 1", habitat.getService(GenericConfig.class, "test1")); assertNotNull("Nested named child 2", habitat.getService(GenericConfig.class, "test2")); assertNull("Nested named grand child replaced", habitat.getService(GenericConfig.class, "test")); }
@Test public void testEnableConfigUtilities() { ServiceLocator locator = ServiceLocatorFactory.getInstance().create(null); Assert.assertNull(locator.getService(ConfigSupport.class)); Assert.assertNull(locator.getService(ConfigurationPopulator.class)); Assert.assertNull(locator.getService(Transactions.class)); Assert.assertNull(locator.getService(ConfigInstanceListener.class)); HK2DomConfigUtilities.enableHK2DomConfiguration(locator); // Twice to check idempotence HK2DomConfigUtilities.enableHK2DomConfiguration(locator); Assert.assertEquals(1, locator.getAllServices(ConfigSupport.class).size()); Assert.assertEquals(1, locator.getAllServices(ConfigurationPopulator.class).size()); Assert.assertEquals(1, locator.getAllServices(Transactions.class).size()); Assert.assertEquals(1, locator.getAllServices(ConfigInstanceListener.class).size()); }
/** * Returns a configured Habitat with the configuration. * * @return a configured Habitat */ public ServiceLocator getHabitat() { ServiceLocator habitat = Utils.instance.getHabitat(this); assertNotNull("Transactions service from Configuration subsystem is null", habitat.getService(Transactions.class)); return habitat; }
public static EjbContainerUtil getInstance() { if (_me == null) { // This situation shouldn't happen. Print the error message // and the stack trace to know how did we get here. // Create the instance first to access the logger. _logger.log(Level.WARNING, "Internal error: EJBContainerUtilImpl is null, creating ...", new Throwable()); _me = Globals.getDefaultHabitat().getService( EjbContainerUtilImpl.class); } return _me; }
DynamicConfigurationService dcs = serviceLocator.getService(DynamicConfigurationService.class); DynamicConfiguration config = dcs.createDynamicConfiguration(); object, contractName, name}); } catch (ClassNotFoundException e) { logger.log(Level.SEVERE, "Cannot resolve contract " + contractName, e);
public String[] getSupportedCipherSuites() { try { final SSLUtils sslUtils = mHabitat.getService(SSLUtils.class); return sslUtils.getSupportedCipherSuites(); } catch (final Exception ex) { AMXLoggerInfo.getLogger().log( Level.INFO, AMXLoggerInfo.cantGetCipherSuites, ex); return new String[0]; } }
@Test public void testRemovedOne() throws TransactionFailure { SimpleConnector sc = habitat.getService(SimpleConnector.class); assertEquals("Extensions", 1, sc.getExtensions().size()); assertNotNull("Nested named child 1", habitat.getService(GenericConfig.class, "test1")); assertNotNull("Nested named grand child", habitat.getService(GenericConfig.class, "test")); assertNotNull("Nested named child 2", habitat.getService(GenericConfig.class, "test2")); assertNotNull("GenericContainer Service", habitat.getService(GenericContainer.class));
@Test // Removed container causes nested elements be removed public void testDisposedNestedAndNamed() throws TransactionFailure { SimpleConnector sc = habitat.getService(SimpleConnector.class); assertEquals("Extensions", 1, sc.getExtensions().size()); assertEquals("Nested children", 2, sc.getExtensions().get(0).getExtensions().size()); habitat.getService(GenericContainer.class)); assertNull("GenericConfig descriptor test still has " + habitat.getDescriptors(BuilderHelper.createContractFilter(GenericConfig.class.getName())), habitat.getService(GenericConfig.class, "test")); assertNull("GenericConfig descriptor still has " + habitat.getDescriptors(BuilderHelper.createContractFilter(GenericConfig.class.getName())), habitat.getService(GenericConfig.class));
public final boolean commit() throws LoginException { if (!success) { return false; } Set<Principal> principalSet = subject.getPrincipals(); for (int i = 0; i < groups.length; i++) { if (groups[i] != null) { Group g = Globals.getDefaultHabitat().<PrincipalGroupFactory>getService(PrincipalGroupFactory.class). getGroupInstance(groups[i], CertificateRealm.AUTH_TYPE); principalSet.add(g); } groups[i] = null; } groups = null; commitsuccess = true; if (_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, "JAAS authentication committed."); } return true; }
@Test public void testRemoveNamed() throws TransactionFailure { SimpleConnector sc = habitat.getService(SimpleConnector.class); assertEquals("Eextensions", 1, sc.getExtensions().size()); assertEquals("Nested children", 2, sc.getExtensions().get(0).getExtensions().size()); GenericContainer extension = sc.getExtensions().get(0); ConfigSupport.apply(new SingleConfigCode<GenericContainer>() { @Override public Object run(GenericContainer container) throws PropertyVetoException, TransactionFailure { List<GenericConfig> childExtensions = container.getExtensions(); GenericConfig nestedChild = childExtensions.get(childExtensions.size() - 1); childExtensions.remove(nestedChild); return nestedChild; } }, extension); assertEquals("Removed extensions", 1, sc.getExtensions().size()); assertNull("Removed nested named child", habitat.getService(GenericConfig.class, "test2")); // make sure other elements are not removed assertNotNull("Nested named child", habitat.getService(GenericConfig.class, "test1")); assertNotNull("Nested named grand child", habitat.getService(GenericConfig.class, "test")); }
@Test public void testEnableConfigUtilities() { ServiceLocator locator = ServiceLocatorFactory.getInstance().create(null); Assert.assertNull(locator.getService(ConfigSupport.class)); Assert.assertNull(locator.getService(ConfigurationPopulator.class)); Assert.assertNull(locator.getService(Transactions.class)); Assert.assertNull(locator.getService(ConfigInstanceListener.class)); HK2DomConfigUtilities.enableHK2DomConfiguration(locator); // Twice to check idempotence HK2DomConfigUtilities.enableHK2DomConfiguration(locator); Assert.assertEquals(1, locator.getAllServices(ConfigSupport.class).size()); Assert.assertEquals(1, locator.getAllServices(ConfigurationPopulator.class).size()); Assert.assertEquals(1, locator.getAllServices(Transactions.class).size()); Assert.assertEquals(1, locator.getAllServices(ConfigInstanceListener.class).size()); }
public CustomSocketFactory() { SSLUtils sslUtils = Globals.getDefaultHabitat().getService(SSLUtils.class); SSLContext sc = null; try { sc = SSLContext.getInstance(SSL); sc.init(sslUtils.getKeyManagers(), sslUtils.getTrustManagers(), SharedSecureRandom.get()); socketFactory = sc.getSocketFactory(); } catch (Exception ex) { _logger.log(Level.WARNING, SecurityLoggerInfo.securityExceptionError, ex); } }
@Test public void testReplaceChild() throws TransactionFailure { SimpleConnector sc = habitat.getService(SimpleConnector.class); assertEquals("Eextensions", 1, sc.getExtensions().size()); GenericContainer extension = sc.getExtensions().get(0); assertEquals("Child extensions", 2, extension.getExtensions().size()); ConfigSupport.apply(new SingleConfigCode<GenericContainer>() { @Override public Object run(GenericContainer extension) throws PropertyVetoException, TransactionFailure { GenericConfig newChild = extension.createChild(GenericConfig.class); newChild.setName("test3"); GenericConfig nestedChild = extension.getExtensions().set(0, newChild); return nestedChild; } }, extension); assertEquals("Extensions", 2, extension.getExtensions().size()); assertNull("Nested named child 1", habitat.getService(GenericConfig.class, "test1")); assertNull("Nested named grand child replaced", habitat.getService(GenericConfig.class, "test")); assertEquals("New Nested child", "test3", extension.getExtensions().get(0).getName()); // can't verify it with getService becaue named alias is not created with createChild //assertNotNull("New Nested child", habitat.getService(GenericConfig.class, "test3")); assertNotNull("Nested named child 2", habitat.getService(GenericConfig.class, "test2")); } }
@Test // Removed container causes nested elements be removed public void testDisposedNestedAndNamed() throws TransactionFailure { SimpleConnector sc = habitat.getService(SimpleConnector.class); assertEquals("Extensions", 1, sc.getExtensions().size()); assertEquals("Nested children", 2, sc.getExtensions().get(0).getExtensions().size()); habitat.getService(GenericContainer.class)); assertNull("GenericConfig descriptor test still has " + habitat.getDescriptors(BuilderHelper.createContractFilter(GenericConfig.class.getName())), habitat.getService(GenericConfig.class, "test")); assertNull("GenericConfig descriptor still has " + habitat.getDescriptors(BuilderHelper.createContractFilter(GenericConfig.class.getName())), habitat.getService(GenericConfig.class));
public void establish_components(IORInfo iorInfo) { try { _logger.log(Level.FINE, "TxIORInterceptor.establish_components->:"); // Add OTS tagged components. These are always the same for all EJBs OTSPolicy otsPolicy = null; try { otsPolicy = (OTSPolicy)iorInfo.get_effective_policy( habitat.getService(GlassFishORBHelper.class).getOTSPolicyType()); } catch ( INV_POLICY ex ) { _logger.log(Level.FINE, "TxIORInterceptor.establish_components: OTSPolicy not present"); } addOTSComponents(iorInfo, otsPolicy); } catch (Exception e) { _logger.log(Level.WARNING,"Exception in establish_components", e); } finally { _logger.log(Level.FINE, "TxIORInterceptor.establish_components<-:"); } }
@Test public void testReplaceNode() throws TransactionFailure { SimpleConnector sc = habitat.getService(SimpleConnector.class); assertEquals("Eextensions", 1, sc.getExtensions().size()); GenericContainer extension = sc.getExtensions().get(0); assertEquals("Child extensions", 2, extension.getExtensions().size()); GenericConfig nestedChild = extension.getExtensions().get(0); ConfigSupport.apply(new SingleConfigCode<GenericConfig>() { @Override public Object run(GenericConfig nestedChild) throws PropertyVetoException, TransactionFailure { nestedChild.setGenericConfig(null); GenericConfig newChild = nestedChild.createChild(GenericConfig.class); newChild.setName("test3"); nestedChild.setGenericConfig(newChild); return nestedChild; } }, nestedChild); assertNotNull("Nested named child 1", habitat.getService(GenericConfig.class, "test1")); assertNotNull("Nested named child 2", habitat.getService(GenericConfig.class, "test2")); assertNull("Nested named grand child replaced", habitat.getService(GenericConfig.class, "test")); }
continue; ConfigInjector injector = serviceLocator.getService(ConfigInjector.class, desc.getName()); if (injector != null) { String clzName = injector.getClass().getName().substring(0, injector.getClass().getName().length() - 8); if (clz == null) { if (LOG.isLoggable(Level.FINE)) { LOG.log(Level.FINE, "Cannot find the class mapping to: " + clzName); LOG.log(Level.FINE, "Cannot load the class", e);
@Test public void testRemovedOne() throws TransactionFailure { SimpleConnector sc = habitat.getService(SimpleConnector.class); assertEquals("Extensions", 1, sc.getExtensions().size()); assertNotNull("Nested named child 1", habitat.getService(GenericConfig.class, "test1")); assertNotNull("Nested named grand child", habitat.getService(GenericConfig.class, "test")); assertNotNull("Nested named child 2", habitat.getService(GenericConfig.class, "test2")); assertNotNull("GenericContainer Service", habitat.getService(GenericContainer.class));
public CLICommand getLocalCommand(String name) { if (serviceLocator == null) { //First hard chack if it is local command try { String className = getCommandClassName(name); if (className == null) { if (logger.isLoggable(Level.FINER)) { logger.log(Level.FINER, "CLICommand not found for name {0}", name); } return null; } CLICommand result = (CLICommand) createInstance(className); if (result != null) { if (logger.isLoggable(Level.FINER)) { logger.log(Level.FINER, "CLIContainer creates instance for command {0}", name); } return result; } } catch (Exception ex) { //Not special case. } } if (logger.isLoggable(Level.FINER)) { logger.log(Level.FINER, "HK2 Service locator will be used for command {0}", name); } return getServiceLocator().getService(CLICommand.class, name); }
@Test public void testRemoveNamed() throws TransactionFailure { SimpleConnector sc = habitat.getService(SimpleConnector.class); assertEquals("Eextensions", 1, sc.getExtensions().size()); assertEquals("Nested children", 2, sc.getExtensions().get(0).getExtensions().size()); GenericContainer extension = sc.getExtensions().get(0); ConfigSupport.apply(new SingleConfigCode<GenericContainer>() { @Override public Object run(GenericContainer container) throws PropertyVetoException, TransactionFailure { List<GenericConfig> childExtensions = container.getExtensions(); GenericConfig nestedChild = childExtensions.get(childExtensions.size() - 1); childExtensions.remove(nestedChild); return nestedChild; } }, extension); assertEquals("Removed extensions", 1, sc.getExtensions().size()); assertNull("Removed nested named child", habitat.getService(GenericConfig.class, "test2")); // make sure other elements are not removed assertNotNull("Nested named child", habitat.getService(GenericConfig.class, "test1")); assertNotNull("Nested named grand child", habitat.getService(GenericConfig.class, "test")); }