private String wrapper(String nodeName) { return StringUtils.wrapper(nodeName, "[@name='", "']"); } }
private String getNodeName(String expression) { return StringUtils.extract(expression, "[@name='", "']"); }
private boolean isValidJaxwsBindingFile(String bindingLocation, XMLStreamReader reader) { try { if (ToolConstants.JAXWS_BINDINGS.equals(reader.getName())) { String wsdlURL = (String)env.get(ToolConstants.CFG_WSDLURL); wsdlURL = ProcessorUtil.absolutize(ProcessorUtil.getFileOrURLName(wsdlURL)); String wsdlLocation = reader.getAttributeValue(null, "wsdlLocation"); if (StringUtils.isFileExist(bindingLocation) && !StringUtils.isFileAbsolute(wsdlLocation)) { String basedir = new File(bindingLocation).getParent(); wsdlLocation = new File(basedir, wsdlLocation).getAbsolutePath(); } wsdlLocation = ProcessorUtil.absolutize(ProcessorUtil.getFileOrURLName(wsdlLocation)); if (!StringUtils.getURL(wsdlURL).equals(StringUtils.getURL(wsdlLocation))) { Message msg = new Message("NOT_POINTTO_URL", LOG, new Object[]{wsdlLocation, wsdlURL}); throw new ToolException(msg); } } else { return false; } } catch (MalformedURLException e) { Message msg = new Message("CAN_NOT_GET_WSDL_LOCATION", LOG); throw new ToolException(msg, e); } return true; }
private static boolean isSame(QName messageQName, QName methodQName) { boolean same = false; if (StringUtils.isEmpty(messageQName.getNamespaceURI())) { same = messageQName.getLocalPart().equals(methodQName.getLocalPart()); } else { same = messageQName.equals(methodQName); } return same; }
public static void encode(byte[] id, int o, int l, Writer writer) throws Base64Exception { try { writer.write(encodeChunk(id, o, l)); } catch (IOException e) { throw new Base64Exception(new Message("BASE64_ENCODE_WRITER_IOEXCEPTION", LOG), e); } }
public static void decode(char[] id, int o, int l, OutputStream ostream) throws Base64Exception { try { ostream.write(decodeChunk(id, o, l)); } catch (IOException e) { // convert exception to Base64Exception throw new Base64Exception(new Message("BASE64_RUNTIME_EXCEPTION", LOG), e); } }
public static boolean isFileAbsolute(String file) { return isFileExist(file) && new File(file).isAbsolute(); }
/** * Shutdown the session factory. */ public void shutdown() { try { PooledSession curr; if (replyCapableSessionCache != null) { curr = replyCapableSessionCache.poll(); while (curr != null) { curr.close(); curr = replyCapableSessionCache.poll(); } } if (sendOnlySessionCache != null) { curr = sendOnlySessionCache.poll(); while (curr != null) { curr.close(); curr = sendOnlySessionCache.poll(); } } theConnection.close(); } catch (JMSException e) { LOG.log(Level.WARNING, "queue connection close failed: " + e); } // help GC // replyCapableSessionCache = null; sendOnlySessionCache = null; }
public static String encode(byte[] id) { char[] cd = encodeChunk(id, 0, id.length); return new String(cd, 0, cd.length); }
obcount += processEncodeme(ib, ob, obcount);
/** * Populate the cache */ public void populateCache() throws Exception { // create cache primaryCache = new LinkedList<E>(); secondaryCache = new LinkedList<SoftReference<E>>(); // preallocate objects into primary cache int primaryCachePreallocation = (preallocation > primaryCacheSize) ? primaryCacheSize : preallocation; for (int i = 0; i < primaryCachePreallocation; i++) { primaryCache.offer(create()); } // preallocate objects into secondary cache int secondaryCachePreallocation = preallocation - primaryCachePreallocation; for (int i = 0; i < secondaryCachePreallocation; i++) { secondaryCache.offer(new SoftReference<E>(create())); } }
/** * Return a Session to the pool * * @param pooled_session the session to recycle */ public void recycle(PooledSession pooledSession) { // sessions used long-term by the server receive side are not cached, // only non-null destinations are temp queues final boolean replyCapable = pooledSession.destination() != null; boolean discard = false; synchronized (this) { // re-cache session, closing if it cannot be it can be accomodated // discard = replyCapable ? (!replyCapableSessionCache.recycle(pooledSession)) : (!sendOnlySessionCache.recycle(pooledSession)); } if (discard) { try { pooledSession.close(); } catch (JMSException e) { LOG.log(Level.WARNING, "JMS Session discard failed: " + e); } } }
protected void setHeaders(MessageContext ctx) { ctx.put(ObjectMessageContext.MESSAGE_INPUT, true); Map<String, List<String>> headers = new HashMap<String, List<String>>(); copyRequestHeaders(ctx, headers); ctx.put(GenericMessageContext.HTTP_REQUEST_HEADERS, headers); if (headers.containsKey("Authorization")) { List<String> authorizationLines = headers.get("Authorization"); String credentials = authorizationLines.get(0); String authType = credentials.split(" ")[0]; if ("Basic".equals(authType)) { String authEncoded = credentials.split(" ")[1]; try { String authDecoded = new String(Base64Utility.decode(authEncoded)); String authInfo[] = authDecoded.split(":"); String username = authInfo[0]; String password = authInfo[1]; ctx.put(BindingProvider.USERNAME_PROPERTY, username); ctx.put(BindingProvider.PASSWORD_PROPERTY, password); } catch (Base64Exception ex) { //ignore, we'll leave things alone. They can try decoding it themselves } } } headers = new HashMap<String, List<String>>(); setPolicies(ctx, headers); ctx.put(GenericMessageContext.HTTP_RESPONSE_HEADERS, headers); } protected void setPolicies(MessageContext ctx, Map<String, List<String>> headers) {
public void load(InputStream is, String delim) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(is)); String line = br.readLine(); while (!StringUtils.isEmpty(line)) { StringTokenizer st = new StringTokenizer(line, delim); String key = null; String value = null; if (st.hasMoreTokens()) { key = st.nextToken().trim(); } if (st.hasMoreTokens()) { value = st.nextToken().trim(); } maps.put(key, value); line = br.readLine(); } br.close(); }
public static void encodeChunk(byte[] id, int o, int l, OutputStream ostream) throws Base64Exception { try { ostream.write(new String(encodeChunk(id, o, l)).getBytes()); } catch (IOException e) { throw new Base64Exception(new Message("BASE64_ENCODE_IOEXCEPTION", LOG), e); } }
public static void decode(String id, OutputStream ostream) throws Base64Exception { try { char[] cd = id.toCharArray(); ostream.write(decodeChunk(cd, 0, cd.length)); } catch (IOException e) { throw new Base64Exception(new Message("BASE64_DECODE_IOEXCEPTION", LOG), e); } }
private void customizeSchema(Element schema, String targetNamespace) { String userPackage = env.mapPackageName(targetNamespace); if (env.hasExcludeNamespace(targetNamespace) && env.getExcludePackageName(targetNamespace) != null) { // generate excluded namespace types classes with specified package // name userPackage = env.getExcludePackageName(targetNamespace); } if (!isSchemaParsed(targetNamespace) && !StringUtils.isEmpty(userPackage)) { Node jaxbBindings = JAXBUtils.innerJaxbPackageBinding(schema, userPackage); schema.appendChild(jaxbBindings); } int nodeListLen = schema.getElementsByTagNameNS(ToolConstants.SCHEMA_URI, "import").getLength(); for (int i = 0; i < nodeListLen; i++) { removeImportElement(schema); } }
private void addWebMethodAnnotation(JavaMethod method, String operationName) { JavaAnnotation methodAnnotation = new JavaAnnotation("WebMethod"); methodAnnotation.addArgument("operationName", operationName); if (!StringUtils.isEmpty(method.getSoapAction())) { methodAnnotation.addArgument("action", method.getSoapAction()); } method.addAnnotation("WebMethod", methodAnnotation); method.getInterface().addImport("javax.jws.WebMethod"); }