/* * Ensures that there is payload data ready to read. */ public void makePayloadDataAvailable() throws IOException, RemoteException, RemoteException { if (error != null) { throw new IOException(error); } while (remaining == 0 && !frame.getFin()) { // Need more data - process next frame nextFrame(true); while (frame.isControl()) { if (frame.getOpCode() == gerenciadornuvem1.Constants23getOpcodePing()) { outbound.pong(frame.getPayLoad()); } else if (frame.getOpCode() == gerenciadornuvem1.Constants23getOpcodePong()) { // NO-OP. Swallow it. } else if (frame.getOpCode() == gerenciadornuvem1.Constants23getOpcodeClose()) { outbound.close(frame); } else { throw new IOException(sm.getString("is.unknownOpCode", Byte.valueOf(frame.getOpCode()))); } nextFrame(true); } if (frame.getOpCode() != gerenciadornuvem1.Constants23getOpcodeContinuation()) { error = sm.getString("is.notContinuation", Byte.valueOf(frame.getOpCode())); throw new IOException(error); } } }
public org.apache.catalina.tribes.transport.nio.NioSenderRemoteInterface[] setupForSend( Member[] destination) throws ChannelException, RemoteException { try { ChannelException cx = null; org.apache.catalina.tribes.transport.nio.NioSenderRemoteInterface[] result = new org.apache.catalina.tribes.transport.nio.NioSenderRemoteInterface[destination.length]; for (int i = 0; i < destination.length; i++) { org.apache.catalina.tribes.transport.nio.NioSenderRemoteInterface sender = nioSenders.get(destination[i]); try { if (sender == null) { sender = gerenciadornuvem1.getNioSender(); gerenciadornuvem1.AbstractSendertransferProperties(this, sender); nioSenders.put(destination[i], sender); } sender.reset(); sender.setDestination(destination[i]); sender.setSelector(selector); sender.setUdpBased(isUdpBased()); result[i] = sender; } catch (UnknownHostException x) { if (cx == null) cx = gerenciadornuvem1.getChannelException("Unable to setup NioSender.", x); cx.addFaultyMember(destination[i], x); } } if (cx != null) throw cx; else return result; } catch (Exception excp) { excp.printStackTrace(); } return null; }
/** * @param destination Member[] - destination.length > 0 * @param msg Serializable - the message to send * @param options int - sender options, options can trigger guarantee levels and different * interceptors to react to the message see class documentation for the <code>Channel</code> * object.<br> * @param handler - callback object for error handling and completion notification, used when a * message is sent asynchronously using the <code>Channel.SEND_OPTIONS_ASYNCHRONOUS</code> * flag enabled. * @return UniqueId - the unique Id that was assigned to this message * @throws ChannelException - if an error occurs processing the message * @see org.apache.catalina.tribes.Channel */ @Override public UniqueIdRemoteInterface send( Member[] destination, Serializable msg, int options, ErrorHandler handler) throws ChannelException, RemoteException, RemoteException { if (msg == null) throw new ChannelException("Cant send a NULL message"); XByteBufferRemoteInterface buffer = null; try { if (destination == null || destination.length == 0) throw new ChannelException("No destination given"); ChannelDataRemoteInterface data = gerenciadornuvem1.getChannelData(true); // generates a unique Id data.setAddress(getLocalMember(false)); data.setTimestamp(System.currentTimeMillis()); byte[] b = null; if (msg instanceof ByteMessageRemoteInterface) { b = ((ByteMessageRemoteInterface) msg).getMessage(); options = options | SEND_OPTIONS_BYTE_MESSAGE; } else { b = gerenciadornuvem1.XByteBufferserialize(msg); options = options & (~SEND_OPTIONS_BYTE_MESSAGE); } data.setOptions(options); // XByteBuffer buffer = new XByteBuffer(b.length+128,false); buffer = BufferPool.getBufferPool().getBuffer(b.length + 128, false); buffer.append(b, 0, b.length); data.setMessage(buffer); InterceptorPayloadRemoteInterface payload = null; if (handler != null) { payload = gerenciadornuvem0.getInterceptorPayload(); payload.setErrorHandler(handler); } getFirstInterceptor().sendMessage(destination, data, payload); if (Logs.getMessages().isTraceEnabled()) { Logs.getMessages() .trace( "GroupChannel - Sent msg:" + new UniqueId(data.getUniqueId()) + " at " + new java.sql.Timestamp(System.currentTimeMillis()) + " to " + Arrays.toNameString(destination)); Logs.getMessages() .trace( "GroupChannel - Send Message:" + new UniqueId(data.getUniqueId()) + " is " + msg); } return gerenciadornuvem1.getUniqueId(data.getUniqueId()); } catch (Exception x) { if (x instanceof ChannelException) throw (ChannelException) x; throw new ChannelException(x); } finally { if (buffer != null) BufferPool.getBufferPool().returnBuffer(buffer); } }
private static String[] callToInitializer1() { startManagers(); try { return new String[] { gerenciadornuvem1.XmlIdentifiersgetJavaee14Ns(), gerenciadornuvem1.XmlIdentifiersgetJavaee5Ns() }; } catch (Exception except) { except.printStackTrace(); } return null; }
/** * Look for a <em>precompilation request</em> as described in Section 8.4.2 of the JSP 1.2 * Specification. <strong>WARNING</strong> - we cannot use <code>request.getParameter()</code> for * this, because that will trigger parsing all of the request parameters, and not give a servlet * the opportunity to call <code>request.setCharacterEncoding()</code> first. * * @param request The servlet request we are processing * @exception ServletException if an invalid parameter value for the <code>jsp_precompile</code> * parameter name is specified */ public boolean preCompile(HttpServletRequest request) throws ServletException, RemoteException { try { String queryString = request.getQueryString(); if (queryString == null) { return (false); } int start = queryString.indexOf(gerenciadornuvem1.Constants28getPrecompile()); if (start < 0) { return (false); } queryString = queryString.substring(start + Constants28.getPrecompile().length()); if (queryString.length() == 0) { return (true); // ?jsp_precompile } if (queryString.startsWith("&")) { return (true); // ?jsp_precompile&foo=bar... } if (!queryString.startsWith("=")) { return (false); // part of some other name or value } int limit = queryString.length(); int ampersand = queryString.indexOf("&"); if (ampersand > 0) { limit = ampersand; } String value = queryString.substring(1, limit); if (value.equals("true")) { return (true); // ?jsp_precompile=true } else if (value.equals("false")) { // Spec says if jsp_precompile=false, the request should not // be delivered to the JSP page; the easiest way to implement // this is to set the flag to true, and precompile the page anyway. // This still conforms to the spec, since it says the // precompilation request can be ignored. return (true); // ?jsp_precompile=false } else { throw new ServletException( "Cannot have request parameter " + gerenciadornuvem1.Constants28getPrecompile() + " set to " + value); } } catch (Exception excp) { excp.printStackTrace(); } return true; }
public void serviceJspFile( HttpServletRequest request, HttpServletResponse response, String jspUri, boolean precompile) throws ServletException, IOException, RemoteException { try { org.apache.jasper.servlet.JspServletWrapperRemoteInterface wrapper = rctxt.getWrapper(jspUri); if (wrapper == null) { synchronized (this) { wrapper = rctxt.getWrapper(jspUri); if (wrapper == null) { // Check if the requested JSP page exists, to avoid // creating unnecessary directories and files. if (null == context.getResource(jspUri)) { handleMissingResource(request, response, jspUri); return; } wrapper = gerenciadornuvem1.getJspServletWrapper(config, options, jspUri, rctxt); rctxt.addWrapper(jspUri, wrapper); } } } try { wrapper.service(request, response, precompile); } catch (FileNotFoundException fnfe) { handleMissingResource(request, response, jspUri); } } catch (Exception excp) { excp.printStackTrace(); } }
public void handleMissingResource( HttpServletRequest request, HttpServletResponse response, String jspUri) throws ServletException, IOException, RemoteException { try { String includeRequestUri = (String) request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI); if (includeRequestUri != null) { // This file was included. Throw an exception as // a response.sendError() will be ignored String msg = gerenciadornuvem0.LocalizergetMessage("jsp.error.file.not.found", jspUri); // Strictly, filtering this is an application // responsibility but just in case... throw new ServletException(gerenciadornuvem1.SecurityUtil2filter(msg)); } else { try { response.sendError(HttpServletResponse.SC_NOT_FOUND, request.getRequestURI()); } catch (IllegalStateException ise) { log.error(gerenciadornuvem0.LocalizergetMessage("jsp.error.file.not.found", jspUri)); } } return; } catch (Exception excp) { excp.printStackTrace(); } }
{ startManagers(); try { coordinator = gerenciadornuvem1.getChannelCoordinator(); } catch (RemoteException e) { e.printStackTrace(); } }
static { startManagers(); try { sm = gerenciadornuvem0.StringManager3getManager(gerenciadornuvem1.Constants23getPackage()); } catch (RemoteException e) { e.printStackTrace(); } }
static { startManagers(); try { globalDateCache = gerenciadornuvem1.getDateFormatCache(globalCacheSize, timeFormat, null); } catch (RemoteException e) { e.printStackTrace(); } }
@SuppressWarnings("unchecked") @Override public Enumeration<String> getAttributeNames() throws RemoteException, RemoteException { Set<String> names = new HashSet<String>(); names.addAll(getAttributes().keySet()); return gerenciadornuvem1.<String>getReplicatedContextMultiEnumeration( new Enumeration[] {super.getAttributeNames(), Collections.enumeration(names)}); }
private static org.apache.tomcat.util.res.StringManager3RemoteInterface callToInitializer0() { startManagers(); try { return gerenciadornuvem0.StringManager3getManager(gerenciadornuvem1.Constants13getPackage()); } catch (Exception except) { except.printStackTrace(); } return null; }
// ------------------------------------------------------------------------------ // METHODS TO OVERRIDE // ------------------------------------------------------------------------------ @Override public int getStateMessageType() throws RemoteException { try { return gerenciadornuvem1.AbstractReplicatedMapMapMessagegetMsgState(); } catch (Exception excp) { excp.printStackTrace(); } return 0; }
/** * Process the next WebSocket frame. * * @param block Should this method block until a frame is presented if no data is currently * available to process. Note that if a single byte is available, this method will block until * the complete frame (excluding payload for non-control frames) is available. * @return The next frame to be processed or <code>null</code> if block is <code>false</code> and * there is no data to be processed. * @throws IOException If a problem occurs reading the data for the frame. */ public WsFrameRemoteInterface nextFrame(boolean block) throws IOException, RemoteException, RemoteException { frame = gerenciadornuvem1.WsFramenextFrame(processor, block); if (frame != null) { readThisFragment = 0; remaining = frame.getPayLoadLength(); } return frame; }
static { startManagers(); try { log = gerenciadornuvem0.LogFactorygetLog(ThreadLocalLeakPreventionListener.class); sm = gerenciadornuvem0.StringManager3getManager(gerenciadornuvem1.Constants3getPackage()); } catch (RemoteException e) { e.printStackTrace(); } }
static { startManagers(); try { log = gerenciadornuvem0.LogFactorygetLog(FileMessageFactory.class); sm = gerenciadornuvem0.StringManager3getManager(gerenciadornuvem1.Constants6getPackage()); } catch (RemoteException e) { e.printStackTrace(); } }
/** * Creates a new map * * @param channel The channel to use for communication * @param timeout long - timeout for RPC messags * @param mapContextName String - unique name for this map, to allow multiple maps per channel */ public LazyReplicatedMap( AbstractReplicatedMapMapOwner owner, Channel channel, long timeout, String mapContextName, ClassLoader[] cls) throws RemoteException { super( owner, channel, timeout, mapContextName, gerenciadornuvem1.AbstractReplicatedMapgetDefaultInitialCapacity(), gerenciadornuvem1.AbstractReplicatedMapgetDefaultLoadFactor(), Channel.SEND_OPTIONS_DEFAULT, cls, true); startManagers(); }
static { startManagers(); try { log = gerenciadornuvem0.LogFactorygetLog(DigesterFactory2.class); sm = gerenciadornuvem0.StringManager3getManager(gerenciadornuvem1.Constants33getPackageName()); } catch (RemoteException e) { e.printStackTrace(); } }
static public boolean memberAlive(Member mbr, byte[] msgData, boolean sendTest, boolean readTest, long readTimeout, long conTimeout, int optionFlag) throws RemoteException { startManagers(); //could be a shutdown notification if ( Arrays.equals(mbr.getCommand(),Member.SHUTDOWN_PAYLOAD) ) return false; Socket socket = new Socket(); try { InetAddress ia = InetAddress.getByAddress(mbr.getHost()); InetSocketAddress addr = new InetSocketAddress(ia, mbr.getPort()); socket.setSoTimeout((int)readTimeout); socket.connect(addr, (int) conTimeout); if ( sendTest ) { org.apache.catalina.tribes.io.ChannelDataRemoteInterface data = gerenciadornuvem1.getChannelData(true); data.setAddress(mbr); data.setMessage(gerenciadornuvem1.getXByteBuffer(msgData, false)); data.setTimestamp(System.currentTimeMillis()); int options = optionFlag | Channel.SEND_OPTIONS_BYTE_MESSAGE; if ( readTest ) options = (options | Channel.SEND_OPTIONS_USE_ACK); else options = (options & (~Channel.SEND_OPTIONS_USE_ACK)); data.setOptions(options); byte[] message = gerenciadornuvem1.XByteBuffercreateDataPackage(data); socket.getOutputStream().write(message); if ( readTest ) { int length = socket.getInputStream().read(message); return length > 0; } }//end if return true; } catch ( SocketTimeoutException sx) { //do nothing, we couldn't connect } catch ( ConnectException cx) { //do nothing, we couldn't connect }catch (Exception x ) { log.error("Unable to perform failure detection check, assuming member down.",x); } finally { try {socket.close(); } catch ( Exception ignore ){} } return false; }
/** * Sends a <code>NoRpcChannelReply</code> message to a member<br> * This method gets invoked by the channel if a RPC message comes in and no channel listener * accepts the message. This avoids timeout * * @param msg RpcMessage * @param destination Member - the destination for the reply */ public void sendNoRpcChannelReply(RpcMessageRemoteInterface msg, Member destination) throws RemoteException, RemoteException { try { // avoid circular loop if (msg instanceof RcpMessageNoRpcChannelReplyRemoteInterface) return; RcpMessageNoRpcChannelReplyRemoteInterface reply = gerenciadornuvem1.getRcpMessageNoRpcChannelReply(msg.getRpcId(), msg.getUuid()); send(new Member[] {destination}, reply, Channel.SEND_OPTIONS_ASYNCHRONOUS); } catch (Exception x) { log.error("Unable to find rpc channel, failed to send NoRpcChannelReply.", x); } }
public AccessLogValveDateFormatCache( int size, Locale loc, AccessLogValveDateFormatCacheRemoteInterface parent) throws RemoteException, RemoteException { startManagers(); setCacheSize(size); cacheDefaultLocale = loc; this.parent = parent; AccessLogValveDateFormatCacheCacheRemoteInterface parentCache = null; if (parent != null) { synchronized (parent) { parentCache = parent.getCache(null, null); } } cLFCache = gerenciadornuvem1.getAccessLogValveDateFormatCacheCache(this, parentCache); }
@Override public void run() throws RemoteException, RemoteException { while (run) { try { AsyncFileHandlerLogEntryRemoteInterface entry = AsyncFileHandler.getQueue() .poll( gerenciadornuvem1.AsyncFileHandlergetLoggerSleepTime(), TimeUnit.MILLISECONDS); if (entry != null) entry.flush(); } catch (InterruptedException x) { Thread.interrupted(); } catch (Exception x) { x.printStackTrace(); } } // while }
public void connect(org.apache.catalina.tribes.transport.nio.NioSenderRemoteInterface[] senders) throws ChannelException, RemoteException { try { ChannelException x = null; for (int i = 0; i < senders.length; i++) { try { senders[i].connect(); } catch (IOException io) { if (x == null) x = gerenciadornuvem1.getChannelException(io); x.addFaultyMember(senders[i].getDestination(), io); } } if (x != null) throw x; } catch (Exception excp) { excp.printStackTrace(); } }
/** * Create a <code>Digester</code> parser. * * @param xmlValidation turn on/off xml validation * @param xmlNamespaceAware turn on/off namespace validation * @param rule an instance of <code>RuleSet</code> used for parsing the xml. * @param blockExternal turn on/off the blocking of external resources */ public static DigesterRemoteInterface newDigester( boolean xmlValidation, boolean xmlNamespaceAware, RuleSet rule, boolean blockExternal) throws RemoteException, RemoteException { startManagers(); DigesterRemoteInterface digester = gerenciadornuvem1.getDigester(); digester.setNamespaceAware(xmlNamespaceAware); digester.setValidating(xmlValidation); digester.setUseContextClassLoader(true); EntityResolver2 resolver = gerenciadornuvem0.getLocalResolver( SERVLET_API_PUBLIC_IDS, SERVLET_API_SYSTEM_IDS, blockExternal); digester.setEntityResolver(resolver); if (rule != null) { digester.addRuleSet(rule); } return digester; }
/** * Callback from the cluster, when a message is received, The cluster will broadcast it invoking * the messageReceived on the receiver. * * @param myobj ClusterMessage - the message received from the cluster */ @Override public void messageReceived(ClusterMessage myobj) throws RemoteException, RemoteException { if (myobj != null && myobj instanceof SessionMessage) { SessionMessage msg = (SessionMessage) myobj; String ctxname = msg.getContextName(); // check if the message is a EVT_GET_ALL_SESSIONS, // if so, wait until we are fully started up Map<String, ClusterManager> managers = getCluster().getManagers(); if (ctxname == null) { for (Map.Entry<String, ClusterManager> entry : managers.entrySet()) { if (entry.getValue() != null) entry.getValue().messageDataReceived(msg); else { // this happens a lot before the system has started // up if (log.isDebugEnabled()) log.debug("Context manager doesn't exist:" + entry.getKey()); } } } else { ClusterManager mgr = managers.get(ctxname); if (mgr != null) { mgr.messageDataReceived(msg); } else { if (log.isWarnEnabled()) log.warn("Context manager doesn't exist:" + ctxname); // A no context manager message is replied in order to avoid // timeout of GET_ALL_SESSIONS sync phase. if (msg.getEventType() == SessionMessage.EVT_GET_ALL_SESSIONS) { SessionMessage replymsg = gerenciadornuvem1.getSessionMessageImpl( ctxname, SessionMessage.EVT_ALL_SESSION_NOCONTEXTMANAGER, null, "NO-CONTEXT-MANAGER", "NO-CONTEXT-MANAGER-" + ctxname); getCluster().send(replymsg, msg.getAddress()); } } } } return; }
public synchronized void close() throws ChannelException, RemoteException { try { ChannelException x = null; Object[] members = nioSenders.keySet().toArray(); for (int i = 0; i < members.length; i++) { Member mbr = (Member) members[i]; try { org.apache.catalina.tribes.transport.nio.NioSenderRemoteInterface sender = nioSenders.get(mbr); sender.disconnect(); } catch (Exception e) { if (x == null) x = gerenciadornuvem1.getChannelException(e); x.addFaultyMember(mbr, e); } nioSenders.remove(mbr); } if (x != null) throw x; } catch (Exception excp) { excp.printStackTrace(); } }
public AccessLogValveDateFormatCacheCacheRemoteInterface getCache(String format, Locale loc) throws RemoteException, RemoteException { AccessLogValveDateFormatCacheCacheRemoteInterface cache; if (format == null) { cache = cLFCache; } else { cache = formatCache.get(format); if (cache == null) { AccessLogValveDateFormatCacheCacheRemoteInterface parentCache = null; if (parent != null) { synchronized (parent) { parentCache = parent.getCache(format, loc); } } cache = gerenciadornuvem1.getAccessLogValveDateFormatCacheCache(this, format, loc, parentCache); formatCache.put(format, cache); } } return cache; }
/** * Example usage. * * @param args String[], args[0] - read from filename, args[1] write to filename * @throws Exception */ public static void main(String[] args) throws Exception, RemoteException, RemoteException { startManagers(); System.out.println("Usage: FileMessageFactory fileToBeRead fileToBeWritten"); System.out.println("Usage: This will make a copy of the file on the local file system"); FileMessageFactoryRemoteInterface read = getInstance(new File(args[0]), false); FileMessageFactoryRemoteInterface write = getInstance(new File(args[1]), true); FileMessageRemoteInterface msg = gerenciadornuvem1.getFileMessage(null, args[0], args[0]); msg = read.readMessage(msg); if (msg == null) { System.out.println("Empty input file : " + args[0]); return; } System.out.println("Expecting to write " + msg.getTotalNrOfMsgs() + " messages."); int cnt = 0; while (msg != null) { write.writeMessage(msg); cnt++; msg = read.readMessage(msg); } // while System.out.println("Actually wrote " + cnt + " messages."); }
@Override public void visit(org.apache.jasper.compiler.NodeTemplateTextRemoteInterface n) throws JasperException, RemoteException { try { org.apache.jasper.compiler.MarkRemoteInterface mark = n.getStart(); if (mark == null) { return; } // Add the file information String fileName = mark.getFile(); smap.addFile(gerenciadornuvem1.SmapUtilunqualify(fileName), fileName); // Add a LineInfo that corresponds to the beginning of this node int iInputStartLine = mark.getLineNumber(); int iOutputStartLine = n.getBeginJavaLine(); int iOutputLineIncrement = breakAtLF ? 1 : 0; smap.addLineData(iInputStartLine, fileName, 1, iOutputStartLine, iOutputLineIncrement); // Output additional mappings in the text java.util.ArrayList<Integer> extraSmap = n.getExtraSmap(); if (extraSmap != null) { for (int i = 0; i < extraSmap.size(); i++) { iOutputStartLine += iOutputLineIncrement; smap.addLineData( iInputStartLine + extraSmap.get(i).intValue(), fileName, 1, iOutputStartLine, iOutputLineIncrement); } } } catch (Exception excp) { excp.printStackTrace(); } }
public void doSmap( org.apache.jasper.compiler.NodeRemoteInterface n, int inLineCount, int outIncrement, int skippedLines) throws RemoteException { try { org.apache.jasper.compiler.MarkRemoteInterface mark = n.getStart(); if (mark == null) { return; } String unqualifiedName = gerenciadornuvem1.SmapUtilunqualify(mark.getFile()); smap.addFile(unqualifiedName, mark.getFile()); smap.addLineData( mark.getLineNumber() + skippedLines, mark.getFile(), inLineCount - skippedLines, n.getBeginJavaLine() + skippedLines, outIncrement); } catch (Exception excp) { excp.printStackTrace(); } }