Java Code Examples for java.io.ObjectInputStream#readUTF()

The following examples show how to use java.io.ObjectInputStream#readUTF() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HadoopOutputFormatBase.java    From flink with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
	super.read(in);
	String hadoopOutputFormatClassName = in.readUTF();

	org.apache.hadoop.conf.Configuration configuration = new org.apache.hadoop.conf.Configuration();
	configuration.readFields(in);

	if (this.configuration == null) {
		this.configuration = configuration;
	}

	try {
		this.mapreduceOutputFormat = (org.apache.hadoop.mapreduce.OutputFormat<K, V>) Class.forName(hadoopOutputFormatClassName, true, Thread.currentThread().getContextClassLoader()).newInstance();
	} catch (Exception e) {
		throw new RuntimeException("Unable to instantiate the hadoop output format", e);
	}
}
 
Example 2
Source File: SessionFactoryImpl.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Custom deserialization hook used during Session deserialization.
 *
 * @param ois The stream from which to "read" the factory
 * @throws IOException
 */
static SessionFactoryImpl deserialize(ObjectInputStream ois) throws IOException, ClassNotFoundException {
	String uuid = ois.readUTF();
	boolean isNamed = ois.readBoolean();
	String name = null;
	if ( isNamed ) {
		name = ois.readUTF();
	}
	Object result = SessionFactoryObjectFactory.getInstance( uuid );
	if ( result == null ) {
		log.trace( "could not locate session factory by uuid [" + uuid + "] during session deserialization; trying name" );
		if ( isNamed ) {
			result = SessionFactoryObjectFactory.getNamedInstance( name );
		}
		if ( result == null ) {
			throw new InvalidObjectException( "could not resolve session factory during session deserialization [uuid=" + uuid + ", name=" + name + "]" );
		}
	}
	return ( SessionFactoryImpl ) result;
}
 
Example 3
Source File: HCatInputFormatBase.java    From flink with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
	this.fieldNames = new String[in.readInt()];
	for (int i = 0; i < this.fieldNames.length; i++) {
		this.fieldNames[i] = in.readUTF();
	}

	Configuration configuration = new Configuration();
	configuration.readFields(in);

	if (this.configuration == null) {
		this.configuration = configuration;
	}

	this.hCatInputFormat = new org.apache.hive.hcatalog.mapreduce.HCatInputFormat();
	this.outputSchema = (HCatSchema) HCatUtil.deserialize(this.configuration.get("mapreduce.lib.hcat.output.schema"));
}
 
Example 4
Source File: FieldSerializer.java    From flink with Apache License 2.0 6 votes vote down vote up
public static Field deserializeField(ObjectInputStream in) throws IOException, ClassNotFoundException  {
	Class<?> clazz = (Class<?>) in.readObject();
	String fieldName = in.readUTF();
	// try superclasses as well
	while (clazz != null) {
		try {
			Field field = clazz.getDeclaredField(fieldName);
			field.setAccessible(true);
			return field;
		} catch (NoSuchFieldException e) {
			clazz = clazz.getSuperclass();
		}
	}

	return null;
}
 
Example 5
Source File: Level.java    From logging-log4j2 with Apache License 2.0 5 votes vote down vote up
/**
 * Custom deserialization of Level.
 *
 * @param s serialization stream.
 * @throws IOException            if IO exception.
 * @throws ClassNotFoundException if class not found.
 */
private void readObject(final ObjectInputStream s) throws IOException, ClassNotFoundException {
    s.defaultReadObject();
    level = s.readInt();
    syslogEquivalent = s.readInt();
    levelStr = s.readUTF();
    if (levelStr == null) {
        levelStr = Strings.EMPTY;
    }
}
 
Example 6
Source File: ShellLaunchManager.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void processHandshake(SocketChannel accepted) throws IOException {
    accepted.configureBlocking(true);
    Socket sock = accepted.socket();
    sock.setSoTimeout(HANDSHAKE_TIMEOUT);
    
    ObjectInputStream is = new ObjectInputStream(sock.getInputStream());
    String authorizationKey = is.readUTF();
    LOG.log(Level.FINE, "Approaching agent with authorization key: {0}", authorizationKey);
    ShellAgent agent;
    
    synchronized (ShellLaunchManager.this) {
        agent = registeredAgents.get(authorizationKey);
    }
    if (agent == null) {
        LOG.log(Level.INFO, "Connection on Java Shell agent port with improper authorization ({0}) from {1}", new Object[] {
            authorizationKey,
            sock
        });
        return;
    }
    
    // read the port
    int targetPort = is.readInt();
    InetSocketAddress connectTo = new InetSocketAddress(
            ((InetSocketAddress)sock.getRemoteSocketAddress()).getAddress(), targetPort);
    
    agent.target(connectTo);
}
 
