Examples of Calculator


Examples of org.hsqldb.cmdline.sqltool.Calculator

            throw new BadSpecial(SqltoolRB.math_expr_fail.getString(re));
        }
        mathMatcher = mathPattern.matcher(dereffed);
        if (mathMatcher.matches()) try {
            shared.userVars.put(mathMatcher.group(1), Long.toString(
                    new Calculator(((mathMatcher.groupCount() > 1
                    && mathMatcher.group(2) != null) ? mathMatcher.group(2)
                    : ""), shared.userVars).reduce(0, false)));
            // No updateUserSettings since can't modify *System vars
            sqlExpandMode = null;
            return;
View Full Code Here

Examples of org.jboss.ejb3.test.proxy.impl.ejbthree1868.Calculator

      {IsLocalProxyFactoryInterceptor.singleton, new NotToBeInvokedInterceptor()};
      PojiProxy handler = new PojiProxy(KEY, null, interceptors);
      Class<?>[] interfaces = new Class<?>[]
      {Calculator.class};
      // create the proxy
      Calculator calculator = (Calculator) Proxy.newProxyInstance(interfaces[0].getClassLoader(), interfaces, handler);
      // register with dispatcher too, since the IsLocalProxyFactoryInterceptor
      // looks for the key in the dispatcher
      Dispatcher.singleton.registerTarget(KEY, new CalculatorImpl());

      try
      {
         int result = calculator.add(1, 2);
         logger.info("Successfully invoked method. Result = " + result);
         Assert.assertEquals("Incorrect result from calculator", result, 3);
      }
      catch (IllegalInvocationException iie)
      {
View Full Code Here

Examples of org.jboss.tutorial.jndibinding.bean.Calculator

public class Client
{
   public static void main(String[] args) throws Exception
   {
      InitialContext ctx = new InitialContext();
      Calculator calculator = (Calculator) ctx.lookup("Calculator");

      System.out.println("1 + 1 = " + calculator.add(1, 1));
      System.out.println("1 - 1 = " + calculator.subtract(1, 1));
     
      // now let's use the customer bean to ensure that the entity manager is bound
      // to jndi
      CustomerManager customerManager = (CustomerManager) ctx.lookup("CustomerManager");
      long id = customerManager.createCustomer("Jaikiran");
View Full Code Here

Examples of org.jboss.tutorial.security.bean.Calculator

      SecurityClient securityClient = SecurityClientFactory.getSecurityClient();
      securityClient.setSimple("kabir", "invalidpassword");
      securityClient.login();

      InitialContext ctx = new InitialContext();
      Calculator calculator = (Calculator) ctx.lookup("CalculatorBean/remote");

      System.out.println("Kabir is a student.");
      System.out.println("Kabir types in the wrong password");
      try
      {
         System.out.println("1 + 1 = " + calculator.add(1, 1));
      }
      catch (EJBAccessException ex)
      {
         System.out.println("Saw expected SecurityException: " + ex.getMessage());
      }

      System.out.println("Kabir types in correct password.");
      System.out.println("Kabir does unchecked addition.");

      // Re-establish the proxy with the correct security identity
      securityClient.logout();
      securityClient.setSimple("kabir", "validpassword");
      securityClient.login();

      calculator = (Calculator) ctx.lookup("CalculatorBean/remote");

      System.out.println("1 + 1 = " + calculator.add(1, 1));

      System.out.println("Kabir is not a teacher so he cannot do division");
      try
      {
         calculator.divide(16, 4);
      }
      catch (javax.ejb.EJBAccessException ex)
      {
         System.out.println(ex.getMessage());
      }

      System.out.println("Students are allowed to do subtraction");
      System.out.println("1 - 1 = " + calculator.subtract(1, 1));
   }
View Full Code Here

Examples of org.jboss.tutorial.ssl.bean.Calculator

      securityClient.setSimple("kabir","invalidpassword");
      securityClient.login();
     
      InitialContext ctx = new InitialContext();
      // let's use the bean whose proxy communicates via ssl
      Calculator sslCalculator = (Calculator) ctx.lookup("CalculatorBean/remote");
      System.out.println("Invoking bean methods on a proxy through sslsocket");
      System.out.println("Kabir is a student.");
      System.out.println("Kabir types in the wrong password");
      try
      {
         System.out.println("1 + 1 = " + sslCalculator.add(1, 1));
         throw new RuntimeException("ERROR - User with incorrect password allowed to operate on bean");
      }
      catch (EJBAccessException ex)
      {
         System.out.println("Saw expected SecurityException: " + ex.getMessage());
      }

      System.out.println("Kabir types in correct password.");
      System.out.println("Kabir does unchecked addition.");

      // Re-establish the proxy with the correct security identity
      securityClient.logout();
      securityClient.setSimple("kabir", "validpassword");
      securityClient.login();
     

      System.out.println("1 + 1 = " + sslCalculator.add(1, 1));

      System.out.println("Kabir is not a teacher so he cannot do division");
      try
      {
         sslCalculator.divide(16, 4);
         throw new RuntimeException("ERROR - User with insufficient role was allowed to operate on bean");
      }
      catch (EJBAccessException  ex)
      {
         System.out.println("Caught expected EJBAccessException : " + ex.getMessage());
      }

      System.out.println("Kabir is a student, and students are allowed to do subtraction");
      System.out.println("1 - 1 = " + sslCalculator.subtract(1, 1));
     
      // Now let's use the bean whose proxy communicates via normal socket: protocol
      Calculator normalCalculator = (Calculator) ctx.lookup("CalculatorNormal");
      // do some operation
      System.out.println("Invoking bean methods on a proxy through normal socket");
      System.out.println("Kabir is a student. So he can do addition");
      System.out.println("2 + 2 = " + normalCalculator.add(2, 2));
   }
View Full Code Here

Examples of org.jboss.tutorial.stateless.bean.Calculator

public class Client
{
   public static void main(String[] args) throws Exception
   {
      InitialContext ctx = new InitialContext();
      Calculator calculator = (Calculator) ctx.lookup("CalculatorBean/remote");

      System.out.println("1 + 1 = " + calculator.add(1, 1));
      System.out.println("1 - 1 = " + calculator.subtract(1, 1));
   }
View Full Code Here

Examples of org.jboss.tutorial.stateless_deployment_descriptor.bean.Calculator

public class Client
{
   public static void main(String[] args) throws Exception
   {
      InitialContext ctx = new InitialContext();
      Calculator calculator = (Calculator) ctx.lookup(CalculatorRemote.class.getName());

      System.out.println("1 + 1 = " + calculator.add(1, 1));
      System.out.println("1 - 1 = " + calculator.subtract(1, 1));
   }
View Full Code Here

Examples of org.jboss.tutorial.webservice.bean.Calculator

      QName qname = new QName("http://bean.webservice.tutorial.jboss.org/", "CalculatorBeanService");

      ServiceFactory factory = ServiceFactory.newInstance();
      Service service = factory.createService(url, qname);

      Calculator calculator = (Calculator) service.getPort(Calculator.class);

      System.out.println("1 + 1 = " + calculator.add(1, 1));
      System.out.println("1 - 1 = " + calculator.subtract(1, 1));
   }
View Full Code Here

Examples of org.lealone.expression.Calculator

        int columnCount = expressions.size();
        if (select.expressions.size() == columnCount)
            return result;
        LocalResult lr = new LocalResult(session, expressionArray, columnCount);

        Calculator calculator;
        int index = 0;
        while (result.next()) {
            calculator = new Calculator(result.currentRow());
            for (int i = 0; i < columnCount; i++) {
                Expression expr = expressions.get(i);
                index = calculator.getIndex();
                expr.calculate(calculator);
                if (calculator.getIndex() == index) {
                    calculator.addResultValue(calculator.getValue(index));
                    calculator.addIndex();
                }
            }

            lr.addRow(calculator.getResult().toArray(new Value[0]));
        }

        return lr;
    }
View Full Code Here

Examples of org.springframework.scripting.Calculator

    ApplicationContext ctx = new ClassPathXmlApplicationContext("groovyContext.xml", getClass());

    assertTrue(Arrays.asList(ctx.getBeanNamesForType(Calculator.class)).contains("calculator"));
    assertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.class)).contains("messenger"));

    Calculator calc = (Calculator) ctx.getBean("calculator");
    Messenger messenger = (Messenger) ctx.getBean("messenger");

    assertFalse("Shouldn't get proxy when refresh is disabled", AopUtils.isAopProxy(calc));
    assertFalse("Shouldn't get proxy when refresh is disabled", AopUtils.isAopProxy(messenger));

    assertFalse("Scripted object should not be instance of Refreshable", calc instanceof Refreshable);
    assertFalse("Scripted object should not be instance of Refreshable", messenger instanceof Refreshable);

    assertEquals(calc, calc);
    assertEquals(messenger, messenger);
    assertTrue(!messenger.equals(calc));
    assertTrue(messenger.hashCode() != calc.hashCode());
    assertTrue(!messenger.toString().equals(calc.toString()));

    String desiredMessage = "Hello World!";
    assertEquals("Message is incorrect", desiredMessage, messenger.getMessage());

    assertTrue(ctx.getBeansOfType(Calculator.class).values().contains(calc));
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.