Tabnine Logo
PetiteException.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
jodd.petite.PetiteException
constructor

Best Java code snippets using jodd.petite.PetiteException.<init> (Showing top 20 results out of 315)

origin: oblac/jodd

/**
 * Specifies default wiring mode.
 */
public PetiteConfig setDefaultWiringMode(final WiringMode defaultWiringMode) {
  if ((defaultWiringMode == null) || (defaultWiringMode == WiringMode.DEFAULT)) {
    throw new PetiteException("Invalid default wiring mode: " + defaultWiringMode);
  }
  this.defaultWiringMode = defaultWiringMode;
  return this;
}
/**
origin: oblac/jodd

/**
 * Defines bean name.
 */
public BeanProvider bean(final String beanName) {
  if (type != null) {
    throw new PetiteException("Petite provider type already defined");
  }
  this.beanName = beanName;
  return this;
}
origin: oblac/jodd

/**
 * Defines bean type.
 */
public BeanProvider type(final Class type) {
  if (beanName != null) {
    throw new PetiteException("Petite provider bean name already defined");
  }
  this.type = type;
  return this;
}
origin: oblac/jodd

public ProviderDefinition(final String name, final Method staticMethod) {
  Objects.requireNonNull(name);
  Objects.requireNonNull(staticMethod);
  this.name = name;
  if (!Modifier.isStatic(staticMethod.getModifiers())) {
    throw new PetiteException("Provider method is not static: " + staticMethod);
  }
  this.method = staticMethod;
  this.beanName = null;
}
origin: oblac/jodd

/**
 * Delegates to {@link jodd.petite.scope.Scope#lookup(String)}. 
 */
protected Object scopeLookup() {
  if (scope == null) {
    throw new PetiteException("Scope not defined");
  }
  return scope.lookup(name);
}
origin: oblac/jodd

/**
 * Returns request from current thread.
 */
protected HttpSession getCurrentHttpSession() {
  HttpServletRequest request = RequestContextListener.getRequest();
  if (request == null) {
    throw new PetiteException("No HTTP request bound to the current thread. Is RequestContextListener registered?");
  }
  return request.getSession();
}
origin: oblac/jodd

/**
 * Lookups for existing {@link jodd.petite.BeanDefinition bean definition}.
 * Throws exception if bean is not found.
 */
protected BeanDefinition lookupExistingBeanDefinition(final String name) {
  BeanDefinition beanDefinition = lookupBeanDefinition(name);
  if (beanDefinition == null) {
    throw new PetiteException("Bean not found: " + name);
  }
  return beanDefinition;
}
origin: oblac/jodd

/**
 * Returns request from current thread.
 */
protected HttpServletRequest getCurrentHttpRequest() {
  HttpServletRequest request = RequestContextListener.getRequest();
  if (request == null) {
    throw new PetiteException("No HTTP request bound to the current thread. Is RequestContextListener registered?");
  }
  return request;
}
origin: oblac/jodd

/**
 * Calls destroy methods on given BeanData. Destroy methods are called
 * without any order.
 */
public void callDestroyMethods() {
  for (final DestroyMethodPoint destroyMethodPoint : beanDefinition.destroyMethodPoints()) {
    try {
      destroyMethodPoint.method.invoke(bean);
    } catch (Exception ex) {
      throw new PetiteException("Invalid destroy method: " + destroyMethodPoint.method, ex);
    }
  }
}
origin: oblac/jodd

/**
 * Returns petite bean property value.
 */
public Object getBeanProperty(final String name) {
  int ndx = name.indexOf('.');
  if (ndx == -1) {
    throw new PetiteException("Only bean name is specified, missing property name: " + name);
  }
  String beanName = name.substring(0, ndx);
  Object bean = getBean(beanName);
  if (bean == null) {
    throw new PetiteException("Bean doesn't exist: " + name);
  }
  try {
    return BeanUtil.declared.getProperty(bean, name.substring(ndx + 1));
  } catch (Exception ex) {
    throw new PetiteException("Invalid bean property: " + name, ex);
  }
}
origin: oblac/jodd