Example 7
Source File: StringFormattedMessage.java    From logging-log4j2 with Apache License 2.0 5 votes vote down vote up
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
    in.defaultReadObject();
    formattedMessage = in.readUTF();
    messagePattern = in.readUTF();
    final int length = in.readInt();
    stringArgs = new String[length];
    for (int i = 0; i < length; ++i) {
        stringArgs[i] = in.readUTF();
    }
}
 
Example 8
Source File: ProcessInstanceResolverStrategy.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
public Object read(ObjectInputStream is) throws IOException,
                                        ClassNotFoundException {
    String processInstanceId = is.readUTF();
    ProcessInstanceManager pim = retrieveProcessInstanceManager( is );
    ProcessInstance processInstance = pim.getProcessInstance( processInstanceId );
    if (processInstance == null) {
    	RuleFlowProcessInstance result = new RuleFlowProcessInstance();
    	result.setId( processInstanceId );
    	result.internalSetState(ProcessInstance.STATE_COMPLETED);
    	return result;
    } else {
    	connectProcessInstanceToRuntimeAndProcess( processInstance, is );
        return processInstance;
    }
}
 
Example 9
Source File: SerializeDataSources.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Attempts to read information from a file assumed to contain a
 * serialized data source.
 * <p>
 * All information is printed to the console.
 *
 * @param fileName the name of the file to read from
 * @return {@code true} if the file was read successfully, {@code false} if
 *      something went wrong.
 */
private static boolean printInfoFromSerializedFile(String fileName) {
    System.out.println(">>> File: " + fileName);
    File file = new File(fileName);
    if (!file.exists()) {
        System.out.println("\tFile does not exist.");
        return false;
    }
    if (!file.canRead()) {
        System.out.println("\tCannot read file.");
        return false;
    }
    try {
        InputStream is = new FileInputStream(file);
        ObjectInputStream ois = new ObjectInputStream(is);
        String version = ois.readUTF();
        System.out.println("\tversion: " + version);
        String buildNr = ois.readUTF();
        System.out.println("\tbuild  : " + buildNr);
        Object obj = ois.readObject();
        System.out.println("\tobject : " + obj);
        obj = ois.readObject();
        System.out.println("\tobject : " + obj);
    } catch (Exception e) {
        System.out.println("\t!! De-serialization failed: " + e.getMessage());
        e.printStackTrace();
        return false;
    }
    return true; 
}
 
Example 10
Source File: Triple.java    From metafacture-core with Apache License 2.0 5 votes vote down vote up
public static Triple read(final ObjectInputStream in) throws IOException {
    try {
        return new Triple(in.readUTF(), in.readUTF(), in.readUTF(),
                (ObjectType) in.readObject());
    } catch (final ClassNotFoundException e) {
        throw new IOException("Cannot read triple", e);
    }
}
 
Example 11
Source File: RichTranslation.java    From phrasal with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Custom deserializer.
 * 
 * @param ois
 * @throws ClassNotFoundException
 * @throws IOException
 */
@SuppressWarnings("unchecked")
private void readObject(ObjectInputStream ois)
    throws ClassNotFoundException, IOException {
  ois.defaultReadObject();
  this.latticeSourceId = ois.readLong();
  this.score = ois.readDouble();
  this.source = (Sequence<TK>) IStrings.tokenize(ois.readUTF());
  this.translation = (Sequence<TK>) IStrings.tokenize(ois.readUTF());
  this.f2eAlignment = ois.readUTF();
  this.features = (FeatureValueCollection<FV>) ois.readObject();
}
 
