当前位置: 首页>>代码示例>>Java>>正文


Java Serializable类代码示例

本文整理汇总了Java中java.io.Serializable的典型用法代码示例。如果您正苦于以下问题:Java Serializable类的具体用法?Java Serializable怎么用?Java Serializable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Serializable类属于java.io包,在下文中一共展示了Serializable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSubProcessCallActivity

import java.io.Serializable; //导入依赖的package包/类
/**
 * ALF-15939: Call-activity should be multi-tenant aware.
 */
public void testSubProcessCallActivity() throws Exception
{
	// Run as User1 so tenant domain 1
    AuthenticationUtil.setFullyAuthenticatedUser(user1);
    
    // Deploy called sub-process on tenant domain 1
    InputStream input = getInputStream(CALLACTIVITY_SUBPROCESS_LOCATION);
    WorkflowDeployment deployment = workflowService.deployDefinition(getEngine(), input, XML);
    
    // Deploy called main-process on tenant domain 1
    input = getInputStream(CALLACTIVITY_MAINPROCESS_LOCATION);
    deployment = workflowService.deployDefinition(getEngine(), input, XML);
    WorkflowDefinition mainProcessDefinition = deployment.getDefinition();
    
    // Start a process, which immediately tries to call the sub-process before returning control to thread
    try {
    	workflowService.startWorkflow(mainProcessDefinition.getId(), new HashMap<QName, Serializable>());
    } catch(Exception e) {
    	e.printStackTrace();
    	fail("No exception was expected while running process, but got: " + e.toString());
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:26,代码来源:ActivitiMultitenantWorkflowTest.java

示例2: getSelectField

import java.io.Serializable; //导入依赖的package包/类
private String getSelectField(String field, Query<? extends Serializable> query, boolean inWhere) {
    Class<?> beanType = query.getBeanType();
    AnnotationHolder ah = AnnotationHelper.getAnnotationHolder(field, beanType);
    if (ah == null) throw new IllegalArgumentException(" Can't find field `"+ field +"` in class["+ beanType +"]");

    String name = ah.getField().getName();
    if (!inWhere) {
        String ref = ah.getColumn().referenceField();
        if (SqlUtils.isNotBlank(ah.getOgnl())) {
            name = "`" + name + "` as `" + ah.getOgnl() + "." + ah.getField().getName() + "`";
        } else if (SqlUtils.isNotBlank(ref)) {
            name = "`" + name + "` as `" + ah.getField().getName() + "." + ref + "`";
        }
    }

    return name;
}
 
开发者ID:cyanqueen,项目名称:backbone,代码行数:18,代码来源:BaseParser.java

示例3: convert

import java.io.Serializable; //导入依赖的package包/类
@Override
Serializable convert(Serializable value)
{
    if (value == null)
    {
        return null;
    }
    else if (value instanceof Long)
    {
        return value;
    }
    else if (value instanceof ContentDataId)
    {
        return ((ContentDataId)value).getId();
    }
    else
    {
        return DefaultTypeConverter.INSTANCE.convert(ContentData.class, value);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:21,代码来源:NodePropertyValue.java

示例4: testAddProperties

import java.io.Serializable; //导入依赖的package包/类
public void testAddProperties() throws Exception
{
    Map<QName, Serializable> properties = nodeService.getProperties(rootNodeRef);
    // Add an aspect with a default value
    nodeService.addAspect(rootNodeRef, ASPECT_QNAME_TEST_TITLED, null);
    assertNull("Expected null property", nodeService.getProperty(rootNodeRef, PROP_QNAME_TEST_TITLE));
    assertNull("Expected null property", nodeService.getProperty(rootNodeRef, PROP_QNAME_TEST_DESCRIPTION));
    
    // Now add a map of two properties and check
    Map<QName, Serializable> addProperties = new HashMap<QName, Serializable>(11);
    addProperties.put(PROP_QNAME_TEST_TITLE, "Title");
    addProperties.put(PROP_QNAME_TEST_DESCRIPTION, "Description");
    nodeService.addProperties(rootNodeRef, addProperties);
    
    // Check
    Map<QName, Serializable> checkProperties = nodeService.getProperties(rootNodeRef);
    assertEquals("Title", checkProperties.get(PROP_QNAME_TEST_TITLE));
    assertEquals("Description", checkProperties.get(PROP_QNAME_TEST_DESCRIPTION));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:BaseNodeServiceTest.java

示例5: openAndCheck

import java.io.Serializable; //导入依赖的package包/类
private Map<String, Serializable> openAndCheck(String fileBase, String expMimeType) throws Throwable {
   // Get the mimetype via the MimeTypeMap 
   // (Uses Tika internally for the detection)
   File file = open(fileBase);
   ContentReader detectReader = new FileContentReader(file);
   String mimetype = mimetypeMap.guessMimetype(fileBase, detectReader);

   assertEquals("Wrong mimetype for " + fileBase, mimetype, expMimeType);
   
   // Ensure the Tika Auto parser actually handles this
   assertTrue("Mimetype should be supported but isn't: " + mimetype, extracter.isSupported(mimetype));
   
   // Now create our proper reader
   ContentReader sourceReader = new FileContentReader(file);
   sourceReader.setMimetype(mimetype);
   
   // And finally do the properties extraction
   return extracter.extractRaw(sourceReader);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:TikaAutoMetadataExtracterTest.java

示例6: createNodeImpl

import java.io.Serializable; //导入依赖的package包/类
private NodeRef createNodeImpl(NodeRef parentNodeRef, String nodeName, QName nodeTypeQName, Map<QName, Serializable> props, QName assocTypeQName)
{
    NodeRef newNode = null;
    if (props == null)
    {
        props = new HashMap<>(1);
    }
    props.put(ContentModel.PROP_NAME, nodeName);

    validatePropValues(props);

    QName assocQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName(nodeName));
    try
    {
        newNode = nodeService.createNode(parentNodeRef, assocTypeQName, assocQName, nodeTypeQName, props).getChildRef();
    }
    catch (DuplicateChildNodeNameException dcne)
    {
        // duplicate - name clash
        throw new ConstraintViolatedException(dcne.getMessage());
    }

    ActivityInfo activityInfo =  getActivityInfo(parentNodeRef, newNode);
    postActivity(Activity_Type.ADDED, activityInfo, false);
    return newNode;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:27,代码来源:NodesImpl.java

示例7: deserialize

import java.io.Serializable; //导入依赖的package包/类
public static Serializable deserialize(byte[] data, int offset, int length, ClassLoader[] cls)
		throws IOException, ClassNotFoundException, ClassCastException {
	invokecount.addAndGet(1);
	Object message = null;
	if (cls == null)
		cls = new ClassLoader[0];
	if (data != null && length > 0) {
		InputStream instream = new ByteArrayInputStream(data, offset, length);
		ObjectInputStream stream = null;
		stream = (cls.length > 0) ? new ReplicationStream(instream, cls) : new ObjectInputStream(instream);
		message = stream.readObject();
		instream.close();
		stream.close();
	}
	if (message == null) {
		return null;
	} else if (message instanceof Serializable)
		return (Serializable) message;
	else {
		throw new ClassCastException("Message has the wrong class. It should implement Serializable, instead it is:"
				+ message.getClass().getName());
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:24,代码来源:XByteBuffer.java

示例8: doReadSession

import java.io.Serializable; //导入依赖的package包/类
@Override
protected Session doReadSession(Serializable sessionId) {
    logger.debug("begin doReadSession {}", sessionId);
    Jedis jedis = jedisPool.getResource();
    Session session = null;
    try {
        String key = prefix + sessionId;
        String value = jedis.get(key);
        if(StringUtils.isNotBlank(value)){
            session = SerializeUtils.deserializeFromString(value);
            logger.info("sessionId {} ttl {}: ", sessionId, jedis.ttl(key));
            //重置Redis中缓存过期的时间
            jedis.expire(key,expireTime);
            logger.info("sessionId {} name {} 被读取", sessionId, session.getClass().getName());
        }
    } catch (Exception e){
        logger.warn("读取session失败");
    } finally {
        jedis.close();
    }
    return session;
}
 
开发者ID:ZhuXS,项目名称:Spring-Shiro-Spark,代码行数:23,代码来源:ShiroSessionDao.java

示例9: getArgsForTask

import java.io.Serializable; //导入依赖的package包/类
protected Serializable[] getArgsForTask(ClusteredTaskWithArgs withArgs)
{
	String argsId = withArgs.getArgsId();
	if( argsId != null )
	{
		String nodeId = withArgs.getNodeId();
		if( nodeId.equals(ourNodeId) )
		{
			Serializable[] args = taskArgs.getIfPresent(argsId);
			taskArgs.invalidate(argsId);
			return args;
		}
		else
		{
			BlockingQueue<SimpleMessage> mq = createResponseQueue(argsId);
			clusterMessagingService.postMessage(nodeId, new ArgsMessage(argsId, ourNodeId));
			ArgsMessage argsResponse = waitForResponse(5000, mq);
			return argsResponse.getArgs();
		}
	}
	else
	{
		return withArgs.getArgs();
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:26,代码来源:ClusteredTaskServiceImpl.java

示例10: DataNode

import java.io.Serializable; //导入依赖的package包/类
/**
 * Create a new data node and fill it with the serialized representation of
 * the data object provided.
 * 
 * @param id
 *            the node id
 * @param data
 *            the data to serialize
 */
public DataNode ( final String id, final Serializable data )
{
    this.id = id;

    if ( data == null )
    {
        this.data = null;
    }
    else
    {
        final ByteArrayOutputStream bos = new ByteArrayOutputStream ();
        try
        {
            final ObjectOutputStream os = new ObjectOutputStream ( bos );
            os.writeObject ( data );
            os.close ();
            this.data = bos.toByteArray ();
        }
        catch ( final IOException e )
        {
            throw new RuntimeException ( "Failed to store data node", e );
        }
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:34,代码来源:DataNode.java

示例11: writePrincipal

import java.io.Serializable; //导入依赖的package包/类
public static void writePrincipal(GenericPrincipal p, ObjectOutput out) throws IOException {
	out.writeUTF(p.getName());
	out.writeBoolean(p.getPassword() != null);
	if (p.getPassword() != null)
		out.writeUTF(p.getPassword());
	String[] roles = p.getRoles();
	if (roles == null)
		roles = new String[0];
	out.writeInt(roles.length);
	for (int i = 0; i < roles.length; i++)
		out.writeUTF(roles[i]);
	boolean hasUserPrincipal = (p != p.getUserPrincipal() && p.getUserPrincipal() instanceof Serializable);
	out.writeBoolean(hasUserPrincipal);
	if (hasUserPrincipal)
		out.writeObject(p.getUserPrincipal());
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:17,代码来源:SerializablePrincipal.java

示例12: testVersionAspectNotSetOnCheckIn

import java.io.Serializable; //导入依赖的package包/类
/**
 * Test when the aspect is not set when check-in is performed
 */
public void testVersionAspectNotSetOnCheckIn()
{
    // Create a bag of props
    Map<QName, Serializable> bagOfProps = createTypePropertyBag();
    bagOfProps.put(ContentModel.PROP_CONTENT, new ContentData(null, MimetypeMap.MIMETYPE_TEXT_PLAIN, 0L, "UTF-8"));

    // Create a new node 
    ChildAssociationRef childAssocRef = nodeService.createNode(
            rootNodeRef,
            ContentModel.ASSOC_CHILDREN,
            QName.createQName("test"),
            ContentModel.TYPE_CONTENT,
            bagOfProps);
    NodeRef noVersionNodeRef = childAssocRef.getChildRef();
    
    // Check out and check in
    NodeRef workingCopy = cociService.checkout(noVersionNodeRef);
    cociService.checkin(workingCopy, new HashMap<String, Serializable>());
    
    // Check that the origional node has no version history dispite sending verion props
    assertNull(this.versionService.getVersionHistory(noVersionNodeRef));        
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:26,代码来源:CheckOutCheckInServiceImplTest.java

示例13: test02OnCopyComplete

import java.io.Serializable; //导入依赖的package包/类
@Test
public final void test02OnCopyComplete() throws Exception
{
  serviceRegistry.getFileFolderService().copy(content2, folder1, null); // keep leaf name

  txn.commit();
  txn = null;
  
  // TODO do we record the parent or the full path? Do we need to?

  assertEquals(1, auditMapList.size());
  Map<String, Serializable> auditMap = auditMapList.get(0);
  assertEquals("COPY", auditMap.get("action"));
  assertContains("createNode", auditMap.get("sub-actions"));
  assertContains("updateNodeProperties", auditMap.get("sub-actions"));
  assertContains("addNodeAspect", auditMap.get("sub-actions"));
  assertContains("copyNode", auditMap.get("sub-actions"));
  assertEquals("/cm:homeFolder/cm:folder1/cm:content2", auditMap.get("path"));
  assertEquals("/cm:homeFolder/cm:folder2/cm:content2", auditMap.get("copy/from/path"));
  assertEquals("cm:content", auditMap.get("type"));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:22,代码来源:AccessAuditorTest.java

示例14: testAR807

import java.io.Serializable; //导入依赖的package包/类
public void testAR807() 
{
	QName prop = QName.createQName("http://www.alfresco.org/test/versionstorebasetest/1.0", "intProp");
	
    ChildAssociationRef childAssociation = 
    	nodeService.createNode(this.rootNodeRef, 
                				 ContentModel.ASSOC_CHILDREN, 
                				 QName.createQName("http://www.alfresco.org/test/versionstorebasetest/1.0", "integerTest"), 
                				 TEST_TYPE_QNAME);
    NodeRef newNode = childAssociation.getChildRef();
    nodeService.setProperty(newNode, prop, 1);

    Object editionCode = nodeService.getProperty(newNode, prop);
    assertEquals(editionCode.getClass(), Integer.class);

    Map<String, Serializable> versionProps = new HashMap<String, Serializable>(1);
    versionProps.put(VersionModel.PROP_VERSION_TYPE, VersionType.MAJOR);
    Version version = versionService.createVersion(newNode, versionProps);

    NodeRef versionNodeRef = version.getFrozenStateNodeRef();
    assertNotNull(versionNodeRef);
    
    Object editionCodeArchive = nodeService.getProperty(versionNodeRef, prop);
    assertEquals(editionCodeArchive.getClass(), Integer.class);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:26,代码来源:VersionServiceImplTest.java

示例15: identityRemove

import java.io.Serializable; //导入依赖的package包/类
static void identityRemove(Collection list, Object object, SessionImplementor session) 
throws HibernateException {
	
	if ( object!=null && session.isSaved(object) ) {
	
		Serializable idOfCurrent = session.getEntityIdentifierIfNotUnsaved(object);
		Iterator iter = list.iterator();
		while ( iter.hasNext() ) {
			Serializable idOfOld = session.getEntityIdentifierIfNotUnsaved( iter.next() );
			if ( idOfCurrent.equals(idOfOld) ) {
				iter.remove();
				break;
			}
		}
		
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:18,代码来源:PersistentCollection.java


注:本文中的java.io.Serializable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。