Examples of MethodSignature


Examples of org.apache.tapestry5.ioc.services.MethodSignature

        ClassFab cf = newClassFab("ConstructableBean", Object.class);

        cf.addField("_stringValue", String.class);
        cf.addConstructor(new Class[] { String.class }, null, "{ _stringValue = $1; }");

        MethodSignature getStringValue = new MethodSignature(String.class, "getStringValue", null, null);

        cf.addMethod(Modifier.PUBLIC, getStringValue, "return _stringValue;");

        Class targetClass = cf.createClass();
View Full Code Here

Examples of org.apache.tapestry5.ioc.services.MethodSignature

        ClassFab cf = newClassFab("MyIntHolder", AbstractIntWrapper.class);

        cf.addField("_intValue", int.class);
        cf.addConstructor(new Class[] { int.class }, null, "{ _intValue = $1; }");

        cf.addMethod(Modifier.PUBLIC, new MethodSignature(int.class, "getIntValue", null, null), "return _intValue;");

        Class targetClass = cf.createClass();
        Constructor c = targetClass.getConstructors()[0];

        AbstractIntWrapper targetBean = (AbstractIntWrapper) c.newInstance(new Object[] { new Integer(137) });
View Full Code Here

Examples of org.apache.tapestry5.ioc.services.MethodSignature

    {
        ClassFab cf = newClassFab("SimpleService", Object.class);

        cf.addInterface(SimpleService.class);

        cf.addMethod(Modifier.PUBLIC, new MethodSignature(int.class, "add", new Class[] { int.class, int.class }, null),
                     "return $1 + $2;");

        Class targetClass = cf.createClass();

        SimpleService s = (SimpleService) targetClass.newInstance();
View Full Code Here

Examples of org.apache.tapestry5.ioc.services.MethodSignature

        cf.addInterface(Runnable.class);

        try
        {
            cf.addMethod(Modifier.PUBLIC, new MethodSignature(void.class, "run", null, null), "fail;");
        }
        catch (RuntimeException ex)
        {
            assertExceptionSubstring(ex, "Unable to add method void run() to class BadMethodBody:");
        }
View Full Code Here

Examples of org.apache.tapestry5.ioc.services.MethodSignature

    @Test
    public void add_duplicate_method_signature() throws Exception
    {
        ClassFab cf = newClassFab("DupeMethodAdd", Object.class);

        cf.addMethod(Modifier.PUBLIC, new MethodSignature(void.class, "foo", null, null), "{}");

        try
        {
            cf.addMethod(Modifier.PUBLIC, new MethodSignature(void.class, "foo", null, null), "{}");
            unreachable();
        }
        catch (RuntimeException ex)
        {
            assertEquals("Attempt to redefine method void foo() of class DupeMethodAdd.", ex
View Full Code Here

Examples of org.apache.tapestry5.ioc.services.MethodSignature

        cf.addField("_map", Map.class);

        cf.addConstructor(new Class[] { Map.class, Runnable.class },
                          new Class[] { IllegalArgumentException.class, DataFormatException.class }, "{ _map = $1; }");

        MethodSignature sig = new MethodSignature(Map.class, "doTheNasty", new Class[] { int.class, String.class },
                                                  new Class[] { InstantiationException.class,
                                                          IllegalAccessException.class });

        cf.addMethod(Modifier.PUBLIC + Modifier.FINAL + Modifier.SYNCHRONIZED, sig, "{ return _map; }");
View Full Code Here

Examples of org.apache.tapestry5.ioc.services.MethodSignature

    public void add_noop_method() throws Exception
    {
        ClassFab cf = newClassFab("NoOp", Object.class);
        cf.addInterface(Runnable.class);

        cf.addNoOpMethod(new MethodSignature(void.class, "run", null, null));
        cf.addNoOpMethod(new MethodSignature(int.class, "getInt", null, null));
        cf.addNoOpMethod(new MethodSignature(double.class, "getDouble", null, null));

        Class clazz = cf.createClass();

        Runnable instance = (Runnable) clazz.newInstance();
View Full Code Here

Examples of org.apache.tapestry5.ioc.services.MethodSignature

        classFab.addInterface(Serializable.class);

        // This is the "magic" signature that allows an object to substitute some other
        // object for itself.
        MethodSignature writeReplaceSig = new MethodSignature(Object.class, "writeReplace", null, new Class[]
        { ObjectStreamException.class });

        classFab.addMethod(Modifier.PRIVATE, writeReplaceSig, "return token;");

        // Now delegate all the methods.

        String body = format("return (%s) creator.createObject();", serviceInterface.getName());

        MethodSignature sig = new MethodSignature(serviceInterface, "delegate", null, null);

        classFab.addMethod(Modifier.PRIVATE, sig, body);

        classFab.proxyMethodsToDelegate(serviceInterface, "delegate()", description);
View Full Code Here

Examples of org.aspectj.lang.reflect.MethodSignature

    @Before("@annotation(javax.annotation.security.RolesAllowed) || @annotation(javax.annotation.security.PermitAll)")
    public void checkRoles(JoinPoint jp) throws SecurityException {
        if (log.isDebugEnabled()) log.debug("Aspect: SecurityInterceptor [" + this.hashCode() + "] has been fired");
        int permitted = -1;
        try {
            MethodSignature met = (MethodSignature) jp.getSignature();
            permitted = checkPermission(jp.getSourceLocation().getWithinType().getMethod(met.getMethod().getName(), met.getMethod().getParameterTypes()));
            if(permitted == -1) permitted = checkPermission(jp.getSourceLocation().getWithinType());
        } catch (Exception ex) {
            if (log.isDebugEnabled()) log.debug(ex);
        } finally {
            if (log.isDebugEnabled()) log.debug("Aspect: SecurityInterceptor [" + this.hashCode() + "] execution result is " + executionResults[permitted + 1]);
View Full Code Here

Examples of org.aspectj.lang.reflect.MethodSignature

public class LogDebugInterceptor
{
    protected Method getMethod(JoinPoint jp) {
        Method invoked = null;
        try {
            MethodSignature met = (MethodSignature) jp.getSignature();
            invoked = jp.getSourceLocation().getWithinType().getMethod(met.getMethod().getName(), met.getMethod().getParameterTypes());
        } finally {
            return invoked;
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.