Package com.sun.jini.start

Examples of com.sun.jini.start.NonActivatableServiceDescriptor


     *
     * @param d the descriptor
     */
    private void checkDescriptor(ServiceDescriptor d) {
  String policy;
  NonActivatableServiceDescriptor nad = null;
  SharedActivationGroupDescriptor gd = null;
  String source = null;
  if (d instanceof SharedActivationGroupDescriptor) {
      gd = (SharedActivationGroupDescriptor) d;
      policy = gd.getPolicy();
      source = getString("for",
            policy,
            "SharedActivationGroupDescriptor");
  } else {
      nad = (NonActivatableServiceDescriptor) d;
            gd = envCheck.getGroupDescriptor();
      policy = nad.getPolicy();
      source = getString("for",
             policy,
             nad.getImplClassName());
  }
  if (!policyAccessible(policy, source)) {
      return;
  }
  Object o = envCheck.launch(nad, gd, taskName("AllPermissionsTask"));
View Full Code Here


  };
    private static ProxyPreparer pp = new BasicProxyPreparer();

    public void run() throws Exception {

        NonActivatableServiceDescriptor nasdWithExtras =
            new NonActivatableServiceDescriptor(
                "http://resendes:8080/mercury-dl.jar",
                "http://resendes:8086/policy.mercury",
                "http://resendes:8080/mercury.jar",
                "com.sun.jini.mercury.TransientMercuryBogusImpl",
                new String[] {
        "http://resendes:8089/mercury_service_trans.config"
    },
                lc,
                pp);
               
        NonActivatableServiceDescriptor nasdWithoutExtras =
            new NonActivatableServiceDescriptor(
                "http://resendes:8080/mercury-dl.jar",
                "http://resendes:8086/policy.mercury",
                "http://resendes:8080/mercury.jar",
                "com.sun.jini.mercury.TransientMercuryBogusImpl",
                new String[] {
        "http://resendes:8089/mercury_service_trans.config"
    });
        LifeCycle DefaultLifeCycle = nasdWithoutExtras.getLifeCycle();
        ProxyPreparer DefaultPreparer = nasdWithoutExtras.getServicePreparer();
       
  String sharedVmLog = "/tmp/sharedvm.log";
        String[] sharedvm_props = new String[] {// server properties
        "com.sun.jini.start.activatewrapper.debug", "init",
          };
        SharedActivationGroupDescriptor sharedvm =
            new SharedActivationGroupDescriptor(
          "/view/resendes/vob/jive/policy/policy.sharedvm",
          "/view/resendes/vob/jive/lib/bogus_sharedvm.jar",
          sharedVmLog,
              "/bin/java", //server command
          new String[] {// server options
        "-ea",
    },
          sharedvm_props);

        SharedActivatableServiceDescriptor sasd =
            new SharedActivatableServiceDescriptor(
          "http://resendes:8080/mercury-dl.jar",
          "http://resendes:8086/policy.mercury",
          "http://resendes:8080/mercury.jar",
          "com.sun.jini.mercury.MailboxBogusImpl",
          sharedVmLog,
          new String[] {
        "http://resendes:8089/mercury_service_act.config"
    },
          true);

        SharedActivatableServiceDescriptor sasdWithExtras =
            new SharedActivatableServiceDescriptor(
          "http://resendes:8080/mercury-dl.jar",
          "http://resendes:8086/policy.mercury",
          "http://resendes:8080/mercury.jar",
          "com.sun.jini.mercury.MailboxBogusImpl",
          sharedVmLog,
          new String[] {
        "http://resendes:8089/mercury_service_act.config"
    },
                pp,
                pp,
          true,
                "localhost",
                1234);
               
        ServiceDescriptor[] serviceDescriptors =
      new ServiceDescriptor[] {
    // sasdWithExtras & nasdWithExtras not written because
                // default/recovered preparer and lifecycle objects won't match.
                nasdWithoutExtras,
    sharedvm,
    sasd
      };

        // Serialize service descriptors to a file
  FileOutputStream f = new FileOutputStream("tmp");   
  ObjectOutput oos = new ObjectOutputStream(f);   
  oos.writeObject(nasdWithExtras);   
         oos.writeObject(nasdWithoutExtras);   
  oos.writeObject(sharedvm);   
  oos.writeObject(sasd);   
  oos.writeObject(sasdWithExtras);   
        oos.writeObject(serviceDescriptors);   
  oos.flush();
  oos.close();
        logger.log(Level.INFO, "Wrote: " + nasdWithExtras);
        logger.log(Level.INFO, "Wrote: " + nasdWithoutExtras);       
        logger.log(Level.INFO, "Wrote: " + sharedvm);
        logger.log(Level.INFO, "Wrote: " + sasd);
        logger.log(Level.INFO, "Wrote: " + sasdWithExtras);
        logger.log(Level.INFO, "Wrote: " + Arrays.asList(serviceDescriptors));

        // Deserialize objects from a file.   
  FileInputStream in = new FileInputStream("tmp");   
  ObjectInputStream ois = new ObjectInputStream(in);   
  NonActivatableServiceDescriptor nasdWithExtras_r =
      (NonActivatableServiceDescriptor)ois.readObject();
  nasdWithExtras_r.setLifeCycle(lc);
        nasdWithExtras_r.setServicePreparer(pp);
  NonActivatableServiceDescriptor nasdWithoutExtras_r =
      (NonActivatableServiceDescriptor)ois.readObject();       
  SharedActivationGroupDescriptor sharedvm_r =
      (SharedActivationGroupDescriptor)ois.readObject();
  SharedActivatableServiceDescriptor sasd_r =
      (SharedActivatableServiceDescriptor)ois.readObject();
  SharedActivatableServiceDescriptor sasdWithExtras_r =
      (SharedActivatableServiceDescriptor)ois.readObject();
  //sasdWithExtras_r.setLifeCycle(lc);
        sasdWithExtras_r.setServicePreparer(pp);
        sasdWithExtras_r.setInnerProxyPreparer(pp);
  ServiceDescriptor[] recovered =
            (ServiceDescriptor[])ois.readObject();
  ois.close();
 
        logger.log(Level.INFO, "Read: " + nasdWithExtras_r);
        logger.log(Level.INFO, "Read: " + nasdWithoutExtras_r);
        logger.log(Level.INFO, "Read: " + sharedvm_r);
        logger.log(Level.INFO, "Read: " + sasd_r);
        logger.log(Level.INFO, "Read: " + sasdWithExtras_r);
        logger.log(Level.INFO, "Read: " + Arrays.asList(recovered));

  if (!verifyNonActivatableServiceDescriptors(nasdWithExtras, nasdWithExtras_r)) {
      throw new TestException(
          "Written and recovered NonActivatableServiceDescriptors don't match");
  }
  if (!verifyNonActivatableServiceDescriptors(nasdWithoutExtras, nasdWithoutExtras_r)) {
      throw new TestException(
          "Written and recovered NonActivatableServiceDescriptors don't match");
  }
        if (!verifySharedActivationGroupDescriptors(sharedvm, sharedvm_r)) {
      throw new TestException(
          "Written and recovered SharedActivationGroupDescriptors don't match");
  }
  if (!verifySharedActivatableServiceDescriptors(sasd, sasd_r)) {
      throw new TestException(
          "Written and recovered SharedActivatableServiceDescriptors don't match");
  }
  if (!verifySharedActivatableServiceDescriptors(sasdWithExtras, sasdWithExtras_r)) {
      throw new TestException(
          "Written and recovered SharedActivatableServiceDescriptors don't match");
  }
  if (!verifyServiceDescriptors(serviceDescriptors, recovered)) {
      throw new TestException(
          "Written and recovered ServiceDescriptor[] don't match");
  }
 
  //Do some negative tests - Ensure bad descriptor doesn't match
        NonActivatableServiceDescriptor bogus_nasd =
            new NonActivatableServiceDescriptor(
                nasdWithoutExtras.getExportCodebase(),
                nasdWithoutExtras.getPolicy(),
                nasdWithoutExtras.getImportCodebase(),
                nasdWithoutExtras.getImplClassName() + "_bogus",
                nasdWithoutExtras.getServerConfigArgs(),
View Full Code Here

        (SharedActivatableServiceDescriptor)read[i];
    if (!verifySharedActivatableServiceDescriptors(sasdw, sasdr)) {
        return false;
    }
      } else if (wrote[i] instanceof NonActivatableServiceDescriptor) {
          NonActivatableServiceDescriptor nasdw =
        (NonActivatableServiceDescriptor)wrote[i];
          NonActivatableServiceDescriptor nasdr =
        (NonActivatableServiceDescriptor)read[i];
    if (!verifyNonActivatableServiceDescriptors(nasdw, nasdr)) {
        return false;
    }
      } else if (wrote[i] instanceof SharedActivationGroupDescriptor) {
View Full Code Here

       
   for (int i=0; i < goodArgsList.length; i++) {
      try {
             logger.log(Level.FINEST, "Trying good args: {0}",
        Arrays.asList(goodArgsList[i]));
    NonActivatableServiceDescriptor tsd =
        (NonActivatableServiceDescriptor)
      cons.newInstance(goodArgsList[i]);
    if (!checkMainArgs(goodArgsList[i], tsd)) {
                    throw new TestException(
                    "Failed -- check args");
    }
    if (!checkLifeCycle((LifeCycle)goodArgsList[i][5], tsd)) {
                    throw new TestException(
                    "Failed -- check LifeCycle");
    }                     
    if (!checkPreparer((ProxyPreparer)goodArgsList[i][6], tsd)) {
                    throw new TestException(
                    "Failed -- check ProxyPreparer");
    }                                 
            } catch (Exception e) {
    e.printStackTrace();
                throw new TestException(
                    "Failed -- failed good args: ["
        + i + "] " + e);
      }
  }
       
       // Excercise alternate constructor       
        consArgs = new Class[] {
      String.class, String.class, String.class, String.class,
      String[].class, LifeCycle.class};
  cons =
            NonActivatableServiceDescriptor.class.getConstructor(consArgs);

        logger.log(Level.FINEST,
            "Trying constructor that takes the following args: {0}",
            Arrays.asList(consArgs));
        //Test bad args
        ArrayList list = new ArrayList();
  for (int i=0; i < badArgsList.length; i++) {
      try {
                list.clear();
                list.add(0, badArgsList[i][0]);
                list.add(1, badArgsList[i][1]);
                list.add(2, badArgsList[i][2]);
                list.add(3, badArgsList[i][3]);
                list.add(4, badArgsList[i][4]);
                list.add(5, badArgsList[i][5]);
             logger.log(Level.FINEST, "Trying bad args: {0}", list);
    cons.newInstance(list.toArray());
                throw new TestException(
                    "Failed -- took bad args: " + i);
      } catch (java.lang.reflect.InvocationTargetException e) {
    Throwable t = e.getCause();
    if (t instanceof NullPointerException) {
        logger.log(Level.FINEST,
            "Got expected NullPointerException", t);
    } else {
        logger.log(Level.FINEST,
      "Got unexpected Exception", t);
        throw e;
    }
      }
  }
   for (int i=0; i < goodArgsList.length; i++) {
      try {
                list.clear();
                list.add(0, goodArgsList[i][0]);
                list.add(1, goodArgsList[i][1]);
                list.add(2, goodArgsList[i][2]);
                list.add(3, goodArgsList[i][3]);
                list.add(4, goodArgsList[i][4]);
                list.add(5, goodArgsList[i][5]);
                logger.log(Level.FINEST, "Trying good args: {0}", list);
                Object[] args = list.toArray();
    NonActivatableServiceDescriptor tsd =
        (NonActivatableServiceDescriptor)
      cons.newInstance(args);
    if (!checkMainArgs(args, tsd)) {
                    throw new TestException(
                    "Failed -- check args");
    }
    if (!checkLifeCycle((LifeCycle)args[5], tsd)) {
                    throw new TestException(
                    "Failed -- check args");
    }               
      } catch (Exception e) {
    e.printStackTrace();
                throw new TestException(
                    "Failed -- failed good args: ["
        + i + "] " + e);
      }
  }       
      // Excercise another alternate constructor       
        consArgs = new Class[] {
      String.class, String.class, String.class, String.class,
      String[].class, ProxyPreparer.class};
  cons =
            NonActivatableServiceDescriptor.class.getConstructor(consArgs);
       
        logger.log(Level.FINEST,
            "Trying constructor that takes the following args: {0}",
            Arrays.asList(consArgs));
       //Test bad args
  for (int i=0; i < badArgsList.length; i++) {
      try {
                list.clear();
                list.add(0, badArgsList[i][0]);
                list.add(1, badArgsList[i][1]);
                list.add(2, badArgsList[i][2]);
                list.add(3, badArgsList[i][3]);
                list.add(4, badArgsList[i][4]);
                list.add(5, badArgsList[i][6]);
                logger.log(Level.FINEST, "Trying bad args: {0}", list);
    cons.newInstance(list.toArray());
                throw new TestException(
                    "Failed -- took bad args: " + i);
      } catch (java.lang.reflect.InvocationTargetException e) {
    Throwable t = e.getCause();
    if (t instanceof NullPointerException) {
        logger.log(Level.FINEST,
            "Got expected NullPointerException", t);
    } else {
        logger.log(Level.FINEST,
      "Got unexpected Exception", t);
        throw e;
    }
      }
  }
   for (int i=0; i < goodArgsList.length; i++) {
      try {
                list.clear();
                list.add(0, goodArgsList[i][0]);
                list.add(1, goodArgsList[i][1]);
                list.add(2, goodArgsList[i][2]);
                list.add(3, goodArgsList[i][3]);
                list.add(4, goodArgsList[i][4]);
                list.add(5, goodArgsList[i][6]);
                logger.log(Level.FINEST, "Trying good args: {0}", list);
                Object[] args = list.toArray();
    NonActivatableServiceDescriptor tsd =
        (NonActivatableServiceDescriptor)
      cons.newInstance(args);
    if (!checkMainArgs(args, tsd)) {
                    throw new TestException(
                    "Failed -- check args");
    }
    if (!checkPreparer((ProxyPreparer)args[5], tsd)) {
                    throw new TestException(
                    "Failed -- check ProxyPreparer");
    }                                 
            } catch (Exception e) {
    e.printStackTrace();
                throw new TestException(
                    "Failed -- failed good args: ["
        + i + "] " + e);
      }
  }               
        // Excercise another alternate constructor       
        consArgs = new Class[] {
      String.class, String.class, String.class, String.class,
      String[].class};
  cons =
            NonActivatableServiceDescriptor.class.getConstructor(consArgs);
       
        logger.log(Level.FINEST,
            "Trying constructor that takes the following args: {0}",
            Arrays.asList(consArgs));
       //Test bad args
  for (int i=0; i < badArgsList.length; i++) {
      try {
                list.clear();
                list.add(0, badArgsList[i][0]);
                list.add(1, badArgsList[i][1]);
                list.add(2, badArgsList[i][2]);
                list.add(3, badArgsList[i][3]);
                list.add(4, badArgsList[i][4]);
                logger.log(Level.FINEST, "Trying bad args: {0}", list);
                cons.newInstance(list.toArray());
                throw new TestException(
                    "Failed -- took bad args: " + i);
      } catch (java.lang.reflect.InvocationTargetException e) {
    Throwable t = e.getCause();
    if (t instanceof NullPointerException) {
        logger.log(Level.FINEST,
            "Got expected NullPointerException", t);
    } else {
        logger.log(Level.FINEST,
      "Got unexpected Exception", t);
        throw e;
    }
      }
  }
   for (int i=0; i < goodArgsList.length; i++) {
      try {
                list.clear();
                list.add(0, goodArgsList[i][0]);
                list.add(1, goodArgsList[i][1]);
                list.add(2, goodArgsList[i][2]);
                list.add(3, goodArgsList[i][3]);
                list.add(4, goodArgsList[i][4]);
                logger.log(Level.FINEST, "Trying good args: {0}", list);               
    NonActivatableServiceDescriptor tsd =
        (NonActivatableServiceDescriptor)
      cons.newInstance(list.toArray());
    if (!checkMainArgs(list.toArray(), tsd)) {
                    throw new TestException(
                    "Failed -- check args");
View Full Code Here

  };
    private static ProxyPreparer pp = new BasicProxyPreparer();

    public void run() throws Exception {

        NonActivatableServiceDescriptor nasd =
      new NonActivatableServiceDescriptor(
    cb, p, cp, impl, confArgs, lc, pp);
     logger.log(Level.INFO, "NASD w/ null serverConfigArgs: {0}",
        nasd);
    }
View Full Code Here

      }
        }

  config =
      ServiceStarterCreateBadTransientServiceTest.getServiceConfigFile().toString();
  NonActivatableServiceDescriptor antiNonActMercuryProxy =
            new NonActivatableServiceDescriptor(
    codebase,
                policy,
                classpath,
                trans_impl,
                new String[] { config },
    antiMercuryProxyPreparer);
        try {
            NonActivatableServiceDescriptor.Created created =
                (NonActivatableServiceDescriptor.Created)antiNonActMercuryProxy.create(
        EmptyConfiguration.INSTANCE);
      throw new TestException(
          "Created proxy: " + created.proxy
    + " with a bad trans proxy descriptor: "
    + antiNonActMercuryProxy);
View Full Code Here

      throw new TestException(
        "Service codebase, classpath, "
        + "impl, or policy was null");
  }

  NonActivatableServiceDescriptor badCodebase =
                new NonActivatableServiceDescriptor(
                    codebase.replaceAll("mercury-dl.jar", "mercury-dl_bogus.jar"),
        policy, classpath, impl,
        new String[] { service_config.toString() });
  try {
      Object proxy = badCodebase.create(EmptyConfiguration.INSTANCE);
            throw new TestException(" Created proxy [" + proxy
                    + "] with bad codebase descriptor: " + badCodebase);
        } catch (ClassNotFoundException e) {
            logger.log(Level.INFO, "Expected Failure with bad codebase descriptor: "
        + badCodebase);
            e.printStackTrace();
  }

  NonActivatableServiceDescriptor badPolicy =
                new NonActivatableServiceDescriptor(
                    codebase, policy.replaceAll("policy", "bogus_policy"),
                    classpath, impl, new String[] { service_config.toString() });
           
  try {
      Object proxy = badPolicy.create(EmptyConfiguration.INSTANCE);
      throw new TestException(
       "Failed - Created proxy [" + proxy
                   + "] with bad policy descriptor: " + badPolicy);
        } catch (InvocationTargetException ce) {
            if (verifyInvocationTargetException(ce)) {
                logger.log(Level.INFO,
         "Expected Failure with bad policy descriptor: "
           + badPolicy);
                ce.printStackTrace();
      } else {
                logger.log(Level.INFO,
         "Unexpected InvocationTargetException with "
         + "bad policy descriptor");
          throw new TestException(
        "Unexpected InvocationTargetException with bad policy", ce);
      }
        }

  NonActivatableServiceDescriptor badClasspath =
                new NonActivatableServiceDescriptor(
                    codebase,
                    policy,
                    classpath.replaceAll("mercury", "mercury_bogus"),
                    impl, new String[] { service_config.toString() });
  try {
      Object proxy = badClasspath.create(EmptyConfiguration.INSTANCE);
            throw new TestException( "Failed - Created proxy ["
             + proxy
             + "] with bad classpath descriptor: "
             + badClasspath);
        } catch (ClassNotFoundException e) {
            logger.log(Level.INFO,
           "Expected Failure with bad classpath descriptor: "
           + badClasspath);
            e.printStackTrace();
  }

  NonActivatableServiceDescriptor badImpl =
                new NonActivatableServiceDescriptor(
                    codebase,
                    policy,
                    classpath,
                    impl.replaceAll("Impl", "Impl_bogus"),
                    new String[] { service_config.toString() });
  try {
      Object proxy = badImpl.create(EmptyConfiguration.INSTANCE);
            throw new TestException(
              "Failed - Created proxy [" + proxy
                    + "] with bad implementation descriptor: " + badImpl);
        } catch (ClassNotFoundException e) {
            logger.log(Level.INFO, "Expected Failure with bad implementation descriptor: "
        + badImpl);
            e.printStackTrace();
  }

  NonActivatableServiceDescriptor badConfig =
            new NonActivatableServiceDescriptor(
                    codebase,
                    policy,
                    classpath,
                    impl,
                    new String[] { service_config.getParent() });
  try {
      Object proxy = badConfig.create(EmptyConfiguration.INSTANCE);
            throw new TestException(
              "Failed - Created proxy [" + proxy
                    + "] with bad configuration descriptor: " + badConfig);
        } catch (java.lang.reflect.InvocationTargetException e) {
            logger.log(Level.INFO, "Expected Failure  with bad configuration descriptor: "
View Full Code Here

           String starterConfigName,
           ServiceDescriptorTransformer transformer)
      throws RemoteException
  {
     
      NonActivatableServiceDescriptor desc =
    new NonActivatableServiceDescriptor(codebase,
                policyFile,
                classpath,
                serviceImpl,
                configArgs);
      Configuration starterConfig = null;
      if (starterConfigName != null) {
    try {
        starterConfig =
      ConfigurationProvider.getInstance(
            new String[]{starterConfigName});
    } catch (ConfigurationException e) {
        throw new RemoteException("Starter configuration problem",
                e);
    }
      }
      if (transformer != null) {
    desc = (NonActivatableServiceDescriptor)
           transformer.transform(desc);
      }
      try {
    Created created = (Created) desc.create(starterConfig);
    serviceList.add(created);
    return created.proxy;
      } catch (Exception e) {
    throw new RemoteException("Create failed", e);
      }
View Full Code Here

  } else {
      ServiceDescriptor[] sd = envCheck.getDescriptors();
      SharedActivationGroupDescriptor g = envCheck.getGroupDescriptor();
      for (int i = 0; i < sd.length; i++) {
    if (sd[i] instanceof NonActivatableServiceDescriptor) {
        NonActivatableServiceDescriptor d =
      (NonActivatableServiceDescriptor) sd[i];
        source = getString("desc") + " " + d.getImplClassName();
        codebase = d.getExportCodebase();
        doChecks(d, g, source, codebase);
    }
      }
  }
    }
View Full Code Here

    public void run(EnvCheck envCheck) {
        this.envCheck = envCheck;
  ServiceDescriptor[] d = envCheck.getDescriptors();
  for (int i = 0; i < d.length; i++) {
      if (d[i] instanceof NonActivatableServiceDescriptor) {
    NonActivatableServiceDescriptor serviceDesc =
        (NonActivatableServiceDescriptor) d[i];
    String source = getString("descfor")
                  + " "
                  + serviceDesc.getImplClassName();
    if (checkArgs(serviceDesc, source)) {
        checkServiceConfig(serviceDesc, source);
    }
      }
  }
View Full Code Here

TOP

Related Classes of com.sun.jini.start.NonActivatableServiceDescriptor

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.