Java源码示例:java.io.Serializable

示例1
@Override
public void open(final Serializable checkpoint) throws Exception {
    final BeanLocator beanLocator = BeanLocator.Finder.get(locator);

    emProvider = findEntityManager();
    if (parameterProvider != null) {
        paramProvider = beanLocator.newInstance(ParameterProvider.class, parameterProvider);
    }
    if (pageSize != null) {
        page = Integer.parseInt(pageSize, page);
    }
    if (namedQuery == null && query == null) {
        throw new BatchRuntimeException("a query should be provided");
    }
    detach = Boolean.parseBoolean(detachEntities);
    transaction = Boolean.parseBoolean(jpaTransaction);
}
 
示例2
@Test
public void testSetType() throws Exception
{
    NodeRef nodeRef = nodeService.createNode(
            rootNodeRef,
            ASSOC_TYPE_QNAME_TEST_CHILDREN,
            QName.createQName("setTypeTest"),
            TYPE_QNAME_TEST_CONTENT).getChildRef();
    assertEquals(TYPE_QNAME_TEST_CONTENT, this.nodeService.getType(nodeRef));
    
    assertNull(this.nodeService.getProperty(nodeRef, PROP_QNAME_PROP1));
    
    // Now change the type
    this.nodeService.setType(nodeRef, TYPE_QNAME_EXTENDED_CONTENT);
    assertEquals(TYPE_QNAME_EXTENDED_CONTENT, this.nodeService.getType(nodeRef));
    
    // Check new defaults
    Serializable defaultValue = this.nodeService.getProperty(nodeRef, PROP_QNAME_PROP1);
    assertNotNull("No default property value assigned", defaultValue);
    assertEquals(DEFAULT_VALUE, defaultValue);
}
 
示例3
/**
 * Return the query results, using the query cache, called
 * by subclasses that implement cacheable queries
 * @see QueryLoader#list(SharedSessionContractImplementor, QueryParameters, Set, Type[])
 */
protected CompletionStage<List<Object>> reactiveList(
		final SessionImplementor session,
		final QueryParameters queryParameters,
		final Set<Serializable> querySpaces,
		final Type[] resultTypes) throws HibernateException {

	final boolean cacheable = factory.getSessionFactoryOptions().isQueryCacheEnabled()
			&& queryParameters.isCacheable();

	if ( cacheable ) {
		return reactiveListUsingQueryCache( getSQLString(), getQueryIdentifier(), session, queryParameters, querySpaces, resultTypes );
	}
	else {
		return reactiveListIgnoreQueryCache( getSQLString(), getQueryIdentifier(), session, queryParameters );
	}
}
 
示例4
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == RESULT_OK) {
        Bundle bundle = data.getExtras();
        String scanResult = bundle.getString("result");
        if (TextUtils.isEmpty(scanResult))
        {
            Toast.makeText(this, "Scan Content is Null", Toast.LENGTH_SHORT).show();
            return;
        }

        FloatingPlayer.getInstance().destroy();
        Intent intent = new Intent(this, LiveDisplayActivity.class);
        intent.putExtra(Ids.PLAY_ID, -1);
        Ids.playingId = -1;
        intent.putExtra(Ids.VIDEO_LIST, (Serializable) videoList);
        intent.putExtra(Ids.PLAY_URL, scanResult);
        startActivity(intent);
    }
}
 
示例5
@Override
protected int bindParameterValues(
		PreparedStatement statement,
		QueryParameters queryParameters,
		int startIndex,
		SharedSessionContractImplementor session) throws SQLException {
	final Serializable optionalId = queryParameters.getOptionalId();
	if ( optionalId != null ) {
		paramValueBinders.get( 0 ).bind( statement, queryParameters, session, startIndex );
		return session.getFactory().getMetamodel()
				.entityPersister( queryParameters.getOptionalEntityName() )
				.getIdentifierType()
				.getColumnSpan( session.getFactory() );
	}

	int span = 0;
	for ( ParameterBinder paramValueBinder : paramValueBinders ) {
		span += paramValueBinder.bind(
				statement,
				queryParameters,
				session,
				startIndex + span
		);
	}
	return span;
}
 
