java.io.Serializable Java Examples

The following examples show how to use java.io.Serializable. 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: JpaItemReader.java    From incubator-batchee with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #2
Source File: AWTEventMulticaster.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example #3
Source File: LiveMainActivity.java    From KSYMediaPlayer_Android with Apache License 2.0 6 votes vote down vote up
@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);
    }
}
 
Example #4
Source File: CustomLoader.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@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;
}
 
Example #5
Source File: ReactiveQueryLoader.java    From hibernate-reactive with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * 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 );
	}
}
 
Example #6
Source File: BaseNodeServiceTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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);
}
 
Example #7
Source File: SearchDal.java    From oneops with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #8
Source File: LoopVertex.java    From nemo with Apache License 2.0 5 votes vote down vote up
/**
 * 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.
}
 
Example #9
Source File: UnknownFormatConversionExceptionTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
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());
}
 
Example #10
Source File: SerializedLambdaTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example #11
Source File: SiteServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #12
Source File: ClusterHostServiceRunner.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
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));
}
 
Example #13
Source File: AuditDAOTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #14
Source File: ActivitiOwnerPropertyHandler.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
* {@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;
}
 
Example #15
Source File: Serializer.java    From james-project with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example #16
Source File: Frame.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #17
Source File: FavListFragment.java    From AndroidReview with GNU General Public License v3.0 5 votes vote down vote up
private Test readTestCache(int testId) {
    Serializable seri = CacheHelper.readObject(getContext(), CacheHelper.TEST + testId);
    if (seri == null) {
        return null;
    } else {
        return (Test) seri;
    }
}
 
Example #18
Source File: CustomerOrderResolver.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #19
Source File: StringResultMapCustomConverter.java    From scheduling with GNU Affero General Public License v3.0 5 votes vote down vote up
@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;
}
 
Example #20
Source File: EntityAction.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * entity id accessor
 *
 * @return The entity id
 */
public final Serializable getId() {
	if ( id instanceof DelayedPostInsertIdentifier ) {
		return session.getPersistenceContext().getEntry( instance ).getId();
	}
	return id;
}
 
Example #21
Source File: ConfigKey.java    From steady with Apache License 2.0 5 votes vote down vote up
@Override
public final String getDefaultValue() {
	
	class InnerClass1 {
		InnerClass1() {}
		void foo() {}			
	};
	
	Serializable s = new Serializable() {
		void foo() {}
	};

	return defaultValue;
}
 
Example #22
Source File: SerializedLambdaTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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(""));
                 });
}
 
Example #23
Source File: Utils.java    From RobotBuilder with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example #24
Source File: ValueProtectingMapTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example #25
Source File: FactoryHelperActivity.java    From PhotoFactory with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #26
Source File: TmxEditorRowSelectionModel.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
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();
	}
}
 
Example #27
Source File: CollectionKey.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 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()
	);
}
 
Example #28
Source File: SQLResponse.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
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;
    }
}
 
Example #29
Source File: PersistentSortedSet.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
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;
}
 
Example #30
Source File: OneToOneCacheTest.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 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;
}