/**
 * Invokes init methods.
 */
public void invokeInitMethods(final InitMethodInvocationStrategy invocationStrategy) {
  for (final InitMethodPoint initMethod : beanDefinition.initMethodPoints()) {
    if (invocationStrategy != initMethod.invocationStrategy) {
      continue;
    }
    try {
      initMethod.method.invoke(bean);
    } catch (Exception ex) {
      throw new PetiteException("Invalid init method: " + initMethod, ex);
    }
  }
}
origin: oblac/jodd

@SuppressWarnings({"unchecked"})
protected Class<T> resolveSetType(final PropertyDescriptor propertyDescriptor) {
  Class<T> type = (Class<T>) propertyDescriptor.getType();
  if (ClassUtil.isTypeOf(type, Collection.class)) {
    return type;
  }
  throw new PetiteException("Unsupported Petite set type: " + type.getName());
}
origin: oblac/jodd

/**
 * Resolves and registers scope from a scope type.
 */
@SuppressWarnings("unchecked")
public <S extends Scope> S resolveScope(final Class<S> scopeType) {
  S scope = (S) scopes.get(scopeType);
  if (scope == null) {
    try {
      scope = newInternalInstance(scopeType, (PetiteContainer) this);
    } catch (Exception ex) {
      throw new PetiteException("Invalid Petite scope: " + scopeType.getName(), ex);
    }
    registerScope(scopeType, scope);
    scopes.put(scopeType, scope);
  }
  return scope;
}
origin: oblac/jodd

/**
 * Registers static method provider.
 *
 * @param providerName provider name
 * @param type class type
 * @param staticMethodName static method name
 * @param arguments method argument types
 */
public void registerPetiteProvider(final String providerName, final Class type, final String staticMethodName, final Class[] arguments) {
  ClassDescriptor cd = ClassIntrospector.get().lookup(type);
  MethodDescriptor md = cd.getMethodDescriptor(staticMethodName, arguments, true);
  if (md == null) {
    throw new PetiteException("Provider method not found: " + staticMethodName);
  }
  ProviderDefinition providerDefinition = new ProviderDefinition(providerName, md.getMethod());
  providers.put(providerName, providerDefinition);
}
origin: oblac/jodd

public SetInjectionPoint(final PropertyDescriptor propertyDescriptor) {
  Objects.requireNonNull(propertyDescriptor);
  this.propertyDescriptor = propertyDescriptor;
  this.type = resolveSetType(propertyDescriptor);
  // resolve component type
  Class targetClass = null;
  MethodDescriptor writeMethodDescriptor = propertyDescriptor.getWriteMethodDescriptor();
  FieldDescriptor fieldDescriptor = propertyDescriptor.getFieldDescriptor();
  if (writeMethodDescriptor != null) {
    targetClass = writeMethodDescriptor.getSetterRawComponentType();
  }
  if (targetClass == null && fieldDescriptor != null) {
    targetClass = fieldDescriptor.getRawComponentType();
  }
  this.targetClass = targetClass;
  if (targetClass == null) {
    throw new PetiteException("Unknown Petite set component type " +
        type.getSimpleName() + '.' + propertyDescriptor.getName());
  }
}
origin: oblac/jodd

/**
 * Takes given parameters references and returns reference set for given method or constructor.
 */
public BeanReferences[] resolveReferenceFromValues(final Executable methodOrCtor, final String... parameterReferences) {
  BeanReferences[] references = convertRefToReferences(parameterReferences);
  if (references == null || references.length == 0) {
    references = buildDefaultReferences(methodOrCtor);
  }
  if (methodOrCtor.getParameterTypes().length != references.length) {
    throw new PetiteException("Different number of method parameters and references for: " +
      methodOrCtor.getDeclaringClass().getName() + '#' + methodOrCtor.getName());
  }
  removeAllDuplicateNames(references);
  return references;
}
origin: oblac/jodd

