Package org.codehaus.aspectwerkz.exception

Examples of org.codehaus.aspectwerkz.exception.DefinitionException


     * @param name the name of the parameter
     * @return the value of the parameter
     */
    public String getParameter(final String name) {
        if (!m_parameters.containsKey(name)) {
            throw new DefinitionException("parameter to advice not specified: " + name);
        }
        return (String)m_parameters.get(name);
    }
View Full Code Here


        // check compatibility
        IntroductionDefinition def = m_prototype.getIntroductionDefinition();
        for (Iterator intfs = def.getInterfaceClassNames().iterator(); intfs.hasNext();) {
            if (!findInterfaceInHierarchy(newImplementationClass, (String)intfs.next())) {
                throw new DefinitionException("new implementation class is not compatible");
            }
        }

        synchronized (this) {
            try {
View Full Code Here

            Class klass = ContextClassLoader.loadClass(ASPECT_CONTAINER_IMPLEMENTATION_CLASS);
            Constructor constructor = klass.getConstructor(new Class[]{CrossCuttingInfo.class});
            return (AspectContainer)constructor.newInstance(new Object[]{crossCuttingInfo});
        }
        catch (NoSuchMethodException e) {
            throw new DefinitionException("aspect container does not have a valid constructor [" + ASPECT_CONTAINER_IMPLEMENTATION_CLASS + "] (one that takes a CrossCuttingInfo instance as its only parameter)");
        }
        catch (Exception e) {
            StringBuffer cause = new StringBuffer();
            cause.append("could not create aspect container using the implementation specified [");
            cause.append(ASPECT_CONTAINER_IMPLEMENTATION_CLASS);
            cause.append("] due to: ");
            cause.append(e.toString());
            throw new DefinitionException(cause.toString());
        }
    }
View Full Code Here

                AspectDefinition aspectDef = (AspectDefinition)it.next();
                registerAspect(uuid, aspectDef, definition.getParameters(aspectDef.getName()));
            }
        }
        catch (NullPointerException e) {
            throw new DefinitionException("aspects not properly defined");
        }
        catch (Exception e) {
            throw new WrappedRuntimeException(e);
        }
    }
View Full Code Here

        final SystemDefinition definition = new SystemDefinition();

        String uuid = systemElement.attributeValue("id");
        if (uuid == null || uuid.equals("")) {
            throw new DefinitionException("system UUID must be specified");
        }
        definition.setUuid(uuid);

        // parse the include, exclude and prepare elements
        parseIncludePackageElements(systemElement, definition, basePackage);
View Full Code Here

                Class mixin = null;
                try {
                    mixin = aspectClass.getClassLoader().loadClass(packageName + klass);
                }
                catch (ClassNotFoundException e) {
                    throw new DefinitionException(
                            "could not find mixin implementation: "
                            + packageName + klass + " " + e.getMessage()
                    );
                }
View Full Code Here

            );
            final AspectContainer container = (AspectContainer) constructor.newInstance(new Object[]{aspectContext});
            aspectContext.setContainer(container);
            return container;
        } catch (InvocationTargetException e) {
            throw new DefinitionException(e.getTargetException().toString());
        } catch (NoSuchMethodException e) {
            throw new DefinitionException(
                    "aspect container does not have a valid constructor ["
                    + containerClassName
                    + "] need to take an AspectContext instance as its only parameter: "
                    + e.toString()
            );
        } catch (Throwable e) {
            StringBuffer cause = new StringBuffer();
            cause.append("could not create aspect container using the implementation specified [");
            cause.append(containerClassName);
            cause.append("] due to: ");
            cause.append(e.toString());
            e.printStackTrace();
            throw new DefinitionException(cause.toString());
        }
    }
View Full Code Here

                    break;
                }
            }
        }
        if (mixinDefinition == null) {
            throw new DefinitionException("could not find definition for mixin: " + mixinClass.getName()
                        + " (loader " + mixinClass.getClassLoader() + ")"
                        + " from loader " + mixinCalledFromLoader);
        }

        String factoryClassName = mixinDefinition.getFactoryClassName();
        try {
            Class containerClass;
            if (factoryClassName == null) {
                containerClass = ContextClassLoader.loadClass(mixinClass.getClassLoader(), DEFAULT_MIXIN_FACTORY);
            } else {
                containerClass = ContextClassLoader.loadClass(mixinClass.getClassLoader(), factoryClassName);
            }
            Constructor constructor = containerClass.getConstructor(new Class[]{Class.class, DeploymentModel.class});
            final MixinFactory factory = (MixinFactory) constructor.newInstance(
                    new Object[]{mixinClass, mixinDefinition.getDeploymentModel()}
            );
            return factory;
        } catch (InvocationTargetException e) {
            throw new DefinitionException(e.getTargetException().toString());
        } catch (NoSuchMethodException e) {
            throw new DefinitionException(
                    "mixin factory does not have a valid constructor ["
                    + factoryClassName
                    + "] need to have a signature like this [MyMixinFactory(Class mixin, DeploymentModel scope)]: "
                    + e.toString()
            );
        } catch (Throwable e) {
            StringBuffer cause = new StringBuffer();
            cause.append("could not create mixin container using the implementation specified [");
            cause.append(factoryClassName);
            cause.append("] due to: ");
            cause.append(e.toString());
            throw new DefinitionException(cause.toString());
        }
    }
View Full Code Here

        }

        // check that around advice return Object else the compiler will fail
        if (adviceType.equals(AdviceType.AROUND)) {
            if (!"java.lang.Object".equals(methodInfo.getReturnType().getName())) {
                throw new DefinitionException(
                        "around advice must return java.lang.Object : " + aspectClassName + "." + methodInfo.getName()
                );
            }
        }
View Full Code Here

    private static SystemDefinition parseSystemElement(final ClassLoader loader,
                                                       final Element systemElement,
                                                       final String basePackage) {
        String uuid = systemElement.attributeValue("id");
        if ((uuid == null) || uuid.equals("")) {
            throw new DefinitionException("system UUID must be specified");
        }
        final SystemDefinition definition = new SystemDefinition(uuid);

        // parse the global pointcuts
        List globalPointcuts = parseGlobalPointcuts(systemElement);
View Full Code Here

TOP

Related Classes of org.codehaus.aspectwerkz.exception.DefinitionException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.