示例6
protected void saveInternal(ObjectOutputStream s, String k) throws IOException {
    if (a instanceof AWTEventMulticaster) {
        ((AWTEventMulticaster)a).saveInternal(s, k);
    }
    else if (a instanceof Serializable) {
        s.writeObject(k);
        s.writeObject(a);
    }

    if (b instanceof AWTEventMulticaster) {
        ((AWTEventMulticaster)b).saveInternal(s, k);
    }
    else if (b instanceof Serializable) {
        s.writeObject(k);
        s.writeObject(b);
    }
}
 
示例7
public int put(String indexName, String type, Serializable object, String id) throws IOException {
    String url = "http://" + esHost + ":" + esPort + "/" + indexName + "/" + type + "/" + id;
    if (esHost == null) {
        log.warn("ES host not set as system property");
        return 400;
    }

    RequestBody body = RequestBody.create(JSON, gson.toJson(object));
    Request request = new Request.Builder()
            .url(url)
            .put(body)
            .build();

    Response response = client.newCall(request).execute();
    String responseBody = response.body().string();
    int responseCode = response.code();
    log.info("ES response body for PUT: " + responseBody + ", code: " + responseCode);

    if (responseCode >= 300) {
        log.error("Error for url : " + url + " body: " + gson.toJson(object));
        throw new IOException("Error code returned by ES: " + responseCode + " with response body: " + responseBody);
    }

    return responseCode;
}
 
示例8
private SaltConfig createSaltConfig(Stack stack, Cluster cluster, GatewayConfig primaryGatewayConfig, Iterable<GatewayConfig> gatewayConfigs,
        Set<Node> nodes)
        throws IOException, CloudbreakOrchestratorException {
    Map<String, SaltPillarProperties> servicePillar = new HashMap<>();
    KerberosConfig kerberosConfig = kerberosConfigService.get(stack.getEnvironmentCrn(), stack.getName()).orElse(null);
    saveCustomNameservers(stack, kerberosConfig, servicePillar);
    addKerberosConfig(servicePillar, kerberosConfig);
    servicePillar.put("discovery", new SaltPillarProperties("/discovery/init.sls", singletonMap("platform", stack.cloudPlatform())));
    String virtualGroupsEnvironmentCrn = environmentConfigProvider.getParentEnvironmentCrn(stack.getEnvironmentCrn());
    boolean deployedInChildEnvironment = !virtualGroupsEnvironmentCrn.equals(stack.getEnvironmentCrn());
    Map<String, ? extends Serializable> clusterProperties = Map.of("name", stack.getCluster().getName(),
            "deployedInChildEnvironment", deployedInChildEnvironment);
    servicePillar.put("metadata", new SaltPillarProperties("/metadata/init.sls", singletonMap("cluster", clusterProperties)));
    ClusterPreCreationApi connector = clusterApiConnectors.getConnector(cluster);
    Map<String, List<String>> serviceLocations = getServiceLocations(cluster);
    Optional<LdapView> ldapView = ldapConfigService.get(stack.getEnvironmentCrn(), stack.getName());
    VirtualGroupRequest virtualGroupRequest = getVirtualGroupRequest(virtualGroupsEnvironmentCrn, ldapView);
    saveGatewayPillar(primaryGatewayConfig, cluster, servicePillar, virtualGroupRequest, connector, kerberosConfig, serviceLocations);

    postgresConfigService.decorateServicePillarWithPostgresIfNeeded(servicePillar, stack, cluster);

    if (blueprintService.isClouderaManagerTemplate(cluster.getBlueprint())) {
        addClouderaManagerConfig(stack, cluster, servicePillar);
    }
    ldapView.ifPresent(ldap -> saveLdapPillar(ldap, servicePillar));

    saveSssdAdPillar(cluster, servicePillar, kerberosConfig);
    saveSssdIpaPillar(servicePillar, kerberosConfig, serviceLocations);
    saveDockerPillar(cluster.getExecutorType(), servicePillar);

    proxyConfigProvider.decoratePillarWithProxyDataIfNeeded(servicePillar, cluster);

    decoratePillarWithJdbcConnectors(cluster, servicePillar);

    return new SaltConfig(servicePillar, grainPropertiesService.createGrainProperties(gatewayConfigs, cluster, nodes));
}
 