private BeanReferences[] updateReferencesWithDefaultsIfNeeded(final Executable methodOrCtor, BeanReferences[] references) {
  BeanReferences[] defaultReferences = buildDefaultReferences(methodOrCtor);
  if (references == null || references.length == 0) {
    references = defaultReferences;
  }
  if (methodOrCtor.getParameterTypes().length != references.length) {
    throw new PetiteException(
      "Different number of parameters and references for: " + methodOrCtor.getName());
  }
  // apply default parameters
  for (int i = 0; i < references.length; i++) {
    BeanReferences parameterReferences = references[i];
    if (parameterReferenceIsNotSet(parameterReferences)) {
      references[i] = defaultReferences[i];
    }
  }
  return references;
}
origin: oblac/jodd

/**
 * Registers set injection point.
 *
 * @param beanName bean name
 * @param property set property name
 */
public void registerPetiteSetInjectionPoint(final String beanName, final String property) {
  BeanDefinition beanDefinition = lookupExistingBeanDefinition(beanName);
  ClassDescriptor cd = ClassIntrospector.get().lookup(beanDefinition.type);
  PropertyDescriptor propertyDescriptor = cd.getPropertyDescriptor(property, true);
  if (propertyDescriptor == null) {
    throw new PetiteException("Property not found: " + beanDefinition.type.getName() + '#' + property);
  }
  SetInjectionPoint sip = new SetInjectionPoint(propertyDescriptor);
  beanDefinition.addSetInjectionPoint(sip);
}
origin: oblac/jodd

/**
 * Configures {@link jodd.petite.PetiteContainer} with specified class path.
 */
public void configure() {
  long elapsed = System.currentTimeMillis();
  final ClassScanner classScanner = new ClassScanner();
  classScanner.detectEntriesMode(true);
  classScanner.scanDefaultClasspath();
  classScannerConsumers.accept(classScanner);
  registerAsConsumer(classScanner);
  try {
    classScanner.start();
  } catch (Exception ex) {
    throw new PetiteException("Scan classpath error", ex);
  }
  elapsed = System.currentTimeMillis() - elapsed;
  log.info("Petite configured in " + elapsed + " ms. Total beans: " + container.beansCount());
}
origin: oblac/jodd

/**
 * Registers property injection point.
 *
 * @param beanName bean name
 * @param property property name
 * @param reference explicit injection reference, may be <code>null</code>
 */
public void registerPetitePropertyInjectionPoint(final String beanName, final String property, final String reference) {
  BeanDefinition beanDefinition = lookupExistingBeanDefinition(beanName);
  ClassDescriptor cd = ClassIntrospector.get().lookup(beanDefinition.type);
  PropertyDescriptor propertyDescriptor = cd.getPropertyDescriptor(property, true);
  if (propertyDescriptor == null) {
    throw new PetiteException("Property not found: " + beanDefinition.type.getName() + '#' + property);
  }
  BeanReferences ref = referencesResolver.resolveReferenceFromValue(propertyDescriptor, reference);
  PropertyInjectionPoint pip = new PropertyInjectionPoint(propertyDescriptor, ref);
  beanDefinition.addPropertyInjectionPoint(pip);
}
jodd.petitePetiteException<init>

Popular methods of PetiteException

    Popular in Java

    • Reading from database using SQL prepared statement
    • getSupportFragmentManager (FragmentActivity)
    • scheduleAtFixedRate (ScheduledExecutorService)
    • addToBackStack (FragmentTransaction)
    • ObjectMapper (com.fasterxml.jackson.databind)
      ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
    • Table (com.google.common.collect)
      A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
    • OutputStream (java.io)
      A writable sink for bytes.Most clients will use output streams that write data to the file system (
    • Collections (java.util)
      This class consists exclusively of static methods that operate on or return collections. It contains
    • SSLHandshakeException (javax.net.ssl)
      The exception that is thrown when a handshake could not be completed successfully.
    • Reflections (org.reflections)
      Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
    • Github Copilot alternatives
    Tabnine Logo
    • Products

      Search for Java codeSearch for JavaScript code
    • IDE Plugins

      IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
    • Company

      About UsContact UsCareers
    • Resources

      FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
    Get Tabnine for your IDE now