Example 12
Source File: TimerData.java    From tomee with Apache License 2.0 5 votes vote down vote up
protected void doReadObject(final ObjectInputStream in) throws IOException {
    id = in.readLong();
    deploymentId = in.readUTF();
    persistent = in.readBoolean();
    autoScheduled = in.readBoolean();

    try {
        timer = (Timer) in.readObject();
        primaryKey = in.readObject();
        timerService = (EjbTimerServiceImpl) in.readObject();
        info = in.readObject();
        trigger = AbstractTrigger.class.cast(in.readObject());
    } catch (final ClassNotFoundException e) {
        throw new IOException(e);
    }

    final String mtd = in.readUTF();
    final BeanContext beanContext = SystemInstance.get().getComponent(ContainerSystem.class).getBeanContext(deploymentId);
    scheduler = timerService.getScheduler();
    for (final Iterator<Map.Entry<Method, MethodContext>> it = beanContext.iteratorMethodContext(); it.hasNext(); ) {
        final MethodContext methodContext = it.next().getValue();
        /* this doesn't work in all cases
        if (methodContext.getSchedules().isEmpty()) {
            continue;
        }
        */

        final Method method = methodContext.getBeanMethod();
        if (method != null && method.getName().equals(mtd)) { // maybe we should check parameters too
            setTimeoutMethod(method);
            break;
        }
    }
}
 
Example 13
Source File: Cardumen_00189_t.java    From coming with MIT License 4 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException {
    iID = in.readUTF();
}
 
Example 14
Source File: Time_8_DateTimeZone_s.java    From coming with MIT License 4 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException {
    iID = in.readUTF();
}
 
Example 15
Source File: MonitoredNumbersResponse.java    From netbeans with Apache License 2.0 4 votes vote down vote up
void readObject(ObjectInputStream in) throws IOException {
    int arrSize;

    mode = in.readInt();
    for (int i = 0; i < generalNumbers.length; i++) {
        generalNumbers[i] = in.readLong();
    }

    if (mode == CommonConstants.MODE_THREADS_SAMPLING) {
        nThreads = in.readInt();
        nThreadStates = in.readInt();
        if (threadIds.length < nThreads) {
            threadIds = new int[nThreads];
        }
        if (stateTimestamps.length < nThreadStates) {
            stateTimestamps = new long[nThreadStates];
        }
        
        int len = nThreads * nThreadStates;
        
        if (threadStates.length < len) {
            threadStates = new byte[len];
        }
        for (int i = 0; i < nThreads; i++) {
            threadIds[i] = in.readInt();
        }
        for (int i = 0; i < nThreadStates; i++) {
            stateTimestamps[i] = in.readLong();
        }
        in.readFully(threadStates, 0, len);
    }  else if (mode == CommonConstants.MODE_THREADS_EXACT) {
        int exactLen = in.readInt();
        exactThreadIds = new int[exactLen];
        exactThreadStates = new byte[exactLen];
        exactTimeStamps = new long[exactLen];
        
        for (int i = 0; i < exactLen; i++) {
            exactThreadIds[i] = in.readInt();
            exactThreadStates[i] = in.readByte();
            exactTimeStamps[i] = in.readLong();
        }
    }

    nNewThreads = in.readInt();

    if (nNewThreads > 0) {
        if ((newThreadIds == null) || (newThreadIds.length < nNewThreads)) {
            newThreadIds = new int[nNewThreads];
            newThreadNames = new String[nNewThreads];
            newThreadClassNames = new String[nNewThreads];
        }

        for (int i = 0; i < nNewThreads; i++) {
            newThreadIds[i] = in.readInt();
            newThreadNames[i] = in.readUTF();
            newThreadClassNames[i] = in.readUTF();
        }
    }

    arrSize = in.readInt();
    gcStarts = new long[arrSize];

    for (int i = 0; i < arrSize; i++) {
        gcStarts[i] = in.readLong();
    }

    arrSize = in.readInt();
    gcFinishs = new long[arrSize];

    for (int i = 0; i < arrSize; i++) {
        gcFinishs[i] = in.readLong();
    }

    Arrays.sort(gcStarts);
    Arrays.sort(gcFinishs);

    serverState = in.readInt();
    serverProgress = in.readInt();
}
 
Example 16
Source File: Nopol2017_0089_t.java    From coming with MIT License 4 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException {
    iID = in.readUTF();
}
 
Example 17
Source File: Time_17_DateTimeZone_t.java    From coming with MIT License 4 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException {
    iID = in.readUTF();
}
 
Example 18
Source File: AsyncMessageCommand.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
void readObject(ObjectInputStream in) throws IOException {
    positive = in.readBoolean();
    message = in.readUTF();
}
 
Example 19
Source File: ContinuationPtr.java    From groovy-cps with Apache License 2.0 4 votes vote down vote up
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
    Class c = (Class)ois.readObject();
    String methodName = ois.readUTF();
    resolveMethod(c,methodName);
}
 
Example 20
Source File: Time_17_DateTimeZone_s.java    From coming with MIT License 4 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException {
    iID = in.readUTF();
}