示例9
public void testCtorRef() throws IOException, ClassNotFoundException {
    @SuppressWarnings("unchecked")
    Supplier<ForCtorRef> ctor = (Supplier<ForCtorRef> & Serializable) ForCtorRef::new;
    Consumer<Supplier<ForCtorRef>> b = s -> {
        assertTrue(s instanceof Serializable);
        ForCtorRef m = s.get();
        assertTrue(m.startsWithB("barf"));
        assertFalse(m.startsWithB("arf"));
    };
    assertSerial(ctor, b);
}
 
示例10
public void assertDeserialized(Serializable initial,
        Serializable deserialized) {

    SerializationTest.THROWABLE_COMPARATOR.assertDeserialized(initial,
            deserialized);

    UnknownFormatConversionException initEx = (UnknownFormatConversionException) initial;
    UnknownFormatConversionException desrEx = (UnknownFormatConversionException) deserialized;

    assertEquals("Conversion", initEx.getConversion(), desrEx
            .getConversion());
}
 
示例11
/**
 * The LoopVertex constructor.
 * @param compositeTransformFullName full name of the composite transform.
 */
public LoopVertex(final String compositeTransformFullName) {
  super();
  this.builder = new DAGBuilder<>();
  this.compositeTransformFullName = compositeTransformFullName;
  this.dagIncomingEdges = new HashMap<>();
  this.iterativeIncomingEdges = new HashMap<>();
  this.nonIterativeIncomingEdges = new HashMap<>();
  this.dagOutgoingEdges = new HashMap<>();
  this.edgeWithLoopToEdgeWithInternalVertex = new HashMap<>();
  this.edgeWithInternalVertexToEdgeWithLoop = new HashMap<>();
  this.maxNumberOfIterations = 1; // 1 is the default number of iterations.
  this.terminationCondition = (IntPredicate & Serializable) (integer -> false); // nothing much yet.
}
 
示例12
@SuppressWarnings("unchecked")
private Optional<T> deserialize(String serializer, AttributeValue<?> value) {
    try {
        Class<?> deserializerClass = Class.forName(serializer);
        if (ArbitrarySerializable.Deserializer.class.isAssignableFrom(deserializerClass)) {
            ArbitrarySerializable.Deserializer<T> deserializer = (ArbitrarySerializable.Deserializer<T>) deserializerClass.newInstance();
            return deserializer.deserialize(new ArbitrarySerializable.Serializable<>(value, (Class<ArbitrarySerializable.Deserializer<T>>) deserializerClass));
        }
    } catch (Exception e) {
        LOGGER.error("Error while deserializing using serializer {} and value {}", serializer, value, e);
    }

    return Optional.empty();
}
 
示例13
/**
 * Writes default serializable fields to stream.  Writes
 * an optional serializable icon <code>Image</code>, which is
 * available as of 1.4.
 *
 * @param s the <code>ObjectOutputStream</code> to write
 * @serialData an optional icon <code>Image</code>
 * @see java.awt.Image
 * @see #getIconImage
 * @see #setIconImage(Image)
 * @see #readObject(ObjectInputStream)
 */
private void writeObject(ObjectOutputStream s)
  throws IOException
{
    s.defaultWriteObject();
    if (icons != null && icons.size() > 0) {
        Image icon1 = icons.get(0);
        if (icon1 instanceof Serializable) {
            s.writeObject(icon1);
            return;
        }
    }
    s.writeObject(null);
}
 
示例14
public static byte[] hessianSerialize(Serializable obj) throws IOException {
	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	HessianOutput ho = new HessianOutput(baos);
	try {
		ho.writeObject(obj);
		return baos.toByteArray();
	} finally {
		CommonUtils.closeQuietly(baos);
	}

}
 
示例15
public Serializable getRoutingObject(EntryOperation opDetails) {
  Serializable key = (Serializable)opDetails.getKey();
  if (key instanceof CustomerId) {
    return key;
  } else if (key instanceof OrderId) {
    return ((OrderId)key).getCustId();
  }
  return null;
}
 
