当前位置: 首页>>代码示例>>Java>>正文


Java ServiceNotFoundException类代码示例

本文整理汇总了Java中javax.management.ServiceNotFoundException的典型用法代码示例。如果您正苦于以下问题:Java ServiceNotFoundException类的具体用法?Java ServiceNotFoundException怎么用?Java ServiceNotFoundException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ServiceNotFoundException类属于javax.management包,在下文中一共展示了ServiceNotFoundException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkMBeansLoadedSuccessfully

import javax.management.ServiceNotFoundException; //导入依赖的package包/类
private static void checkMBeansLoadedSuccessfully(Set mbeans) throws ServiceNotFoundException
{
   // MLet.getMBeansFromURL returns a Set containing exceptions if an MBean could not be loaded
   boolean allLoaded = true;
   for (Iterator i = mbeans.iterator(); i.hasNext();)
   {
      Object mbean = i.next();
      if (mbean instanceof Throwable)
      {
         ((Throwable)mbean).printStackTrace();
         allLoaded = false;
         // And go on with the next
      }
      else
      {
         // Ok, the MBean was registered successfully
         System.out.println("Registered MBean: " + mbean);
      }
   }

   if (!allLoaded) throw new ServiceNotFoundException("Some MBean could not be loaded");
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:23,代码来源:Main.java

示例2: getServiceInfoByVertx

import javax.management.ServiceNotFoundException; //导入依赖的package包/类
private ServiceInfo getServiceInfoByVertx(Consumer<ServiceInfoResult> consumer, Function<ServiceInfo,Boolean> criteria) {
    // TODO add caching mechanism with TTL to reduce
    vertx.eventBus().send(GlobalKeyHolder.SERVICE_REGISTRY_GET, "xyz", (AsyncResultHandler<Message<byte[]>>) h ->
            {
                if (h.succeeded()) {
                    final List<ServiceInfo> serviceInfos = getServiceInfoFromMessage(h).filter(info -> criteria.apply(info)).collect(Collectors.toList());
                    if(!serviceInfos.isEmpty()){
                        consumer.accept(new ServiceInfoResult(serviceInfos.stream(),h.succeeded(),h.cause()));
                    }else {
                        consumer.accept(new ServiceInfoResult(serviceInfos.stream(),false,new ServiceNotFoundException("selected service not found")));
                    }
                } else {
                    consumer.accept(new ServiceInfoResult(Stream.<ServiceInfo>empty(),h.succeeded(),h.cause()));
                }

            }
    );

    return null;
}
 
开发者ID:amoAHCP,项目名称:vert.x-microservice,代码行数:21,代码来源:ServiceDiscovery.java

示例3: getFormToolkit

import javax.management.ServiceNotFoundException; //导入依赖的package包/类
/**
 * Find in the Service Loader a {@link FormToolkit} that returns the required form instance type of rendered forms
 * 
 * @param implementationClass
 *            The specific implementation class that the form toolkit must return
 * @return The FormToolkit that build form instances of that its specific implementation returns the given class
 * @throws ServiceNotFoundException
 *             When a FormToolkit is not found
 */
@SuppressWarnings("unchecked")
public <S> FormToolkit<S> getFormToolkit(Class<S> implementationClass) throws ServiceNotFoundException {
	Iterator<FormToolkit> it = loader.iterator();
	FormToolkit toolkit = null;
	while (toolkit == null && it.hasNext()) {
		FormToolkit tl = it.next();
		if (implementationClass.isAssignableFrom(tl.getImplementationClass())) {
			toolkit = tl;
		}
	}
	if (toolkit == null) {
		throw new ServiceNotFoundException();
	} else {
		return toolkit;
	}
}
 
开发者ID:frincon,项目名称:abstractform,代码行数:26,代码来源:FormService.java

示例4: getFormToolkit

import javax.management.ServiceNotFoundException; //导入依赖的package包/类
@SuppressWarnings({ "unchecked" })
public <S> BFormToolkit<S> getFormToolkit(Class<S> implementationClass) throws ServiceNotFoundException {
	Iterator<BFormToolkit> it = loader.iterator();
	BFormToolkit toolkit = null;
	while (toolkit == null && it.hasNext()) {
		BFormToolkit tl = it.next();
		if (implementationClass.isAssignableFrom(tl.getImplementationClass())) {
			toolkit = tl;
		}
	}
	if (toolkit == null) {
		throw new ServiceNotFoundException();
	} else {
		return toolkit;
	}
}
 
开发者ID:frincon,项目名称:abstractform,代码行数:17,代码来源:BFormService.java

示例5: testServiceLoader

import javax.management.ServiceNotFoundException; //导入依赖的package包/类
@Test
public void testServiceLoader() throws ServiceNotFoundException {
	FormToolkit<Component> toolkit = FormService.getInstance().getFormToolkit(Component.class);

	Form form = new SampleForm();
	VaadinFormInstance instance = (VaadinFormInstance) toolkit.buildForm(form);
	assertNotNull(instance);
	Component component = instance.getImplementation();
	assertThat(component, instanceOf(VerticalLayout.class));

	Component cifCode = instance.getComponentById("fCif");
	assertThat(cifCode, instanceOf(TextField.class));

	Component active = instance.getComponentById("fActive");
	assertThat(active, instanceOf(CheckBox.class));

}
 
开发者ID:frincon,项目名称:abstractform,代码行数:18,代码来源:TestVaadinBuilder.java

示例6: addURL

import javax.management.ServiceNotFoundException; //导入依赖的package包/类
/**
 * Appends the specified URL to the list of URLs to search for classes and
 * resources.
 * @exception ServiceNotFoundException The specified URL is malformed.
 */
public void addURL(String url) throws ServiceNotFoundException {
    try {
        URL ur = new URL(url);
        if (!Arrays.asList(getURLs()).contains(ur))
            super.addURL(ur);
    } catch (MalformedURLException e) {
        if (MLET_LOGGER.isLoggable(Level.FINEST)) {
            MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
                    "addUrl", "Malformed URL: " + url, e);
        }
        throw new
            ServiceNotFoundException("The specified URL is malformed");
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:MLet.java

示例7: addURL

import javax.management.ServiceNotFoundException; //导入依赖的package包/类
/**
 * Appends the specified URL to the list of URLs to search for classes and
 * resources.
 * @exception ServiceNotFoundException The specified URL is malformed.
 */
public void addURL(String url) throws ServiceNotFoundException {
    try {
        URL ur = new URL(url);
        if (!Arrays.asList(getURLs()).contains(ur))
            super.addURL(ur);
    } catch (MalformedURLException e) {
        if (MLET_LOGGER.isLoggable(Level.DEBUG)) {
            MLET_LOGGER.log(Level.DEBUG, "Malformed URL: " + url, e);
        }
        throw new
            ServiceNotFoundException("The specified URL is malformed");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:MLet.java

示例8: invoke

import javax.management.ServiceNotFoundException; //导入依赖的package包/类
public Object invoke(String actionName, Object[] params, String[] argTypes)
        throws MBeanException, ReflectionException
{
    assertNotNull("actionName", actionName);

    // params argTypes are allowed to be null and mean no-arg method
    if (params == null) {
        params = NO_PARAMS;
    }
    if (argTypes == null) {
        argTypes = NO_ARGS;
    }

    for (int i = 0; i < argTypes.length; i++) {
        assertNotNull("argTypes[" + i + "]", argTypes[i]);
    }

    Signature signature = new Signature(actionName, argTypes);
    MBeanOperation operation = operations.get(signature);
    if (operation == null) {
        String message = "Operation " + signature + " not found";
        throw new MBeanException(new ServiceNotFoundException(message), message);
    }

    Object result = operation.invoke(params);
    return result;
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:28,代码来源:MBean.java

示例9: operation

import javax.management.ServiceNotFoundException; //导入依赖的package包/类
public ServiceInfo operation(final String name, Consumer<OperationResult> consumer) {
    final Optional<Operation> first = Stream.of(operations).filter(op -> op.getName().equalsIgnoreCase(name)).findFirst();
    if(first.isPresent()){
         consumer.accept(new OperationResult(first.get(),true,null));
    }   else {
        consumer.accept(new OperationResult(null,false,new ServiceNotFoundException("no operation "+name+" was found")));
    }
    return this;
}
 
开发者ID:amoAHCP,项目名称:vert.x-microservice,代码行数:10,代码来源:ServiceInfo.java

示例10: buildForm

import javax.management.ServiceNotFoundException; //导入依赖的package包/类
@Override
public <U> VaadinBindingFormInstance<U> buildForm(BForm<U> form) {
	try {
		return buildForm(form, BindingService.getInstance().getBindingToolkit());
	} catch (ServiceNotFoundException e) {
		throw new UnsupportedOperationException("Default binding toolkit not found", e);
	}
}
 
开发者ID:frincon,项目名称:abstractform,代码行数:9,代码来源:VaadinBindingFormToolkit.java

示例11: getBindingToolkit

import javax.management.ServiceNotFoundException; //导入依赖的package包/类
public BindingToolkit getBindingToolkit() throws ServiceNotFoundException {
	Iterator<BindingToolkit> it = loader.iterator();
	BindingToolkit toolkit = null;
	while (toolkit == null && it.hasNext()) {
		BindingToolkit tl = it.next();
		toolkit = tl;
	}
	if (toolkit == null) {
		throw new ServiceNotFoundException();
	} else {
		return toolkit;
	}
}
 
开发者ID:frincon,项目名称:abstractform,代码行数:14,代码来源:BindingService.java

示例12: testServiceLoader

import javax.management.ServiceNotFoundException; //导入依赖的package包/类
@Test
public void testServiceLoader() throws ServiceNotFoundException {
	FormToolkit<JComponent> toolkit = FormService.getInstance().getFormToolkit(JComponent.class);

	Form form = new SampleForm();
	FormInstance<JComponent> instance = toolkit.buildForm(form);
	assertNotNull(instance);

}
 
开发者ID:frincon,项目名称:abstractform,代码行数:10,代码来源:TestSwingBuilder.java

示例13: getProjects

import javax.management.ServiceNotFoundException; //导入依赖的package包/类
public List<Project> getProjects() throws AuthenticationFailedException, ServiceNotFoundException, Exception {
    HttpURLConnection con = getServiceConnection("api/projects");
    if (con.getResponseCode() == 401) {
        throw new AuthenticationFailedException();
    } else if (con.getResponseCode() == 404) {
        throw new ServiceNotFoundException();
    }
    JavaType type = CollectionType.construct(ArrayList.class, SimpleType.construct(Project.class));
    InputStream in = con.getInputStream();
    try {
        return (List<Project>) objectMapper.readValue(in, type);
    } finally {
        in.close();
    }
}
 
开发者ID:lodms,项目名称:lodms-plugins,代码行数:16,代码来源:PPTApi.java

示例14: main

import javax.management.ServiceNotFoundException; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

        boolean error = false;

        // Instantiate the MBean server
        //
        System.out.println("Create the MBean server");
        MBeanServer mbs = MBeanServerFactory.createMBeanServer();

        // Instantiate an MLet
        //
        System.out.println("Create the MLet");
        MLet mlet = new MLet();

        // Register the MLet MBean with the MBeanServer
        //
        System.out.println("Register the MLet MBean");
        ObjectName mletObjectName = new ObjectName("Test:type=MLet");
        mbs.registerMBean(mlet, mletObjectName);

        // Call getMBeansFromURL
        //
        System.out.println("Call mlet.getMBeansFromURL(<url>)");
        String testSrc = System.getProperty("test.src");
        System.out.println("test.src = " + testSrc);
        String urlCodebase;
        if (testSrc.startsWith("/")) {
            urlCodebase =
                "file:" + testSrc.replace(File.separatorChar, '/') + "/";
        } else {
            urlCodebase =
                "file:/" + testSrc.replace(File.separatorChar, '/') + "/";
        }
        String mletFile = urlCodebase + args[0];
        System.out.println("MLet File = " + mletFile);
        try {
            mlet.getMBeansFromURL(mletFile);
            System.out.println(
                "TEST FAILED: Expected ServiceNotFoundException not thrown");
            error = true;
        } catch (ServiceNotFoundException e) {
            if (e.getCause() == null) {
                System.out.println("TEST FAILED: Got unexpected null cause " +
                    "in ServiceNotFoundException");
                error = true;
            } else if (!(e.getCause() instanceof IOException)) {
                System.out.println("TEST FAILED: Got unexpected non-null " +
                    "cause in ServiceNotFoundException");
                error = true;
            } else {
                System.out.println("TEST PASSED: Got expected non-null " +
                    "cause in ServiceNotFoundException");
                error = false;
            }
            e.printStackTrace(System.out);
        }

        // Unregister the MLet MBean
        //
        System.out.println("Unregister the MLet MBean");
        mbs.unregisterMBean(mletObjectName);

        // Release MBean server
        //
        System.out.println("Release the MBean server");
        MBeanServerFactory.releaseMBeanServer(mbs);

        // End Test
        //
        System.out.println("Bye! Bye!");
        if (error) System.exit(1);
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:73,代码来源:ParserInfiniteLoopTest.java

示例15: main

import javax.management.ServiceNotFoundException; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

        boolean error = false;

        // Instantiate the MBean server
        //
        System.out.println("Create the MBean server");
        MBeanServer mbs = MBeanServerFactory.createMBeanServer();

        // Instantiate an MLet
        //
        System.out.println("Create the MLet");
        MLet mlet = new MLet();

        // Register the MLet MBean with the MBeanServer
        //
        System.out.println("Register the MLet MBean");
        ObjectName mletObjectName = new ObjectName("Test:type=MLet");
        mbs.registerMBean(mlet, mletObjectName);

        // Call getMBeansFromURL
        //
        System.out.println("Call mlet.getMBeansFromURL(<url>)");
        try {
            mlet.getMBeansFromURL("bogus://whatever");
            System.out.println("TEST FAILED: Expected " +
                               ServiceNotFoundException.class +
                               " exception not thrown.");
            error = true;
        } catch (ServiceNotFoundException e) {
            if (e.getCause() == null) {
                System.out.println("TEST FAILED: Got null cause in " +
                                   ServiceNotFoundException.class +
                                   " exception.");
                error = true;
            } else {
                System.out.println("TEST PASSED: Got non-null cause in " +
                                   ServiceNotFoundException.class +
                                   " exception.");
                error = false;
            }
            e.printStackTrace(System.out);
        }

        // Unregister the MLet MBean
        //
        System.out.println("Unregister the MLet MBean");
        mbs.unregisterMBean(mletObjectName);

        // Release MBean server
        //
        System.out.println("Release the MBean server");
        MBeanServerFactory.releaseMBeanServer(mbs);

        // End Test
        //
        System.out.println("Bye! Bye!");
        if (error) System.exit(1);
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:60,代码来源:GetMBeansFromURLTest.java


注:本文中的javax.management.ServiceNotFoundException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。