/** * Creates statistics providers for Servlet, JSP, Session, and * Request/Response related events. */ private void createStatsProviders() { HttpServiceStatsProviderBootstrap httpStatsProviderBootstrap = habitat.getByType(HttpServiceStatsProviderBootstrap.class); webStatsProviderBootstrap = habitat.getByType(WebStatsProviderBootstrap.class); }
/** * Instantiate the passed type and injects all the {@link org.jvnet.hk2.annotations.Inject} * annotated fields and methods * * @param type class of the requested instance * @param <T> type of the requested instance * @return the instantiated and injected instance */ public <T> T inject(Class<T> type) { return getByType(type); }
protected static <V> V getComponentInjectValue( Habitat habitat, Class<V> type) throws ComponentException { V result = habitat.getByType(type); return result; }
/** * restart-instance needs to try to start the instance from scratch if it is not * running. We need to do some housekeeping first. * There is no clean way to do this through CommandRunner -- it is twisted together * with Grizzly parameters and so on. So we short-circuit this way! * do NOT make this public!! * @author Byron Nevins */ StartInstanceCommand(Habitat habitat_, String iname_, boolean debug_, ServerEnvironment env_) { instanceName = iname_; debug = debug_; habitat = habitat_; nodes = habitat.getByType(Nodes.class); // env: neither getByType or getByContract works. Not worth the effort //to find the correct magic incantation for HK2! env = env_; servers = habitat.getByType(Servers.class); }
S1ASThreadPoolManager() { try { _iiopUtils = Globals.getDefaultHabitat().getByType(IIOPUtils.class); Collection<com.sun.grizzly.config.dom.ThreadPool> tpCol = _iiopUtils.getAllThreadPools(); com.sun.grizzly.config.dom.ThreadPool[] allThreadPools = tpCol.toArray(new com.sun.grizzly.config.dom.ThreadPool[tpCol.size()]); for (int i = 0; i < allThreadPools.length; i++) { createThreadPools(allThreadPools[i], i); } defaultID = (String) indexToIdTable.get(new Integer(0)); } catch (NullPointerException npe) { _logger.log(Level.FINE, "Server Context is NULL. Ignoring and proceeding."); } }
private void promoteSystemProperties() throws TransactionFailure { ConfigSupport.apply(new SingleConfigCode<JavaConfig>() { @Override public Object run(JavaConfig param) throws PropertyVetoException, TransactionFailure { final List<String> props = new ArrayList<String>(param.getJvmOptions()); final Iterator<String> iterator = props.iterator(); while (iterator.hasNext()) { String prop = iterator.next(); if (prop.startsWith("-D")) { final String[] parts = prop.split("="); String name = parts[0].substring(2); if (SSL_CONFIGURATION_WANTAUTH.equals(name) || SSL_CONFIGURATION_SSLIMPL.equals(name)) { iterator.remove(); updateSsl(name, parts[1]); } if ("com.sun.grizzly.maxTransactionTimeout".equals(name)) { iterator.remove(); updateHttp(parts[1]); } } } param.setJvmOptions(props); return param; } }, habitat.getByType(JavaConfig.class)); }
private void rollbackDeployment(PaaSDeploymentContext context, PaaSDeploymentState failedState, List<Class> tasksList) { int index = tasksList.indexOf(failedState.getClass()); if(index == -1){ logger.log(Level.WARNING, "no.such.task.to.initiate.rollback",failedState.getClass()); return; } List<Class> tmpTasksList = new ArrayList<Class>(); tmpTasksList.addAll(tasksList); List<Class> rollbackTasksList = tmpTasksList.subList(0, index); Collections.reverse(rollbackTasksList); for(Class clz : rollbackTasksList){ PaaSDeploymentState state = habitat.getByType(clz.getName()); Class rollbackClz = state.getRollbackState(); if(rollbackClz != null){ PaaSDeploymentState rollbackState = habitat.getByType(rollbackClz.getName()); try{ rollbackState.handle(context); }catch(Exception e){ // we cannot handle failures while rolling back. // continue rolling back. Object args[]=new Object[] {context.getAppName(),rollbackState.getClass().getSimpleName()}; logger.log(Level.WARNING,localStrings.getString("failure.while.rollback",args),e); } } } }
/** * Obtains a reference to the component inside the manager. * <p/> * <p/> * This is the "new Foo()" equivalent in the IoC world. * <p/> * <p/> * Depending on the {@link Scope} of the component, a new instance might be * created, or an existing instance might be returned. * * @return non-null. * @throws ComponentException If failed to obtain a requested instance. In practice, * failure only happens when we try to create a new instance of * the component. */ public <T> T getComponent(Class<T> clazz) throws ComponentException { if (isContract(clazz)) { return getByContract(clazz); } else { return getByType(clazz); } }
/** * Obtains a reference to the component inside the manager. * <p/> * <p/> * This is the "new Foo()" equivalent in the IoC world. * <p/> * <p/> * Depending on the {@link Scope} of the component, a new instance might be * created, or an existing instance might be returned. * * @return non-null. * @throws ComponentException If failed to obtain a requested instance. In practice, * failure only happens when we try to create a new instance of * the component. */ public <T> T getComponent(Class<T> clazz) throws ComponentException { if (isContract(clazz)) { return getByContract(clazz); } else { return getByType(clazz); } }
public static <T> Inhabitant<T> wrapByScope(Creator<T> creator, Habitat habitat, Class<? extends Scope> scopeClass) { // those two scopes are so common and different that they deserve // specialized code optimized for them. if (scopeClass== PerLookup.class) { return creator; } if (scopeClass==null || scopeClass== Singleton.class) { return new SingletonInhabitant<T>(creator); } // other general case Scope scope = habitat.getByType(scopeClass); if (scope==null) { throw new ComponentException("Failed to look up %s", scopeClass); } return new ScopedInhabitant<T>(creator,scope); }
public static <T> Inhabitant<T> wrapByScope(Creator<T> creator, Habitat habitat, Class<? extends Scope> scopeClass) { // those two scopes are so common and different that they deserve // specialized code optimized for them. if (scopeClass== PerLookup.class || scopeClass==org.jvnet.hk2.component.PerLookup.class) { return creator; } if (scopeClass==null || scopeClass== Singleton.class || scopeClass==org.jvnet.hk2.component.Singleton.class) { return new SingletonInhabitant<T>(creator); } // other general case Scope scope = habitat.getByType(scopeClass); if (scope==null) { throw new ComponentException("Failed to look up %s", scopeClass); } return new ScopedInhabitant<T>(creator,scope); }
public ServiceMetadata getServices(ReadableArchive archive) throws Exception { ServiceDependencyDiscoveryState state = habitat.getByType(ServiceDependencyDiscoveryState.class); PaaSDeploymentContext pc = new PaaSDeploymentContext(archive.getName(), archive); return state.getServiceDependencyMetadata(pc, archive.getName(), archive); }
private void initSSLUtils() { if (sslUtils == null) { if (Globals.getDefaultHabitat() != null) { sslUtils = Globals.getDefaultHabitat().getByType(SSLUtils.class); } else { sslUtils = new SSLUtils(); sslUtils.postConstruct(); } } } }
private void orchestrateTask(Class[] tasks, String appName, PaaSDeploymentContext pc, boolean deployment) { for(Class clz : tasks){ PaaSDeploymentState state = habitat.getByType(clz.getName()); try{ state.beforeExecution(pc); state.handle(pc); state.afterExecution(pc); }catch(PaaSDeploymentException e){ handleFailure(appName, tasks, deployment, state, pc, e); }catch(Exception e){ handleFailure(appName, tasks, deployment, state, pc, e); } } }
ApplicationRegistry appRegistry = wscImpl.getHabitat().getByType(ApplicationRegistry.class); ApplicationInfo appInfo = appRegistry.get(endpoint.getBundleDescriptor().getApplication().getRegistrationName()); URI deployedDir =appInfo.getSource().getURI();
_embedded = habitat.getByType(EmbeddedWebContainer.class); _embedded.setWebContainer(this); _embedded.setLogServiceFile(logServiceFile);
if (httpListeners != null) { for (NetworkListener httpListener : httpListeners) { updateConnector(httpListener, habitat.getByType(HttpService.class));