示例16
/**
* {@inheritDoc}
*/
@Override
protected Object handleTaskProperty(Task task, TypeDefinition type, QName key, Serializable value)
{
    //Task assignment needs to be done after setting all properties
    // so it is handled in ActivitiPropertyConverter.
    return DO_NOT_ADD;
}
 
示例17
/**
 * Gets a map containing the site's custom properties
 * 
 * @return  map containing the custom properties of the site
 */
private Map<QName, Serializable> getSiteCustomProperties(Map<QName, Serializable> properties)
{
    Map<QName, Serializable> customProperties = new HashMap<QName, Serializable>(4);
    
    for (Map.Entry<QName, Serializable> entry : properties.entrySet())                
    {
        if (entry.getKey().getNamespaceURI().equals(SITE_CUSTOM_PROPERTY_URL) == true)
        {                
            customProperties.put(entry.getKey(), entry.getValue());
        }
    }  
    
    return customProperties;
}
 
示例18
@Override
public final String getDefaultValue() {
	
	class InnerClass1 {
		InnerClass1() {}
		void foo() {}			
	};
	
	Serializable s = new Serializable() {
		void foo() {}
	};

	return defaultValue;
}
 
示例19
public static void cropPhoto(Context context, Map<String, Object> map, ActivityResultListener listener) {
    FactoryHelperActivity.mActivityResultListener = listener;

    Intent intent = new Intent(context, FactoryHelperActivity.class);
    intent.putExtra(KEY_JOB, JOB_CROP_PHOTO);
    intent.putExtra(KEY_PARAM, (Serializable) map);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}
 
示例20
protected Serializable snapshot(BasicCollectionPersister persister, EntityMode entityMode) 
throws HibernateException {
	//if (set==null) return new Set(session);
	TreeMap clonedSet = new TreeMap(comparator);
	Iterator iter = set.iterator();
	while ( iter.hasNext() ) {
		Object copy = persister.getElementType().deepCopy( iter.next(), entityMode, persister.getFactory() );
		clonedSet.put(copy, copy);
	}
	return clonedSet;
}
 
示例21
/**
 * reads the newly created MainObject
 * and its Object2 if it exists
 * <p/>
 * one hibernate transaction
 */
private MainObject readMainObject() throws HibernateException {
	Long returnId = null;
	Session session = openSession();
	Transaction tx = session.beginTransaction();

	Serializable id = generatedId;

	MainObject mo = ( MainObject ) session.load( MainObject.class, id );

	tx.commit();
	session.close();

	return mo;
}
 
示例22
/**
 * entity id accessor
 *
 * @return The entity id
 */
public final Serializable getId() {
	if ( id instanceof DelayedPostInsertIdentifier ) {
		return session.getPersistenceContext().getEntry( instance ).getId();
	}
	return id;
}
 
示例23
public void setCubeSegmentStatisticsList(
        List<QueryContext.CubeSegmentStatisticsResult> cubeSegmentStatisticsList) {
    try {
        this.queryStatistics = cubeSegmentStatisticsList == null ? null
                : SerializationUtils.serialize((Serializable) cubeSegmentStatisticsList);
    } catch (Exception e) { // serialize exception should not block query
        logger.warn("Error while serialize queryStatistics due to " + e);
        this.queryStatistics = null;
    }
}
 
示例24
/**
 * Custom deserialization routine used during deserialization of a
 * Session/PersistenceContext for increased performance.
 *
 * @param ois The stream from which to read the entry.
 * @param session The session being deserialized.
 * @return The deserialized CollectionKey
 * @throws IOException
 * @throws ClassNotFoundException
 */
static CollectionKey deserialize(
		ObjectInputStream ois,
        SessionImplementor session) throws IOException, ClassNotFoundException {
	return new CollectionKey(
			( String ) ois.readObject(),
	        ( Serializable ) ois.readObject(),
	        ( Type ) ois.readObject(),
	        EntityMode.parse( ( String ) ois.readObject() ),
	        session.getFactory()
	);
}
 
