/** * Returns the nested exception. * * <p> * This method predates the general purpose exception chaining mechanism. * The {@code getCause()} method is now the preferred means of obtaining * this information. * * @return The result of calling {@code getCause()}. */ public Throwable getException() { return getCause(); }
/** * Validate that a given alias is legal. * * @param alias input alias * @throws NamespaceException is thrown if alias is illegal */ private void validateAlias( String alias ) throws NamespaceException { if (alias == null) { throw new NamespaceException( "Alias is null." ); } if (alias.trim().length() == 0) { throw new NamespaceException( "Alias is an empty string." ); } if (!alias.startsWith( "/" )) { throw new NamespaceException( "Alias must begin with '/'." ); } } }
public Object addingService(ServiceReference reference) { HttpService httpService = (HttpService) context.getService(reference); try { httpService.registerResources("/js", "/src-web", null); } catch (NamespaceException e) { e.printStackTrace(); } return null; }
/** * Validate that a given alias is legal. * * @param alias input alias * @throws NamespaceException is thrown if alias is illegal */ private void validateAlias( String alias ) throws NamespaceException { if (alias == null) { throw new NamespaceException( "Alias is null." ); } if (alias.trim().length() == 0) { throw new NamespaceException( "Alias is an empty string." ); } if (!alias.startsWith( "/" )) { throw new NamespaceException( "Alias must begin with '/'." ); } } }
@Override public HttpService addingService(ServiceReference<HttpService> reference) { HttpService service = ExtendedInternalNode.this.bundleContext.getService(reference); try { service.registerServlet("/elasticsearch", ExtendedInternalNode.this.servlet, null, null); } catch (ServletException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } catch (NamespaceException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } return service; } @Override
/** * Returns the nested exception. * * <p> * This method predates the general purpose exception chaining mechanism. * The <code>getCause()</code> method is now the preferred means of * obtaining this information. * * @return The result of calling <code>getCause()</code>. */ public Throwable getException() { return getCause(); }
private void validateName(String name) throws NamespaceException { // The name parameter must also not end with slash ('/') with the exception // that a name of the form "/" is used to denote the root of the bundle. if (name == null || (name.length() > 1 && name.endsWith("/"))) throw new NamespaceException(OSGiMessages.MESSAGES.invalidResourceName(name)); }
@Override public Object addingService(ServiceReference reference) { HttpService httpService = (HttpService) context.getService(reference); try { httpService.registerResources("/VAADIN", "/VAADIN", new TargetBundleHttpContext(context, "com.vaadin")); } catch (NamespaceException e) { e.printStackTrace(); } ApplicationFactoryTracker bridge = new ApplicationFactoryTracker(httpService, context); bridge.open(); return bridge; } @Override
/** * Returns the nested exception. * * <p> * This method predates the general purpose exception chaining mechanism. The <code>getCause()</code> method is now the * preferred means of obtaining this information. * * @return The result of calling <code>getCause()</code>. */ public Throwable getException() { return getCause(); }
/** * Chek if <code>alias</code> has been already registered. * * @param alias Alias to check. * @throws NamespaceException If <code>alias</code> has been registered. */ private void validateAlias4RegOk(String alias) throws NamespaceException { if (!alias.startsWith("/")) { // have to start with "/" String msg = "Invalid alias '" + alias + "', have to start with '/'."; logger.warn(msg); throw new NamespaceException(msg); } if (alias.length() > 1 && alias.endsWith("/")) { // if longer than "/", should not end with "/" String msg = "Alias '" + alias + "' can't and with '/' with exception to alias '/'."; logger.warn(msg); throw new NamespaceException(msg); } if (OSGiCleanMapper.containsAlias(alias)) { String msg = "Alias: '" + alias + "', already registered"; logger.warn(msg); throw new NamespaceException(msg); } }
@Override public Object addingService(ServiceReference ref) { Object aliasObj = ref.getProperty(ApplicationFactory.ALIAS_NAME); if(aliasObj instanceof String) { String alias = (String) aliasObj; BundleContentHttpContext httpContext = new BundleContentHttpContext(ref.getBundle()); ApplicationFactory factory = (ApplicationFactory) context.getService(ref); ApplicationFactoryServlet servlet = new ApplicationFactoryServlet(factory); try { httpService.registerServlet(alias, servlet, null, httpContext); return alias; } catch (ServletException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NamespaceException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return null; } @Override
/** * Returns the nested exception. * * <p> * This method predates the general purpose exception chaining mechanism. * The {@code getCause()} method is now the preferred means of obtaining * this information. * * @return The result of calling {@code getCause()}. */ public Throwable getException() { return getCause(); }
/** * Chek if <code>alias</code> has been already registered. * * @param alias Alias to check. * @throws NamespaceException If <code>alias</code> has been registered. */ private void validateAlias4RegOk(String alias) throws NamespaceException { if (!alias.startsWith("/")) { // have to start with "/" String msg = "Invalid alias '" + alias + "', have to start with '/'."; logger.warn(msg); throw new NamespaceException(msg); } if (alias.length() > 1 && alias.endsWith("/")) { // if longer than "/", should not end with "/" String msg = "Alias '" + alias + "' can't and with '/' with exception to alias '/'."; logger.warn(msg); throw new NamespaceException(msg); } if (OSGiCleanMapper.containsAlias(alias)) { String msg = "Alias: '" + alias + "', already registered"; logger.warn(msg); throw new NamespaceException(msg); } }
/** * Returns the nested exception. * * <p> * This method predates the general purpose exception chaining mechanism. * The {@code getCause()} method is now the preferred means of obtaining * this information. * * @return The result of calling {@code getCause()}. */ public Throwable getException() { return getCause(); }
private void validateAlias(String alias, boolean exists) throws NamespaceException { // An alias must begin with slash ('/') and must not end with slash ('/'), with the exception // that an alias of the form "/" is used to denote the root alias if (alias == null || !alias.startsWith("/")) throw new IllegalArgumentException(OSGiMessages.MESSAGES.invalidServletAlias(alias)); if (alias.length() > 1 && alias.endsWith("/")) throw new IllegalArgumentException(OSGiMessages.MESSAGES.invalidServletAlias(alias)); if (exists && !registry.exists(alias)) throw new IllegalArgumentException(OSGiMessages.MESSAGES.aliasMappingDoesNotExist(alias)); if (!exists && registry.exists(alias)) throw new NamespaceException(OSGiMessages.MESSAGES.aliasMappingAlreadyExists(alias)); }
public HttpService addingService(ServiceReference<HttpService> reference) { final HttpService httpService = (HttpService) bundleContext .getService(reference); if (httpService != null) { // create a default context to share between registrations final HttpContext httpContext = httpService.createDefaultHttpContext(); final Dictionary<String, Object> initParams = new Hashtable<String, Object>(); try { httpService.registerServlet("/hello", new HelloServlet(), initParams, httpContext); httpService.registerServlet("/hello/logo", new HelloImage(), initParams, httpContext); httpService.registerResources("/images", "/images", httpContext); } catch (ServletException e) { e.printStackTrace(); } catch (NamespaceException e) { e.printStackTrace(); } } return httpService; }
/** * Returns the nested exception. * * <p> * This method predates the general purpose exception chaining mechanism. * The {@code getCause()} method is now the preferred means of obtaining * this information. * * @return The result of calling {@code getCause()}. */ public Throwable getException() { return getCause(); }
/** * Register a servlet */ public void registerServlet(@NotNull final String alias, @NotNull final ExtServletContext httpContext, @NotNull final Servlet servlet, @NotNull final ServletInfo servletInfo) throws ServletException, NamespaceException { final ServletHandler handler = new HttpServiceServletHandler(httpContext, servletInfo, servlet); synchronized (this.aliasMap) { if (this.aliasMap.containsKey(alias)) { throw new NamespaceException("Alias " + alias + " is already in use."); } this.handlerRegistry.getRegistry(handler.getContextServiceId()).registerServlet(handler); this.aliasMap.put(alias, handler); } }
e.printStackTrace(); } catch (NamespaceException e) { e.printStackTrace();