示例25
public void addSelection(Rectangle range) {
	selectionsLock.writeLock().lock();

	try {
		if (range == lastSelectedRange) {
			// Unselect all previously selected rowIds
			if (lastSelectedRowIds != null) {
				for (Serializable rowId : lastSelectedRowIds) {
					selectedRows.remove(rowId);
				}
			}
		}

		int rowPosition = range.y;
		int length = range.height;
		
		int[] rowIndexs = new int[length];
		Set<Integer> rowsToSelect = new HashSet<Integer>();
		for (int i = 0; i < rowIndexs.length; i++) {
			rowsToSelect.add(rowPosition + i);
		}

		selectedRows.addAll(rowsToSelect);

		if (range == lastSelectedRange) {
			lastSelectedRowIds = rowsToSelect;
		} else {
			lastSelectedRowIds = null;
		}

		lastSelectedRange = range;
	} finally {
		selectionsLock.writeLock().unlock();
	}
}
 
示例26
@Override
protected void setUp() throws Exception
{
    valueList = new ArrayList<String>(4);
    valueList.add("ONE");
    valueList.add("TWO");
    valueList.add("THREE");
    valueList.add("FOUR");
    valueList = Collections.unmodifiableList(valueList);
    
    valueMap = new HashMap<String, String>(5);
    valueMap.put("ONE", "ONE");
    valueMap.put("TWO", "TWO");
    valueMap.put("THREE", "THREE");
    valueMap.put("FOUR", "FOUR");
    valueMap = Collections.unmodifiableMap(valueMap);
    
    valueDate = new Date();
    
    valueImmutable = new TestImmutable();
    valueMutable = new TestMutable();
    
    holyMap = new HashMap<String, Serializable>();
    holyMap.put("DATE", valueDate);
    holyMap.put("LIST", (Serializable) valueList);
    holyMap.put("MAP", (Serializable) valueMap);
    holyMap.put("IMMUTABLE", valueImmutable);
    holyMap.put("MUTABLE", valueMutable);
    
    // Now wrap our 'holy' map so that it cannot be modified
    holyMap = Collections.unmodifiableMap(holyMap);
    
    map = new ValueProtectingMap<String, Serializable>(holyMap, moreImmutableClasses);
}
 
示例27
/**
 * Performs a deep copy of the given object. This method is preferable to
 * the more general version because that relies on the object having a
 * default (zero-argument) constructor; however, this method only works for
 * serializable objects.
 *
 * @param <T> the type of the object to copy and return
 * @param original the object to copy
 * @return a deep copy of the given object
 */
public static <T extends Serializable> T deepCopy(T original) {
    if (original == null) {
        return null;
    }
    try {
        return SerializationUtils.clone(original);
    } catch (SerializationException notSerializable) {
        return (T) deepCopy((Object) original);
    }
}
 
示例28
public void testSimpleSerializedInstantiation2() throws IOException, ClassNotFoundException {
    SerPredicate<String> serPred = (SerPredicate<String>) s -> true;
    assertSerial(serPred,
                 p -> {
                     assertTrue(p instanceof Predicate);
                     assertTrue(p instanceof Serializable);
                     assertTrue(p instanceof SerPredicate);
                     assertTrue(p.test(""));
                 });
}
 
示例29
@Override
@SuppressWarnings("unchecked")
public Map convertFrom(Map source, Map destination) {
    if (source == null) {
        return null;
    }
    Map<String, String> converted = new HashMap<>();
    for (Map.Entry<String, Serializable> entry : ((Map<String, Serializable>) source).entrySet()) {
        if (entry.getValue() != null) {
            converted.put(entry.getKey(), entry.getValue().toString());
        }

    }
    return converted;
}
 
示例30
/**
 * Create an audit item
 * @param appInfo The audit application to create the item for.
 * @param value The value that will be stored against the path /a/b/c
 */
private void createItem(final AuditApplicationInfo appInfo, final int value)
{
    String username = "alexi";    
    Map<String, Serializable> values = Collections.singletonMap("/a/b/c", (Serializable) value);
    long now = System.currentTimeMillis();
    auditDAO.createAuditEntry(appInfo.getId(), now, username, values);
}